@Test public void should_create_iterator_OK() throws Exception { XMLEventReader xmlEventReader = createXmlEventReader(PropertiesUtils.getResourceAsStream("logbook_events.xml")); LogbookEvent event = new LogBookEventIterator(xmlEventReader).next(); assertThat(event).extracting(LogbookEvent::getEvId).isEqualTo("aedqaaaaacglsdgpaa3ikalnhzhaxfiaaaaq"); assertThat(event).extracting(LogbookEvent::getEvTypeProc).isEqualTo("INGEST"); assertThat(event).extracting(LogbookEvent::getEvType).isEqualTo("LFC.CHECK_MANIFEST"); assertThat(event).extracting(LogbookEvent::getEvDateTime).isEqualTo("2019-09-17T08:19:25.206"); assertThat(event).extracting(LogbookEvent::getOutcome).isEqualTo("OK"); assertThat(event).extracting(LogbookEvent::getOutDetail).isEqualTo("LFC.CHECK_MANIFEST.OK"); assertThat(event).extracting(LogbookEvent::getOutMessg).isEqualTo("Succès de la vérification de la cohérence du bordereau de transfert"); assertThat(event).extracting(LogbookEvent::getEvDetData).isEqualTo("{ }"); assertThat(event).extracting(LogbookEvent::getAgId).isEqualTo("{\"Name\":\"5ca8d99a4a94\",\"Role\":\"worker\",\"ServerId\":1555631311,\"SiteId\":1,\"GlobalPlatformId\":213454031}"); }
@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();  }