use of org.eclipse.bpmn2.UserTask in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest method testUnmarshallSimulationProperties.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallSimulationProperties() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_SIMULATIONPROPERTIES);
assertDiagram(diagram, 4);
assertEquals("SimulationProperties", diagram.getMetadata().getTitle());
SimulationSet simulationSet = null;
Iterator<Element> it = nodesIterator(diagram);
while (it.hasNext()) {
Element element = it.next();
if (element.getContent() instanceof View) {
Object oDefinition = ((View) element.getContent()).getDefinition();
if (oDefinition instanceof UserTask) {
UserTask userTask = (UserTask) oDefinition;
simulationSet = userTask.getSimulationSet();
break;
}
}
}
assertEquals(Double.valueOf(111), simulationSet.getQuantity().getValue());
assertEquals("poisson", simulationSet.getDistributionType().getValue());
assertEquals(Double.valueOf(123), simulationSet.getUnitCost().getValue());
assertEquals(Double.valueOf(999), simulationSet.getWorkingHours().getValue());
assertEquals(Double.valueOf(321), simulationSet.getMean().getValue());
}
use of org.eclipse.bpmn2.UserTask in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest method testUnmarshallUserTaskProperties.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallUserTaskProperties() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_USERTASKPROPERTIES);
assertDiagram(diagram, 4);
assertEquals("MyBP", diagram.getMetadata().getTitle());
UserTaskExecutionSet userTaskExecutionSet = null;
Iterator<Element> it = nodesIterator(diagram);
while (it.hasNext()) {
Element element = it.next();
if (element.getContent() instanceof View) {
Object oDefinition = ((View) element.getContent()).getDefinition();
if (oDefinition instanceof UserTask) {
UserTask userTask = (UserTask) oDefinition;
userTaskExecutionSet = userTask.getExecutionSet();
break;
}
}
}
assertEquals("MyUserTask", userTaskExecutionSet.getTaskName().getValue());
assertEquals("true", userTaskExecutionSet.getIsAsync().getValue().toString());
assertEquals("false", userTaskExecutionSet.getSkippable().getValue().toString());
assertEquals("my subject", userTaskExecutionSet.getSubject().getValue());
assertEquals("admin", userTaskExecutionSet.getCreatedBy().getValue());
assertEquals("my description", userTaskExecutionSet.getDescription().getValue());
assertEquals("3", userTaskExecutionSet.getPriority().getValue());
assertEquals("true", userTaskExecutionSet.getAdHocAutostart().getValue().toString());
assertEquals("System.out.println(\"Hello\");", userTaskExecutionSet.getOnEntryAction().getValue().getValues().get(0).getScript());
assertEquals("java", userTaskExecutionSet.getOnEntryAction().getValue().getValues().get(0).getLanguage());
assertEquals("System.out.println(\"Bye\");", userTaskExecutionSet.getOnExitAction().getValue().getValues().get(0).getScript());
assertEquals("java", userTaskExecutionSet.getOnExitAction().getValue().getValues().get(0).getLanguage());
}
use of org.eclipse.bpmn2.UserTask in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest method testMarshallUserTaskAssignments.
@Test
public void testMarshallUserTaskAssignments() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_USERTASKASSIGNMENTS);
JBPMBpmn2ResourceImpl resource = tested.marshallToBpmn2Resource(diagram);
String result = tested.marshall(diagram);
assertDiagram(result, 1, 7, 7);
Definitions definitions = (Definitions) resource.getContents().get(0);
assertNotNull(definitions);
Process process = getProcess(definitions);
assertNotNull(process);
org.eclipse.bpmn2.UserTask userTask = (org.eclipse.bpmn2.UserTask) getNamedFlowElement(process, org.eclipse.bpmn2.UserTask.class, "Self Evaluation");
assertNotNull(userTask);
DataInput dataInput = (DataInput) getDataInput(userTask, "reason");
validateDataInputOrOutput(dataInput, "_reasonInputX", "com.test.Reason", "_reasonInputXItem");
DataOutput dataOutput = (DataOutput) getDataOutput(userTask, "performance");
validateDataInputOrOutput(dataOutput, "_performanceOutputX", "Object", "_performanceOutputXItem");
ItemAwareElement sourceRef = getDataInputAssociationSourceRef(userTask, "reason");
assertNotNull(sourceRef);
ItemAwareElement targetRef = getDataInputAssociationTargetRef(userTask, "_reasonInputX");
assertNotNull(targetRef);
sourceRef = getDataOutputAssociationSourceRef(userTask, "_performanceOutputX");
assertNotNull(sourceRef);
targetRef = getDataOutputAssociationTargetRef(userTask, "performance");
assertNotNull(targetRef);
}
use of org.eclipse.bpmn2.UserTask in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method setUserTaskInfo.
private void setUserTaskInfo(FlowElementsContainer container) {
List<FlowElement> flowElements = container.getFlowElements();
for (FlowElement fe : flowElements) {
// Set name and metaData "elementname" to "Task_n" if empty
if (fe instanceof UserTask) {
UserTask task = (UserTask) fe;
String name = task.getName();
if (name == null || name.length() == 0) {
LastUserTaskID++;
String newName = DEFAULT_USERTASK_NAME_PREFIX + LastUserTaskID;
task.setName(newName);
if (task.getExtensionValues() != null && task.getExtensionValues().size() > 0) {
for (ExtensionAttributeValue extattrval : task.getExtensionValues()) {
FeatureMap extensionElements = extattrval.getValue();
List<MetaDataType> metadataExtensions = (List<MetaDataType>) extensionElements.get(DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA, true);
for (MetaDataType eleMetadata : metadataExtensions) {
if (eleMetadata.getName() != null && eleMetadata.getName().equals("elementname")) {
eleMetadata.setMetaValue(wrapInCDATABlock(newName));
}
}
}
}
}
}
if (fe instanceof FlowElementsContainer) {
setUserTaskInfo((FlowElementsContainer) fe);
}
}
}
use of org.eclipse.bpmn2.UserTask in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testMarshallUserTaskAssignments.
@Test
public void testMarshallUserTaskAssignments() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_USERTASKASSIGNMENTS);
// JBPMBpmn2ResourceImpl resource = tested.marshallToBpmn2Resource(diagram);
String result = tested.marshall(diagram);
assertDiagram(result, 1, 7, 7);
DefinitionsConverter definitionsConverter = new DefinitionsConverter(diagram.getGraph());
Definitions definitions = definitionsConverter.toDefinitions();
assertNotNull(definitions);
Process process = getProcess(definitions);
assertNotNull(process);
org.eclipse.bpmn2.UserTask userTask = (org.eclipse.bpmn2.UserTask) getNamedFlowElement(process, org.eclipse.bpmn2.UserTask.class, "Self Evaluation");
assertNotNull(userTask);
DataInput dataInput = (DataInput) getDataInput(userTask, "reason");
// this fails because of type
validateDataInputOrOutput(dataInput, "_reasonInputX", "com.test.Reason", "_reasonInputXItem");
DataOutput dataOutput = (DataOutput) getDataOutput(userTask, "performance");
validateDataInputOrOutput(dataOutput, "_performanceOutputX", "Object", "_performanceOutputXItem");
ItemAwareElement sourceRef = getDataInputAssociationSourceRef(userTask, "reason");
assertNotNull(sourceRef);
ItemAwareElement targetRef = getDataInputAssociationTargetRef(userTask, "_reasonInputX");
assertNotNull(targetRef);
sourceRef = getDataOutputAssociationSourceRef(userTask, "_performanceOutputX");
assertNotNull(sourceRef);
targetRef = getDataOutputAssociationTargetRef(userTask, "performance");
assertNotNull(targetRef);
}
Aggregations