@Test public void checkLFCandOperation() throws Exception { logbookDetailsCheckService = new LogbookDetailsCheckServiceImpl(); List<LogbookCheckError> logbookCheckErrors = new ArrayList<>(); Map<String, EventModel> mapOpEvents = new HashMap<>(); Map<String, EventModel> mapLfcEvents = new HashMap<>(); mapOpEvents.put("SANITY_CHECK_SIP", new EventModel(LogbookEventType.ACTION, "aedqaaaabggsoscfaat22albarkwtiqaaaaq", "aeaqaaaabeghay2jabzuaalbarkwwzyaaabq", "aedqaaaabggsoscfaat22albarkwtviaaaba", "aedqaaaabggsoscfaat22albarkwtviaaaaq", "STP_SANITY_CHECK_SIP", "STP_SANITY_CHECK_SIP", "OK", "STP_SANITY_CHECK_SIP.OK") ); mapOpEvents.put("CHECK_HEADER", new EventModel(LogbookEventType.ACTION, "aedqaaaabggsoscfaat22albarkwtiqaaaaq", "aeaqaaaabeghay2jabzuaalbarkwwzyaaabq", "aedqaaaabghwqkjyabmlsalbarkwzxqaaaba", "aedqaaaabghwqkjyabmlsalbarkwwciaaaaq", "CHECK_HEADER", "CHECK_SEDA", "OK", "CHECK_HEADER.OK") ); mapOpEvents.put("UNIT_METADATA_INDEXATION", new EventModel(LogbookEventType.ACTION, "aedqaaaabggsoscfaat22albarkwtiqaaaaq", "aeaqaaaabeghay2jabzuaalbarkwwzyaaabq", "aedqaaaabghwqkjyabmlsalbarkypbiaaaaq", "aedqaaaabghwqkjyabmlsalbarkxx4aaaaaq", "UNIT_METADATA_INDEXATION", "STP_UNIT_METADATA", "OK", "UNIT_METADATA_INDEXATION.OK") ); mapOpEvents.put("UNIT_METADATA_STORAGE", new EventModel(LogbookEventType.ACTION, "aedqaaaabggsoscfaat22albarkwtiqaaaaq", "aeaqaaaabeghay2jabzuaalbarkwwzyaaabq", "aedqaaaabghwqkjyabmlsalbark3whiaaaaq", "aedqaaaabghwqkjyabmlsalbarkyscqaaaaq", "UNIT_METADATA_STORAGE", "STP_UNIT_STORING", "FATAL", "UNIT_METADATA_STORAGE.FATAL") ); mapLfcEvents.put("CHECK_UNIT_SCHEMA", new EventModel(LogbookEventType.ACTION, "aedqaaaabggsoscfaat22albarkwtiqaaaaq", "aeaqaaaabeghay2jabzuaalbarkwwzyaaabq", "aedqaaaabgghay2jabzuaalbarkw3vaaaaaq", null, "CHECK_UNIT_SCHEMA", "", "OK", "CHECK_UNIT_SCHEMA.OK") ); mapLfcEvents.put("CHECK_CLASSIFICATION_LEVEL", new EventModel(LogbookEventType.ACTION, "aedqaaaabggsoscfaat22albarkwtiqaaaaq", "aeaqaaaabeghay2jabzuaalbarkwwzyaaabq", "aedqaaaabgghay2jabzuaalbarkw35qaaaaq", null, "CHECK_CLASSIFICATION_LEVEL", "", "OK", "CHECK_CLASSIFICATION_LEVEL.OK") ); mapLfcEvents.put("UNIT_METADATA_INDEXATION", new EventModel(LogbookEventType.ACTION, "aedqaaaabggsoscfaat22albarkwtiqaaaaq", "aeaqaaaabeghay2jabzuaalbarkwwzyaaabq", "aedqaaaabgghay2jabzuaalbarkxxjaaaaaq", null, "UNIT_METADATA_INDEXATION", "", "OK", "UNIT_METADATA_INDEXATION.OK") ); mapLfcEvents.put("UNIT_METADATA_STORAGE", new EventModel(LogbookEventType.ACTION, "aedqaaaabggsoscfaat22albarkwtiqaaaaq", "", "aedqaaaabgghay2jabzuaalbarkyr2qaaaaq", null, "UNIT_METADATA_STORAGE", "", "OK", "UNIT_METADATA_STORAGE.OK") ); logbookCheckErrors = logbookDetailsCheckService.checkLFCandOperation(mapOpEvents, mapLfcEvents); Assert.assertEquals(5, logbookCheckErrors.size()); Assert.assertEquals("aedqaaaabggsoscfaat22albarkwtiqaaaaq", logbookCheckErrors.get(0).getOperationId()); Assert.assertEquals("aeaqaaaabeghay2jabzuaalbarkwwzyaaabq", logbookCheckErrors.get(0).getLfcId()); Assert.assertEquals("CHECK_UNIT_SCHEMA", logbookCheckErrors.get(0).getCheckedProperty()); Assert.assertTrue("The saved LFC event evType value CHECK_UNIT_SCHEMA, is not present in logbook operation" .contains(logbookCheckErrors.get(0).getSavedLogbookMsg())); Assert.assertTrue("The logbook operation must contains the lifecycle event value evType" .contains(logbookCheckErrors.get(0).getExpectedLogbookMsg())); Assert.assertEquals("CHECK_CLASSIFICATION_LEVEL", logbookCheckErrors.get(1).getCheckedProperty()); Assert.assertTrue( "The saved LFC event evType value CHECK_CLASSIFICATION_LEVEL, is not present in logbook operation" .contains(logbookCheckErrors.get(1).getSavedLogbookMsg())); Assert.assertTrue( "The logbook operation must contains the lifecycle event value evType" .contains(logbookCheckErrors.get(1).getExpectedLogbookMsg())); Assert.assertEquals("UNIT_METADATA_STORAGE", logbookCheckErrors.get(2).getCheckedProperty()); Assert.assertTrue("The saved LFC event outcome value OK, is not conforme in logbook operation" .contains(logbookCheckErrors.get(2).getSavedLogbookMsg())); Assert.assertTrue( "The logbook operation must have the same event value outcome as in the lifecycle" .contains(logbookCheckErrors.get(2).getExpectedLogbookMsg())); Assert.assertEquals("CHECK_HEADER", logbookCheckErrors.get(3).getCheckedProperty()); Assert.assertTrue("The saved logbook operation event evType value CHECK_HEADER, is not present in the lifecycles" .contains(logbookCheckErrors.get(3).getSavedLogbookMsg())); Assert.assertTrue( "The logbook operation event evType, must be present in the lifecycles" .contains(logbookCheckErrors.get(3).getExpectedLogbookMsg())); }
@Override public List<LogbookCheckError> checkLFCandOperation(Map<String, EventModel> mapOpEvents, Map<String, EventModel> mapLfcEvents) { List<LogbookCheckError> logbookCheckErrors = new ArrayList<>(); LOGGER.debug("Check coherence between logbook operation and Lifecycles"); EventModel eventLfc; EventModel eventOp; Set<String> treatedEvents = new HashSet<>(); for (String evType : mapLfcEvents.keySet()) { eventLfc = mapLfcEvents.get(evType); eventOp = mapOpEvents.get(evType); if (eventOp == null) { logbookCheckErrors.add(new LogbookCheckError(eventLfc.getOperationId(), eventLfc.getLfcId(), eventLfc.getEvType(), String.format(SAVED_LOGBOOK_OP_LFC_NOT_EXISTS_MSG, LogbookEventName.EVTYPE.getValue(), eventLfc.getEvType()), String.format(EXPECTED_LOGBOOK_OP_LFC_NOT_EXISTS_MSG, LogbookEventName.EVTYPE.getValue(), eventLfc.getEvType()))); } else if (!eventLfc.getOutcome().equals(eventOp.getOutcome())) { logbookCheckErrors.add(new LogbookCheckError(eventLfc.getOperationId(), eventLfc.getLfcId(), eventLfc.getEvType(), String.format(SAVED_LOGBOOK_OP_LFC_NOT_CONFORME_MSG, LogbookEventName.OUTCOME.getValue(), eventLfc.getOutcome()), String.format(EXPECTED_LOGBOOK_OP_LFC_NOT_CONFORME_MSG, LogbookEventName.OUTCOME.getValue(), eventLfc.getOutcome()))); } treatedEvents.add(evType); } mapOpEvents.keySet().removeAll(treatedEvents); if (!mapOpEvents.isEmpty()) { mapOpEvents.values().forEach(event -> logbookCheckErrors.add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String.format(SAVED_LOGBOOK_OPERATION_EVENTS_NOT_EXIST_IN_LFC_MSG, LogbookEventName.EVTYPE.getValue(), event.getEvType()), String.format(EXPECTED_LOGBOOK_OPERATION_EVENTS_NOT_EXIST_IN_LFC_MSG, LogbookEventName.EVTYPE.getValue(), event.getEvType()))) ); } return logbookCheckErrors; }
LogbookDetailsCheckServiceImpl implements LogbookDetailsCheckService { @Override public List<LogbookCheckError> checkLFCandOperation(Map<String, EventModel> mapOpEvents, Map<String, EventModel> mapLfcEvents) { List<LogbookCheckError> logbookCheckErrors = new ArrayList<>(); LOGGER.debug("Check coherence between logbook operation and Lifecycles"); EventModel eventLfc; EventModel eventOp; Set<String> treatedEvents = new HashSet<>(); for (String evType : mapLfcEvents.keySet()) { eventLfc = mapLfcEvents.get(evType); eventOp = mapOpEvents.get(evType); if (eventOp == null) { logbookCheckErrors.add(new LogbookCheckError(eventLfc.getOperationId(), eventLfc.getLfcId(), eventLfc.getEvType(), String.format(SAVED_LOGBOOK_OP_LFC_NOT_EXISTS_MSG, LogbookEventName.EVTYPE.getValue(), eventLfc.getEvType()), String.format(EXPECTED_LOGBOOK_OP_LFC_NOT_EXISTS_MSG, LogbookEventName.EVTYPE.getValue(), eventLfc.getEvType()))); } else if (!eventLfc.getOutcome().equals(eventOp.getOutcome())) { logbookCheckErrors.add(new LogbookCheckError(eventLfc.getOperationId(), eventLfc.getLfcId(), eventLfc.getEvType(), String.format(SAVED_LOGBOOK_OP_LFC_NOT_CONFORME_MSG, LogbookEventName.OUTCOME.getValue(), eventLfc.getOutcome()), String.format(EXPECTED_LOGBOOK_OP_LFC_NOT_CONFORME_MSG, LogbookEventName.OUTCOME.getValue(), eventLfc.getOutcome()))); } treatedEvents.add(evType); } mapOpEvents.keySet().removeAll(treatedEvents); if (!mapOpEvents.isEmpty()) { mapOpEvents.values().forEach(event -> logbookCheckErrors.add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String.format(SAVED_LOGBOOK_OPERATION_EVENTS_NOT_EXIST_IN_LFC_MSG, LogbookEventName.EVTYPE.getValue(), event.getEvType()), String.format(EXPECTED_LOGBOOK_OPERATION_EVENTS_NOT_EXIST_IN_LFC_MSG, LogbookEventName.EVTYPE.getValue(), event.getEvType()))) ); } return logbookCheckErrors; } }
LogbookDetailsCheckServiceImpl implements LogbookDetailsCheckService { @Override public List<LogbookCheckError> checkLFCandOperation(Map<String, EventModel> mapOpEvents, Map<String, EventModel> mapLfcEvents) { List<LogbookCheckError> logbookCheckErrors = new ArrayList<>(); LOGGER.debug("Check coherence between logbook operation and Lifecycles"); EventModel eventLfc; EventModel eventOp; Set<String> treatedEvents = new HashSet<>(); for (String evType : mapLfcEvents.keySet()) { eventLfc = mapLfcEvents.get(evType); eventOp = mapOpEvents.get(evType); if (eventOp == null) { logbookCheckErrors.add(new LogbookCheckError(eventLfc.getOperationId(), eventLfc.getLfcId(), eventLfc.getEvType(), String.format(SAVED_LOGBOOK_OP_LFC_NOT_EXISTS_MSG, LogbookEventName.EVTYPE.getValue(), eventLfc.getEvType()), String.format(EXPECTED_LOGBOOK_OP_LFC_NOT_EXISTS_MSG, LogbookEventName.EVTYPE.getValue(), eventLfc.getEvType()))); } else if (!eventLfc.getOutcome().equals(eventOp.getOutcome())) { logbookCheckErrors.add(new LogbookCheckError(eventLfc.getOperationId(), eventLfc.getLfcId(), eventLfc.getEvType(), String.format(SAVED_LOGBOOK_OP_LFC_NOT_CONFORME_MSG, LogbookEventName.OUTCOME.getValue(), eventLfc.getOutcome()), String.format(EXPECTED_LOGBOOK_OP_LFC_NOT_CONFORME_MSG, LogbookEventName.OUTCOME.getValue(), eventLfc.getOutcome()))); } treatedEvents.add(evType); } mapOpEvents.keySet().removeAll(treatedEvents); if (!mapOpEvents.isEmpty()) { mapOpEvents.values().forEach(event -> logbookCheckErrors.add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String.format(SAVED_LOGBOOK_OPERATION_EVENTS_NOT_EXIST_IN_LFC_MSG, LogbookEventName.EVTYPE.getValue(), event.getEvType()), String.format(EXPECTED_LOGBOOK_OPERATION_EVENTS_NOT_EXIST_IN_LFC_MSG, LogbookEventName.EVTYPE.getValue(), event.getEvType()))) ); } return logbookCheckErrors; }  }
LogbookDetailsCheckServiceImpl implements LogbookDetailsCheckService { @Override public List<LogbookCheckError> checkLFCandOperation(Map<String, EventModel> mapOpEvents, Map<String, EventModel> mapLfcEvents) { List<LogbookCheckError> logbookCheckErrors = new ArrayList<>(); LOGGER.debug("Check coherence between logbook operation and Lifecycles"); EventModel eventLfc; EventModel eventOp; Set<String> treatedEvents = new HashSet<>(); for (String evType : mapLfcEvents.keySet()) { eventLfc = mapLfcEvents.get(evType); eventOp = mapOpEvents.get(evType); if (eventOp == null) { logbookCheckErrors.add(new LogbookCheckError(eventLfc.getOperationId(), eventLfc.getLfcId(), eventLfc.getEvType(), String.format(SAVED_LOGBOOK_OP_LFC_NOT_EXISTS_MSG, LogbookEventName.EVTYPE.getValue(), eventLfc.getEvType()), String.format(EXPECTED_LOGBOOK_OP_LFC_NOT_EXISTS_MSG, LogbookEventName.EVTYPE.getValue(), eventLfc.getEvType()))); } else if (!eventLfc.getOutcome().equals(eventOp.getOutcome())) { logbookCheckErrors.add(new LogbookCheckError(eventLfc.getOperationId(), eventLfc.getLfcId(), eventLfc.getEvType(), String.format(SAVED_LOGBOOK_OP_LFC_NOT_CONFORME_MSG, LogbookEventName.OUTCOME.getValue(), eventLfc.getOutcome()), String.format(EXPECTED_LOGBOOK_OP_LFC_NOT_CONFORME_MSG, LogbookEventName.OUTCOME.getValue(), eventLfc.getOutcome()))); } treatedEvents.add(evType); } mapOpEvents.keySet().removeAll(treatedEvents); if (!mapOpEvents.isEmpty()) { mapOpEvents.values().forEach(event -> logbookCheckErrors.add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String.format(SAVED_LOGBOOK_OPERATION_EVENTS_NOT_EXIST_IN_LFC_MSG, LogbookEventName.EVTYPE.getValue(), event.getEvType()), String.format(EXPECTED_LOGBOOK_OPERATION_EVENTS_NOT_EXIST_IN_LFC_MSG, LogbookEventName.EVTYPE.getValue(), event.getEvType()))) ); } return logbookCheckErrors; }  @Override List<LogbookCheckError> checkEvent(EventModel event); @Override List<LogbookCheckError> checkLFCandOperation(Map<String, EventModel> mapOpEvents,
                                                        Map<String, EventModel> mapLfcEvents); }
