@Test public void testCreate() { UUID uuid = UUID.randomUUID(); RepositoryVersionEntity first = createSingleRecord(); Assert.assertNotNull(first); StackEntity stackEntity = stackDAO.find(first.getStackName(), first.getStackVersion()); Assert.assertNotNull(stackEntity); RepositoryVersionEntity dupVersion = new RepositoryVersionEntity(); dupVersion.setDisplayName("display name " + uuid.toString()); dupVersion.setOperatingSystems("repositories"); dupVersion.setStack(stackEntity); dupVersion.setVersion(first.getVersion()); boolean exceptionThrown = false; try { repositoryVersionDAO.create(stackEntity, dupVersion.getVersion(), dupVersion.getDisplayName(), dupVersion.getOperatingSystemsJson()); } catch (AmbariException e) { exceptionThrown = true; Assert.assertTrue(e.getMessage().contains("already exists")); } Assert.assertTrue(exceptionThrown); exceptionThrown = false; dupVersion.setVersion("2.3-1234"); try { repositoryVersionDAO.create(stackEntity, dupVersion.getVersion(), dupVersion.getDisplayName(), dupVersion.getOperatingSystemsJson()); } catch (AmbariException e) { exceptionThrown = true; Assert.assertTrue(e.getMessage().contains("needs to belong to stack")); } Assert.assertTrue(exceptionThrown); dupVersion.setVersion(stackEntity.getStackVersion() + "-1234"); try { repositoryVersionDAO.create(stackEntity, dupVersion.getVersion(), dupVersion.getDisplayName(), dupVersion.getOperatingSystemsJson()); } catch (AmbariException e) { Assert.fail("Did not expect a failure creating the Repository Version"); } }
@Override @Transactional public void create(RepositoryVersionEntity entity){ super.create(entity); }
RepositoryVersionDAO extends CrudDAO<RepositoryVersionEntity, Long> { @Override @Transactional public void create(RepositoryVersionEntity entity){ super.create(entity); } }
RepositoryVersionDAO extends CrudDAO<RepositoryVersionEntity, Long> { @Override @Transactional public void create(RepositoryVersionEntity entity){ super.create(entity); } RepositoryVersionDAO(); }
RepositoryVersionDAO extends CrudDAO<RepositoryVersionEntity, Long> { @Override @Transactional public void create(RepositoryVersionEntity entity){ super.create(entity); } RepositoryVersionDAO(); @Override @Transactional void create(RepositoryVersionEntity entity); @RequiresSession RepositoryVersionEntity findByDisplayName(String displayName); @RequiresSession RepositoryVersionEntity findByStackAndVersion(StackId stackId,
      String version); @RequiresSession RepositoryVersionEntity findByStackAndVersion(StackEntity stackEntity,
      String version); @RequiresSession RepositoryVersionEntity findByStackNameAndVersion(String stackName, String version); @RequiresSession List<RepositoryVersionEntity> findByStack(StackId stackId); RepositoryVersionEntity create(StackEntity stackEntity,
      String version, String displayName,
      String operatingSystems); @Transactional RepositoryVersionEntity create(StackEntity stackEntity,
      String version, String displayName,
      String operatingSystems, RepositoryType type); @RequiresSession List<RepositoryVersionEntity> findAllDefinitions(); }
RepositoryVersionDAO extends CrudDAO<RepositoryVersionEntity, Long> { @Override @Transactional public void create(RepositoryVersionEntity entity){ super.create(entity); } RepositoryVersionDAO(); @Override @Transactional void create(RepositoryVersionEntity entity); @RequiresSession RepositoryVersionEntity findByDisplayName(String displayName); @RequiresSession RepositoryVersionEntity findByStackAndVersion(StackId stackId,
      String version); @RequiresSession RepositoryVersionEntity findByStackAndVersion(StackEntity stackEntity,
      String version); @RequiresSession RepositoryVersionEntity findByStackNameAndVersion(String stackName, String version); @RequiresSession List<RepositoryVersionEntity> findByStack(StackId stackId); RepositoryVersionEntity create(StackEntity stackEntity,
      String version, String displayName,
      String operatingSystems); @Transactional RepositoryVersionEntity create(StackEntity stackEntity,
      String version, String displayName,
      String operatingSystems, RepositoryType type); @RequiresSession List<RepositoryVersionEntity> findAllDefinitions();  }