@Test public void should_validate_accession_register_client_for_object_group() throws InvalidParseOperationException, MetaDataClientServerException { RequestResponseOK<ObjectGroupPerOriginatingAgency> requestResponseOK = new RequestResponseOK<>(); requestResponseOK.addResult( new ObjectGroupPerOriginatingAgency("op1", "sp1", 3, 2, 2000)); requestResponseOK.addResult( new ObjectGroupPerOriginatingAgency("op1", "sp2", 4, 1, 3400)); when(mock.get()) .thenReturn(Response.status(Status.OK).entity(JsonHandler.writeAsString(requestResponseOK)).build()); List<ObjectGroupPerOriginatingAgency> unitPerOriginatingAgencies = client.selectAccessionRegisterOnObjectByOperationId("122345"); assertThat(unitPerOriginatingAgencies).hasSize(2) .extracting("operation", "agency", "numberOfObject", "numberOfGOT", "size") .contains(tuple("op1", "sp1", 3L, 2L, 2000L), tuple("op1", "sp2", 4L, 1L, 3400L)); }
@Override public List<ObjectGroupPerOriginatingAgency> selectAccessionRegisterOnObjectByOperationId(String operationId) throws MetaDataClientServerException { try (Response response = make(get().withJson().withPath("/accession-registers/objects/" + operationId))) { check(response); RequestResponse<ObjectGroupPerOriginatingAgency> requestResponse = RequestResponse.parseFromResponse(response, ObjectGroupPerOriginatingAgency.class); if (requestResponse.isOk()) { RequestResponseOK<ObjectGroupPerOriginatingAgency> requestResponseOK = (RequestResponseOK<ObjectGroupPerOriginatingAgency>) requestResponse; return requestResponseOK.getResults(); } VitamError vitamError = (VitamError) requestResponse; LOGGER .error("find accession register for object group failed, http code is {}, error is {}", vitamError.getCode(), vitamError.getErrors()); throw new MetaDataClientServerException(vitamError.getDescription()); } catch (InvalidParseOperationException | VitamClientInternalException | MetaDataExecutionException | MetaDataDocumentSizeException | MetaDataNotFoundException e) { throw new MetaDataClientServerException(e); } }
MetaDataClientRest extends DefaultClient implements MetaDataClient { @Override public List<ObjectGroupPerOriginatingAgency> selectAccessionRegisterOnObjectByOperationId(String operationId) throws MetaDataClientServerException { try (Response response = make(get().withJson().withPath("/accession-registers/objects/" + operationId))) { check(response); RequestResponse<ObjectGroupPerOriginatingAgency> requestResponse = RequestResponse.parseFromResponse(response, ObjectGroupPerOriginatingAgency.class); if (requestResponse.isOk()) { RequestResponseOK<ObjectGroupPerOriginatingAgency> requestResponseOK = (RequestResponseOK<ObjectGroupPerOriginatingAgency>) requestResponse; return requestResponseOK.getResults(); } VitamError vitamError = (VitamError) requestResponse; LOGGER .error("find accession register for object group failed, http code is {}, error is {}", vitamError.getCode(), vitamError.getErrors()); throw new MetaDataClientServerException(vitamError.getDescription()); } catch (InvalidParseOperationException | VitamClientInternalException | MetaDataExecutionException | MetaDataDocumentSizeException | MetaDataNotFoundException e) { throw new MetaDataClientServerException(e); } } }
MetaDataClientRest extends DefaultClient implements MetaDataClient { @Override public List<ObjectGroupPerOriginatingAgency> selectAccessionRegisterOnObjectByOperationId(String operationId) throws MetaDataClientServerException { try (Response response = make(get().withJson().withPath("/accession-registers/objects/" + operationId))) { check(response); RequestResponse<ObjectGroupPerOriginatingAgency> requestResponse = RequestResponse.parseFromResponse(response, ObjectGroupPerOriginatingAgency.class); if (requestResponse.isOk()) { RequestResponseOK<ObjectGroupPerOriginatingAgency> requestResponseOK = (RequestResponseOK<ObjectGroupPerOriginatingAgency>) requestResponse; return requestResponseOK.getResults(); } VitamError vitamError = (VitamError) requestResponse; LOGGER .error("find accession register for object group failed, http code is {}, error is {}", vitamError.getCode(), vitamError.getErrors()); throw new MetaDataClientServerException(vitamError.getDescription()); } catch (InvalidParseOperationException | VitamClientInternalException | MetaDataExecutionException | MetaDataDocumentSizeException | MetaDataNotFoundException e) { throw new MetaDataClientServerException(e); } } MetaDataClientRest(VitamClientFactoryInterface factory); }
MetaDataClientRest extends DefaultClient implements MetaDataClient { @Override public List<ObjectGroupPerOriginatingAgency> selectAccessionRegisterOnObjectByOperationId(String operationId) throws MetaDataClientServerException { try (Response response = make(get().withJson().withPath("/accession-registers/objects/" + operationId))) { check(response); RequestResponse<ObjectGroupPerOriginatingAgency> requestResponse = RequestResponse.parseFromResponse(response, ObjectGroupPerOriginatingAgency.class); if (requestResponse.isOk()) { RequestResponseOK<ObjectGroupPerOriginatingAgency> requestResponseOK = (RequestResponseOK<ObjectGroupPerOriginatingAgency>) requestResponse; return requestResponseOK.getResults(); } VitamError vitamError = (VitamError) requestResponse; LOGGER .error("find accession register for object group failed, http code is {}, error is {}", vitamError.getCode(), vitamError.getErrors()); throw new MetaDataClientServerException(vitamError.getDescription()); } catch (InvalidParseOperationException | VitamClientInternalException | MetaDataExecutionException | MetaDataDocumentSizeException | MetaDataNotFoundException e) { throw new MetaDataClientServerException(e); } } 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 List<ObjectGroupPerOriginatingAgency> selectAccessionRegisterOnObjectByOperationId(String operationId) throws MetaDataClientServerException { try (Response response = make(get().withJson().withPath("/accession-registers/objects/" + operationId))) { check(response); RequestResponse<ObjectGroupPerOriginatingAgency> requestResponse = RequestResponse.parseFromResponse(response, ObjectGroupPerOriginatingAgency.class); if (requestResponse.isOk()) { RequestResponseOK<ObjectGroupPerOriginatingAgency> requestResponseOK = (RequestResponseOK<ObjectGroupPerOriginatingAgency>) requestResponse; return requestResponseOK.getResults(); } VitamError vitamError = (VitamError) requestResponse; LOGGER .error("find accession register for object group failed, http code is {}, error is {}", vitamError.getCode(), vitamError.getErrors()); throw new MetaDataClientServerException(vitamError.getDescription()); } catch (InvalidParseOperationException | VitamClientInternalException | MetaDataExecutionException | MetaDataDocumentSizeException | MetaDataNotFoundException e) { throw new MetaDataClientServerException(e); } } 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();  }