Search in sources :

Example 21 with PortableWorkDefinition

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);
}
Also used : HashMap(java.util.HashMap) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 22 with PortableWorkDefinition

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);
}
Also used : ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) HashMap(java.util.HashMap) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 23 with PortableWorkDefinition

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);
}
Also used : PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) Test(org.junit.Test)

Example 24 with PortableWorkDefinition

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);
}
Also used : PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) Test(org.junit.Test)

Example 25 with PortableWorkDefinition

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);
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) HashMap(java.util.HashMap) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) ArrayList(java.util.ArrayList) PortableParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableParameterDefinition) Mockito.anyString(org.mockito.Mockito.anyString) Test(org.junit.Test)

Aggregations

PortableWorkDefinition (org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition)48 Test (org.junit.Test)30 ActionWorkItemCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52)17 PortableStringParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableStringParameterDefinition)16 ActionExecuteWorkItem (org.drools.workbench.models.datamodel.rule.ActionExecuteWorkItem)14 PortableFloatParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableFloatParameterDefinition)14 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)13 PortableBooleanParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableBooleanParameterDefinition)13 ArrayList (java.util.ArrayList)11 PortableIntegerParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableIntegerParameterDefinition)11 HashSet (java.util.HashSet)7 HashMap (java.util.HashMap)6 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)6 CompositeFactPattern (org.drools.workbench.models.datamodel.rule.CompositeFactPattern)6 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)6 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)6 FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)6 FromCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern)6 FromEntryPointFactPattern (org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern)6 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)6