@Test void testCopyRepository() { Repository<Entity> repository = getMockRepository(); @SuppressWarnings("unchecked") Query<Entity> query = mock(Query.class); @SuppressWarnings("unchecked") Stream<Entity> entitiesStream = mock(Stream.class); when(query.findAll()).thenReturn(entitiesStream); when(repository.query()).thenReturn(query); String entityTypeId = "copiedEntityTypeId"; Package package_ = mock(Package.class); when(package_.toString()).thenReturn("Package"); String entityTypeLabel = "copiedEntityTypeLabel"; @SuppressWarnings("unchecked") Repository<Entity> copiedRepository = mock(Repository.class); when(metaDataService.createRepository(any(EntityType.class))).thenReturn(copiedRepository); assertEquals( copiedRepository, repositoryCopier.copyRepository(repository, entityTypeId, package_, entityTypeLabel)); ArgumentCaptor<EntityType> entityTypeCaptor = ArgumentCaptor.forClass(EntityType.class); verify(metaDataService).createRepository(entityTypeCaptor.capture()); EntityType copiedEntityType = entityTypeCaptor.getValue(); assertEquals(entityTypeId, copiedEntityType.getId()); assertEquals(entityTypeLabel, copiedEntityType.getLabel()); assertEquals(package_, copiedEntityType.getPackage()); verify(copiedRepository).add(entitiesStream); }
@Transactional public Repository<Entity> copyRepository( Repository<Entity> repository, String entityTypeId, Package pack, String entityTypeLabel) { LOG.info( "Creating a copy of {} repository, with id: {}, package: {} and label: {}", repository.getName(), entityTypeId, pack, entityTypeLabel); EntityType emd = EntityType.newInstance(repository.getEntityType(), DEEP_COPY_ATTRS, attrFactory); emd.setId(entityTypeId); emd.setLabel(entityTypeLabel); emd.setPackage(pack); Repository<Entity> repositoryCopy = metaDataService.createRepository(emd); repositoryCopy.add(repository.query().findAll()); return repositoryCopy; }
RepositoryCopier { @Transactional public Repository<Entity> copyRepository( Repository<Entity> repository, String entityTypeId, Package pack, String entityTypeLabel) { LOG.info( "Creating a copy of {} repository, with id: {}, package: {} and label: {}", repository.getName(), entityTypeId, pack, entityTypeLabel); EntityType emd = EntityType.newInstance(repository.getEntityType(), DEEP_COPY_ATTRS, attrFactory); emd.setId(entityTypeId); emd.setLabel(entityTypeLabel); emd.setPackage(pack); Repository<Entity> repositoryCopy = metaDataService.createRepository(emd); repositoryCopy.add(repository.query().findAll()); return repositoryCopy; } }
RepositoryCopier { @Transactional public Repository<Entity> copyRepository( Repository<Entity> repository, String entityTypeId, Package pack, String entityTypeLabel) { LOG.info( "Creating a copy of {} repository, with id: {}, package: {} and label: {}", repository.getName(), entityTypeId, pack, entityTypeLabel); EntityType emd = EntityType.newInstance(repository.getEntityType(), DEEP_COPY_ATTRS, attrFactory); emd.setId(entityTypeId); emd.setLabel(entityTypeLabel); emd.setPackage(pack); Repository<Entity> repositoryCopy = metaDataService.createRepository(emd); repositoryCopy.add(repository.query().findAll()); return repositoryCopy; } RepositoryCopier(MetaDataService metaDataService, AttributeFactory attrFactory); }
RepositoryCopier { @Transactional public Repository<Entity> copyRepository( Repository<Entity> repository, String entityTypeId, Package pack, String entityTypeLabel) { LOG.info( "Creating a copy of {} repository, with id: {}, package: {} and label: {}", repository.getName(), entityTypeId, pack, entityTypeLabel); EntityType emd = EntityType.newInstance(repository.getEntityType(), DEEP_COPY_ATTRS, attrFactory); emd.setId(entityTypeId); emd.setLabel(entityTypeLabel); emd.setPackage(pack); Repository<Entity> repositoryCopy = metaDataService.createRepository(emd); repositoryCopy.add(repository.query().findAll()); return repositoryCopy; } RepositoryCopier(MetaDataService metaDataService, AttributeFactory attrFactory); @Transactional Repository<Entity> copyRepository(
      Repository<Entity> repository, String entityTypeId, Package pack, String entityTypeLabel); }
RepositoryCopier { @Transactional public Repository<Entity> copyRepository( Repository<Entity> repository, String entityTypeId, Package pack, String entityTypeLabel) { LOG.info( "Creating a copy of {} repository, with id: {}, package: {} and label: {}", repository.getName(), entityTypeId, pack, entityTypeLabel); EntityType emd = EntityType.newInstance(repository.getEntityType(), DEEP_COPY_ATTRS, attrFactory); emd.setId(entityTypeId); emd.setLabel(entityTypeLabel); emd.setPackage(pack); Repository<Entity> repositoryCopy = metaDataService.createRepository(emd); repositoryCopy.add(repository.query().findAll()); return repositoryCopy; } RepositoryCopier(MetaDataService metaDataService, AttributeFactory attrFactory); @Transactional Repository<Entity> copyRepository(
      Repository<Entity> repository, String entityTypeId, Package pack, String entityTypeLabel);  }