@Test public final void shouldGetSelectedEntities() { // given List<Entity> entities = ImmutableList.of(mockEntity(), mockEntity(), mockEntity(), mockEntity()); given(workPlansGrid.getSelectedEntities()).willReturn(entities); // when List<Entity> result = workPlansListView.getSelectedWorkPlans(); // then assertEquals(entities, result); }
@Test public final void shouldBuildFromViewDefinitionState() { // given ViewDefinitionState viewDefinitionState = mock(ViewDefinitionState.class); given(viewDefinitionState.getComponentByReference("window")).willReturn(windowComponent); Ribbon ribbon = mock(Ribbon.class); given((windowComponent).getRibbon()).willReturn(ribbon); RibbonGroup actionsRibbonGroup = mock(RibbonGroup.class); given(ribbon.getGroupByName("actions")).willReturn(actionsRibbonGroup); given(actionsRibbonGroup.getItemByName("delete")).willReturn(deleteButton); given(viewDefinitionState.getComponentByReference("grid")).willReturn(workPlansGrid); // when WorkPlansListView workPlansListView = WorkPlansListView.from(viewDefinitionState); workPlansListView.setUpDeleteButton(true, null); workPlansListView.getSelectedWorkPlans(); // then verify(deleteButton).setEnabled(anyBoolean()); verify(workPlansGrid).getSelectedEntities(); }
@Test public final void shouldSetUpDeleteButton() { // given boolean isEnabled = true; String message = "some arbitrary mesage"; // when workPlansListView.setUpDeleteButton(isEnabled, message); // then verify(deleteButton).setEnabled(isEnabled); verify(deleteButton).setMessage(message); verify(deleteButton).requestUpdate(true); verify(windowComponent).requestRibbonRender(); }