@Test public void checkEvents() throws Exception { logbookDetailsCheckService = new LogbookDetailsCheckServiceImpl(); List<LogbookCheckError> logbookCheckErrors; EventModel eventModel = new EventModel(LogbookEventType.ACTION, "aecaaaaabgheitkvabyhoalbapdzhniaaaaq", "", "aedqaaaabggsoscfaat22albarjmsvyaaaba", "aedqaaaabggsoscfaat22albarjmsvyaaaaq", "SANITY_CHECK_SIP", "STP_PREPARE_LC_TRACEABILITY", "OK", "SANITY_CHECK_SIP.OK"); logbookCheckErrors = logbookDetailsCheckService.checkEvent(eventModel); Assert.assertTrue(logbookCheckErrors.isEmpty()); eventModel = new EventModel(LogbookEventType.ACTION, "aecaaaaabgheitkvabyhoalbapdzhniaaaaq", "", "aedqaaaabggsoscfaat22albarjmsvyaaaba", "aedqaaaabggsoscfaat22albarjmsvyaaaaq", "SANITY_CHECK_SIP", "STP_PREPARE_LC_TRACEABILITY", "OK", "PREPARE_LC_TRACEABILITY.OK"); logbookCheckErrors = logbookDetailsCheckService.checkEvent(eventModel); Assert.assertEquals(1, logbookCheckErrors.size()); Assert.assertEquals("aecaaaaabgheitkvabyhoalbapdzhniaaaaq", logbookCheckErrors.get(0).getOperationId()); Assert.assertEquals("SANITY_CHECK_SIP", logbookCheckErrors.get(0).getCheckedProperty()); Assert.assertTrue("The saved event outDetail value is : PREPARE_LC_TRACEABILITY.OK" .contains(logbookCheckErrors.get(0).getSavedLogbookMsg())); Assert.assertTrue("The event outDetail value must be as : ^SANITY_CHECK_SIP(\\.(\\w+))*\\.OK$" .contains(logbookCheckErrors.get(0).getExpectedLogbookMsg())); eventModel = new EventModel(LogbookEventType.STEP, "aecaaaaabgheitkvabyhoalbapdzhniaaaaq", "", "aedqaaaabggsoscfaat22albarkwtviaaaaq", null, "STP_SANITY_CHECK_SIP", "", "WARNN", "PREPARE_LC_TRACEABILITY.FATAL"); logbookCheckErrors = logbookDetailsCheckService.checkEvent(eventModel); Assert.assertEquals(2, logbookCheckErrors.size()); Assert.assertEquals("aecaaaaabgheitkvabyhoalbapdzhniaaaaq", logbookCheckErrors.get(0).getOperationId()); Assert.assertEquals("STP_SANITY_CHECK_SIP", logbookCheckErrors.get(0).getCheckedProperty()); Assert.assertTrue("The saved event STP_SANITY_CHECK_SIP outcome value is : WARNN" .contains(logbookCheckErrors.get(0).getSavedLogbookMsg())); Assert.assertTrue("The event outcome value must be as : STARTED, OK, WARNING, KO, FATAL" .contains(logbookCheckErrors.get(0).getExpectedLogbookMsg())); Assert.assertTrue("The saved event outDetail value is : PREPARE_LC_TRACEABILITY.FATAL" .contains(logbookCheckErrors.get(1).getSavedLogbookMsg())); Assert.assertTrue("The event outDetail value must be as : ^STP_SANITY_CHECK_SIP(\\.(\\w+))*\\.WARNN$" .contains(logbookCheckErrors.get(1).getExpectedLogbookMsg())); eventModel = new EventModel(LogbookEventType.TASK, "aedqaaaabggsoscfaat22albarkwtiqaaaaq", "aeaqaaaabeghay2jabzuaalbarkwwzyaaabq", "aedqaaaabgghay2jabzuaalbarkwxnyaaaba", "aedqaaaabgghay2jabzuaalbarkwxnyaaaaq", "LFC.CHECK_MANIFEST.LFC_CREATION", "LFC.CHECK_UNIT_SCHEMA", "KO", "LFC.CHECK_MANIFEST.LFC_CREATION.OK"); logbookCheckErrors = logbookDetailsCheckService.checkEvent(eventModel); Assert.assertEquals(2, logbookCheckErrors.size()); Assert.assertEquals("aedqaaaabggsoscfaat22albarkwtiqaaaaq", logbookCheckErrors.get(0).getOperationId()); Assert.assertEquals("aeaqaaaabeghay2jabzuaalbarkwwzyaaabq", logbookCheckErrors.get(0).getLfcId()); Assert.assertEquals("LFC.CHECK_MANIFEST.LFC_CREATION", logbookCheckErrors.get(0).getCheckedProperty()); Assert.assertTrue("The saved event evType value is : LFC.CHECK_MANIFEST.LFC_CREATION" .contains(logbookCheckErrors.get(0).getSavedLogbookMsg())); Assert.assertTrue("The event evType value must be as : LFC.CHECK_UNIT_SCHEMA.*" .contains(logbookCheckErrors.get(0).getExpectedLogbookMsg())); Assert.assertTrue("The saved event outDetail value is : LFC.CHECK_MANIFEST.LFC_CREATION.OK" .contains(logbookCheckErrors.get(1).getSavedLogbookMsg())); Assert.assertTrue( "The event outDetail value must be as : ^LFC.CHECK_MANIFEST.LFC_CREATION(\\.(\\w+))*\\.KO$" .contains(logbookCheckErrors.get(1).getExpectedLogbookMsg())); }
@Override public List<LogbookCheckError> checkEvent(EventModel event) { List<LogbookCheckError> logbookCheckErrors = new ArrayList<>(); if (LogbookEventType.TASK.equals(event.getLogbookEventType()) && event.getEvTypeParent() != null) { String evTypeFormat = event.getEvTypeParent() + DOT; if (!event.getEvType().startsWith(evTypeFormat)) { logbookCheckErrors .add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String.format(SAVED_LOGBOOK_MSG, LogbookEventName.EVTYPE.getValue(), event.getEvType()), String.format(EXPECTED_LOGBOOK_MSG, LogbookEventName.EVTYPE.getValue(), evTypeFormat + "*"))); } } boolean isOutcomeOk = Stream.of(OutcomeStatus.values()).map(String::valueOf) .anyMatch(s -> s.contains(event.getOutcome())); if (!isOutcomeOk) { logbookCheckErrors.add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String .format(SAVED_LOGBOOK_MSG, event.getEvType() + " " + LogbookEventName.OUTCOME.getValue(), event.getOutcome()), String.format(EXPECTED_LOGBOOK_MSG, LogbookEventName.OUTCOME.getValue() , Stream.of(OutcomeStatus.values()).map(String::valueOf).collect(Collectors.joining(", "))))); } String regex = "^" + event.getEvType() + "(\\.(\\w+))*\\." + event.getOutcome() + "$"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(event.getOutDetail()); if (!matcher.find()) { logbookCheckErrors.add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String.format(SAVED_LOGBOOK_MSG, LogbookEventName.OUTCOMEDETAILS.getValue(), event.getOutDetail()), String.format(EXPECTED_LOGBOOK_MSG, LogbookEventName.OUTCOMEDETAILS.getValue(), regex))); } return logbookCheckErrors; }
LogbookDetailsCheckServiceImpl implements LogbookDetailsCheckService { @Override public List<LogbookCheckError> checkEvent(EventModel event) { List<LogbookCheckError> logbookCheckErrors = new ArrayList<>(); if (LogbookEventType.TASK.equals(event.getLogbookEventType()) && event.getEvTypeParent() != null) { String evTypeFormat = event.getEvTypeParent() + DOT; if (!event.getEvType().startsWith(evTypeFormat)) { logbookCheckErrors .add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String.format(SAVED_LOGBOOK_MSG, LogbookEventName.EVTYPE.getValue(), event.getEvType()), String.format(EXPECTED_LOGBOOK_MSG, LogbookEventName.EVTYPE.getValue(), evTypeFormat + "*"))); } } boolean isOutcomeOk = Stream.of(OutcomeStatus.values()).map(String::valueOf) .anyMatch(s -> s.contains(event.getOutcome())); if (!isOutcomeOk) { logbookCheckErrors.add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String .format(SAVED_LOGBOOK_MSG, event.getEvType() + " " + LogbookEventName.OUTCOME.getValue(), event.getOutcome()), String.format(EXPECTED_LOGBOOK_MSG, LogbookEventName.OUTCOME.getValue() , Stream.of(OutcomeStatus.values()).map(String::valueOf).collect(Collectors.joining(", "))))); } String regex = "^" + event.getEvType() + "(\\.(\\w+))*\\." + event.getOutcome() + "$"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(event.getOutDetail()); if (!matcher.find()) { logbookCheckErrors.add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String.format(SAVED_LOGBOOK_MSG, LogbookEventName.OUTCOMEDETAILS.getValue(), event.getOutDetail()), String.format(EXPECTED_LOGBOOK_MSG, LogbookEventName.OUTCOMEDETAILS.getValue(), regex))); } return logbookCheckErrors; } }
LogbookDetailsCheckServiceImpl implements LogbookDetailsCheckService { @Override public List<LogbookCheckError> checkEvent(EventModel event) { List<LogbookCheckError> logbookCheckErrors = new ArrayList<>(); if (LogbookEventType.TASK.equals(event.getLogbookEventType()) && event.getEvTypeParent() != null) { String evTypeFormat = event.getEvTypeParent() + DOT; if (!event.getEvType().startsWith(evTypeFormat)) { logbookCheckErrors .add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String.format(SAVED_LOGBOOK_MSG, LogbookEventName.EVTYPE.getValue(), event.getEvType()), String.format(EXPECTED_LOGBOOK_MSG, LogbookEventName.EVTYPE.getValue(), evTypeFormat + "*"))); } } boolean isOutcomeOk = Stream.of(OutcomeStatus.values()).map(String::valueOf) .anyMatch(s -> s.contains(event.getOutcome())); if (!isOutcomeOk) { logbookCheckErrors.add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String .format(SAVED_LOGBOOK_MSG, event.getEvType() + " " + LogbookEventName.OUTCOME.getValue(), event.getOutcome()), String.format(EXPECTED_LOGBOOK_MSG, LogbookEventName.OUTCOME.getValue() , Stream.of(OutcomeStatus.values()).map(String::valueOf).collect(Collectors.joining(", "))))); } String regex = "^" + event.getEvType() + "(\\.(\\w+))*\\." + event.getOutcome() + "$"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(event.getOutDetail()); if (!matcher.find()) { logbookCheckErrors.add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String.format(SAVED_LOGBOOK_MSG, LogbookEventName.OUTCOMEDETAILS.getValue(), event.getOutDetail()), String.format(EXPECTED_LOGBOOK_MSG, LogbookEventName.OUTCOMEDETAILS.getValue(), regex))); } return logbookCheckErrors; }  }
LogbookDetailsCheckServiceImpl implements LogbookDetailsCheckService { @Override public List<LogbookCheckError> checkEvent(EventModel event) { List<LogbookCheckError> logbookCheckErrors = new ArrayList<>(); if (LogbookEventType.TASK.equals(event.getLogbookEventType()) && event.getEvTypeParent() != null) { String evTypeFormat = event.getEvTypeParent() + DOT; if (!event.getEvType().startsWith(evTypeFormat)) { logbookCheckErrors .add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String.format(SAVED_LOGBOOK_MSG, LogbookEventName.EVTYPE.getValue(), event.getEvType()), String.format(EXPECTED_LOGBOOK_MSG, LogbookEventName.EVTYPE.getValue(), evTypeFormat + "*"))); } } boolean isOutcomeOk = Stream.of(OutcomeStatus.values()).map(String::valueOf) .anyMatch(s -> s.contains(event.getOutcome())); if (!isOutcomeOk) { logbookCheckErrors.add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String .format(SAVED_LOGBOOK_MSG, event.getEvType() + " " + LogbookEventName.OUTCOME.getValue(), event.getOutcome()), String.format(EXPECTED_LOGBOOK_MSG, LogbookEventName.OUTCOME.getValue() , Stream.of(OutcomeStatus.values()).map(String::valueOf).collect(Collectors.joining(", "))))); } String regex = "^" + event.getEvType() + "(\\.(\\w+))*\\." + event.getOutcome() + "$"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(event.getOutDetail()); if (!matcher.find()) { logbookCheckErrors.add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String.format(SAVED_LOGBOOK_MSG, LogbookEventName.OUTCOMEDETAILS.getValue(), event.getOutDetail()), String.format(EXPECTED_LOGBOOK_MSG, LogbookEventName.OUTCOMEDETAILS.getValue(), regex))); } 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> checkEvent(EventModel event) { List<LogbookCheckError> logbookCheckErrors = new ArrayList<>(); if (LogbookEventType.TASK.equals(event.getLogbookEventType()) && event.getEvTypeParent() != null) { String evTypeFormat = event.getEvTypeParent() + DOT; if (!event.getEvType().startsWith(evTypeFormat)) { logbookCheckErrors .add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String.format(SAVED_LOGBOOK_MSG, LogbookEventName.EVTYPE.getValue(), event.getEvType()), String.format(EXPECTED_LOGBOOK_MSG, LogbookEventName.EVTYPE.getValue(), evTypeFormat + "*"))); } } boolean isOutcomeOk = Stream.of(OutcomeStatus.values()).map(String::valueOf) .anyMatch(s -> s.contains(event.getOutcome())); if (!isOutcomeOk) { logbookCheckErrors.add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String .format(SAVED_LOGBOOK_MSG, event.getEvType() + " " + LogbookEventName.OUTCOME.getValue(), event.getOutcome()), String.format(EXPECTED_LOGBOOK_MSG, LogbookEventName.OUTCOME.getValue() , Stream.of(OutcomeStatus.values()).map(String::valueOf).collect(Collectors.joining(", "))))); } String regex = "^" + event.getEvType() + "(\\.(\\w+))*\\." + event.getOutcome() + "$"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(event.getOutDetail()); if (!matcher.find()) { logbookCheckErrors.add(new LogbookCheckError(event.getOperationId(), event.getLfcId(), event.getEvType(), String.format(SAVED_LOGBOOK_MSG, LogbookEventName.OUTCOMEDETAILS.getValue(), event.getOutDetail()), String.format(EXPECTED_LOGBOOK_MSG, LogbookEventName.OUTCOMEDETAILS.getValue(), regex))); } return logbookCheckErrors; }  @Override List<LogbookCheckError> checkEvent(EventModel event); @Override List<LogbookCheckError> checkLFCandOperation(Map<String, EventModel> mapOpEvents,
                                                        Map<String, EventModel> mapLfcEvents);  }