Code example for JTextComponent

Methods: getText

0
    reader = new JTextComponentTextReader();
  } 
 
  @Test
  public void should_return_false_if_text_in_JTextComponent_is_null() { 
    when(textComponent.getText()).thenReturn(null);
    assertThat(reader.checkContainsText(textComponent, "Yoda")).isFalse();
  } 
 
  @Test
  public void should_return_false_if_text_in_JTextComponent_does_not_contain_given_String() { 
    when(textComponent.getText()).thenReturn("Leia");
    assertThat(reader.checkContainsText(textComponent, "Yoda")).isFalse();
  } 
 
  @Test
  public void should_return_true_if_text_in_JTextComponent_contains_given_String() { 
    when(textComponent.getText()).thenReturn("Yoda");
    assertThat(reader.checkContainsText(textComponent, "Yo")).isTrue();
  } 
Contextual code suggestions in your IDE  Get Codota for Java