EventStream { public static <S> Builder<S> builder(S state) { return new Builder<>(state); } EventStream(S state, Stream<? extends Event> stream); static Builder<S> builder(S state); static Builder<S> builder(); static EventStream<S> empty(); static EventStream<S> empty(S state); static EventStream<S> ofWithState(S state, Stream<? extends Event> stream); static EventStream<S> of(Stream<? extends Event> stream); static EventStream<S> ofWithState(S state, Event event); static EventStream<S> of(Event event); static EventStream<S> ofWithState(S state, Event ...events); static EventStream<S> of(Event ...events);  }
@Test public void testBuilder() throws Exception { EventStream<String> test = EventStream.builder("test").add(EventCausalityEstablished.builder().build()).build(); assertEquals(test.getState(), "test"); Event event = test.getStream().findFirst().get(); assertTrue(event instanceof EventCausalityEstablished); }
@Test public void testBuilder1() throws Exception { EventStream<String> test = EventStream.<String>builder().add(EventCausalityEstablished.builder().build()).build(); assertNull(test.getState()); Event event = test.getStream().findFirst().get(); assertTrue(event instanceof EventCausalityEstablished); }