@Test public void testFindByClusterAndState() throws Exception { createRecordsUntilStep(1); Assert.assertEquals(1, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.CURRENT).size()); Assert.assertEquals(0, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALLED).size()); Assert.assertEquals(0, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALLING).size()); Assert.assertEquals(0, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALL_FAILED).size()); createRecordsUntilStep(2); Assert.assertEquals(1, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.CURRENT).size()); Assert.assertEquals(1, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALLED).size()); Assert.assertEquals(0, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALLING).size()); Assert.assertEquals(0, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALL_FAILED).size()); createRecordsUntilStep(3); Assert.assertEquals(1, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.CURRENT).size()); Assert.assertEquals(1, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALLED).size()); Assert.assertEquals(0, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALLING).size()); Assert.assertEquals(0, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALL_FAILED).size()); createRecordsUntilStep(4); Assert.assertEquals(1, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.CURRENT).size()); Assert.assertEquals(1, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALLED).size()); Assert.assertEquals(1, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALLING).size()); Assert.assertEquals(0, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALL_FAILED).size()); createRecordsUntilStep(5); Assert.assertEquals(1, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.CURRENT).size()); Assert.assertEquals(1, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALLED).size()); Assert.assertEquals(0, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALLING).size()); Assert.assertEquals(1, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALL_FAILED).size()); createRecordsUntilStep(6); Assert.assertEquals(1, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.CURRENT).size()); Assert.assertEquals(1, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALLED).size()); Assert.assertEquals(1, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALLING).size()); Assert.assertEquals(0, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALL_FAILED).size()); createRecordsUntilStep(7); Assert.assertEquals(1, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.CURRENT).size()); Assert.assertEquals(2, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALLED).size()); Assert.assertEquals(0, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALLING).size()); Assert.assertEquals(0, clusterVersionDAO.findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALL_FAILED).size()); }
@RequiresSession public List<ClusterVersionEntity> findByClusterAndState(String clusterName, RepositoryVersionState state) { final TypedQuery<ClusterVersionEntity> query = entityManagerProvider.get() .createNamedQuery("clusterVersionByClusterAndState", ClusterVersionEntity.class); query.setParameter("clusterName", clusterName); query.setParameter("state", state); return daoUtils.selectList(query); }
ClusterVersionDAO extends CrudDAO<ClusterVersionEntity, Long> { @RequiresSession public List<ClusterVersionEntity> findByClusterAndState(String clusterName, RepositoryVersionState state) { final TypedQuery<ClusterVersionEntity> query = entityManagerProvider.get() .createNamedQuery("clusterVersionByClusterAndState", ClusterVersionEntity.class); query.setParameter("clusterName", clusterName); query.setParameter("state", state); return daoUtils.selectList(query); } }
ClusterVersionDAO extends CrudDAO<ClusterVersionEntity, Long> { @RequiresSession public List<ClusterVersionEntity> findByClusterAndState(String clusterName, RepositoryVersionState state) { final TypedQuery<ClusterVersionEntity> query = entityManagerProvider.get() .createNamedQuery("clusterVersionByClusterAndState", ClusterVersionEntity.class); query.setParameter("clusterName", clusterName); query.setParameter("state", state); return daoUtils.selectList(query); } ClusterVersionDAO(); }
ClusterVersionDAO extends CrudDAO<ClusterVersionEntity, Long> { @RequiresSession public List<ClusterVersionEntity> findByClusterAndState(String clusterName, RepositoryVersionState state) { final TypedQuery<ClusterVersionEntity> query = entityManagerProvider.get() .createNamedQuery("clusterVersionByClusterAndState", ClusterVersionEntity.class); query.setParameter("clusterName", clusterName); query.setParameter("state", state); return daoUtils.selectList(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); }
ClusterVersionDAO extends CrudDAO<ClusterVersionEntity, Long> { @RequiresSession public List<ClusterVersionEntity> findByClusterAndState(String clusterName, RepositoryVersionState state) { final TypedQuery<ClusterVersionEntity> query = entityManagerProvider.get() .createNamedQuery("clusterVersionByClusterAndState", ClusterVersionEntity.class); query.setParameter("clusterName", clusterName); query.setParameter("state", state); return daoUtils.selectList(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);  }