### Question:
HostConfigMappingDAO { @RequiresSession public Set<HostConfigMapping> findByType(final long clusterId, Long hostId, final String type) { populateCache(); if (!hostConfigMappingByHost.containsKey(hostId)) return Collections.emptySet(); Set<HostConfigMapping> set = new HashSet<>(hostConfigMappingByHost.get(hostId)); CollectionUtils.filter(set, new Predicate() { @Override public boolean evaluate(Object arg0) { return ((HostConfigMapping) arg0).getClusterId().equals(clusterId) && ((HostConfigMapping) arg0).getType().equals(type); } }); return set; }  @Transactional void create(HostConfigMapping hostConfigMapping); @Transactional HostConfigMapping merge(HostConfigMapping hostConfigMapping); @RequiresSession Set<HostConfigMapping> findByType(final long clusterId, Long hostId, final String type); @RequiresSession HostConfigMapping findSelectedByType(final long clusterId,
      Long hostId, final String type); @RequiresSession Set<HostConfigMapping> findSelected(final long clusterId, Long hostId); @RequiresSession Set<HostConfigMapping> findSelectedByHosts(Collection<Long> hostIds); @RequiresSession Map<String, List<HostConfigMapping>> findSelectedHostsByTypes(final long clusterId,
                                                                             Collection<String> types); @RequiresSession List<HostConfigMappingEntity> findAll(); @Transactional void removeByHostId(Long hostId); @Transactional void removeByClusterAndHostName(final long clusterId, String hostName); HostConfigMappingEntity buildHostConfigMappingEntity(HostConfigMapping hostConfigMapping); HostConfigMapping buildHostConfigMapping(
      HostConfigMappingEntity hostConfigMappingEntity);  }### Answer:
@Test public void testFindByType() throws Exception { HostConfigMapping source = createEntity(1L, "h1", "global", "v1"); HostEntity hostEntity = hostDAO.findByName("h1"); Set<HostConfigMapping> target = hostConfigMappingDAO.findByType(1L, hostEntity.getHostId(), "global"); Assert.assertEquals("Expected one result", 1, target.size()); for (HostConfigMapping item : target) Assert.assertEquals("Expected version 'v1'", source.getVersion(), item.getVersion()); }