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