use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions in project kie-wb-common by kiegroup.
the class JBPMBpmn2ResourceFactoryImpl method createAndInitResource.
/*
*
* Creates a new BpmnResourceImpl and initializes it.
*
* The method creates a DocumentRoot and a Definitions element, as both are
* mandatory.
*/
public Definitions createAndInitResource(URI uri) {
DroolsFactoryImpl.init();
BpsimFactoryImpl.init();
Resource resource = createResource(uri);
Bpmn2Factory factory = Bpmn2Factory.eINSTANCE;
Definitions definitions = factory.createDefinitions();
DocumentRoot docummentRoot = factory.createDocumentRoot();
docummentRoot.setDefinitions(definitions);
resource.getContents().add(docummentRoot);
return definitions;
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest method testMarshallProcessVariables.
@Test
public void testMarshallProcessVariables() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSVARIABLES);
JBPMBpmn2ResourceImpl resource = tested.marshallToBpmn2Resource(diagram);
String result = tested.marshall(diagram);
assertDiagram(result, 1, 7, 7);
Definitions definitions = (Definitions) resource.getContents().get(0);
assertNotNull(definitions);
List<RootElement> rootElements = definitions.getRootElements();
assertNotNull(rootElements);
assertNotNull(getItemDefinition(rootElements, "_employeeItem", "java.lang.String"));
assertNotNull(getItemDefinition(rootElements, "_reasonItem", "java.lang.String"));
assertNotNull(getItemDefinition(rootElements, "_performanceItem", "java.lang.String"));
Process process = getProcess(definitions);
assertNotNull(process);
List<Property> properties = process.getProperties();
assertNotNull(properties);
assertNotNull(getProcessProperty(properties, "employee", "_employeeItem"));
assertNotNull(getProcessProperty(properties, "reason", "_reasonItem"));
assertNotNull(getProcessProperty(properties, "performance", "_performanceItem"));
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testMarshallProcessVariables.
@Test
public void testMarshallProcessVariables() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSVARIABLES);
String result = tested.marshall(diagram);
assertDiagram(result, 1, 7, 7);
Definitions definitions = new DefinitionsConverter(diagram.getGraph()).toDefinitions();
assertNotNull(definitions);
List<RootElement> rootElements = definitions.getRootElements();
assertNotNull(rootElements);
assertItemExists(rootElements, "_employeeItem", "java.lang.String");
assertItemExists(rootElements, "_reasonItem", "java.lang.String");
assertItemExists(rootElements, "_performanceItem", "java.lang.String");
Process process = getProcess(definitions);
assertNotNull(process);
List<Property> properties = process.getProperties();
assertNotNull(properties);
assertNotNull(getProcessProperty(properties, "employee", "_employeeItem"));
assertNotNull(getProcessProperty(properties, "reason", "_reasonItem"));
assertNotNull(getProcessProperty(properties, "performance", "_performanceItem"));
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshallerTest method testUpdateIDs.
@Test
public void testUpdateIDs() {
Definitions defs = mock(Definitions.class);
Process process = mock(Process.class);
DataObject flowElement = mock(DataObject.class);
final Value<String> processId = new Value<>("Project:Bad Id");
final Value<String> flowElementId = new Value<>("Bad Flow Id!");
when(process.getId()).thenAnswer((m) -> processId.get());
doAnswer((m) -> {
processId.set(m.getArgumentAt(0, String.class));
return null;
}).when(process).setId(anyString());
when(flowElement.getId()).thenAnswer((m) -> flowElementId.get());
when(flowElement.getName()).thenAnswer((m) -> flowElementId.get());
doAnswer((m) -> {
flowElementId.set(m.getArgumentAt(0, String.class));
return null;
}).when(flowElement).setId(anyString());
when(process.getFlowElements()).thenReturn(Arrays.asList(flowElement));
when(defs.getRootElements()).thenReturn(Arrays.asList(process));
tested.updateIDs(defs);
assertEquals("Project:BadId", processId.get());
assertEquals("BadFlowId", flowElementId.get());
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions 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);
}
Aggregations