@Test @RunWithCustomExecutor public void should_log_warning_when_used_agency_updated() throws Exception { LogbookOperationsClient logbookOperationsclient = mock(LogbookOperationsClient.class); when(logbookOperationsClientFactory.getClient()).thenReturn(logbookOperationsclient); agencyService.findAllAgenciesUsedByAccessContracts(); verify(manager).logEventSuccess("IMPORT_AGENCIES.USED_CONTRACT"); AgenciesModel agModel = new AgenciesModel().setIdentifier("Test"); agenciesToUpdate.add(agModel); usedAgenciesByContracts.add(agModel); agencyService.findAllAgenciesUsedByAccessContracts(); verify(manager).logEventWarning("IMPORT_AGENCIES.USED_CONTRACT"); }
public void findAllAgenciesUsedByAccessContracts() throws InvalidCreateOperationException, VitamException { if (agenciesToUpdate.isEmpty()) { manager.logEventSuccess(AGENCIES_IMPORT_CONTRACT_USAGE); return; } for (AgenciesModel agency : agenciesToUpdate) { final Select select = new Select(); select.setQuery(in(AccessContract.ORIGINATINGAGENCIES, agency.getIdentifier())); final JsonNode queryDsl = select.getFinalSelect(); RequestResponseOK<AccessContractModel> result = finder.findAccessContrats(queryDsl); if (result != null && !result.getResults().isEmpty()) { usedAgenciesByContracts.add(agency); } } if (usedAgenciesByContracts.isEmpty()) { manager.logEventSuccess(AGENCIES_IMPORT_CONTRACT_USAGE); return; } final ArrayNode usedAgenciesContractNode = JsonHandler.createArrayNode(); usedAgenciesByContracts.forEach(agency -> usedAgenciesContractNode.add(agency.getIdentifier())); final ObjectNode data = JsonHandler.createObjectNode(); data.set(ReportConstants.ADDITIONAL_INFORMATION, usedAgenciesContractNode); manager.setEvDetData(data); manager.logEventWarning(AGENCIES_IMPORT_CONTRACT_USAGE); }
AgenciesService implements VitamAutoCloseable { public void findAllAgenciesUsedByAccessContracts() throws InvalidCreateOperationException, VitamException { if (agenciesToUpdate.isEmpty()) { manager.logEventSuccess(AGENCIES_IMPORT_CONTRACT_USAGE); return; } for (AgenciesModel agency : agenciesToUpdate) { final Select select = new Select(); select.setQuery(in(AccessContract.ORIGINATINGAGENCIES, agency.getIdentifier())); final JsonNode queryDsl = select.getFinalSelect(); RequestResponseOK<AccessContractModel> result = finder.findAccessContrats(queryDsl); if (result != null && !result.getResults().isEmpty()) { usedAgenciesByContracts.add(agency); } } if (usedAgenciesByContracts.isEmpty()) { manager.logEventSuccess(AGENCIES_IMPORT_CONTRACT_USAGE); return; } final ArrayNode usedAgenciesContractNode = JsonHandler.createArrayNode(); usedAgenciesByContracts.forEach(agency -> usedAgenciesContractNode.add(agency.getIdentifier())); final ObjectNode data = JsonHandler.createObjectNode(); data.set(ReportConstants.ADDITIONAL_INFORMATION, usedAgenciesContractNode); manager.setEvDetData(data); manager.logEventWarning(AGENCIES_IMPORT_CONTRACT_USAGE); } }
AgenciesService implements VitamAutoCloseable { public void findAllAgenciesUsedByAccessContracts() throws InvalidCreateOperationException, VitamException { if (agenciesToUpdate.isEmpty()) { manager.logEventSuccess(AGENCIES_IMPORT_CONTRACT_USAGE); return; } for (AgenciesModel agency : agenciesToUpdate) { final Select select = new Select(); select.setQuery(in(AccessContract.ORIGINATINGAGENCIES, agency.getIdentifier())); final JsonNode queryDsl = select.getFinalSelect(); RequestResponseOK<AccessContractModel> result = finder.findAccessContrats(queryDsl); if (result != null && !result.getResults().isEmpty()) { usedAgenciesByContracts.add(agency); } } if (usedAgenciesByContracts.isEmpty()) { manager.logEventSuccess(AGENCIES_IMPORT_CONTRACT_USAGE); return; } final ArrayNode usedAgenciesContractNode = JsonHandler.createArrayNode(); usedAgenciesByContracts.forEach(agency -> usedAgenciesContractNode.add(agency.getIdentifier())); final ObjectNode data = JsonHandler.createObjectNode(); data.set(ReportConstants.ADDITIONAL_INFORMATION, usedAgenciesContractNode); manager.setEvDetData(data); manager.logEventWarning(AGENCIES_IMPORT_CONTRACT_USAGE); } AgenciesService(MongoDbAccessAdminImpl mongoAccess,
        VitamCounterService vitamCounterService, FunctionalBackupService backupService, OntologyLoader ontologyLoader); @VisibleForTesting  AgenciesService(
        MongoDbAccessAdminImpl mongoAccess,
        VitamCounterService vitamCounterService,
        FunctionalBackupService backupService,
        LogbookOperationsClientFactory logbookOperationsClientFactory,
        AgenciesManager manager,
        Set<AgenciesModel> agenciesInDb,
        Set<AgenciesModel> agenciesToDelete,
        Set<AgenciesModel> agenciesToInsert,
        Set<AgenciesModel> agenciesToUpdate,
        Set<AgenciesModel> usedAgenciesByAU,
        Set<AgenciesModel> usedAgenciesByContracts,
        Set <AgenciesModel> unusedAgenciesToDelete,
        OntologyLoader ontologyLoader); }
