@Test public void test_toString() { Panel panel = new Panel(evaluator, id); assertThat(panel.toString(), is("class org.testatoo.core.component.Panel with state : enabled:true, visible:true, title:PanelTitle")); } }
public static Panel panel() { Evaluator evaluator = mock(Evaluator.class); when(evaluator.existComponent(id)).thenReturn(true); when(evaluator.isVisible(any(Component.class))).thenReturn(true); when(evaluator.isEnabled(any(Component.class))).thenReturn(true); when(evaluator.componentType(id)).thenReturn(Panel); when(evaluator.title(any(Panel.class))).thenReturn("myPanelTitle"); return new Panel(evaluator, id); }
@Test public void test_panel_as_container() { when(evaluator.existComponent("myId2")).thenReturn(true); when(evaluator.componentType("myId2")).thenReturn(Panel); Panel panel_1 = new Panel(evaluator, id); Panel panel_2 = new Panel(evaluator, "myId2"); when(evaluator.contains(panel_1, panel_2)).thenReturn(true); when(evaluator.contains(panel_2, panel_1)).thenReturn(false); assertThat(panel_1.contains(panel_2), is(true)); assertThat(panel_2.contains(panel_1), is(false)); }
@Test public void test_component_type() { evaluator = mock(Evaluator.class); when(evaluator.existComponent(id)).thenReturn(true); when(evaluator.componentType(id)).thenReturn(Radio); try { new Panel(evaluator, id); fail(); } catch (ComponentException e) { assertThat(e.getMessage(), is("The component with id=" + id + " is not a Panel but a Radio")); } }