@RunWithCustomExecutor @Test public void should_throw_IllegalArgumentException_when_item_is_null() { ReconstructionService reconstructionService = new ReconstructionService(vitamRepositoryProvider, restoreBackupService, logbookLifecycleClientFactory, storageClientFactory, offsetRepository); assertThatCode(() -> reconstructionService.reconstruct(null)) .isInstanceOf(IllegalArgumentException.class); }
public ReconstructionResponseItem reconstruct(ReconstructionRequestItem reconstructionItem) { ParametersChecker.checkParameter(RECONSTRUCTION_ITEM_MANDATORY_MSG, reconstructionItem); ParametersChecker.checkParameter(RECONSTRUCTION_COLLECTION_MANDATORY_MSG, reconstructionItem.getCollection()); ParametersChecker.checkParameter(RECONSTRUCTION_TENANT_MANDATORY_MSG, reconstructionItem.getTenant()); if (reconstructionItem.getLimit() < 0) { throw new IllegalArgumentException(RECONSTRUCTION_LIMIT_POSITIVE_MSG); } LOGGER .info(String.format( "[Reconstruction]: Reconstruction of {%s} Collection on {%s} Vitam tenant", reconstructionItem.getCollection(), reconstructionItem.getTenant())); switch (DataCategory.valueOf(reconstructionItem.getCollection().toUpperCase())) { case UNIT_GRAPH: case OBJECTGROUP_GRAPH: return reconstructGraphFromZipStream(reconstructionItem.getCollection(), reconstructionItem.getLimit()); case UNIT: case OBJECTGROUP: return reconstructCollection(MetadataCollections.getFromValue(reconstructionItem.getCollection()), reconstructionItem.getTenant(), reconstructionItem.getLimit()); default: return new ReconstructionResponseItem(reconstructionItem, StatusCode.KO); } }
ReconstructionService { public ReconstructionResponseItem reconstruct(ReconstructionRequestItem reconstructionItem) { ParametersChecker.checkParameter(RECONSTRUCTION_ITEM_MANDATORY_MSG, reconstructionItem); ParametersChecker.checkParameter(RECONSTRUCTION_COLLECTION_MANDATORY_MSG, reconstructionItem.getCollection()); ParametersChecker.checkParameter(RECONSTRUCTION_TENANT_MANDATORY_MSG, reconstructionItem.getTenant()); if (reconstructionItem.getLimit() < 0) { throw new IllegalArgumentException(RECONSTRUCTION_LIMIT_POSITIVE_MSG); } LOGGER .info(String.format( "[Reconstruction]: Reconstruction of {%s} Collection on {%s} Vitam tenant", reconstructionItem.getCollection(), reconstructionItem.getTenant())); switch (DataCategory.valueOf(reconstructionItem.getCollection().toUpperCase())) { case UNIT_GRAPH: case OBJECTGROUP_GRAPH: return reconstructGraphFromZipStream(reconstructionItem.getCollection(), reconstructionItem.getLimit()); case UNIT: case OBJECTGROUP: return reconstructCollection(MetadataCollections.getFromValue(reconstructionItem.getCollection()), reconstructionItem.getTenant(), reconstructionItem.getLimit()); default: return new ReconstructionResponseItem(reconstructionItem, StatusCode.KO); } } }
ReconstructionService { public ReconstructionResponseItem reconstruct(ReconstructionRequestItem reconstructionItem) { ParametersChecker.checkParameter(RECONSTRUCTION_ITEM_MANDATORY_MSG, reconstructionItem); ParametersChecker.checkParameter(RECONSTRUCTION_COLLECTION_MANDATORY_MSG, reconstructionItem.getCollection()); ParametersChecker.checkParameter(RECONSTRUCTION_TENANT_MANDATORY_MSG, reconstructionItem.getTenant()); if (reconstructionItem.getLimit() < 0) { throw new IllegalArgumentException(RECONSTRUCTION_LIMIT_POSITIVE_MSG); } LOGGER .info(String.format( "[Reconstruction]: Reconstruction of {%s} Collection on {%s} Vitam tenant", reconstructionItem.getCollection(), reconstructionItem.getTenant())); switch (DataCategory.valueOf(reconstructionItem.getCollection().toUpperCase())) { case UNIT_GRAPH: case OBJECTGROUP_GRAPH: return reconstructGraphFromZipStream(reconstructionItem.getCollection(), reconstructionItem.getLimit()); case UNIT: case OBJECTGROUP: return reconstructCollection(MetadataCollections.getFromValue(reconstructionItem.getCollection()), reconstructionItem.getTenant(), reconstructionItem.getLimit()); default: return new ReconstructionResponseItem(reconstructionItem, StatusCode.KO); } } ReconstructionService(VitamRepositoryProvider vitamRepositoryProvider,
        OffsetRepository offsetRepository); @VisibleForTesting  ReconstructionService(VitamRepositoryProvider vitamRepositoryProvider,
        RestoreBackupService recoverBackupService, LogbookLifeCyclesClientFactory logbookLifecycleClientFactory,
        StorageClientFactory storageClientFactory, OffsetRepository offsetRepository); }
