@Test @RunWithCustomExecutor public void should_event_logbook_ok_when_call_log_finish() throws Exception { VitamThreadUtils.getVitamSession().setTenantId(TENANT_ID); ArgumentCaptor<LogbookOperationParameters> captor = ArgumentCaptor.forClass(LogbookOperationParameters.class); AgenciesManager manager = new AgenciesManager(logbookOperationsClient, newOperationLogbookGUID(0), false); manager.logFinish("test.json"); verify(logbookOperationsClient, times(1)).update(captor.capture()); LogbookOperationParameters log = captor.getValue(); assertThat(log.getParameterValue(eventType)).isEqualTo(AGENCIES_IMPORT_EVENT); assertThat(log.getParameterValue(eventTypeProcess)).isEqualTo("MASTERDATA"); assertThat(log.getParameterValue(outcome)).isEqualTo("OK"); manager = new AgenciesManager(logbookOperationsClient, newOperationLogbookGUID(0), true); manager.logFinish("test.json"); verify(logbookOperationsClient, times(2)).update(captor.capture()); log = captor.getValue(); assertThat(log.getParameterValue(eventType)).isEqualTo(AGENCIES_IMPORT_EVENT); assertThat(log.getParameterValue(eventTypeProcess)).isEqualTo("MASTERDATA"); assertThat(log.getParameterValue(outcome)).isEqualTo("WARNING"); assertThat(log.getParameterValue(eventDetailData)).isEqualTo("{\"FileName\":\"test.json\"}"); }
public void logFinish(String fileName) throws VitamException { LogbookOperationParameters logbookParameters; final GUID eipId = GUIDFactory.newOperationLogbookGUID(ParameterHelper.getTenantParameter()); if (warning) { logbookParameters = LogbookParameterHelper .newLogbookOperationParameters(eipId, AGENCIES_IMPORT_EVENT, eip, LogbookTypeProcess.MASTERDATA, StatusCode.WARNING, VitamLogbookMessages.getCodeOp(AGENCIES_IMPORT_EVENT, StatusCode.WARNING), eip); logbookParameters.putParameterValue(LogbookParameterName.eventDetailData, JsonHandler.unprettyPrint(evDetData)); } else { logbookParameters = LogbookParameterHelper .newLogbookOperationParameters(eipId, AGENCIES_IMPORT_EVENT, eip, LogbookTypeProcess.MASTERDATA, StatusCode.OK, VitamLogbookMessages.getCodeOp(AGENCIES_IMPORT_EVENT, StatusCode.OK), eip); } ReferentialFileUtils.addFilenameInLogbookOperation(fileName, logbookParameters); logbookClient.update(logbookParameters); }
AgenciesManager { public void logFinish(String fileName) throws VitamException { LogbookOperationParameters logbookParameters; final GUID eipId = GUIDFactory.newOperationLogbookGUID(ParameterHelper.getTenantParameter()); if (warning) { logbookParameters = LogbookParameterHelper .newLogbookOperationParameters(eipId, AGENCIES_IMPORT_EVENT, eip, LogbookTypeProcess.MASTERDATA, StatusCode.WARNING, VitamLogbookMessages.getCodeOp(AGENCIES_IMPORT_EVENT, StatusCode.WARNING), eip); logbookParameters.putParameterValue(LogbookParameterName.eventDetailData, JsonHandler.unprettyPrint(evDetData)); } else { logbookParameters = LogbookParameterHelper .newLogbookOperationParameters(eipId, AGENCIES_IMPORT_EVENT, eip, LogbookTypeProcess.MASTERDATA, StatusCode.OK, VitamLogbookMessages.getCodeOp(AGENCIES_IMPORT_EVENT, StatusCode.OK), eip); } ReferentialFileUtils.addFilenameInLogbookOperation(fileName, logbookParameters); logbookClient.update(logbookParameters); } }
AgenciesManager { public void logFinish(String fileName) throws VitamException { LogbookOperationParameters logbookParameters; final GUID eipId = GUIDFactory.newOperationLogbookGUID(ParameterHelper.getTenantParameter()); if (warning) { logbookParameters = LogbookParameterHelper .newLogbookOperationParameters(eipId, AGENCIES_IMPORT_EVENT, eip, LogbookTypeProcess.MASTERDATA, StatusCode.WARNING, VitamLogbookMessages.getCodeOp(AGENCIES_IMPORT_EVENT, StatusCode.WARNING), eip); logbookParameters.putParameterValue(LogbookParameterName.eventDetailData, JsonHandler.unprettyPrint(evDetData)); } else { logbookParameters = LogbookParameterHelper .newLogbookOperationParameters(eipId, AGENCIES_IMPORT_EVENT, eip, LogbookTypeProcess.MASTERDATA, StatusCode.OK, VitamLogbookMessages.getCodeOp(AGENCIES_IMPORT_EVENT, StatusCode.OK), eip); } ReferentialFileUtils.addFilenameInLogbookOperation(fileName, logbookParameters); logbookClient.update(logbookParameters); } AgenciesManager(LogbookOperationsClient logbookClient, GUID eip); @VisibleForTesting  AgenciesManager(LogbookOperationsClient logBookclient, GUID eip, boolean warning); }
AgenciesManager { public void logFinish(String fileName) throws VitamException { LogbookOperationParameters logbookParameters; final GUID eipId = GUIDFactory.newOperationLogbookGUID(ParameterHelper.getTenantParameter()); if (warning) { logbookParameters = LogbookParameterHelper .newLogbookOperationParameters(eipId, AGENCIES_IMPORT_EVENT, eip, LogbookTypeProcess.MASTERDATA, StatusCode.WARNING, VitamLogbookMessages.getCodeOp(AGENCIES_IMPORT_EVENT, StatusCode.WARNING), eip); logbookParameters.putParameterValue(LogbookParameterName.eventDetailData, JsonHandler.unprettyPrint(evDetData)); } else { logbookParameters = LogbookParameterHelper .newLogbookOperationParameters(eipId, AGENCIES_IMPORT_EVENT, eip, LogbookTypeProcess.MASTERDATA, StatusCode.OK, VitamLogbookMessages.getCodeOp(AGENCIES_IMPORT_EVENT, StatusCode.OK), eip); } ReferentialFileUtils.addFilenameInLogbookOperation(fileName, logbookParameters); logbookClient.update(logbookParameters); } AgenciesManager(LogbookOperationsClient logbookClient, GUID eip); @VisibleForTesting  AgenciesManager(LogbookOperationsClient logBookclient, GUID eip, boolean warning); void logStarted(String eventType); void logFinish(String fileName); void logEventSuccess(String eventType); void logEventWarning(String eventType); void logError(String errorsDetails, String subEvenType); void setEvDetData(ObjectNode evDetData); }
AgenciesManager { public void logFinish(String fileName) throws VitamException { LogbookOperationParameters logbookParameters; final GUID eipId = GUIDFactory.newOperationLogbookGUID(ParameterHelper.getTenantParameter()); if (warning) { logbookParameters = LogbookParameterHelper .newLogbookOperationParameters(eipId, AGENCIES_IMPORT_EVENT, eip, LogbookTypeProcess.MASTERDATA, StatusCode.WARNING, VitamLogbookMessages.getCodeOp(AGENCIES_IMPORT_EVENT, StatusCode.WARNING), eip); logbookParameters.putParameterValue(LogbookParameterName.eventDetailData, JsonHandler.unprettyPrint(evDetData)); } else { logbookParameters = LogbookParameterHelper .newLogbookOperationParameters(eipId, AGENCIES_IMPORT_EVENT, eip, LogbookTypeProcess.MASTERDATA, StatusCode.OK, VitamLogbookMessages.getCodeOp(AGENCIES_IMPORT_EVENT, StatusCode.OK), eip); } ReferentialFileUtils.addFilenameInLogbookOperation(fileName, logbookParameters); logbookClient.update(logbookParameters); } AgenciesManager(LogbookOperationsClient logbookClient, GUID eip); @VisibleForTesting  AgenciesManager(LogbookOperationsClient logBookclient, GUID eip, boolean warning); void logStarted(String eventType); void logFinish(String fileName); void logEventSuccess(String eventType); void logEventWarning(String eventType); void logError(String errorsDetails, String subEvenType); void setEvDetData(ObjectNode evDetData); static final VitamLogger LOGGER; }