ActionWorkItemPlugin extends BaseDecisionTableColumnPlugin implements HasWorkItemPage,
                                                                                   HasAdditionalInfoPage { @Override public void forEachWorkItem(final BiConsumer<String, String> biConsumer) { getPresenter() .getWorkItemDefinitions() .stream() .filter(this::isWorkItemAvailable) .forEach(workDefinition -> biConsumer.accept(workDefinition.getDisplayName(), workDefinition.getName())); } @Inject  ActionWorkItemPlugin(final AdditionalInfoPage<ActionWorkItemPlugin> additionalInfoPage,
                                final WorkItemPage workItemPage,
                                final Event<WizardPageStatusChangeEvent> changeEvent,
                                final TranslationService translationService); @Override String getTitle(); @Override List<WizardPage> getPages(); @Override void init(final NewGuidedDecisionTableColumnWizard wizard); @Override String getWorkItem(); @Override void setWorkItem(final String workItem); @Override ActionWorkItemCol52 editingCol(); @Override String getHeader(); @Override void setHeader(final String header); @Override Set<String> getAlreadyUsedColumnHeaders(); @Override Boolean isWorkItemSet(); @Override PortableWorkDefinition getWorkItemDefinition(); @Override void forEachWorkItem(final BiConsumer<String, String> biConsumer); @Override void setWorkItemPageAsCompleted(); @Override boolean isHideColumn(); @Override void setHideColumn(boolean hideColumn); @Override void setInsertLogical(final Boolean value); @Override void setUpdate(final Boolean value); @Override boolean showUpdateEngineWithChanges(); @Override boolean showLogicallyInsert(); @Override boolean isLogicallyInsert(); @Override boolean isUpdateEngine(); @Override Boolean generateColumn(); @Override Type getType();  }
@Test public void testForEachWorkItem() { final PortableWorkDefinition workItem1 = getMock("workItem1"); final PortableWorkDefinition workItem2 = getMock("workItem2"); final HashMap<String, String> actualWorkItems = new HashMap<>(); final HashMap<String, String> expectedWorkItems = new HashMap<String, String>() {{ put("workItem1", "workItem1"); put("workItem2", "workItem2"); }}; final HashSet<PortableWorkDefinition> fakeDefinitions = new HashSet<PortableWorkDefinition>() {{ add(workItem1); add(workItem2); }}; when(presenter.getWorkItemDefinitions()).thenReturn(fakeDefinitions); when(presenter.getModel()).thenReturn(model); when(model.getActionCols()).thenReturn(Collections.emptyList()); plugin.forEachWorkItem(actualWorkItems::put); assertEquals(expectedWorkItems, actualWorkItems); }
@Test public void testForEachWorkItemWhenOneHasBeenExecutedNewColumn() { final PortableWorkDefinition workItem1 = getMock("workItem1"); final PortableWorkDefinition workItem2 = getMock("workItem2"); final HashMap<String, String> actualWorkItems = new HashMap<>(); final HashMap<String, String> expectedWorkItems = new HashMap<String, String>() {{ put("workItem2", "workItem2"); }}; final HashSet<PortableWorkDefinition> fakeDefinitions = new HashSet<PortableWorkDefinition>() {{ add(workItem1); add(workItem2); }}; when(presenter.getWorkItemDefinitions()).thenReturn(fakeDefinitions); when(presenter.getModel()).thenReturn(model); when(model.getActionCols()).thenReturn(Collections.singletonList(new ActionWorkItemCol52() {{ setWorkItemDefinition(workItem1); }})); when(plugin.isNewColumn()).thenReturn(true); plugin.forEachWorkItem(actualWorkItems::put); assertEquals(expectedWorkItems, actualWorkItems); }