@Test @RunWithCustomExecutor public void given_OK_When_getUnitByIdRaw_ThenReturn_Unit() throws Exception { InputStream unit = PropertiesUtils.getResourceAsStream("unit_raw.json"); RequestResponse<JsonNode> requestResponseOK = new RequestResponseOK<JsonNode>() .addResult(JsonHandler.getFromInputStream(unit)).setHttpCode(Status.OK.getStatusCode()); when(mock.get()).thenReturn(Response.status(Status.OK).entity(requestResponseOK).build()); RequestResponse<JsonNode> requestResponse = client.getUnitByIdRaw("aeaqaaaaaagwky22aboqialbbrqygviaaaaq"); assertThat(requestResponse).isNotNull(); assertThat(requestResponse.getStatus()).isEqualTo(Status.OK.getStatusCode()); assertThat(requestResponse.isOk()).isTrue(); assertThat(((RequestResponseOK<JsonNode>) requestResponse).getResults().size()).isEqualTo(1); assertThat(((RequestResponseOK<JsonNode>) requestResponse).getFirstResult().get("_id").asText()) .isEqualTo("aeaqaaaaaagwky22aboqialbbrqygviaaaaq"); }
@Override public RequestResponse<JsonNode> getUnitByIdRaw(String unitId) throws VitamClientException { Response response = null; try { response = make(get().withJson().withPath("/raw/units/" + unitId)); check(response); return RequestResponse.parseFromResponse(response, JsonNode.class); } catch (IllegalStateException | InvalidParseOperationException | MetaDataExecutionException | MetaDataDocumentSizeException | MetaDataClientServerException e) { throw new VitamClientException(e); } catch (MetaDataNotFoundException e) { return RequestResponse.parseFromResponse(response, JsonNode.class); } finally { if (response != null) { response.close(); } } }
MetaDataClientRest extends DefaultClient implements MetaDataClient { @Override public RequestResponse<JsonNode> getUnitByIdRaw(String unitId) throws VitamClientException { Response response = null; try { response = make(get().withJson().withPath("/raw/units/" + unitId)); check(response); return RequestResponse.parseFromResponse(response, JsonNode.class); } catch (IllegalStateException | InvalidParseOperationException | MetaDataExecutionException | MetaDataDocumentSizeException | MetaDataClientServerException e) { throw new VitamClientException(e); } catch (MetaDataNotFoundException e) { return RequestResponse.parseFromResponse(response, JsonNode.class); } finally { if (response != null) { response.close(); } } } }
MetaDataClientRest extends DefaultClient implements MetaDataClient { @Override public RequestResponse<JsonNode> getUnitByIdRaw(String unitId) throws VitamClientException { Response response = null; try { response = make(get().withJson().withPath("/raw/units/" + unitId)); check(response); return RequestResponse.parseFromResponse(response, JsonNode.class); } catch (IllegalStateException | InvalidParseOperationException | MetaDataExecutionException | MetaDataDocumentSizeException | MetaDataClientServerException e) { throw new VitamClientException(e); } catch (MetaDataNotFoundException e) { return RequestResponse.parseFromResponse(response, JsonNode.class); } finally { if (response != null) { response.close(); } } } MetaDataClientRest(VitamClientFactoryInterface factory); }
MetaDataClientRest extends DefaultClient implements MetaDataClient { @Override public RequestResponse<JsonNode> getUnitByIdRaw(String unitId) throws VitamClientException { Response response = null; try { response = make(get().withJson().withPath("/raw/units/" + unitId)); check(response); return RequestResponse.parseFromResponse(response, JsonNode.class); } catch (IllegalStateException | InvalidParseOperationException | MetaDataExecutionException | MetaDataDocumentSizeException | MetaDataClientServerException e) { throw new VitamClientException(e); } catch (MetaDataNotFoundException e) { return RequestResponse.parseFromResponse(response, JsonNode.class); } finally { if (response != null) { response.close(); } } } MetaDataClientRest(VitamClientFactoryInterface factory); @Override JsonNode insertUnitBulk(BulkUnitInsertRequest request); @Override JsonNode selectUnits(JsonNode selectQuery); @Override JsonNode selectObjectGroups(JsonNode selectQuery); @Override JsonNode selectUnitbyId(JsonNode selectQuery, String unitId); @Override JsonNode selectObjectGrouptbyId(JsonNode selectQuery, String objectGroupId); @Override JsonNode updateUnitById(JsonNode updateQuery, String unitId); @Override JsonNode insertObjectGroup(JsonNode insertQuery); @Override JsonNode insertObjectGroups(List<JsonNode> insertQueries); @Override void updateObjectGroupById(JsonNode queryUpdate, String objectGroupId); @Override List<UnitPerOriginatingAgency> selectAccessionRegisterOnUnitByOperationId(String operationId); @Override List<ObjectGroupPerOriginatingAgency> selectAccessionRegisterOnObjectByOperationId(String operationId); @Override boolean refreshUnits(); @Override boolean refreshObjectGroups(); @Override JsonNode reindex(IndexParameters indexParam); @Override JsonNode switchIndexes(SwitchIndexParameters switchIndexParam); @Override RequestResponse<JsonNode> getUnitByIdRaw(String unitId); @Override RequestResponse<JsonNode> getUnitsByIdsRaw(Collection<String> unitIds); @Override RequestResponse<JsonNode> getObjectGroupByIdRaw(String objectGroupId); @Override RequestResponse<JsonNode> getObjectGroupsByIdsRaw(Collection<String> objectGroupId); @Override GraphComputeResponse computeGraph(JsonNode queryDsl); @Override GraphComputeResponse computeGraph(GraphComputeResponse.GraphComputeAction action, Set<String> ids); @Override void exportReclassificationChildNodes(Set<String> ids, String unitsToUpdateJsonLineFileName,
        String objectGroupsToUpdateJsonLineFileName); @Override void deleteUnitsBulk(Collection<String> listIds); @Override void deleteObjectGroupBulk(Collection<String> listIds); RequestResponse<JsonNode> updateUnitBulk(JsonNode updateQuery); @Override RequestResponse<JsonNode> updateUnitsRulesBulk(List<String> unitsIds, RuleActions actions,
        Map<String, DurationData> rulesToDurationData); @Override JsonNode selectUnitsWithInheritedRules(JsonNode selectQuery); @Override JsonNode createAccessionRegisterSymbolic(); }
