use of org.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest 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.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallReusableSubprocess.
@Test
public void testUnmarshallReusableSubprocess() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_REUSABLE_SUBPROCESS);
ReusableSubprocess reusableSubprocess = 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 ReusableSubprocess) {
reusableSubprocess = (ReusableSubprocess) oDefinition;
break;
}
}
}
assertNotNull(reusableSubprocess);
assertNotNull(reusableSubprocess.getExecutionSet());
assertNotNull(reusableSubprocess.getExecutionSet().getCalledElement());
assertNotNull(reusableSubprocess.getGeneral());
BPMNGeneralSet generalSet = reusableSubprocess.getGeneral();
ReusableSubprocessTaskExecutionSet executionSet = reusableSubprocess.getExecutionSet();
assertNotNull(generalSet);
assertNotNull(executionSet);
assertEquals("my subprocess", generalSet.getName().getValue());
assertEquals("my-called-element", executionSet.getCalledElement().getValue());
assertEquals(false, executionSet.getIndependent().getValue());
assertEquals(false, executionSet.getWaitForCompletion().getValue());
String assignmentsInfo = reusableSubprocess.getDataIOSet().getAssignmentsinfo().getValue();
assertEquals("|input1:String,input2:Float||output1:String,output2:Float|[din]pv1->input1,[din]pv2->input2,[dout]output1->pv1,[dout]output2->pv2", assignmentsInfo);
assertEquals("true", reusableSubprocess.getExecutionSet().getIsAsync().getValue().toString());
}
use of org.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallUserTaskAssignees.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallUserTaskAssignees() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_USERTASKASSIGNEES);
assertDiagram(diagram, 6);
assertEquals("UserGroups", diagram.getMetadata().getTitle());
UserTaskExecutionSet executionSet = 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;
executionSet = userTask.getExecutionSet();
break;
}
}
}
assertEquals("user,user1", executionSet.getActors().getValue());
assertEquals("admin,kiemgmt", executionSet.getGroupid().getValue());
}
use of org.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallAddHocSubprocess.
@Test
public void testUnmarshallAddHocSubprocess() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_ADHOC_SUBPROCESS);
AdHocSubprocess adHocSubprocess = 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 AdHocSubprocess) {
adHocSubprocess = (AdHocSubprocess) oDefinition;
break;
}
}
}
assertNotNull(adHocSubprocess);
BPMNGeneralSet generalSet = adHocSubprocess.getGeneral();
AdHocSubprocessTaskExecutionSet executionSet = adHocSubprocess.getExecutionSet();
ProcessData processData = adHocSubprocess.getProcessData();
assertNotNull(generalSet);
assertNotNull(executionSet);
assertNotNull(processData);
assertEquals("AdHocSubprocess1", generalSet.getName().getValue());
assertEquals("AdHocSubprocess1Documentation", generalSet.getDocumentation().getValue());
assertNotNull(executionSet.getAdHocCompletionCondition());
assertNotNull(executionSet.getAdHocCompletionCondition().getValue());
assertNotNull(executionSet.getAdHocOrdering());
assertNotNull(executionSet.getOnEntryAction());
assertNotNull(executionSet.getOnExitAction());
assertEquals("autocomplete", executionSet.getAdHocCompletionCondition().getValue().getScript());
assertEquals("drools", executionSet.getAdHocCompletionCondition().getValue().getLanguage());
assertEquals("Sequential", executionSet.getAdHocOrdering().getValue());
assertEquals(1, executionSet.getOnEntryAction().getValue().getValues().size());
assertEquals("System.out.println(\"onEntryAction\");", executionSet.getOnEntryAction().getValue().getValues().get(0).getScript());
assertEquals("mvel", executionSet.getOnEntryAction().getValue().getValues().get(0).getLanguage());
assertEquals(1, executionSet.getOnExitAction().getValue().getValues().size());
assertEquals("System.out.println(\"onExitAction\");", executionSet.getOnExitAction().getValue().getValues().get(0).getScript());
assertEquals("java", executionSet.getOnExitAction().getValue().getValues().get(0).getLanguage());
assertEquals("subProcessVar1:String,subProcessVar2:String", processData.getProcessVariables().getValue());
}
use of org.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.
the class MigrationDiagramMarshallerTest method assertNodeEquals.
private void assertNodeEquals(Diagram<Graph, Metadata> oldDiagram, Diagram<Graph, Metadata> newDiagram, String fileName) {
Map<String, Node<View, ?>> oldNodes = asNodeMap(oldDiagram.getGraph().nodes());
Map<String, Node<View, ?>> newNodes = asNodeMap(newDiagram.getGraph().nodes());
assertEquals(fileName + ": Number of nodes should match", oldNodes.size(), newNodes.size());
for (Node<View, ?> o : oldNodes.values()) {
Node<View, ?> n = newNodes.get(o.getUUID());
View oldContent = o.getContent();
View newContent = n.getContent();
Bounds oldBounds = oldContent.getBounds();
Bounds newBounds = newContent.getBounds();
assertEquals(fileName + ": Bounds should match for " + o.getUUID(), oldBounds, newBounds);
Object oldDefinition = oldContent.getDefinition();
Object newDefinition = newContent.getDefinition();
assertEquals(fileName + ": Definitions should match for " + o.getUUID(), oldDefinition, newDefinition);
}
}
Aggregations