HostVersionDAO extends CrudDAO<HostVersionEntity, Long> { @RequiresSession public List<HostVersionEntity> findByClusterAndHost(String clusterName, String hostName) { final TypedQuery<HostVersionEntity> query = entityManagerProvider.get() .createNamedQuery("hostVersionByClusterAndHostname", HostVersionEntity.class); query.setParameter("clusterName", clusterName); query.setParameter("hostName", hostName); return daoUtils.selectList(query); } HostVersionDAO(); @Override @Transactional void create(HostVersionEntity entity); @RequiresSession List<HostVersionEntity> findByClusterStackAndVersion(
      String clusterName, StackId stackId, String version); @RequiresSession List<HostVersionEntity> findByHost(String hostName); @RequiresSession List<HostVersionEntity> findByClusterAndHost(String  clusterName, String hostName); @RequiresSession List<HostVersionEntity> findByClusterHostAndState(String  clusterName, String hostName, RepositoryVersionState state); @RequiresSession List<HostVersionEntity> findByClusterHostAndState(long clusterId, long hostId, RepositoryVersionState state); @RequiresSession HostVersionEntity findByHostAndStateCurrent(String clusterName, String hostName); @RequiresSession HostVersionEntity findByHostAndStateCurrent(long clusterId, long hostId); @RequiresSession HostVersionEntity findByClusterStackVersionAndHost(String clusterName,
      StackId stackId, String version, String hostName); @RequiresSession HostVersionEntity findByClusterStackVersionAndHost(long clusterId, StackId stackId, String version,
                                                            long hostId); @Transactional void removeByHostName(String hostName); @Transactional void updateVersions(RepositoryVersionEntity target, RepositoryVersionEntity current);  }
@Test public void testFindByClusterAndHost() { Assert.assertEquals(1, hostVersionDAO.findByClusterAndHost("test_cluster1", "test_host1").size()); Assert.assertEquals(1, hostVersionDAO.findByClusterAndHost("test_cluster1", "test_host2").size()); Assert.assertEquals(1, hostVersionDAO.findByClusterAndHost("test_cluster1", "test_host3").size()); addMoreVersions(); Assert.assertEquals(3, hostVersionDAO.findByClusterAndHost("test_cluster1", "test_host1").size()); Assert.assertEquals(3, hostVersionDAO.findByClusterAndHost("test_cluster1", "test_host2").size()); Assert.assertEquals(3, hostVersionDAO.findByClusterAndHost("test_cluster1", "test_host3").size()); }