Beispiel #1
0
  @Test
  public void getAllStations()
      throws URISyntaxException, ParserConfigurationException, SAXException, IOException,
          XPathExpressionException {
    final Set<Station> stations = manager.getAllStations();

    assertNotNull("Set of stations cannot be null.", stations);
    assertTrue("Stations cannot be empty.", !stations.isEmpty());

    final URI xml = manager.getClass().getResource("resources/linksIDS.xml").toURI();

    final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    final DocumentBuilder builder = factory.newDocumentBuilder();
    final Document doc = builder.parse(new File(xml));
    final XPath xpath = XPathFactory.newInstance().newXPath();

    final NodeList expectedStationsXpath =
        (NodeList) xpath.evaluate("//station/name", doc, XPathConstants.NODESET);
    Set<String> expectedStations = new HashSet<>();

    for (int i = 0; i < expectedStationsXpath.getLength(); i++) {
      expectedStations.add(expectedStationsXpath.item(i).getTextContent());
    }

    assertTrue("Expected stations cannot be empty.", !expectedStations.isEmpty());
    assertEquals(expectedStations, stations);
    assertNotSame(expectedStations, stations);
    // assertDeepEquals(expectedStations, stations);
  }
Beispiel #2
0
 // Special test for linksIDS.xml
 @Test
 public void getPathTest2() {
   Path path = manager.getPath("Nihov", "Kurim");
   assertNotNull("Path cannot be null.", path);
   assertEquals(path.getTotalMinutes(), null);
   assertEquals(path.isBrno(), false);
   assertDeepEquals(path.getZones(), Arrays.asList(345, 340, 330, 320, 310));
   assertDeepEquals(
       path.getStations(),
       Arrays.asList("Níhov", "Řikonín", "Dolní Loučky", "Tišnov", "Hradčany", "Čebín", "Kuřim"));
 }
Beispiel #3
0
 // Special test for linksIDS.xml
 @Test
 public void getPathTest5() {
   Path path = manager.getPath("Oslavany", "Ivančice letovisko");
   assertNotNull("Path cannot be null.", path);
   assertEquals(path.getTotalMinutes(), null);
   assertEquals(path.isBrno(), false);
   assertDeepEquals(path.getZones(), Arrays.asList(447));
   assertDeepEquals(
       path.getStations(),
       Arrays.asList("Ivančice město", "Ivančice", "Oslavany", "Ivančice letovisko"));
 }
Beispiel #4
0
 // Special test for linksIDS.xml
 @Test
 public void getPathTest4() {
   Path path = manager.getPath("Radostice", "Bohutice");
   assertNotNull("Path cannot be null.", path);
   assertEquals(path.getTotalMinutes(), null);
   assertEquals(path.isBrno(), false);
   assertDeepEquals(path.getZones(), Arrays.asList(427, 437, 448, 459));
   assertDeepEquals(
       path.getStations(),
       Arrays.asList(
           "Radostice", "Silůvky", "Moravské Bránice", "Moravský Krumlov", "Rakšice", "Bohutice"));
 }
Beispiel #5
0
 // Special test for linksIDS.xml
 @Test
 public void getPathTest3() {
   Path path = manager.getPath("Brno hl.n.", "Radostice");
   assertNotNull("Path cannot be null.", path);
   assertEquals(path.getTotalMinutes(), null);
   assertEquals(path.isBrno(), true);
   assertDeepEquals(path.getZones(), Arrays.asList(100, 101, 410, 427));
   assertDeepEquals(
       path.getStations(),
       Arrays.asList(
           "Brno hl.n.",
           "Brno-Horní Heršpice",
           "Troubsko",
           "Střelice dolní",
           "Střelice",
           "Radostice"));
 }
Beispiel #6
0
 // Special test for linksIDS.xml
 @Test
 public void getPathTest1() {
   Path path = manager.getPath("Brno hl.n.", "Blansko-mesto");
   assertNotNull("Path cannot be null.", path);
   assertEquals(path.getTotalMinutes(), null);
   assertEquals(path.isBrno(), true);
   assertDeepEquals(path.getZones(), Arrays.asList(100, 215, 225, 235));
   assertDeepEquals(
       path.getStations(),
       Arrays.asList(
           "Brno hl.n.",
           "Brno-Židenice",
           "Bílovice n.Svitavou",
           "Babice n.Svitavou",
           "Adamov",
           "Adamov zast.",
           "Blansko",
           "Blansko město"));
 }
Beispiel #7
0
 @Test(expected = IllegalEntityException.class)
 public void getPathWithWrongArg() {
   manager.getPath("from", "to");
 }
Beispiel #8
0
 @Test(expected = IllegalArgumentException.class)
 public void getPathWithEmptyArg2() {
   manager.getPath("from", "");
 }
Beispiel #9
0
 @Test(expected = IllegalArgumentException.class)
 public void getPathWithNullArg() {
   manager.getPath(null, "to");
 }