@Test @RunWithCustomExecutor public void when_find_should_return_contracts_given_valid_query() throws VitamException, InvalidCreateOperationException { final Select select = new Select(); select.setQuery(QueryHelper.eq("Name", "mcContract1")); DbRequestResult findResultMock = mock(DbRequestResult.class); when(findResultMock.getCount()).thenReturn(1l); when(findResultMock.getRequestResponseOK(any(JsonNode.class), eq(ManagementContract.class), eq(ManagementContractModel.class))) .thenReturn(new RequestResponseOK<ManagementContractModel>() .addAllResults(Arrays.asList(getManagementContract("IdentifierMC1")))); when(mongoAccess.findDocuments(any(), eq(FunctionalAdminCollections.MANAGEMENT_CONTRACT))) .thenReturn(findResultMock); ArgumentCaptor<JsonNode> queryCaptor = ArgumentCaptor.forClass(JsonNode.class); RequestResponse<ManagementContractModel> response = managementContractService .findContracts(select.getFinalSelect()); assertThat(response.isOk()).isTrue(); verify(mongoAccess, times(1)).findDocuments(queryCaptor.capture(), eq(FunctionalAdminCollections.MANAGEMENT_CONTRACT)); JsonNode querySentToMongo = queryCaptor.getValue(); assertThat(querySentToMongo).isNotNull(); assertThat(querySentToMongo).isEqualTo(select.getFinalSelect()); }
@Override public RequestResponseOK<ManagementContractModel> findContracts(JsonNode queryDsl) throws ReferentialException, InvalidParseOperationException { SanityChecker.checkJsonAll(queryDsl); try (DbRequestResult result = mongoAccess.findDocuments(queryDsl, FunctionalAdminCollections.MANAGEMENT_CONTRACT)) { return result.getRequestResponseOK(queryDsl, ManagementContract.class, ManagementContractModel.class); } }
ManagementContractImpl implements ContractService<ManagementContractModel> { @Override public RequestResponseOK<ManagementContractModel> findContracts(JsonNode queryDsl) throws ReferentialException, InvalidParseOperationException { SanityChecker.checkJsonAll(queryDsl); try (DbRequestResult result = mongoAccess.findDocuments(queryDsl, FunctionalAdminCollections.MANAGEMENT_CONTRACT)) { return result.getRequestResponseOK(queryDsl, ManagementContract.class, ManagementContractModel.class); } } }
ManagementContractImpl implements ContractService<ManagementContractModel> { @Override public RequestResponseOK<ManagementContractModel> findContracts(JsonNode queryDsl) throws ReferentialException, InvalidParseOperationException { SanityChecker.checkJsonAll(queryDsl); try (DbRequestResult result = mongoAccess.findDocuments(queryDsl, FunctionalAdminCollections.MANAGEMENT_CONTRACT)) { return result.getRequestResponseOK(queryDsl, ManagementContract.class, ManagementContractModel.class); } } ManagementContractImpl(MongoDbAccessAdminImpl mongoAccess, VitamCounterService vitamCounterService);  ManagementContractImpl(MongoDbAccessAdminImpl mongoAccess, VitamCounterService vitamCounterService,
            StorageClient storageClient, LogbookOperationsClient logbookOperationsClient,
            FunctionalBackupService functionalBackupService); }
ManagementContractImpl implements ContractService<ManagementContractModel> { @Override public RequestResponseOK<ManagementContractModel> findContracts(JsonNode queryDsl) throws ReferentialException, InvalidParseOperationException { SanityChecker.checkJsonAll(queryDsl); try (DbRequestResult result = mongoAccess.findDocuments(queryDsl, FunctionalAdminCollections.MANAGEMENT_CONTRACT)) { return result.getRequestResponseOK(queryDsl, ManagementContract.class, ManagementContractModel.class); } } ManagementContractImpl(MongoDbAccessAdminImpl mongoAccess, VitamCounterService vitamCounterService);  ManagementContractImpl(MongoDbAccessAdminImpl mongoAccess, VitamCounterService vitamCounterService,
            StorageClient storageClient, LogbookOperationsClient logbookOperationsClient,
            FunctionalBackupService functionalBackupService); @Override RequestResponse<ManagementContractModel> createContracts(List<ManagementContractModel> contractModelList); @Override RequestResponse<ManagementContractModel> updateContract(String identifier, JsonNode queryDsl); @Override ManagementContractModel findByIdentifier(String identifier); @Override RequestResponseOK<ManagementContractModel> findContracts(JsonNode queryDsl); @Override void close(); }
ManagementContractImpl implements ContractService<ManagementContractModel> { @Override public RequestResponseOK<ManagementContractModel> findContracts(JsonNode queryDsl) throws ReferentialException, InvalidParseOperationException { SanityChecker.checkJsonAll(queryDsl); try (DbRequestResult result = mongoAccess.findDocuments(queryDsl, FunctionalAdminCollections.MANAGEMENT_CONTRACT)) { return result.getRequestResponseOK(queryDsl, ManagementContract.class, ManagementContractModel.class); } } ManagementContractImpl(MongoDbAccessAdminImpl mongoAccess, VitamCounterService vitamCounterService);  ManagementContractImpl(MongoDbAccessAdminImpl mongoAccess, VitamCounterService vitamCounterService,
            StorageClient storageClient, LogbookOperationsClient logbookOperationsClient,
            FunctionalBackupService functionalBackupService); @Override RequestResponse<ManagementContractModel> createContracts(List<ManagementContractModel> contractModelList); @Override RequestResponse<ManagementContractModel> updateContract(String identifier, JsonNode queryDsl); @Override ManagementContractModel findByIdentifier(String identifier); @Override RequestResponseOK<ManagementContractModel> findContracts(JsonNode queryDsl); @Override void close(); static final String CONTRACT_BACKUP_EVENT; }