FixtureMapTraversal { public static void traverse(FixtureMap fixtureMap, final Processor processor) { for (Map.Entry<String, FixtureTemplate> entry : fixtureMap.entrySet()) { handleSubType(entry.getValue(), processor); } }  static void traverse(FixtureMap fixtureMap, final Processor processor);  }
@Test public void testSimpleTraversal() { final List<String> allKeys = new ArrayList<>(); allKeys.add("edge1"); allKeys.add("edge2"); allKeys.add("edge5"); allKeys.add("edge6"); allKeys.add("list"); Map<String, Object> map = new HashMap<>(); map.put("list", allKeys); FixtureMap fixture = FixtureTemplateWrapper.wrap(map, null, null); FixtureMapTraversal.traverse(fixture, new FixtureMapTraversal.Processor() { @Override public void visit(FixtureValue edge) { allKeys.remove(edge.getValue()); } }); assertTrue(allKeys.isEmpty()); }
@Test public void testTraversalAndUpdateValue() { FixtureMapTraversal.traverse(sampleFixture, new FixtureMapTraversal.Processor() { @Override public void visit(FixtureValue edge) { edge.setValue((Integer) edge.getValue() + 1); } }); assertEquals("{edge1=2, edge2=3, list=[4, 5, {edge5=6, edge6=7}]}", sampleFixture.toString()); }