ReconstructionService { public ReconstructionResponseItem reconstruct(ReconstructionRequestItem reconstructionItem) { ParametersChecker.checkParameter(RECONSTRUCTION_ITEM_MANDATORY_MSG, reconstructionItem); ParametersChecker.checkParameter(RECONSTRUCTION_COLLECTION_MANDATORY_MSG, reconstructionItem.getCollection()); ParametersChecker.checkParameter(RECONSTRUCTION_TENANT_MANDATORY_MSG, reconstructionItem.getTenant()); if (reconstructionItem.getLimit() < 0) { throw new IllegalArgumentException(RECONSTRUCTION_LIMIT_POSITIVE_MSG); } LOGGER .info(String.format( "[Reconstruction]: Reconstruction of {%s} Collection on {%s} Vitam tenant", reconstructionItem.getCollection(), reconstructionItem.getTenant())); switch (DataCategory.valueOf(reconstructionItem.getCollection().toUpperCase())) { case UNIT_GRAPH: case OBJECTGROUP_GRAPH: return reconstructGraphFromZipStream(reconstructionItem.getCollection(), reconstructionItem.getLimit()); case UNIT: case OBJECTGROUP: return reconstructCollection(MetadataCollections.getFromValue(reconstructionItem.getCollection()), reconstructionItem.getTenant(), reconstructionItem.getLimit()); default: return new ReconstructionResponseItem(reconstructionItem, StatusCode.KO); } } ReconstructionService(VitamRepositoryProvider vitamRepositoryProvider,
        OffsetRepository offsetRepository); @VisibleForTesting  ReconstructionService(VitamRepositoryProvider vitamRepositoryProvider,
        RestoreBackupService recoverBackupService, LogbookLifeCyclesClientFactory logbookLifecycleClientFactory,
        StorageClientFactory storageClientFactory, OffsetRepository offsetRepository); ReconstructionResponseItem reconstruct(ReconstructionRequestItem reconstructionItem); void purgeReconstructedDocumentsWithGraphOnlyData(MetadataCollections metaDaCollection); }
ReconstructionService { public ReconstructionResponseItem reconstruct(ReconstructionRequestItem reconstructionItem) { ParametersChecker.checkParameter(RECONSTRUCTION_ITEM_MANDATORY_MSG, reconstructionItem); ParametersChecker.checkParameter(RECONSTRUCTION_COLLECTION_MANDATORY_MSG, reconstructionItem.getCollection()); ParametersChecker.checkParameter(RECONSTRUCTION_TENANT_MANDATORY_MSG, reconstructionItem.getTenant()); if (reconstructionItem.getLimit() < 0) { throw new IllegalArgumentException(RECONSTRUCTION_LIMIT_POSITIVE_MSG); } LOGGER .info(String.format( "[Reconstruction]: Reconstruction of {%s} Collection on {%s} Vitam tenant", reconstructionItem.getCollection(), reconstructionItem.getTenant())); switch (DataCategory.valueOf(reconstructionItem.getCollection().toUpperCase())) { case UNIT_GRAPH: case OBJECTGROUP_GRAPH: return reconstructGraphFromZipStream(reconstructionItem.getCollection(), reconstructionItem.getLimit()); case UNIT: case OBJECTGROUP: return reconstructCollection(MetadataCollections.getFromValue(reconstructionItem.getCollection()), reconstructionItem.getTenant(), reconstructionItem.getLimit()); default: return new ReconstructionResponseItem(reconstructionItem, StatusCode.KO); } } ReconstructionService(VitamRepositoryProvider vitamRepositoryProvider,
        OffsetRepository offsetRepository); @VisibleForTesting  ReconstructionService(VitamRepositoryProvider vitamRepositoryProvider,
        RestoreBackupService recoverBackupService, LogbookLifeCyclesClientFactory logbookLifecycleClientFactory,
        StorageClientFactory storageClientFactory, OffsetRepository offsetRepository); ReconstructionResponseItem reconstruct(ReconstructionRequestItem reconstructionItem); void purgeReconstructedDocumentsWithGraphOnlyData(MetadataCollections metaDaCollection);  }