### Question:
EPPolicyTemplateDaoImpl implements DSAsyncDao<Sgt, EndpointPolicyTemplateBySgt>,
        ReadableByKey<EpPolicyTemplateValueKey, EndpointPolicyTemplateBySgt> { @Override public Collection<EndpointPolicyTemplateBySgt> readBy(@Nonnull final EpPolicyTemplateValueKey specialKey) { final Predicate<EpPolicyTemplateValueKey> templateValuePredicate = Predicates.equalTo(specialKey); final Collection<EndpointPolicyTemplateBySgt> foundTemplates = new ArrayList<>(); for (EndpointPolicyTemplateBySgt epPolicyTemplate : cachedDao.values()) { final EpPolicyTemplateValueKey templateValueKey = keyFactory.createKeyWithDefaultOrdering(epPolicyTemplate); if (templateValuePredicate.apply(templateValueKey)) { foundTemplates.add(epPolicyTemplate); } } return foundTemplates; } EPPolicyTemplateDaoImpl(final DataBroker dataBroker,
                                   final SimpleCachedDao<Sgt, EndpointPolicyTemplateBySgt> cachedDao,
                                   final EpPolicyTemplateValueKeyFactory keyFactory); @Override ListenableFuture<Optional<EndpointPolicyTemplateBySgt>> read(@Nonnull final Sgt key); @Override Collection<EndpointPolicyTemplateBySgt> readBy(@Nonnull final EpPolicyTemplateValueKey specialKey);  }### Answer:
@Test public void testReadBy_single() throws Exception { final EpPolicyTemplateValueKey key = new EpPolicyTemplateValueKey(new TenantId("tn1"), buildEndpointGroupIds(new String[]{"epg1", "epg2"}), buildConditions(new String[]{"cn1", "cn2"})); Mockito.doCallRealMethod().when(keyFactory).createKeyWithDefaultOrdering(Matchers.<EndpointPolicyTemplateBySgt>any()); Mockito.when(cachedDao.values()).thenReturn(Lists.newArrayList( createEpPolicytemplate(new Sgt(1), new String[]{"cn2", "cn1"}, new String[]{"epg1", "epg2"}, "tn1"), createEpPolicytemplate(new Sgt(2), new String[]{"cn1", "cn2"}, new String[]{"epg2", "epg1"}, "tn1"), createEpPolicytemplate(new Sgt(3), new String[]{"cn2", "cn1"}, new String[]{"epg2", "epg1"}, "tn1"), createEpPolicytemplate(new Sgt(4), new String[]{"cn1", "cn2"}, new String[]{"epg1", "epg2"}, "tn1") )); final Collection<EndpointPolicyTemplateBySgt> policyTemplates = dao.readBy(key); Assert.assertEquals(1, policyTemplates.size()); Assert.assertEquals(4, Iterables.getFirst(policyTemplates, null).getSgt().getValue().intValue()); }