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