Text extends Component implements HasText { @Override public void setVisible(boolean visible) { throw new UnsupportedOperationException("Cannot change " + getClass().getSimpleName() + " component visibility because it doesn't " + "represent an HTML Element but a text Node on the client side."); } Text(String text); @Override void setText(String text); @Override String getText(); @Override void setId(String id); @Override void setVisible(boolean visible);  }
@Test public void setVisibility_throwsWithMeaningfulMessage() { exception.expect(UnsupportedOperationException.class); exception.expectMessage(CoreMatchers.allOf( CoreMatchers.containsString( "Cannot change Text component visibility"), CoreMatchers.containsString( "because it doesn't represent an HTML Element"))); new Text("").setVisible(false); }