@RunWithCustomExecutor @Test public void givenStartedServerWhenSearchLogbookThenOK() throws Exception { reset(logbookOperationsClient); reset(processingManagementClient); reset(workspaceClient); when(logbookOperationsClient.selectOperation(any())) .thenReturn(JsonHandler.getFromString(queryDsql)); given().contentType(ContentType.JSON).body(new Select().getFinalSelect()) .header(GlobalDataRest.X_TENANT_ID, TENANT_ID) .header(GlobalDataRest.X_REQUEST_ID, VitamThreadUtils.getVitamSession().getRequestId()) .when().get("/operations").then().statusCode(Status.OK.getStatusCode()); }
@GET @Path("/operations") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response selectOperation(JsonNode query) { Status status; try (LogbookOperationsClient client = logbookOperationsClientFactory.getClient()) { final SelectParserSingle parser = new SelectParserSingle(); parser.parse(query); parser.getRequest().reset(); final JsonNode result = client.selectOperation(query); return Response.status(Status.OK).entity(result).build(); } catch (final LogbookClientException e) { LOGGER.error(e); status = Status.INTERNAL_SERVER_ERROR; return Response.status(status).entity(getErrorEntity(status, e.getMessage())).build(); } catch (final InvalidParseOperationException e) { LOGGER.error(e); status = Status.PRECONDITION_FAILED; return Response.status(status).entity(getErrorEntity(status, e.getMessage())).build(); } }
LogbookInternalResourceImpl { @GET @Path("/operations") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response selectOperation(JsonNode query) { Status status; try (LogbookOperationsClient client = logbookOperationsClientFactory.getClient()) { final SelectParserSingle parser = new SelectParserSingle(); parser.parse(query); parser.getRequest().reset(); final JsonNode result = client.selectOperation(query); return Response.status(Status.OK).entity(result).build(); } catch (final LogbookClientException e) { LOGGER.error(e); status = Status.INTERNAL_SERVER_ERROR; return Response.status(status).entity(getErrorEntity(status, e.getMessage())).build(); } catch (final InvalidParseOperationException e) { LOGGER.error(e); status = Status.PRECONDITION_FAILED; return Response.status(status).entity(getErrorEntity(status, e.getMessage())).build(); } } }
LogbookInternalResourceImpl { @GET @Path("/operations") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response selectOperation(JsonNode query) { Status status; try (LogbookOperationsClient client = logbookOperationsClientFactory.getClient()) { final SelectParserSingle parser = new SelectParserSingle(); parser.parse(query); parser.getRequest().reset(); final JsonNode result = client.selectOperation(query); return Response.status(Status.OK).entity(result).build(); } catch (final LogbookClientException e) { LOGGER.error(e); status = Status.INTERNAL_SERVER_ERROR; return Response.status(status).entity(getErrorEntity(status, e.getMessage())).build(); } catch (final InvalidParseOperationException e) { LOGGER.error(e); status = Status.PRECONDITION_FAILED; return Response.status(status).entity(getErrorEntity(status, e.getMessage())).build(); } } LogbookInternalResourceImpl(); @VisibleForTesting  LogbookInternalResourceImpl(LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory,
        LogbookOperationsClientFactory logbookOperationsClientFactory, StorageClientFactory storageClientFactory,
        WorkspaceClientFactory workspaceClientFactory, AdminManagementClientFactory adminManagementClientFactory,
        MetaDataClientFactory metaDataClientFactory,
        ProcessingManagementClientFactory processingManagementClientFactory); }
