### Question:
AlertAssert extends AbstractAssert<AlertAssert, AlertImpl> implements AlertStateAssert { @Override public AlertStateAssert hasText(String text) { try { String actualText = actual.getText(); if (!actualText.contains(text)) { failWithMessage( "The alert box does not contain the text: " + text + ". Actual text found : " + actualText); } } catch (NoAlertPresentException e) { failWithMessage("There is no alert box"); } return this; } AlertAssert(AlertImpl actual); @Override AlertStateAssert hasText(String text); @Override AlertStateAssert isPresent();  }### Answer:
@Test public void testHasTextPositive() { when(alert.getText()).thenReturn("some text"); assertThatCode(() -> alertAssert.hasText("some text")).doesNotThrowAnyException(); }
@Test public void testHasTextNegative() { when(alert.getText()).thenReturn("other text"); assertThatThrownBy(() -> alertAssert.hasText("some text")) .isInstanceOf(AssertionError.class) .hasMessage("The alert box does not contain the text: some text. Actual text found : other text"); }
@Test public void testHasTextNotPresent() { doThrow(new NoAlertPresentException()).when(alert).getText(); assertThatThrownBy(() -> alertAssert.hasText("some text")) .isInstanceOf(AssertionError.class) .hasMessage("There is no alert box"); }