@Test @RunWithCustomExecutor public void should_log_Event_success() throws Exception { VitamThreadUtils.getVitamSession().setTenantId(TENANT_ID); ArgumentCaptor<LogbookOperationParameters> captor = ArgumentCaptor.forClass(LogbookOperationParameters.class); BackupLogbookManager manager = new BackupLogbookManager(logbookOperationsClientFactory); Digest digest = new Digest(VitamConfiguration.getDefaultDigestType()); digest.update("toto".getBytes()); ObjectNode evdetData = JsonHandler.createObjectNode(); evdetData.put(BackupLogbookManager.FILE_NAME, "toto.json"); evdetData.put(BackupLogbookManager.DIGEST, digest.digestHex()); evdetData.put(BackupLogbookManager.DIGESTTYPE, VitamConfiguration.getDefaultDigestType().getName()); manager.logEventSuccess(newOperationLogbookGUID(0), "STP_TEST", digest.digestHex(), "toto.json", null); verify(logbookOperationsClient).update(captor.capture()); LogbookOperationParameters parameter = captor.getValue(); assertThat(parameter.getParameterValue(eventType)).isEqualTo("STP_TEST"); assertThat(parameter.getParameterValue(eventTypeProcess)).isEqualTo("MASTERDATA"); assertThat(parameter.getParameterValue(outcome)).isEqualTo("OK"); assertThat(parameter.getParameterValue(eventDetailData)).isEqualTo(evdetData.toString()); }
public void logEventSuccess(GUID logbookOperationMasterId, String eventType, String digestStr, String fileName, String objectIdentifier) throws VitamException { final GUID eipId = GUIDFactory.newOperationLogbookGUID(ParameterHelper.getTenantParameter()); final LogbookOperationParameters logbookParameters = LogbookParameterHelper .newLogbookOperationParameters(eipId, eventType, logbookOperationMasterId, LogbookTypeProcess.MASTERDATA, StatusCode.OK, getCodeOp(eventType, StatusCode.OK), logbookOperationMasterId); if (objectIdentifier != null && !objectIdentifier.isEmpty()) { logbookParameters.putParameterValue(LogbookParameterName.objectIdentifier, objectIdentifier); } ObjectNode evDetData = JsonHandler.createObjectNode(); evDetData.put(FILE_NAME, fileName); evDetData.put(DIGEST, digestStr); evDetData.put(DIGESTTYPE, VitamConfiguration.getDefaultDigestType().getName()); logbookParameters.putParameterValue( LogbookParameterName.eventDetailData, JsonHandler.unprettyPrint(evDetData)); LogbookOperationsClient logbookClient = logbookClientFactory.getClient(); logbookClient.update(logbookParameters); }
BackupLogbookManager { public void logEventSuccess(GUID logbookOperationMasterId, String eventType, String digestStr, String fileName, String objectIdentifier) throws VitamException { final GUID eipId = GUIDFactory.newOperationLogbookGUID(ParameterHelper.getTenantParameter()); final LogbookOperationParameters logbookParameters = LogbookParameterHelper .newLogbookOperationParameters(eipId, eventType, logbookOperationMasterId, LogbookTypeProcess.MASTERDATA, StatusCode.OK, getCodeOp(eventType, StatusCode.OK), logbookOperationMasterId); if (objectIdentifier != null && !objectIdentifier.isEmpty()) { logbookParameters.putParameterValue(LogbookParameterName.objectIdentifier, objectIdentifier); } ObjectNode evDetData = JsonHandler.createObjectNode(); evDetData.put(FILE_NAME, fileName); evDetData.put(DIGEST, digestStr); evDetData.put(DIGESTTYPE, VitamConfiguration.getDefaultDigestType().getName()); logbookParameters.putParameterValue( LogbookParameterName.eventDetailData, JsonHandler.unprettyPrint(evDetData)); LogbookOperationsClient logbookClient = logbookClientFactory.getClient(); logbookClient.update(logbookParameters); } }
BackupLogbookManager { public void logEventSuccess(GUID logbookOperationMasterId, String eventType, String digestStr, String fileName, String objectIdentifier) throws VitamException { final GUID eipId = GUIDFactory.newOperationLogbookGUID(ParameterHelper.getTenantParameter()); final LogbookOperationParameters logbookParameters = LogbookParameterHelper .newLogbookOperationParameters(eipId, eventType, logbookOperationMasterId, LogbookTypeProcess.MASTERDATA, StatusCode.OK, getCodeOp(eventType, StatusCode.OK), logbookOperationMasterId); if (objectIdentifier != null && !objectIdentifier.isEmpty()) { logbookParameters.putParameterValue(LogbookParameterName.objectIdentifier, objectIdentifier); } ObjectNode evDetData = JsonHandler.createObjectNode(); evDetData.put(FILE_NAME, fileName); evDetData.put(DIGEST, digestStr); evDetData.put(DIGESTTYPE, VitamConfiguration.getDefaultDigestType().getName()); logbookParameters.putParameterValue( LogbookParameterName.eventDetailData, JsonHandler.unprettyPrint(evDetData)); LogbookOperationsClient logbookClient = logbookClientFactory.getClient(); logbookClient.update(logbookParameters); } BackupLogbookManager(); @VisibleForTesting  BackupLogbookManager(LogbookOperationsClientFactory logbookClientFactory); }
BackupLogbookManager { public void logEventSuccess(GUID logbookOperationMasterId, String eventType, String digestStr, String fileName, String objectIdentifier) throws VitamException { final GUID eipId = GUIDFactory.newOperationLogbookGUID(ParameterHelper.getTenantParameter()); final LogbookOperationParameters logbookParameters = LogbookParameterHelper .newLogbookOperationParameters(eipId, eventType, logbookOperationMasterId, LogbookTypeProcess.MASTERDATA, StatusCode.OK, getCodeOp(eventType, StatusCode.OK), logbookOperationMasterId); if (objectIdentifier != null && !objectIdentifier.isEmpty()) { logbookParameters.putParameterValue(LogbookParameterName.objectIdentifier, objectIdentifier); } ObjectNode evDetData = JsonHandler.createObjectNode(); evDetData.put(FILE_NAME, fileName); evDetData.put(DIGEST, digestStr); evDetData.put(DIGESTTYPE, VitamConfiguration.getDefaultDigestType().getName()); logbookParameters.putParameterValue( LogbookParameterName.eventDetailData, JsonHandler.unprettyPrint(evDetData)); LogbookOperationsClient logbookClient = logbookClientFactory.getClient(); logbookClient.update(logbookParameters); } BackupLogbookManager(); @VisibleForTesting  BackupLogbookManager(LogbookOperationsClientFactory logbookClientFactory); void logEventSuccess(GUID logbookOperationMasterId, String eventType, String digestStr, String fileName, String objectIdentifier); void logError(GUID logbookOperationMasterId, String eventType, String errorsDetails); }
BackupLogbookManager { public void logEventSuccess(GUID logbookOperationMasterId, String eventType, String digestStr, String fileName, String objectIdentifier) throws VitamException { final GUID eipId = GUIDFactory.newOperationLogbookGUID(ParameterHelper.getTenantParameter()); final LogbookOperationParameters logbookParameters = LogbookParameterHelper .newLogbookOperationParameters(eipId, eventType, logbookOperationMasterId, LogbookTypeProcess.MASTERDATA, StatusCode.OK, getCodeOp(eventType, StatusCode.OK), logbookOperationMasterId); if (objectIdentifier != null && !objectIdentifier.isEmpty()) { logbookParameters.putParameterValue(LogbookParameterName.objectIdentifier, objectIdentifier); } ObjectNode evDetData = JsonHandler.createObjectNode(); evDetData.put(FILE_NAME, fileName); evDetData.put(DIGEST, digestStr); evDetData.put(DIGESTTYPE, VitamConfiguration.getDefaultDigestType().getName()); logbookParameters.putParameterValue( LogbookParameterName.eventDetailData, JsonHandler.unprettyPrint(evDetData)); LogbookOperationsClient logbookClient = logbookClientFactory.getClient(); logbookClient.update(logbookParameters); } BackupLogbookManager(); @VisibleForTesting  BackupLogbookManager(LogbookOperationsClientFactory logbookClientFactory); void logEventSuccess(GUID logbookOperationMasterId, String eventType, String digestStr, String fileName, String objectIdentifier); void logError(GUID logbookOperationMasterId, String eventType, String errorsDetails); static final VitamLogger LOGGER; static final String ERROR_MESSAGE; static final String FILE_NAME; static final String DIGEST; static final String DIGESTTYPE; }