EventStorage { public Event getParent(Event event) { if (event.getParentId() != null) { return events.get(event.getParentId()); } else return null; }  static EventStorage storage(); static EventStorage newInstance(); void store(final Event event); boolean has(Event event); void clean(); FluentIterable<? extends Event> getChildren(Event event, final EventType type); Event getParent(Event event); Event getParent(Event event, EventType type); FluentIterable<? extends Event> getAllChildren(Event event, final EventType type); FluentIterable<? extends Event> getTree(Event event); Event getRootParent(Event event); void remove(Event event); void clearTree(Event event); FluentIterable<? extends Event> getChildren(final Event event); FluentIterable<? extends Event> getAllChildren(Event event); FluentIterable<? extends Event> getAll(); boolean storeIf(Event event, boolean expression); boolean storeIfParentStored(Event event); boolean hasEvents(final EventType type); boolean hasParent(Event event);  }
@Test public void should_provideParent() { assertThat(st.getParent(ef1), is(equalTo((Event) es1))); assertThat(st.getParent(ef2), is(equalTo((Event) es2))); assertThat(st.getParent(tcs2), is(equalTo((Event) tss2))); }
@Test public void should_provideParentOfType() { assertThat(st.getParent(ef2, EventType.EXECUTION_START), is(equalTo((Event) es2))); assertThat(st.getParent(ef2, EventType.EXECUTION_FINISH), is(nullValue())); assertThat(st.getParent(tstf2, EventType.EXECUTION_START), is(equalTo((Event) es2))); assertThat(st.getParent(tstf2, EventType.TEST_SUITE_START), is(equalTo((Event) tss2))); assertThat(st.getParent(ef1, EventType.EXECUTION_START), is(equalTo((Event) es1))); }