@Test @RunWithCustomExecutor public void should_retrieve_unit_with_xml_format() throws Exception { RequestResponseOK<JsonNode> requestResponse = new RequestResponseOK<>(); InputStream resourceAsStream = getClass().getResourceAsStream("/simpleUnit.json"); JsonNode jsonNode = JsonHandler.getFromInputStream(resourceAsStream); requestResponse.addResult(jsonNode); when(metaDataClient.selectUnitbyId(any(), anyString())) .thenReturn(JsonHandler.toJsonNode(requestResponse)); ArchiveUnitModel archiveUnitModel = buildObjectMapper().treeToValue(jsonNode, ArchiveUnitModel.class); Assert.notNull(archiveUnitModel); Assert.notNull(archiveUnitModel.getManagement()); given().contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_XML) .header(GlobalDataRest.X_ACCESS_CONTRAT_ID, "all") .headers(getStreamHeaders()) .body(BODY_TEST).when().get(ACCESS_UNITS_URI + "/1234").then() .statusCode(Status.OK.getStatusCode()); }
private ObjectMapper buildObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); mapper.enable(SerializationFeature.INDENT_OUTPUT); SimpleModule module = new SimpleModule(); module.addDeserializer(TextByLang.class, new TextByLangDeserializer()); module.addDeserializer(LevelType.class, new LevelTypeDeserializer()); module.addDeserializer(IdentifierType.class, new IdentifierTypeDeserializer()); mapper.registerModule(module); return mapper; }
AccessInternalResourceImpl extends ApplicationStatusResource implements AccessInternalResource { private ObjectMapper buildObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); mapper.enable(SerializationFeature.INDENT_OUTPUT); SimpleModule module = new SimpleModule(); module.addDeserializer(TextByLang.class, new TextByLangDeserializer()); module.addDeserializer(LevelType.class, new LevelTypeDeserializer()); module.addDeserializer(IdentifierType.class, new IdentifierTypeDeserializer()); mapper.registerModule(module); return mapper; } }
AccessInternalResourceImpl extends ApplicationStatusResource implements AccessInternalResource { private ObjectMapper buildObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); mapper.enable(SerializationFeature.INDENT_OUTPUT); SimpleModule module = new SimpleModule(); module.addDeserializer(TextByLang.class, new TextByLangDeserializer()); module.addDeserializer(LevelType.class, new LevelTypeDeserializer()); module.addDeserializer(IdentifierType.class, new IdentifierTypeDeserializer()); mapper.registerModule(module); return mapper; } AccessInternalResourceImpl(AccessInternalConfiguration configuration); @VisibleForTesting  AccessInternalResourceImpl(LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory,
        LogbookOperationsClientFactory logbookOperationsClientFactory, StorageClientFactory storageClientFactory,
        WorkspaceClientFactory workspaceClientFactory, AdminManagementClientFactory adminManagementClientFactory,
        MetaDataClientFactory metaDataClientFactory,
        ProcessingManagementClientFactory processingManagementClientFactory); @VisibleForTesting private  AccessInternalResourceImpl(AccessInternalModule accessModule,
        LogbookOperationsClientFactory logbookOperationsClientFactory,
        WorkspaceClientFactory workspaceClientFactory,
        ProcessingManagementClientFactory processingManagementClientFactory); }
