use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.
the class EdgeBuilderImplTest method testDoBuild.
@Test
public void testDoBuild() {
when(context.getIndex().getNode(EDGE_ID)).thenReturn(null);
when(context.getOryxManager()).thenReturn(oryxManager);
when(context.getOryxManager().getMappingsManager()).thenReturn(oryxIdMappings);
when(context.getOryxManager().getMappingsManager().getDefinitionId(any(Class.class))).thenReturn(DEFINITION_ID);
when(factoryManager.newElement(null, DEFINITION_ID)).thenReturn(edge);
when(edge.getContent()).thenReturn(view);
when(view.getDefinition()).thenReturn(definition);
when(context.getDefinitionManager()).thenReturn(definitionManager);
when(context.getDefinitionManager().adapters()).thenReturn(adapters);
when(context.getDefinitionManager().adapters().forDefinition()).thenReturn(forDefinition);
when(context.getDefinitionManager().adapters().forDefinition().getProperties(definition)).thenReturn(set);
when(context.execute(any())).thenReturn(res);
when(context.getCommandFactory()).thenReturn(graphCommandFactory);
Element edge1 = edgeBuilder.build(context);
Assert.assertEquals(edge1, edge);
}
use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest method testMarshallIntermediateTimerEvent.
@Test
public void testMarshallIntermediateTimerEvent() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_TIMER_EVENT);
IntermediateTimerEvent timerEvent = 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 IntermediateTimerEvent) {
timerEvent = (IntermediateTimerEvent) oDefinition;
break;
}
}
}
assertNotNull(timerEvent);
assertNotNull(timerEvent.getGeneral());
assertNotNull(timerEvent.getExecutionSet());
assertEquals("myTimeDateValue", timerEvent.getExecutionSet().getTimerSettings().getValue().getTimeDate());
assertEquals("MyTimeDurationValue", timerEvent.getExecutionSet().getTimerSettings().getValue().getTimeDuration());
assertEquals("myTimeCycleValue", timerEvent.getExecutionSet().getTimerSettings().getValue().getTimeCycle());
assertEquals("cron", timerEvent.getExecutionSet().getTimerSettings().getValue().getTimeCycleLanguage());
}
use of org.kie.workbench.common.stunner.core.graph.Element 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.kie.workbench.common.stunner.core.graph.Element 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.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest method testUnmarshallSequenceFlow.
@Test
public void testUnmarshallSequenceFlow() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_SEQUENCEFLOW);
SequenceFlow sequenceFlow1 = null;
SequenceFlow sequenceFlow2 = 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 ExclusiveGateway) {
List<Edge> outEdges = ((NodeImpl) element).getOutEdges();
for (Edge edge : outEdges) {
SequenceFlow flow = (SequenceFlow) ((ViewConnectorImpl) ((EdgeImpl) edge).getContent()).getDefinition();
if ("route1".equals(flow.getGeneral().getName().getValue())) {
sequenceFlow1 = flow;
}
if ("route2".equals(flow.getGeneral().getName().getValue())) {
sequenceFlow2 = flow;
}
}
}
}
}
assertNotNull(sequenceFlow1);
assertNotNull(sequenceFlow1.getExecutionSet());
assertNotNull(sequenceFlow1.getExecutionSet().getConditionExpression());
assertNotNull(sequenceFlow1.getExecutionSet().getPriority());
assertNotNull(sequenceFlow1.getGeneral());
assertNotNull(sequenceFlow1.getGeneral().getName());
assertEquals("route1", sequenceFlow1.getGeneral().getName().getValue());
assertEquals("age >= 10;", sequenceFlow1.getExecutionSet().getConditionExpression().getValue().getScript());
assertEquals("javascript", sequenceFlow1.getExecutionSet().getConditionExpression().getValue().getLanguage());
assertEquals("2", sequenceFlow1.getExecutionSet().getPriority().getValue());
assertNotNull(sequenceFlow2);
assertNotNull(sequenceFlow2.getExecutionSet());
assertNotNull(sequenceFlow2.getExecutionSet().getConditionExpression());
assertNotNull(sequenceFlow2.getExecutionSet().getPriority());
assertNotNull(sequenceFlow2.getGeneral());
assertNotNull(sequenceFlow2.getGeneral().getName());
assertEquals("route2", sequenceFlow2.getGeneral().getName().getValue());
assertEquals("age\n" + "<\n" + "10;", sequenceFlow2.getExecutionSet().getConditionExpression().getValue().getScript());
assertEquals("java", sequenceFlow2.getExecutionSet().getConditionExpression().getValue().getLanguage());
assertEquals("1", sequenceFlow2.getExecutionSet().getPriority().getValue());
}
Aggregations