/** * @see Component */ @Override public String toString() { return super.toString() + ", message:" + message(); } }
/** * Class constructor specifying the evaluator to use and the id of the dialogBox we want to test. * The constructor checks if the given id does correspond to a dialogBox. * * @param evaluator a technology specific evaluator * @param id the id (unique) of the dialogBox */ public DialogBox(Evaluator evaluator, String id) { super(evaluator, id); checkIsExpectedComponent(DialogBox); }
@Test public void test_toString() { DialogBox dialogBox = new DialogBox(evaluator, id); when(evaluator.isVisible(any(Component.class))).thenReturn(true); when(evaluator.isEnabled(any(Component.class))).thenReturn(true); when(evaluator.title(dialogBox)).thenReturn("title"); when(evaluator.message(dialogBox)).thenReturn("message"); assertThat(dialogBox.toString(), is("class org.testatoo.core.component.DialogBox with state : enabled:true, visible:true, title:title, message:message")); } }
@Test public void test_component_type() { evaluator = mock(Evaluator.class); when(evaluator.existComponent(id)).thenReturn(true); when(evaluator.componentType(id)).thenReturn(Radio); try { new DialogBox(evaluator, id); fail(); } catch (ComponentException e) { assertThat(e.getMessage(), is("The component with id=" + id + " is not a DialogBox but a Radio")); } }