MetaDataClientRest extends DefaultClient implements MetaDataClient { @Override public RequestResponse<JsonNode> getUnitByIdRaw(String unitId) throws VitamClientException { Response response = null; try { response = make(get().withJson().withPath("/raw/units/" + unitId)); check(response); return RequestResponse.parseFromResponse(response, JsonNode.class); } catch (IllegalStateException | InvalidParseOperationException | MetaDataExecutionException | MetaDataDocumentSizeException | MetaDataClientServerException e) { throw new VitamClientException(e); } catch (MetaDataNotFoundException e) { return RequestResponse.parseFromResponse(response, JsonNode.class); } finally { if (response != null) { response.close(); } } } MetaDataClientRest(VitamClientFactoryInterface factory); @Override JsonNode insertUnitBulk(BulkUnitInsertRequest request); @Override JsonNode selectUnits(JsonNode selectQuery); @Override JsonNode selectObjectGroups(JsonNode selectQuery); @Override JsonNode selectUnitbyId(JsonNode selectQuery, String unitId); @Override JsonNode selectObjectGrouptbyId(JsonNode selectQuery, String objectGroupId); @Override JsonNode updateUnitById(JsonNode updateQuery, String unitId); @Override JsonNode insertObjectGroup(JsonNode insertQuery); @Override JsonNode insertObjectGroups(List<JsonNode> insertQueries); @Override void updateObjectGroupById(JsonNode queryUpdate, String objectGroupId); @Override List<UnitPerOriginatingAgency> selectAccessionRegisterOnUnitByOperationId(String operationId); @Override List<ObjectGroupPerOriginatingAgency> selectAccessionRegisterOnObjectByOperationId(String operationId); @Override boolean refreshUnits(); @Override boolean refreshObjectGroups(); @Override JsonNode reindex(IndexParameters indexParam); @Override JsonNode switchIndexes(SwitchIndexParameters switchIndexParam); @Override RequestResponse<JsonNode> getUnitByIdRaw(String unitId); @Override RequestResponse<JsonNode> getUnitsByIdsRaw(Collection<String> unitIds); @Override RequestResponse<JsonNode> getObjectGroupByIdRaw(String objectGroupId); @Override RequestResponse<JsonNode> getObjectGroupsByIdsRaw(Collection<String> objectGroupId); @Override GraphComputeResponse computeGraph(JsonNode queryDsl); @Override GraphComputeResponse computeGraph(GraphComputeResponse.GraphComputeAction action, Set<String> ids); @Override void exportReclassificationChildNodes(Set<String> ids, String unitsToUpdateJsonLineFileName,
        String objectGroupsToUpdateJsonLineFileName); @Override void deleteUnitsBulk(Collection<String> listIds); @Override void deleteObjectGroupBulk(Collection<String> listIds); RequestResponse<JsonNode> updateUnitBulk(JsonNode updateQuery); @Override RequestResponse<JsonNode> updateUnitsRulesBulk(List<String> unitsIds, RuleActions actions,
        Map<String, DurationData> rulesToDurationData); @Override JsonNode selectUnitsWithInheritedRules(JsonNode selectQuery); @Override JsonNode createAccessionRegisterSymbolic();  }