@Test public void should_return_ok_when_request_item_full() throws DatabaseException { ReconstructionResponseItem responseItem = new ReconstructionResponseItem(requestItem, StatusCode.OK); when(reconstructionService.reconstruct(requestItem)).thenReturn(responseItem); LogbookReconstructionResource reconstructionResource = new LogbookReconstructionResource(reconstructionService); Response response = reconstructionResource.reconstructCollection(Arrays.asList(requestItem)); assertThat(response.getStatus()).isEqualTo(Status.OK.getStatusCode()); List<ReconstructionResponseItem> responseEntity = (ArrayList<ReconstructionResponseItem>) response.getEntity(); assertThat(responseEntity).isNotNull(); assertThat(responseEntity.size()).isEqualTo(1); assertThat(responseEntity.get(0).getTenant()).isEqualTo(10); assertThat(responseEntity.get(0).getStatus()).isEqualTo(StatusCode.OK); }
@Path(RECONSTRUCTION_OPERATIONS_URI) @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @VitamAuthentication(authentLevel = AuthenticationLevel.BASIC_AUTHENT) public Response reconstructCollection(List<ReconstructionRequestItem> reconstructionItems) { ParametersChecker.checkParameter(RECONSTRUCTION_JSON_MONDATORY_PARAMETERS_MSG, reconstructionItems); List<ReconstructionResponseItem> responses = new ArrayList<>(); if (!reconstructionItems.isEmpty()) { LOGGER.debug(String .format("Starting reconstruction Vitam service with the json parameters : (%s)", reconstructionItems)); reconstructionItems.forEach(item -> { LOGGER.debug(String.format( "Starting reconstruction for the collection {%s} on the tenant (%s) with (%s) elements", LogbookCollections.OPERATION.name(), item.getTenant(), item.getLimit())); try { responses.add(reconstructionService.reconstruct(item)); } catch (DatabaseException | IllegalArgumentException e) { LOGGER.error(RECONSTRUCTION_EXCEPTION_MSG, e); responses.add(new ReconstructionResponseItem(item, StatusCode.KO)); } }); } return Response.ok().entity(responses).build(); }
LogbookReconstructionResource { @Path(RECONSTRUCTION_OPERATIONS_URI) @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @VitamAuthentication(authentLevel = AuthenticationLevel.BASIC_AUTHENT) public Response reconstructCollection(List<ReconstructionRequestItem> reconstructionItems) { ParametersChecker.checkParameter(RECONSTRUCTION_JSON_MONDATORY_PARAMETERS_MSG, reconstructionItems); List<ReconstructionResponseItem> responses = new ArrayList<>(); if (!reconstructionItems.isEmpty()) { LOGGER.debug(String .format("Starting reconstruction Vitam service with the json parameters : (%s)", reconstructionItems)); reconstructionItems.forEach(item -> { LOGGER.debug(String.format( "Starting reconstruction for the collection {%s} on the tenant (%s) with (%s) elements", LogbookCollections.OPERATION.name(), item.getTenant(), item.getLimit())); try { responses.add(reconstructionService.reconstruct(item)); } catch (DatabaseException | IllegalArgumentException e) { LOGGER.error(RECONSTRUCTION_EXCEPTION_MSG, e); responses.add(new ReconstructionResponseItem(item, StatusCode.KO)); } }); } return Response.ok().entity(responses).build(); } }
LogbookReconstructionResource { @Path(RECONSTRUCTION_OPERATIONS_URI) @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @VitamAuthentication(authentLevel = AuthenticationLevel.BASIC_AUTHENT) public Response reconstructCollection(List<ReconstructionRequestItem> reconstructionItems) { ParametersChecker.checkParameter(RECONSTRUCTION_JSON_MONDATORY_PARAMETERS_MSG, reconstructionItems); List<ReconstructionResponseItem> responses = new ArrayList<>(); if (!reconstructionItems.isEmpty()) { LOGGER.debug(String .format("Starting reconstruction Vitam service with the json parameters : (%s)", reconstructionItems)); reconstructionItems.forEach(item -> { LOGGER.debug(String.format( "Starting reconstruction for the collection {%s} on the tenant (%s) with (%s) elements", LogbookCollections.OPERATION.name(), item.getTenant(), item.getLimit())); try { responses.add(reconstructionService.reconstruct(item)); } catch (DatabaseException | IllegalArgumentException e) { LOGGER.error(RECONSTRUCTION_EXCEPTION_MSG, e); responses.add(new ReconstructionResponseItem(item, StatusCode.KO)); } }); } return Response.ok().entity(responses).build(); } LogbookReconstructionResource(
        VitamRepositoryProvider vitamRepositoryProvider,
        OffsetRepository offsetRepository); @VisibleForTesting  LogbookReconstructionResource(ReconstructionService reconstructionService); }
