@Test void testMaxProgress() { ResourceIdentifier id1 = create(ENTITY_TYPE, "e1"); ResourceIdentifier id2 = create(ENTITY_TYPE_ABSTRACT, "e2"); ResourceIdentifier id3 = create(PACKAGE, "p1"); EntityType entityType1 = mock(EntityType.class); EntityType entityType2 = mock(EntityType.class); Package pack = mock(Package.class); Package childPack1 = mock(Package.class); Package childPack2 = mock(Package.class); when(childPack2.getEntityTypes()).thenReturn(singletonList(mock(EntityType.class))); when(pack.getChildren()).thenReturn(asList(childPack1, childPack2)); ResourceCollection collection = ResourceCollection.of(singletonList(pack), asList(entityType1, entityType2)); when(resourceCollector.get(asList(id1, id2, id3))).thenReturn(collection); Progress progress = mock(Progress.class); copyService.copy(asList(id1, id2, id3), null, progress); verify(progress).setProgressMax(6); }
@Override @SuppressWarnings( "java:S1193") @Transactional(isolation = Isolation.SERIALIZABLE) public Void copy( List<ResourceIdentifier> resources, @Nullable @CheckForNull String targetPackageId, Progress progress) { try { ResourceCollection resourceCollection = resourceCollector.get(resources); Package targetPackage = getPackage(targetPackageId); CopyState state = CopyState.create(targetPackage, progress); copyResources(resourceCollection, state); } catch (RuntimeException e) { if (e instanceof ErrorCoded) { throw e; } else { throw new UnknownCopyFailedException(e); } } return null; }
CopyServiceImpl implements CopyService { @Override @SuppressWarnings( "java:S1193") @Transactional(isolation = Isolation.SERIALIZABLE) public Void copy( List<ResourceIdentifier> resources, @Nullable @CheckForNull String targetPackageId, Progress progress) { try { ResourceCollection resourceCollection = resourceCollector.get(resources); Package targetPackage = getPackage(targetPackageId); CopyState state = CopyState.create(targetPackage, progress); copyResources(resourceCollection, state); } catch (RuntimeException e) { if (e instanceof ErrorCoded) { throw e; } else { throw new UnknownCopyFailedException(e); } } return null; } }
CopyServiceImpl implements CopyService { @Override @SuppressWarnings( "java:S1193") @Transactional(isolation = Isolation.SERIALIZABLE) public Void copy( List<ResourceIdentifier> resources, @Nullable @CheckForNull String targetPackageId, Progress progress) { try { ResourceCollection resourceCollection = resourceCollector.get(resources); Package targetPackage = getPackage(targetPackageId); CopyState state = CopyState.create(targetPackage, progress); copyResources(resourceCollection, state); } catch (RuntimeException e) { if (e instanceof ErrorCoded) { throw e; } else { throw new UnknownCopyFailedException(e); } } return null; } CopyServiceImpl(
      ResourceCollector resourceCollector,
      MetaDataService metadataService,
      PackageCopier packageCopier,
      EntityTypeCopier entityTypeCopier,
      ContextMessageSource contextMessageSource); }
CopyServiceImpl implements CopyService { @Override @SuppressWarnings( "java:S1193") @Transactional(isolation = Isolation.SERIALIZABLE) public Void copy( List<ResourceIdentifier> resources, @Nullable @CheckForNull String targetPackageId, Progress progress) { try { ResourceCollection resourceCollection = resourceCollector.get(resources); Package targetPackage = getPackage(targetPackageId); CopyState state = CopyState.create(targetPackage, progress); copyResources(resourceCollection, state); } catch (RuntimeException e) { if (e instanceof ErrorCoded) { throw e; } else { throw new UnknownCopyFailedException(e); } } return null; } CopyServiceImpl(
      ResourceCollector resourceCollector,
      MetaDataService metadataService,
      PackageCopier packageCopier,
      EntityTypeCopier entityTypeCopier,
      ContextMessageSource contextMessageSource); @Override @SuppressWarnings( "java:S1193") // Exception types should not be tested using "instanceof" in catch blocks @Transactional(isolation = Isolation.SERIALIZABLE) Void copy(
      List<ResourceIdentifier> resources,
      @Nullable @CheckForNull String targetPackageId,
      Progress progress); }
CopyServiceImpl implements CopyService { @Override @SuppressWarnings( "java:S1193") @Transactional(isolation = Isolation.SERIALIZABLE) public Void copy( List<ResourceIdentifier> resources, @Nullable @CheckForNull String targetPackageId, Progress progress) { try { ResourceCollection resourceCollection = resourceCollector.get(resources); Package targetPackage = getPackage(targetPackageId); CopyState state = CopyState.create(targetPackage, progress); copyResources(resourceCollection, state); } catch (RuntimeException e) { if (e instanceof ErrorCoded) { throw e; } else { throw new UnknownCopyFailedException(e); } } return null; } CopyServiceImpl(
      ResourceCollector resourceCollector,
      MetaDataService metadataService,
      PackageCopier packageCopier,
      EntityTypeCopier entityTypeCopier,
      ContextMessageSource contextMessageSource); @Override @SuppressWarnings( "java:S1193") // Exception types should not be tested using "instanceof" in catch blocks @Transactional(isolation = Isolation.SERIALIZABLE) Void copy(
      List<ResourceIdentifier> resources,
      @Nullable @CheckForNull String targetPackageId,
      Progress progress);  }