### Question:
ZooCachePropertyAccessor { void getProperties(Map<String,String> props, String path, Predicate<String> filter, AccumuloConfiguration parent, Predicate<String> parentFilter) { parent.getProperties(props, parentFilter != null ? parentFilter : filter); List<String> children = propCache.getChildren(path); if (children != null) { for (String child : children) { if (child != null && filter.test(child)) { String value = get(path + "/" + child); if (value != null) { props.put(child, value); } } } } } ZooCachePropertyAccessor(ZooCache propCache);   }### Answer:
@Test public void testGetProperties() { Map<String,String> props = new java.util.HashMap<>(); AccumuloConfiguration parent = createMock(AccumuloConfiguration.class); Predicate<String> filter = createMock(Predicate.class); parent.getProperties(props, filter); replay(parent); String child1 = "child1"; String child2 = "child2"; List<String> children = new java.util.ArrayList<>(); children.add(child1); children.add(child2); expect(zc.getChildren(PATH)).andReturn(children); expect(zc.get(PATH + "/" + child1)).andReturn(VALUE_BYTES); expect(zc.get(PATH + "/" + child2)).andReturn(null); replay(zc); expect(filter.test(child1)).andReturn(true); expect(filter.test(child2)).andReturn(true); replay(filter); a.getProperties(props, PATH, filter, parent, null); assertEquals(1, props.size()); assertEquals(VALUE, props.get(child1)); verify(parent); }
@Test public void testGetProperties_NoChildren() { Map<String,String> props = new java.util.HashMap<>(); AccumuloConfiguration parent = createMock(AccumuloConfiguration.class); Predicate<String> filter = createMock(Predicate.class); parent.getProperties(props, filter); replay(parent); expect(zc.getChildren(PATH)).andReturn(null); replay(zc); a.getProperties(props, PATH, filter, parent, null); assertEquals(0, props.size()); }
@Test public void testGetProperties_Filter() { Map<String,String> props = new java.util.HashMap<>(); AccumuloConfiguration parent = createMock(AccumuloConfiguration.class); Predicate<String> filter = createMock(Predicate.class); parent.getProperties(props, filter); replay(parent); String child1 = "child1"; List<String> children = new java.util.ArrayList<>(); children.add(child1); expect(zc.getChildren(PATH)).andReturn(children); replay(zc); expect(filter.test(child1)).andReturn(false); replay(filter); a.getProperties(props, PATH, filter, parent, null); assertEquals(0, props.size()); }
@Test public void testGetProperties_ParentFilter() { Map<String,String> props = new java.util.HashMap<>(); AccumuloConfiguration parent = createMock(AccumuloConfiguration.class); Predicate<String> filter = createMock(Predicate.class); Predicate<String> parentFilter = createMock(Predicate.class); parent.getProperties(props, parentFilter); replay(parent); expect(zc.getChildren(PATH)).andReturn(null); replay(zc); a.getProperties(props, PATH, filter, parent, parentFilter); verify(parent); }