LogbookInternalResourceImpl { @GET @Path("/operations") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response selectOperation(JsonNode query) { Status status; try (LogbookOperationsClient client = logbookOperationsClientFactory.getClient()) { final SelectParserSingle parser = new SelectParserSingle(); parser.parse(query); parser.getRequest().reset(); final JsonNode result = client.selectOperation(query); return Response.status(Status.OK).entity(result).build(); } catch (final LogbookClientException e) { LOGGER.error(e); status = Status.INTERNAL_SERVER_ERROR; return Response.status(status).entity(getErrorEntity(status, e.getMessage())).build(); } catch (final InvalidParseOperationException e) { LOGGER.error(e); status = Status.PRECONDITION_FAILED; return Response.status(status).entity(getErrorEntity(status, e.getMessage())).build(); } } LogbookInternalResourceImpl(); @VisibleForTesting  LogbookInternalResourceImpl(LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory,
        LogbookOperationsClientFactory logbookOperationsClientFactory, StorageClientFactory storageClientFactory,
        WorkspaceClientFactory workspaceClientFactory, AdminManagementClientFactory adminManagementClientFactory,
        MetaDataClientFactory metaDataClientFactory,
        ProcessingManagementClientFactory processingManagementClientFactory); @GET @Path("/operations/{id_op}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response getOperationById(@PathParam("id_op") String operationId, JsonNode queryDsl); @GET @Path("/operations") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response selectOperation(JsonNode query); @GET @Path("/slicedOperations") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response selectOperationSliced(JsonNode query); @GET @Path("/unitlifecycles/{id_lc}") @Produces(MediaType.APPLICATION_JSON) Response getUnitLifeCycleById(@PathParam("id_lc") String unitLifeCycleId, JsonNode queryDsl); @GET @Path("/objectgrouplifecycles/{id_lc}") @Produces(MediaType.APPLICATION_JSON) Response getObjectGroupLifeCycleById(@PathParam("id_lc") String objectGroupLifeCycleId, JsonNode queryDsl); @POST @Path("/traceability/check") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response checkOperationTraceability(JsonNode query); @GET @Path("/traceability/{idOperation}/content") @Produces(MediaType.APPLICATION_OCTET_STREAM) Response downloadTraceabilityOperation(@PathParam("idOperation") String operationId); }
LogbookInternalResourceImpl { @GET @Path("/operations") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response selectOperation(JsonNode query) { Status status; try (LogbookOperationsClient client = logbookOperationsClientFactory.getClient()) { final SelectParserSingle parser = new SelectParserSingle(); parser.parse(query); parser.getRequest().reset(); final JsonNode result = client.selectOperation(query); return Response.status(Status.OK).entity(result).build(); } catch (final LogbookClientException e) { LOGGER.error(e); status = Status.INTERNAL_SERVER_ERROR; return Response.status(status).entity(getErrorEntity(status, e.getMessage())).build(); } catch (final InvalidParseOperationException e) { LOGGER.error(e); status = Status.PRECONDITION_FAILED; return Response.status(status).entity(getErrorEntity(status, e.getMessage())).build(); } } LogbookInternalResourceImpl(); @VisibleForTesting  LogbookInternalResourceImpl(LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory,
        LogbookOperationsClientFactory logbookOperationsClientFactory, StorageClientFactory storageClientFactory,
        WorkspaceClientFactory workspaceClientFactory, AdminManagementClientFactory adminManagementClientFactory,
        MetaDataClientFactory metaDataClientFactory,
        ProcessingManagementClientFactory processingManagementClientFactory); @GET @Path("/operations/{id_op}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response getOperationById(@PathParam("id_op") String operationId, JsonNode queryDsl); @GET @Path("/operations") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response selectOperation(JsonNode query); @GET @Path("/slicedOperations") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response selectOperationSliced(JsonNode query); @GET @Path("/unitlifecycles/{id_lc}") @Produces(MediaType.APPLICATION_JSON) Response getUnitLifeCycleById(@PathParam("id_lc") String unitLifeCycleId, JsonNode queryDsl); @GET @Path("/objectgrouplifecycles/{id_lc}") @Produces(MediaType.APPLICATION_JSON) Response getObjectGroupLifeCycleById(@PathParam("id_lc") String objectGroupLifeCycleId, JsonNode queryDsl); @POST @Path("/traceability/check") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response checkOperationTraceability(JsonNode query); @GET @Path("/traceability/{idOperation}/content") @Produces(MediaType.APPLICATION_OCTET_STREAM) Response downloadTraceabilityOperation(@PathParam("idOperation") String operationId);  }