### Question:
InMemoryMessageVerifier { public static boolean eventTypePublished(final InMemoryMessagePublisher<TypedMessage> inMemoryMessagePublisher, final Class<? extends Event> eventClass) { try { final String messageType = eventClass.newInstance().type(); return containsMessageOfType(inMemoryMessagePublisher.getPublishedMessages(), messageType); } catch (InstantiationException | IllegalAccessException e) { throw new IllegalStateException("Unable to instantiate prototype event to verify publication"); } }  static boolean messageTypeSent(final InMemoryMessageSender<TypedMessage> inMemoryMessageSender,
            final String messageType); static boolean eventTypePublished(final InMemoryMessagePublisher<TypedMessage> inMemoryMessagePublisher,
            final Class<? extends Event> eventClass); static boolean eventPublished(final InMemoryMessagePublisher<TypedMessage> inMemoryMessagePublisher,
            final Event event); @SafeVarargs static List<Event> publishedEvents(final InMemoryMessagePublisher<TypedMessage> inMemoryMessagePublisher,
            final Class<? extends Event>... eventClasses);  }### Answer:
@Test public void shouldReturnTrueWhenEventPublished_onEventTypePublished() { final InMemoryMessagePublisher<TypedMessage> inMemoryMessagePublisher = mock(InMemoryMessagePublisher.class); final List<TypedMessage> mockPublishedMessages = new ArrayList<>(); final StubEvent stubEvent = new StubEvent(); stubEvent.setEventField(randomString()); addSerializedEventMessage(mockPublishedMessages, stubEvent); when(inMemoryMessagePublisher.getPublishedMessages()).thenReturn(mockPublishedMessages); final Class<? extends Event> eventClass = StubEvent.class; final boolean eventTypePublished = InMemoryMessageVerifier.eventTypePublished(inMemoryMessagePublisher, eventClass); assertTrue(eventTypePublished); }
@Test public void shouldReturnFalseWhenEventNotPublished_onEventTypePublished() { final InMemoryMessagePublisher<TypedMessage> inMemoryMessagePublisher = mock(InMemoryMessagePublisher.class); final List<TypedMessage> mockPublishedMessages = new ArrayList<>(); when(inMemoryMessagePublisher.getPublishedMessages()).thenReturn(mockPublishedMessages); final Class<? extends Event> eventClass = StubEvent.class; final boolean eventTypePublished = InMemoryMessageVerifier.eventTypePublished(inMemoryMessagePublisher, eventClass); assertFalse(eventTypePublished); }