AccessInternalResourceImpl extends ApplicationStatusResource implements AccessInternalResource { private ObjectMapper buildObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); mapper.enable(SerializationFeature.INDENT_OUTPUT); SimpleModule module = new SimpleModule(); module.addDeserializer(TextByLang.class, new TextByLangDeserializer()); module.addDeserializer(LevelType.class, new LevelTypeDeserializer()); module.addDeserializer(IdentifierType.class, new IdentifierTypeDeserializer()); mapper.registerModule(module); return mapper; } AccessInternalResourceImpl(AccessInternalConfiguration configuration); @VisibleForTesting  AccessInternalResourceImpl(LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory,
        LogbookOperationsClientFactory logbookOperationsClientFactory, StorageClientFactory storageClientFactory,
        WorkspaceClientFactory workspaceClientFactory, AdminManagementClientFactory adminManagementClientFactory,
        MetaDataClientFactory metaDataClientFactory,
        ProcessingManagementClientFactory processingManagementClientFactory); @VisibleForTesting private  AccessInternalResourceImpl(AccessInternalModule accessModule,
        LogbookOperationsClientFactory logbookOperationsClientFactory,
        WorkspaceClientFactory workspaceClientFactory,
        ProcessingManagementClientFactory processingManagementClientFactory); @Override @GET @Path("/units") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response getUnits(JsonNode queryDsl); @Override @GET @Path("/unitsWithInheritedRules") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response selectUnitsWithInheritedRules(JsonNode queryDsl); @Override @POST @Path("/dipexport") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response exportDIP(JsonNode dslRequest); @Override @POST @Path("/export/usagefilter") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response exportByUsageFilter(ExportRequest exportRequest); @POST @Path("/transfers/reply") @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_JSON) Response transferReply(InputStream transferReply); @Override @GET @Path("/dipexport/{id}/dip") @Consumes(MediaType.APPLICATION_OCTET_STREAM) Response findDIPByID(@PathParam("id") String id); @Override @GET @Path("/transferexport/{id}/sip") @Consumes(MediaType.APPLICATION_OCTET_STREAM) Response findTransferSIPByID(@PathParam("id") String id); @Override @POST @Path("/reclassification") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response startReclassificationWorkflow(JsonNode reclassificationRequestJson); Response startReclassificationWorkflow(JsonNode reclassificationRequestJson, ProcessAction processAction); @Override @POST @Path("/elimination/analysis") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response startEliminationAnalysisWorkflow(EliminationRequestBody eliminationRequestBody); @Override @POST @Path("/elimination/action") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response startEliminationActionWorkflow(EliminationRequestBody eliminationRequestBody); @Override @GET @Path("/units/{id_unit}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response getUnitById(JsonNode queryDsl,
        @PathParam("id_unit") String idUnit); @GET @Path("/units/{id_unit}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_XML) @Override Response getUnitByIdWithXMLFormat(JsonNode queryDsl, @PathParam("id_unit") String idUnit); @Override @PUT @Path("/units/{id_unit}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response updateUnitById(JsonNode queryDsl,
        @PathParam("id_unit") String idUnit, @HeaderParam(GlobalDataRest.X_REQUEST_ID) String requestId); @Override @GET @Path("/objects/{id_object_group}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response getObjectGroup(@PathParam("id_object_group") String idObjectGroup, JsonNode query); @GET @Path("/objects/{id_object_group}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_XML) @Override Response getObjectByIdWithXMLFormat(JsonNode dslQuery, @PathParam("id_object_group") String objectId); @GET @Path("/units/{id_unit}/object") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_XML) @Override Response getObjectByUnitIdWithXMLFormat(JsonNode queryDsl, @PathParam("id_unit") String idUnit); @Override @GET @Path("/objects/{id_object_group}/{id_unit}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_OCTET_STREAM) Response getObjectStreamAsync(@Context HttpHeaders headers,
        @PathParam("id_object_group") String idObjectGroup, @PathParam("id_unit") String idUnit); @Override @GET @Path("/storageaccesslog") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_OCTET_STREAM) Response getAccessLogStreamAsync(@Context HttpHeaders headers, JsonNode params); @Override @POST @Path(UNITS_URI) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response massUpdateUnits(JsonNode queryDsl); @Override @POST @Path(UNITS_RULES_URI) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response massUpdateUnitsRules(MassUpdateUnitRuleRequest massUpdateUnitRuleRequest); @Path("/units/computedInheritedRules") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response startComputeInheritedRules(JsonNode dslQuery); @Path("/units/computedInheritedRules") @DELETE @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response deleteComputeInheritedRules(JsonNode dslQuery); @Override @GET @Path("/objects") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response getObjects(JsonNode queryDsl); @Path("/preservation") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response startPreservation(PreservationRequest preservationRequest); }