AgenciesService implements VitamAutoCloseable { public void findAllAgenciesUsedByAccessContracts() throws InvalidCreateOperationException, VitamException { if (agenciesToUpdate.isEmpty()) { manager.logEventSuccess(AGENCIES_IMPORT_CONTRACT_USAGE); return; } for (AgenciesModel agency : agenciesToUpdate) { final Select select = new Select(); select.setQuery(in(AccessContract.ORIGINATINGAGENCIES, agency.getIdentifier())); final JsonNode queryDsl = select.getFinalSelect(); RequestResponseOK<AccessContractModel> result = finder.findAccessContrats(queryDsl); if (result != null && !result.getResults().isEmpty()) { usedAgenciesByContracts.add(agency); } } if (usedAgenciesByContracts.isEmpty()) { manager.logEventSuccess(AGENCIES_IMPORT_CONTRACT_USAGE); return; } final ArrayNode usedAgenciesContractNode = JsonHandler.createArrayNode(); usedAgenciesByContracts.forEach(agency -> usedAgenciesContractNode.add(agency.getIdentifier())); final ObjectNode data = JsonHandler.createObjectNode(); data.set(ReportConstants.ADDITIONAL_INFORMATION, usedAgenciesContractNode); manager.setEvDetData(data); manager.logEventWarning(AGENCIES_IMPORT_CONTRACT_USAGE); } AgenciesService(MongoDbAccessAdminImpl mongoAccess,
        VitamCounterService vitamCounterService, FunctionalBackupService backupService, OntologyLoader ontologyLoader); @VisibleForTesting  AgenciesService(
        MongoDbAccessAdminImpl mongoAccess,
        VitamCounterService vitamCounterService,
        FunctionalBackupService backupService,
        LogbookOperationsClientFactory logbookOperationsClientFactory,
        AgenciesManager manager,
        Set<AgenciesModel> agenciesInDb,
        Set<AgenciesModel> agenciesToDelete,
        Set<AgenciesModel> agenciesToInsert,
        Set<AgenciesModel> agenciesToUpdate,
        Set<AgenciesModel> usedAgenciesByAU,
        Set<AgenciesModel> usedAgenciesByContracts,
        Set <AgenciesModel> unusedAgenciesToDelete,
        OntologyLoader ontologyLoader); RequestResponseOK findDocuments(JsonNode select); void findAllAgenciesUsedByUnits(); void findAllAgenciesUsedByAccessContracts(); void checkFile(InputStream stream); void checkAgenciesInDb(); RequestResponse<AgenciesModel> importAgencies(InputStream stream, String filename); DbRequestResult findAgencies(JsonNode queryDsl); InputStream generateErrorReport(); @Override void close(); }
AgenciesService implements VitamAutoCloseable { public void findAllAgenciesUsedByAccessContracts() throws InvalidCreateOperationException, VitamException { if (agenciesToUpdate.isEmpty()) { manager.logEventSuccess(AGENCIES_IMPORT_CONTRACT_USAGE); return; } for (AgenciesModel agency : agenciesToUpdate) { final Select select = new Select(); select.setQuery(in(AccessContract.ORIGINATINGAGENCIES, agency.getIdentifier())); final JsonNode queryDsl = select.getFinalSelect(); RequestResponseOK<AccessContractModel> result = finder.findAccessContrats(queryDsl); if (result != null && !result.getResults().isEmpty()) { usedAgenciesByContracts.add(agency); } } if (usedAgenciesByContracts.isEmpty()) { manager.logEventSuccess(AGENCIES_IMPORT_CONTRACT_USAGE); return; } final ArrayNode usedAgenciesContractNode = JsonHandler.createArrayNode(); usedAgenciesByContracts.forEach(agency -> usedAgenciesContractNode.add(agency.getIdentifier())); final ObjectNode data = JsonHandler.createObjectNode(); data.set(ReportConstants.ADDITIONAL_INFORMATION, usedAgenciesContractNode); manager.setEvDetData(data); manager.logEventWarning(AGENCIES_IMPORT_CONTRACT_USAGE); } AgenciesService(MongoDbAccessAdminImpl mongoAccess,
        VitamCounterService vitamCounterService, FunctionalBackupService backupService, OntologyLoader ontologyLoader); @VisibleForTesting  AgenciesService(
        MongoDbAccessAdminImpl mongoAccess,
        VitamCounterService vitamCounterService,
        FunctionalBackupService backupService,
        LogbookOperationsClientFactory logbookOperationsClientFactory,
        AgenciesManager manager,
        Set<AgenciesModel> agenciesInDb,
        Set<AgenciesModel> agenciesToDelete,
        Set<AgenciesModel> agenciesToInsert,
        Set<AgenciesModel> agenciesToUpdate,
        Set<AgenciesModel> usedAgenciesByAU,
        Set<AgenciesModel> usedAgenciesByContracts,
        Set <AgenciesModel> unusedAgenciesToDelete,
        OntologyLoader ontologyLoader); RequestResponseOK findDocuments(JsonNode select); void findAllAgenciesUsedByUnits(); void findAllAgenciesUsedByAccessContracts(); void checkFile(InputStream stream); void checkAgenciesInDb(); RequestResponse<AgenciesModel> importAgencies(InputStream stream, String filename); DbRequestResult findAgencies(JsonNode queryDsl); InputStream generateErrorReport(); @Override void close(); static final VitamLogger LOGGER; }