ClusterVersionDAO extends CrudDAO<ClusterVersionEntity, Long> { @RequiresSession public ClusterVersionEntity findByClusterAndStackAndVersion( String clusterName, StackId stackId, String version) { final TypedQuery<ClusterVersionEntity> query = entityManagerProvider.get() .createNamedQuery("clusterVersionByClusterAndStackAndVersion", ClusterVersionEntity.class); query.setParameter("clusterName", clusterName); query.setParameter("stackName", stackId.getStackName()); query.setParameter("stackVersion", stackId.getStackVersion()); query.setParameter("version", version); return daoUtils.selectSingle(query); } ClusterVersionDAO(); @RequiresSession List<ClusterVersionEntity> findByStackAndVersion(String stackName,
      String stackVersion, String version); @RequiresSession ClusterVersionEntity findByClusterAndStackAndVersion(
      String clusterName, StackId stackId, String version); @RequiresSession List<ClusterVersionEntity> findByCluster(String clusterName); @RequiresSession ClusterVersionEntity findByClusterAndStateCurrent(String clusterName); @RequiresSession List<ClusterVersionEntity> findByClusterAndState(String clusterName, RepositoryVersionState state); @Override @Transactional void create(ClusterVersionEntity entity); @Transactional ClusterVersionEntity create(ClusterEntity cluster, RepositoryVersionEntity repositoryVersion,
                                     RepositoryVersionState state, long startTime, long endTime, String userName); @Transactional void updateVersions(Long clusterId, RepositoryVersionEntity target, RepositoryVersionEntity current);  }
@Test public void testFindByClusterAndStackAndVersion() throws Exception { createRecordsUntilStep(1); Assert.assertNull(clusterVersionDAO.findByClusterAndStackAndVersion( cluster.getClusterName(), BAD_STACK, "non existing")); Assert.assertNotNull(clusterVersionDAO.findByClusterAndStackAndVersion( cluster.getClusterName(), HDP_22_STACK, "2.2.0.0-995")); }