00001 package edu.wpi.rail.jinteractiveworld.model; 00002 00003 import static org.junit.Assert.*; 00004 00005 import edu.wpi.rail.jinteractiveworld.data.DataPoint; 00006 import edu.wpi.rail.jinteractiveworld.ros.msgs.interactiveworldmsgs.*; 00007 import edu.wpi.rail.jinteractiveworld.data.DataSet; 00008 import org.junit.Test; 00009 00010 public class TestEMModel { 00011 00012 @Test 00013 public void testInvalidDataSet() { 00014 EMModel model = new EMModel(null); 00015 assertNull(model.getPlacementLocation()); 00016 } 00017 00018 @Test 00019 public void testGetHighestPlacementLocation() { 00020 DataSet data = new DataSet(new Item(), new Room(), new Surface(), "test"); 00021 00022 data.add(1, 1, 0, Math.PI); 00023 data.add(0.5, 0.5, 0, Math.PI / 2.0); 00024 data.add(0.5, 1.5, 0, Math.PI); 00025 data.add(1.5, 0.5, 0, Math.PI / 2.0); 00026 data.add(1.5, 1.5, 0, Math.PI); 00027 00028 data.add(-5, -5, 0, Math.PI); 00029 data.add(-4.875, -4.875, 0, Math.PI / 2.0); 00030 data.add(-4.875, -5.125, 0, Math.PI); 00031 data.add(-5.125, -4.875, 0, Math.PI / 2.0); 00032 data.add(-5.125, -5.125, 0, Math.PI); 00033 00034 EMModel model = new EMModel(data); 00035 00036 Placement p = model.getPlacementLocation(); 00037 assertEquals("test", p.getReferenceFrameId()); 00038 assertEquals(model.getItem(), p.getItem()); 00039 assertEquals(model.getRoom(), p.getRoom()); 00040 assertEquals(model.getSurface(), p.getSurface()); 00041 assertEquals(-5.0, p.getPosition().getX()); 00042 assertEquals(-5.0, p.getPosition().getY()); 00043 assertEquals(0.0, p.getPosition().getZ()); 00044 assertEquals((Math.PI * 4.0) / 5.0, p.getRotation()); 00045 assertEquals(2.083259, model.getDecisionValue(), 0.000001); 00046 } 00047 }