@Test public void typicalEmptyRead() { when(delegate.read()).thenReturn(Optional.empty()); Optional<BeekeeperEvent> read = messageReaderAdapter.read(); assertThat(read).isEmpty(); }
@Override public Optional<BeekeeperEvent> read() { Optional<MessageEvent> messageEvent = delegate.read(); if (messageEvent.isEmpty()) { return Optional.empty(); } MessageEvent message = messageEvent.get(); List<HousekeepingEntity> housekeepingEntities = handlers.parallelStream() .map(eventHandler -> eventHandler.handleMessage(message)) .flatMap(Collection::stream) .collect(Collectors.toList()); if (housekeepingEntities.size() <= 0) { delete(new BeekeeperEvent(Collections.emptyList(), message)); return Optional.empty(); } return Optional.of(new BeekeeperEvent(housekeepingEntities, message)); }
MessageReaderAdapter implements BeekeeperEventReader { @Override public Optional<BeekeeperEvent> read() { Optional<MessageEvent> messageEvent = delegate.read(); if (messageEvent.isEmpty()) { return Optional.empty(); } MessageEvent message = messageEvent.get(); List<HousekeepingEntity> housekeepingEntities = handlers.parallelStream() .map(eventHandler -> eventHandler.handleMessage(message)) .flatMap(Collection::stream) .collect(Collectors.toList()); if (housekeepingEntities.size() <= 0) { delete(new BeekeeperEvent(Collections.emptyList(), message)); return Optional.empty(); } return Optional.of(new BeekeeperEvent(housekeepingEntities, message)); } }
MessageReaderAdapter implements BeekeeperEventReader { @Override public Optional<BeekeeperEvent> read() { Optional<MessageEvent> messageEvent = delegate.read(); if (messageEvent.isEmpty()) { return Optional.empty(); } MessageEvent message = messageEvent.get(); List<HousekeepingEntity> housekeepingEntities = handlers.parallelStream() .map(eventHandler -> eventHandler.handleMessage(message)) .flatMap(Collection::stream) .collect(Collectors.toList()); if (housekeepingEntities.size() <= 0) { delete(new BeekeeperEvent(Collections.emptyList(), message)); return Optional.empty(); } return Optional.of(new BeekeeperEvent(housekeepingEntities, message)); } MessageReaderAdapter(MessageReader delegate,
      List<MessageEventHandler> handlers); }
MessageReaderAdapter implements BeekeeperEventReader { @Override public Optional<BeekeeperEvent> read() { Optional<MessageEvent> messageEvent = delegate.read(); if (messageEvent.isEmpty()) { return Optional.empty(); } MessageEvent message = messageEvent.get(); List<HousekeepingEntity> housekeepingEntities = handlers.parallelStream() .map(eventHandler -> eventHandler.handleMessage(message)) .flatMap(Collection::stream) .collect(Collectors.toList()); if (housekeepingEntities.size() <= 0) { delete(new BeekeeperEvent(Collections.emptyList(), message)); return Optional.empty(); } return Optional.of(new BeekeeperEvent(housekeepingEntities, message)); } MessageReaderAdapter(MessageReader delegate,
      List<MessageEventHandler> handlers); @Override Optional<BeekeeperEvent> read(); @Override void delete(BeekeeperEvent beekeeperEvent); @Override void close(); }
MessageReaderAdapter implements BeekeeperEventReader { @Override public Optional<BeekeeperEvent> read() { Optional<MessageEvent> messageEvent = delegate.read(); if (messageEvent.isEmpty()) { return Optional.empty(); } MessageEvent message = messageEvent.get(); List<HousekeepingEntity> housekeepingEntities = handlers.parallelStream() .map(eventHandler -> eventHandler.handleMessage(message)) .flatMap(Collection::stream) .collect(Collectors.toList()); if (housekeepingEntities.size() <= 0) { delete(new BeekeeperEvent(Collections.emptyList(), message)); return Optional.empty(); } return Optional.of(new BeekeeperEvent(housekeepingEntities, message)); } MessageReaderAdapter(MessageReader delegate,
      List<MessageEventHandler> handlers); @Override Optional<BeekeeperEvent> read(); @Override void delete(BeekeeperEvent beekeeperEvent); @Override void close();  }