/** * @see Component */ @Override public String toString() { return super.toString() + ", message:" + message(); } }
/** * Class constructor specifying the evaluator to use and the id of the alertBox we want to test. * The constructor checks if the given id does correspond to an alertBox. * * @param evaluator a technology specific evaluator * @param id the id (unique) of the alertBox */ public AlertBox(Evaluator evaluator, String id) { super(evaluator, id); checkIsExpectedComponent(AlertBox); }
@Test public void test_toString() { AlertBox alertBox = new AlertBox(evaluator, id); when(evaluator.isVisible(alertBox)).thenReturn(true); when(evaluator.isEnabled(alertBox)).thenReturn(true); when(evaluator.title(alertBox)).thenReturn("title"); when(evaluator.message(alertBox)).thenReturn("message"); assertThat(alertBox.toString(), is("class org.testatoo.core.component.AlertBox 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 AlertBox(evaluator, id); fail(); } catch (ComponentException e) { assertThat(e.getMessage(), is("The component with id=" + id + " is not a AlertBox but a Radio")); } }