### Question:
FlashMessages { void showFlashMessage(final FlashMessage flashMessage) { switch (flashMessage.getType()) { case ERROR: view.showErrorMessage(flashMessage.getStrongMessage(), flashMessage.getRegularMessage()); break; case WARNING: view.showWarningMessage(flashMessage.getStrongMessage(), flashMessage.getRegularMessage()); break; case SUCCESS: view.showSuccessMessage(flashMessage.getStrongMessage(), flashMessage.getRegularMessage()); break; } } @Inject  FlashMessages(final View view); HTMLElement getElement(); void onFlashMessageEvent(final @Observes FlashMessage flashMessage); void hideMessages();  }### Answer:
@Test public void testShowFlashMessageWhenItsAnErrorMessage() { final FlashMessage flashMessage = mock(FlashMessage.class); final String strongMessage = "*message*"; final String regularMessage = "message"; when(flashMessage.getType()).thenReturn(ERROR); when(flashMessage.getStrongMessage()).thenReturn(strongMessage); when(flashMessage.getRegularMessage()).thenReturn(regularMessage); flashMessages.showFlashMessage(flashMessage); verify(view).showErrorMessage(strongMessage, regularMessage); verify(view, never()).showWarningMessage(anyString(), anyString()); verify(view, never()).showSuccessMessage(anyString(), anyString()); }
@Test public void testShowFlashMessageWhenItsAWarningMessage() { final FlashMessage flashMessage = mock(FlashMessage.class); final String strongMessage = "*message*"; final String regularMessage = "message"; when(flashMessage.getType()).thenReturn(WARNING); when(flashMessage.getStrongMessage()).thenReturn(strongMessage); when(flashMessage.getRegularMessage()).thenReturn(regularMessage); flashMessages.showFlashMessage(flashMessage); verify(view).showWarningMessage(strongMessage, regularMessage); verify(view, never()).showErrorMessage(anyString(), anyString()); verify(view, never()).showSuccessMessage(anyString(), anyString()); }
@Test public void testShowFlashMessageWhenItsASuccessMessage() { final FlashMessage flashMessage = mock(FlashMessage.class); final String strongMessage = "*message*"; final String regularMessage = "message"; when(flashMessage.getType()).thenReturn(SUCCESS); when(flashMessage.getStrongMessage()).thenReturn(strongMessage); when(flashMessage.getRegularMessage()).thenReturn(regularMessage); flashMessages.showFlashMessage(flashMessage); verify(view).showSuccessMessage(strongMessage, regularMessage); verify(view, never()).showWarningMessage(anyString(), anyString()); verify(view, never()).showErrorMessage(anyString(), anyString()); }