@Test public void topologyShouldReturnEvenDisconnectedGraphs() { Map<String, Set<String>> graph1 = new HashMap<>(); graph1.put("a", Collections.singleton("b")); graph1.put("b", Collections.singleton("a")); Map<String, Set<String>> graph2 = new HashMap<>(); graph2.put("c", Collections.singleton("d")); graph2.put("d", Collections.singleton("c")); cache.putGraph("x", 1, graph1); cache.putGraph("z", 2, graph2); Map<String, Set<String>> topology = cache.getTopology(); Map<String, Set<String>> expected = new HashMap<>(); expected.put("a", Collections.singleton("b")); expected.put("b", Collections.singleton("a")); expected.put("c", Collections.singleton("d")); expected.put("d", Collections.singleton("c")); assertEquals(expected, topology); }
@Test public void wholeTopology_shouldReturnAllGraphsTogetherAsOne() { Map<String, Set<String>> graph1 = new HashMap<>(); graph1.put("a", Collections.singleton("b")); graph1.put("c", Collections.singleton("b")); graph1.put("b", neigh("a", "c")); Map<String, Set<String>> graph2 = new HashMap<>(); graph2.put("d", Collections.singleton("b")); graph2.put("e", Collections.singleton("b")); graph2.put("b", neigh("d", "e")); cache.putGraph("x", 1, graph1); cache.putGraph("z", 2, graph2); Map<String, Set<String>> topology = cache.getTopology(); Map<String, Set<String>> expected = new HashMap<>(); expected.put("a", Collections.singleton("b")); expected.put("c", Collections.singleton("b")); expected.put("d", Collections.singleton("b")); expected.put("e", Collections.singleton("b")); expected.put("b", neigh("a", "c", "d", "e")); assertEquals(expected, topology); }