### Question:
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); @RequiresSession List<RepositoryVersionEntity> findByStackAndType(StackId stackId, RepositoryType type); RepositoryVersionEntity create(StackEntity stackEntity,
                                        String version, String displayName,
                                        List<RepoOsEntity> repoOsEntities); @Transactional RepositoryVersionEntity create(StackEntity stackEntity,
                                        String version, String displayName, List<RepoOsEntity> repoOsEntities,
                                        RepositoryType type); @RequiresSession List<RepositoryVersionEntity> findRepositoriesWithVersionDefinitions(); @RequiresSession RepositoryVersionEntity findByVersion(String repositoryVersion); @RequiresSession List<RepositoryVersionEntity> findByServiceDesiredVersion(List<RepositoryVersionEntity> matching);  }### Answer:
@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); dupVersion.addRepoOsEntities(new ArrayList<>()); dupVersion.setStack(stackEntity); dupVersion.setVersion(first.getVersion()); boolean exceptionThrown = false; try { repositoryVersionDAO.create(stackEntity, dupVersion.getVersion(), dupVersion.getDisplayName(), dupVersion.getRepoOsEntities()); } 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.getRepoOsEntities()); } 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.getRepoOsEntities()); } catch (AmbariException e) { Assert.fail("Did not expect a failure creating the Repository Version"); } }