source: tmcsimulator/trunk/test/tmcsim/highwaymodel/StationTest.java @ 422

Revision 422, 3.0 KB checked in by jdalbey, 7 years ago (diff)

Remove ATMS functionality. Reworked and simplified the Highway model to use only VDS data from PeMS. Updated all unit tests.

Line 
1
2package tmcsim.highwaymodel;
3
4import tmcsim.highwaymodel.LoopDetector;
5import tmcsim.highwaymodel.Station;
6import tmcsim.highwaymodel.Station.DIRECTION;
7import java.util.ArrayList;
8import junit.framework.TestCase;
9import org.w3c.dom.Element;
10
11/**
12 *
13 * @author jdalbey
14 */
15public class StationTest extends TestCase {
16    Station alpha;
17    public StationTest(String testName) {
18        super(testName);
19    }
20   
21    @Override
22    protected void setUp() throws Exception {
23        super.setUp();
24        alpha = new Station(1,2,3,"A",new ArrayList<LoopDetector>(), 4, DIRECTION.NORTH, 1.0);
25    }
26   
27    @Override
28    protected void tearDown() throws Exception {
29        super.tearDown();
30    }
31
32    /**
33     * Test of getHighwayNumber method, of class Station.
34     */
35    public void testGetHighwayNumber() {
36        System.out.println("getHighwayNumber");
37        assertEquals(4, alpha.routeNumber);
38    }
39
40    /**
41     * Test of getDirection method, of class Station.
42     */
43    public void testGetDirection() {
44        System.out.println("getDirection");
45        assertEquals(DIRECTION.NORTH, alpha.direction);
46    }
47
48    /**
49     * Test of getStationMeta method, of class Station.
50     */
51    public void testGetStationMeta() {
52        System.out.println("getStationMeta");
53        String expResult = "2 3 4 N 1.0 0 A\n";
54        String result = alpha.toCondensedFormat(true);
55        assertEquals(expResult, result);
56    }
57
58    /**
59     * Test of getPostmile method, of class Station.
60     */
61    public void testGetPostmile() {
62        System.out.println("getPostmile");
63        assertEquals(1.0, alpha.postmile,0.1);
64    }
65
66    /**
67     * Test of compareTo method, of class Station.
68     */
69    public void testCompareTo() {
70        System.out.println("compareTo");
71        Station beta = new Station(1,2,3,"B",new ArrayList<LoopDetector>(), 4, DIRECTION.NORTH, 2.0);
72        int expResult = 0;
73        assertEquals(-1, alpha.compareTo(beta));
74        assertEquals(1, beta.compareTo(alpha));
75        assertEquals(0, beta.compareTo(beta));
76    }
77
78    public void testMatches()
79    {
80        Station alpha = new Station(1,2,3,"A",new ArrayList<LoopDetector>(), 4, DIRECTION.NORTH, 2.0);
81        assertTrue(alpha.matches(DIRECTION.NORTH, 2.0));
82        assertFalse(alpha.matches(DIRECTION.NORTH,2.1));
83    }
84    /**
85     * Test get Color and LoopDetector accessors
86     */
87    public void testGetColor()
88    {
89        LoopDetector lane = new LoopDetector(999,"locid","loc");
90        ArrayList<LoopDetector> lanes = new ArrayList<LoopDetector>();
91        lanes.add(lane);
92        Station alpha = new Station(1,2,3,"A",lanes, 4, DIRECTION.NORTH, 2.0);
93        assertEquals('-',alpha.getColor().symbol());
94        assertEquals("lime",alpha.getColor().htmlColor());
95        lane.setAttributes(LoopDetector.DOTCOLOR.YELLOW);
96        assertEquals('+',alpha.getColor().symbol());
97        assertEquals("yellow",alpha.getColor().htmlColor());
98        lane.setAttributes(LoopDetector.DOTCOLOR.RED);
99        assertEquals('@',alpha.getColor().symbol());
100        assertEquals("red",alpha.getColor().htmlColor());
101    }
102}
Note: See TracBrowser for help on using the repository browser.