Пример #1
0
  // test Track typename support
  public void testTrackTypeNameSupport() {
    Location l = new Location("Location Test Name id", "Location Test Name");
    Track t = new Track("Test id", "Test Name", "Test Type", l);
    Assert.assertEquals("Location Track id", "Test id", t.getId());
    Assert.assertEquals("Location Track Name", "Test Name", t.getName());
    Assert.assertEquals("Location Track Type", "Test Type", t.getTrackType());
    Assert.assertEquals("Location", l, t.getLocation());

    /* Test Type Name */
    Assert.assertEquals(
        "Location Track Accepts Type Name undefined", false, t.acceptsTypeName("TestTypeName"));

    t.addTypeName("TestTypeName");
    Assert.assertEquals(
        "Location Track Accepts Type Name defined", false, t.acceptsTypeName("TestTypeName"));

    // now add to car types
    CarTypes ct = CarTypes.instance();
    ct.addName("TestTypeName");
    t.addTypeName("TestTypeName");
    Assert.assertEquals(
        "Location Track Accepts Type Name defined after ct",
        false,
        t.acceptsTypeName("TestTypeName"));

    // location must also accept the same type
    l.addTypeName("TestTypeName");
    Assert.assertEquals(
        "Location Track Accepts Type Name defined after location",
        true,
        t.acceptsTypeName("TestTypeName"));

    t.deleteTypeName("TestTypeName");
    Assert.assertEquals(
        "Location Track Accepts Type Name deleted", false, t.acceptsTypeName("TestTypeName"));

    /* Needed so later tests will behave correctly */
    ct.deleteName("TestTypeName");

    ct.addName("Baggager");
    t.addTypeName("Baggager");
    l.addTypeName("Baggager");

    Assert.assertEquals(
        "Location Track Accepts Type Name Baggager", true, t.acceptsTypeName("Baggager"));

    /* Test Road Name */
    t.setRoadOption(Track.INCLUDE_ROADS);
    Assert.assertEquals(
        "Location Track set Road Option INCLUDEROADS", "Include", t.getRoadOption());

    Assert.assertEquals(
        "Location Track Accepts Road Name undefined", false, t.acceptsRoadName("TestRoadName"));

    t.addRoadName("TestRoadName");
    Assert.assertEquals(
        "Location Track Accepts Road Name defined", true, t.acceptsRoadName("TestRoadName"));

    t.addRoadName("TestOtherRoadName");
    Assert.assertEquals(
        "Location Track Accepts Road Name other defined", true, t.acceptsRoadName("TestRoadName"));

    t.deleteRoadName("TestRoadName");
    Assert.assertEquals(
        "Location Track Accepts Road Name deleted", false, t.acceptsRoadName("TestRoadName"));

    t.setRoadOption(Track.ALL_ROADS);
    Assert.assertEquals("Location Track set Road Option AllROADS", "All", t.getRoadOption());
    Assert.assertEquals(
        "Location Track Accepts All Road Names", true, t.acceptsRoadName("TestRoadName"));

    t.setRoadOption(Track.EXCLUDE_ROADS);
    Assert.assertEquals(
        "Location Track set Road Option EXCLUDEROADS", "Exclude", t.getRoadOption());
    Assert.assertEquals(
        "Location Track Excludes Road Names", true, t.acceptsRoadName("TestRoadName"));

    t.addRoadName("TestRoadName");
    Assert.assertEquals(
        "Location Track Excludes Road Names 2", false, t.acceptsRoadName("TestRoadName"));

    /* Test Drop IDs */
    Assert.assertEquals(
        "Location Track Accepts Drop ID undefined", false, t.containsDropId("TestDropId"));

    t.addDropId("TestDropId");
    Assert.assertEquals(
        "Location Track Accepts Drop ID defined", true, t.containsDropId("TestDropId"));

    t.addDropId("TestOtherDropId");
    Assert.assertEquals(
        "Location Track Accepts Drop ID other defined", true, t.containsDropId("TestDropId"));

    t.deleteDropId("TestDropId");
    Assert.assertEquals(
        "Location Track Accepts Drop ID deleted", false, t.containsDropId("TestDropId"));

    /* Test Pickup IDs */
    Assert.assertEquals(
        "Location Track Accepts Pickup ID undefined", false, t.containsPickupId("TestPickupId"));

    t.addPickupId("TestPickupId");
    Assert.assertEquals(
        "Location Track Accepts Pickup ID defined", true, t.containsPickupId("TestPickupId"));

    t.addPickupId("TestOtherPickupId");
    Assert.assertEquals(
        "Location Track Accepts Pickup ID other defined", true, t.containsPickupId("TestPickupId"));

    t.deletePickupId("TestPickupId");
    Assert.assertEquals(
        "Location Track Accepts Pickup ID deleted", false, t.containsPickupId("TestPickupId"));
  }