LogbookReconstructionResource { @Path(RECONSTRUCTION_OPERATIONS_URI) @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @VitamAuthentication(authentLevel = AuthenticationLevel.BASIC_AUTHENT) public Response reconstructCollection(List<ReconstructionRequestItem> reconstructionItems) { ParametersChecker.checkParameter(RECONSTRUCTION_JSON_MONDATORY_PARAMETERS_MSG, reconstructionItems); List<ReconstructionResponseItem> responses = new ArrayList<>(); if (!reconstructionItems.isEmpty()) { LOGGER.debug(String .format("Starting reconstruction Vitam service with the json parameters : (%s)", reconstructionItems)); reconstructionItems.forEach(item -> { LOGGER.debug(String.format( "Starting reconstruction for the collection {%s} on the tenant (%s) with (%s) elements", LogbookCollections.OPERATION.name(), item.getTenant(), item.getLimit())); try { responses.add(reconstructionService.reconstruct(item)); } catch (DatabaseException | IllegalArgumentException e) { LOGGER.error(RECONSTRUCTION_EXCEPTION_MSG, e); responses.add(new ReconstructionResponseItem(item, StatusCode.KO)); } }); } return Response.ok().entity(responses).build(); } LogbookReconstructionResource(
        VitamRepositoryProvider vitamRepositoryProvider,
        OffsetRepository offsetRepository); @VisibleForTesting  LogbookReconstructionResource(ReconstructionService reconstructionService); @Path(RECONSTRUCTION_OPERATIONS_URI) @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @VitamAuthentication(authentLevel = AuthenticationLevel.BASIC_AUTHENT) Response reconstructCollection(List<ReconstructionRequestItem> reconstructionItems); }
LogbookReconstructionResource { @Path(RECONSTRUCTION_OPERATIONS_URI) @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @VitamAuthentication(authentLevel = AuthenticationLevel.BASIC_AUTHENT) public Response reconstructCollection(List<ReconstructionRequestItem> reconstructionItems) { ParametersChecker.checkParameter(RECONSTRUCTION_JSON_MONDATORY_PARAMETERS_MSG, reconstructionItems); List<ReconstructionResponseItem> responses = new ArrayList<>(); if (!reconstructionItems.isEmpty()) { LOGGER.debug(String .format("Starting reconstruction Vitam service with the json parameters : (%s)", reconstructionItems)); reconstructionItems.forEach(item -> { LOGGER.debug(String.format( "Starting reconstruction for the collection {%s} on the tenant (%s) with (%s) elements", LogbookCollections.OPERATION.name(), item.getTenant(), item.getLimit())); try { responses.add(reconstructionService.reconstruct(item)); } catch (DatabaseException | IllegalArgumentException e) { LOGGER.error(RECONSTRUCTION_EXCEPTION_MSG, e); responses.add(new ReconstructionResponseItem(item, StatusCode.KO)); } }); } return Response.ok().entity(responses).build(); } LogbookReconstructionResource(
        VitamRepositoryProvider vitamRepositoryProvider,
        OffsetRepository offsetRepository); @VisibleForTesting  LogbookReconstructionResource(ReconstructionService reconstructionService); @Path(RECONSTRUCTION_OPERATIONS_URI) @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @VitamAuthentication(authentLevel = AuthenticationLevel.BASIC_AUTHENT) Response reconstructCollection(List<ReconstructionRequestItem> reconstructionItems);  }