LogbookDetailsCheckServiceImpl implements LogbookDetailsCheckService { @Override public List<LogbookCheckError> checkLFCandOperation(Map<String, EventModel> mapOpEvents, Map<String, EventModel> mapLfcEvents) { List<LogbookCheckError> logbookCheckErrors = new ArrayList<>(); LOGGER.debug("Check coherence between logbook operation and Lifecycles"); EventModel eventLfc; EventModel eventOp; Set<String> treatedEvents = new HashSet<>(); for (String evType : mapLfcEvents.keySet()) { eventLfc = mapLfcEvents.get(evType); eventOp = mapOpEvents.get(evType); if (eventOp == null) { logbookCheckErrors.add(new LogbookCheckError(eventLfc.getOperationId(), eventLfc.getLfcId(), eventLfc.getEvType(), String.format(SAVED_LOGBOOK_OP_LFC_NOT_EXISTS_MSG, LogbookEventName.EVTYPE.getValue(), eventLfc.getEvType()), String.format(EXPECTED_LOGBOOK_OP_LFC_NOT_EXISTS_MSG, LogbookEventName.EVTYPE.getValue(), eventLfc.getEvType()))); } else if (!eventLfc.getOutcome().equals(eventOp.getOutcome())) { logbookCheckErrors.add(new LogbookCheckError(eventLfc.getOperationId(), eventLfc.getLfcId(), eventLfc.getEvType(), String.format(SAVED_LOGBOOK_OP_LFC_NOT_CONFORME_MSG, LogbookEventName.OUTCOME.getValue(), eventLfc.getOutcome()), String.format(EXPECTED_LOGBOOK_OP_LFC_NOT_CONFORME_MSG, LogbookEventName.OUTCOME.getValue(), eventLfc.getOutcome()))); } treatedEvents.add(evType); } mapOpEvents.keySet().removeAll(treatedEvents); if (!mapOpEvents.isEmpty()) { mapOpEvents.values().forEach(event -> logbookCheckErrors.add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String.format(SAVED_LOGBOOK_OPERATION_EVENTS_NOT_EXIST_IN_LFC_MSG, LogbookEventName.EVTYPE.getValue(), event.getEvType()), String.format(EXPECTED_LOGBOOK_OPERATION_EVENTS_NOT_EXIST_IN_LFC_MSG, LogbookEventName.EVTYPE.getValue(), event.getEvType()))) ); } return logbookCheckErrors; }  @Override List<LogbookCheckError> checkEvent(EventModel event); @Override List<LogbookCheckError> checkLFCandOperation(Map<String, EventModel> mapOpEvents,
                                                        Map<String, EventModel> mapLfcEvents);  }