AccessInternalResourceImpl extends ApplicationStatusResource implements AccessInternalResource { private ObjectMapper buildObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); mapper.enable(SerializationFeature.INDENT_OUTPUT); SimpleModule module = new SimpleModule(); module.addDeserializer(TextByLang.class, new TextByLangDeserializer()); module.addDeserializer(LevelType.class, new LevelTypeDeserializer()); module.addDeserializer(IdentifierType.class, new IdentifierTypeDeserializer()); mapper.registerModule(module); return mapper; } AccessInternalResourceImpl(AccessInternalConfiguration configuration); @VisibleForTesting  AccessInternalResourceImpl(LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory,
        LogbookOperationsClientFactory logbookOperationsClientFactory, StorageClientFactory storageClientFactory,
        WorkspaceClientFactory workspaceClientFactory, AdminManagementClientFactory adminManagementClientFactory,
        MetaDataClientFactory metaDataClientFactory,
        ProcessingManagementClientFactory processingManagementClientFactory); @VisibleForTesting private  AccessInternalResourceImpl(AccessInternalModule accessModule,
        LogbookOperationsClientFactory logbookOperationsClientFactory,
        WorkspaceClientFactory workspaceClientFactory,
        ProcessingManagementClientFactory processingManagementClientFactory); @Override @GET @Path("/units") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response getUnits(JsonNode queryDsl); @Override @GET @Path("/unitsWithInheritedRules") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response selectUnitsWithInheritedRules(JsonNode queryDsl); @Override @POST @Path("/dipexport") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response exportDIP(JsonNode dslRequest); @Override @POST @Path("/export/usagefilter") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response exportByUsageFilter(ExportRequest exportRequest); @POST @Path("/transfers/reply") @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_JSON) Response transferReply(InputStream transferReply); @Override @GET @Path("/dipexport/{id}/dip") @Consumes(MediaType.APPLICATION_OCTET_STREAM) Response findDIPByID(@PathParam("id") String id); @Override @GET @Path("/transferexport/{id}/sip") @Consumes(MediaType.APPLICATION_OCTET_STREAM) Response findTransferSIPByID(@PathParam("id") String id); @Override @POST @Path("/reclassification") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response startReclassificationWorkflow(JsonNode reclassificationRequestJson); Response startReclassificationWorkflow(JsonNode reclassificationRequestJson, ProcessAction processAction); @Override @POST @Path("/elimination/analysis") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response startEliminationAnalysisWorkflow(EliminationRequestBody eliminationRequestBody); @Override @POST @Path("/elimination/action") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response startEliminationActionWorkflow(EliminationRequestBody eliminationRequestBody); @Override @GET @Path("/units/{id_unit}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response getUnitById(JsonNode queryDsl,
        @PathParam("id_unit") String idUnit); @GET @Path("/units/{id_unit}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_XML) @Override Response getUnitByIdWithXMLFormat(JsonNode queryDsl, @PathParam("id_unit") String idUnit); @Override @PUT @Path("/units/{id_unit}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response updateUnitById(JsonNode queryDsl,
        @PathParam("id_unit") String idUnit, @HeaderParam(GlobalDataRest.X_REQUEST_ID) String requestId); @Override @GET @Path("/objects/{id_object_group}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response getObjectGroup(@PathParam("id_object_group") String idObjectGroup, JsonNode query); @GET @Path("/objects/{id_object_group}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_XML) @Override Response getObjectByIdWithXMLFormat(JsonNode dslQuery, @PathParam("id_object_group") String objectId); @GET @Path("/units/{id_unit}/object") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_XML) @Override Response getObjectByUnitIdWithXMLFormat(JsonNode queryDsl, @PathParam("id_unit") String idUnit); @Override @GET @Path("/objects/{id_object_group}/{id_unit}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_OCTET_STREAM) Response getObjectStreamAsync(@Context HttpHeaders headers,
        @PathParam("id_object_group") String idObjectGroup, @PathParam("id_unit") String idUnit); @Override @GET @Path("/storageaccesslog") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_OCTET_STREAM) Response getAccessLogStreamAsync(@Context HttpHeaders headers, JsonNode params); @Override @POST @Path(UNITS_URI) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response massUpdateUnits(JsonNode queryDsl); @Override @POST @Path(UNITS_RULES_URI) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response massUpdateUnitsRules(MassUpdateUnitRuleRequest massUpdateUnitRuleRequest); @Path("/units/computedInheritedRules") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response startComputeInheritedRules(JsonNode dslQuery); @Path("/units/computedInheritedRules") @DELETE @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response deleteComputeInheritedRules(JsonNode dslQuery); @Override @GET @Path("/objects") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response getObjects(JsonNode queryDsl); @Path("/preservation") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response startPreservation(PreservationRequest preservationRequest);  }