@Test public void should_throw_error_when_not_expected_element_in_events() throws Exception { XMLEventReader xmlEventReader = createXmlEventReader(PropertiesUtils.getResourceAsStream("logbook_events_unexpected_element.xml")); ThrowingCallable createIterator = () -> new LogBookEventIterator(xmlEventReader).next(); assertThatThrownBy(createIterator).isInstanceOf(VitamRuntimeException.class); }
@Override public LogbookEvent next() { LogbookEvent logbookEvent = new LogbookEvent(); skip("Event"); logbookEvent.setEvId(tryTake("EventIdentifier")); logbookEvent.setEvTypeProc(tryTake("EventTypeCode")); logbookEvent.setEvType(tryTake("EventType")); logbookEvent.setEvDateTime(take("EventDateTime")); logbookEvent.setOutcome(tryTake("Outcome")); logbookEvent.setOutDetail(tryTake("OutcomeDetail")); logbookEvent.setOutMessg(tryTake("OutcomeDetailMessage")); logbookEvent.setEvDetData(tryTake("EventDetailData")); logbookEvent.setAgId(tryTake("AgentIdentifier")); logbookEvent.setObId(tryTake("ObjectIdentifier")); skip("Event"); return logbookEvent; }
LogBookEventIterator implements Iterator<LogbookEvent>, Iterable<LogbookEvent> { @Override public LogbookEvent next() { LogbookEvent logbookEvent = new LogbookEvent(); skip("Event"); logbookEvent.setEvId(tryTake("EventIdentifier")); logbookEvent.setEvTypeProc(tryTake("EventTypeCode")); logbookEvent.setEvType(tryTake("EventType")); logbookEvent.setEvDateTime(take("EventDateTime")); logbookEvent.setOutcome(tryTake("Outcome")); logbookEvent.setOutDetail(tryTake("OutcomeDetail")); logbookEvent.setOutMessg(tryTake("OutcomeDetailMessage")); logbookEvent.setEvDetData(tryTake("EventDetailData")); logbookEvent.setAgId(tryTake("AgentIdentifier")); logbookEvent.setObId(tryTake("ObjectIdentifier")); skip("Event"); return logbookEvent; } }
LogBookEventIterator implements Iterator<LogbookEvent>, Iterable<LogbookEvent> { @Override public LogbookEvent next() { LogbookEvent logbookEvent = new LogbookEvent(); skip("Event"); logbookEvent.setEvId(tryTake("EventIdentifier")); logbookEvent.setEvTypeProc(tryTake("EventTypeCode")); logbookEvent.setEvType(tryTake("EventType")); logbookEvent.setEvDateTime(take("EventDateTime")); logbookEvent.setOutcome(tryTake("Outcome")); logbookEvent.setOutDetail(tryTake("OutcomeDetail")); logbookEvent.setOutMessg(tryTake("OutcomeDetailMessage")); logbookEvent.setEvDetData(tryTake("EventDetailData")); logbookEvent.setAgId(tryTake("AgentIdentifier")); logbookEvent.setObId(tryTake("ObjectIdentifier")); skip("Event"); return logbookEvent; } LogBookEventIterator(XMLEventReader reader); }
LogBookEventIterator implements Iterator<LogbookEvent>, Iterable<LogbookEvent> { @Override public LogbookEvent next() { LogbookEvent logbookEvent = new LogbookEvent(); skip("Event"); logbookEvent.setEvId(tryTake("EventIdentifier")); logbookEvent.setEvTypeProc(tryTake("EventTypeCode")); logbookEvent.setEvType(tryTake("EventType")); logbookEvent.setEvDateTime(take("EventDateTime")); logbookEvent.setOutcome(tryTake("Outcome")); logbookEvent.setOutDetail(tryTake("OutcomeDetail")); logbookEvent.setOutMessg(tryTake("OutcomeDetailMessage")); logbookEvent.setEvDetData(tryTake("EventDetailData")); logbookEvent.setAgId(tryTake("AgentIdentifier")); logbookEvent.setObId(tryTake("ObjectIdentifier")); skip("Event"); return logbookEvent; } LogBookEventIterator(XMLEventReader reader); @Override boolean hasNext(); @Override LogbookEvent next(); @Override Iterator<LogbookEvent> iterator(); @Override Spliterator<LogbookEvent> spliterator(); Stream<LogbookEvent> stream(); }
LogBookEventIterator implements Iterator<LogbookEvent>, Iterable<LogbookEvent> { @Override public LogbookEvent next() { LogbookEvent logbookEvent = new LogbookEvent(); skip("Event"); logbookEvent.setEvId(tryTake("EventIdentifier")); logbookEvent.setEvTypeProc(tryTake("EventTypeCode")); logbookEvent.setEvType(tryTake("EventType")); logbookEvent.setEvDateTime(take("EventDateTime")); logbookEvent.setOutcome(tryTake("Outcome")); logbookEvent.setOutDetail(tryTake("OutcomeDetail")); logbookEvent.setOutMessg(tryTake("OutcomeDetailMessage")); logbookEvent.setEvDetData(tryTake("EventDetailData")); logbookEvent.setAgId(tryTake("AgentIdentifier")); logbookEvent.setObId(tryTake("ObjectIdentifier")); skip("Event"); return logbookEvent; } LogBookEventIterator(XMLEventReader reader); @Override boolean hasNext(); @Override LogbookEvent next(); @Override Iterator<LogbookEvent> iterator(); @Override Spliterator<LogbookEvent> spliterator(); Stream<LogbookEvent> stream();  }