use of org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition in project drools-wb by kiegroup.
the class ActionWorkItemPluginTest method testForEachWorkItem.
@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);
}
use of org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition in project drools-wb by kiegroup.
the class ActionWorkItemPluginTest method testForEachWorkItemWhenOneHasBeenExecutedUpdatedColumn.
@Test
public void testForEachWorkItemWhenOneHasBeenExecutedUpdatedColumn() {
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.singletonList(new ActionWorkItemCol52() {
{
setWorkItemDefinition(workItem1);
}
}));
when(plugin.isNewColumn()).thenReturn(false);
when(plugin.getWorkItemDefinition()).thenReturn(workItem1);
plugin.forEachWorkItem(actualWorkItems::put);
assertEquals(expectedWorkItems, actualWorkItems);
}
use of org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition in project drools-wb by kiegroup.
the class ActionWorkItemPluginTest method testWorkItemWhenItDoesNotHaveWorkItemDefinition.
@Test
public void testWorkItemWhenItDoesNotHaveWorkItemDefinition() {
final PortableWorkDefinition workDefinition = mock(PortableWorkDefinition.class);
final String workItemName = "workItem";
doReturn(workItemName).when(workDefinition).getName();
doReturn(workDefinition).when(plugin).getWorkItemDefinition();
final String workItem = plugin.getWorkItem();
assertEquals(workItemName, workItem);
}
use of org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition in project drools-wb by kiegroup.
the class ActionWorkItemPluginTest method testSetWorkItemWithAValidValue.
@Test
public void testSetWorkItemWithAValidValue() throws Exception {
final PortableWorkDefinition workDefinition = mock(PortableWorkDefinition.class);
final String workItem = "workItem";
doReturn(workDefinition).when(plugin).findWorkItemDefinition(workItem);
plugin.setWorkItem(workItem);
verify(editingCol).setWorkItemDefinition(workDefinition);
verify(plugin).fireChangeEvent(workItemPage);
}
use of org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition in project drools-wb by kiegroup.
the class ActionWorkItemSetFieldPluginTest method testSetWorkItem.
@Test
public void testSetWorkItem() throws Exception {
final String workItemKey = "workItem";
final PortableWorkDefinition workDefinition = mock(PortableWorkDefinition.class);
final PortableParameterDefinition parameterDefinition = mock(PortableParameterDefinition.class);
final ActionWorkItemSetFieldPlugin.WorkItemParameter parameter = mock(ActionWorkItemSetFieldPlugin.WorkItemParameter.class);
final HashMap<String, ActionWorkItemSetFieldPlugin.WorkItemParameter> workItems = new HashMap<String, ActionWorkItemSetFieldPlugin.WorkItemParameter>() {
{
put(workItemKey, parameter);
}
};
final List<ActionInsertFactCol52> actions = new ArrayList<ActionInsertFactCol52>() {
{
add(mock(ActionInsertFactCol52.class));
}
};
doReturn(model).when(presenter).getModel();
doReturn(actions).when(model).getActionCols();
doReturn("workName").when(workDefinition).getName();
doReturn("parameterName").when(parameterDefinition).getName();
doReturn("parameterClassName").when(parameterDefinition).getClassName();
doReturn(workItems).when(plugin).getWorkItems();
doReturn(workDefinition).when(parameter).getWorkDefinition();
doReturn(parameterDefinition).when(parameter).getWorkParameterDefinition();
plugin.setWorkItem(workItemKey);
assertEquals(workItemKey, plugin.getWorkItem());
verify(editingWrapper).setWorkItemName("workName");
verify(editingWrapper).setWorkItemResultParameterName("parameterName");
verify(editingWrapper).setParameterClassName("parameterClassName");
verify(plugin).fireChangeEvent(workItemPage);
}
Aggregations