use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory in project kie-wb-common by kiegroup.
the class TaskConverterPriorityTest method setPriorityMvel.
@Test
public void setPriorityMvel() {
propertyWriterFactory = new PropertyWriterFactory();
taskConverter = spy(new TaskConverter(propertyWriterFactory));
when(n.getContent()).thenReturn(view);
when(view.getBounds()).thenReturn(Bounds.create(0, 0, 10, 10));
when(view.getDefinition()).thenReturn(definition);
when(general.getName()).thenReturn(new Name("Name"));
when(general.getDocumentation()).thenReturn(new Documentation());
when(definition.getGeneral()).thenReturn(general);
when(definition.getSimulationSet()).thenReturn(new SimulationSet());
when(definition.getExecutionSet()).thenReturn(baseUserTaskExecutionSet);
when(baseUserTaskExecutionSet.getTaskName()).thenReturn(new TaskName("taskName"));
when(baseUserTaskExecutionSet.getActors()).thenReturn(new Actors());
when(baseUserTaskExecutionSet.getAssignmentsinfo()).thenReturn(new AssignmentsInfo());
when(baseUserTaskExecutionSet.getReassignmentsInfo()).thenReturn(new ReassignmentsInfo());
when(baseUserTaskExecutionSet.getNotificationsInfo()).thenReturn(new NotificationsInfo());
when(baseUserTaskExecutionSet.getSkippable()).thenReturn(new Skippable(true));
when(baseUserTaskExecutionSet.getGroupid()).thenReturn(new Groupid("groupId"));
when(baseUserTaskExecutionSet.getSubject()).thenReturn(new Subject());
when(baseUserTaskExecutionSet.getDescription()).thenReturn(new Description());
when(baseUserTaskExecutionSet.getPriority()).thenReturn(new TaskPriority("#{varOne}"));
when(baseUserTaskExecutionSet.getIsAsync()).thenReturn(new IsAsync(true));
when(baseUserTaskExecutionSet.getCreatedBy()).thenReturn(new CreatedBy());
when(baseUserTaskExecutionSet.getAdHocAutostart()).thenReturn(new AdHocAutostart());
when(baseUserTaskExecutionSet.getIsMultipleInstance()).thenReturn(new IsMultipleInstance(false));
when(baseUserTaskExecutionSet.getOnEntryAction()).thenReturn(new OnEntryAction(new ScriptTypeListValue().addValue(new ScriptTypeValue("java", ""))));
when(baseUserTaskExecutionSet.getOnExitAction()).thenReturn(new OnExitAction(new ScriptTypeListValue().addValue(new ScriptTypeValue("java", ""))));
when(baseUserTaskExecutionSet.getContent()).thenReturn(new Content());
when(baseUserTaskExecutionSet.getSlaDueDate()).thenReturn(new SLADueDate());
when(definition.getAdvancedData()).thenReturn(new AdvancedData(new MetaDataAttributes()));
doCallRealMethod().when(taskConverter).userTask(any());
final UserTaskPropertyWriter propertyWriter = (UserTaskPropertyWriter) taskConverter.userTask(n);
assertTrue(propertyWriter.getPriority().equals("<![CDATA[#{varOne}]]>"));
System.out.println("Priority: " + propertyWriter.getPriority());
}
use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory in project kie-wb-common by kiegroup.
the class IntermediateCatchEventConverterTest method setUp.
@Before
public void setUp() {
Event boundaryEvent = bpmn2.createBoundaryEvent();
boundaryEventPropertyWriter = spy(new BoundaryEventPropertyWriter((BoundaryEvent) spy(boundaryEvent), new FlatVariableScope(), new HashSet<>()));
// when(boundaryEventPropertyWriter.getFlowElement()).thenReturn(spy(FlowElement.class));
Event catchEvent = bpmn2.createIntermediateCatchEvent();
catchEventPropertyWriter = spy(new CatchEventPropertyWriter((CatchEvent) spy(catchEvent), new FlatVariableScope(), new HashSet<>()));
propertyWriterFactory = spy(PropertyWriterFactory.class);
when(propertyWriterFactory.of(any(BoundaryEvent.class))).thenReturn(boundaryEventPropertyWriter);
when(propertyWriterFactory.of(any(CatchEvent.class))).thenReturn(catchEventPropertyWriter);
generalSet = new BPMNGeneralSet(NAME, DOCUMENTATION);
assignmentsInfo = new AssignmentsInfo(ASSIGNMENTS_INFO);
dataIOSet = new DataIOSet(assignmentsInfo);
advancedData = new AdvancedData();
slaDueDate = mock(SLADueDate.class);
errorRef = mock(ErrorRef.class);
signalRef = mock(SignalRef.class);
linkRef = mock(LinkRef.class);
timerSettingsValue = mock(TimerSettingsValue.class);
timerSettings = new TimerSettings(timerSettingsValue);
messageRef = mock(MessageRef.class);
scriptTypeValue = mock(ScriptTypeValue.class);
conditionExpression = new ConditionExpression(scriptTypeValue);
escalationRef = mock(EscalationRef.class);
tested = spy(new IntermediateCatchEventConverter(propertyWriterFactory));
}
use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory in project kie-wb-common by kiegroup.
the class DefinitionsConverterTest method toDefinitions.
@Test
public void toDefinitions() {
final String LOCATION = "Location";
final String NAMESPACE = "Namespace";
ImportsValue importsValue = new ImportsValue();
importsValue.addImport(new WSDLImport(LOCATION, NAMESPACE));
BPMNDiagramImpl diag = new BPMNDiagramImpl();
diag.setDiagramSet(new DiagramSet(new Name(), new Documentation(), new Id(), new Package(), new ProcessType(), new Version(), new AdHoc(false), new ProcessInstanceDescription(), new Imports(importsValue), new Executable(true), new SLADueDate()));
GraphNodeStoreImpl nodeStore = new GraphNodeStoreImpl();
NodeImpl x = new NodeImpl("x");
x.setContent(new ViewImpl<>(diag, Bounds.create()));
nodeStore.add(x);
ConverterFactory f = new ConverterFactory(new DefinitionsBuildingContext(new GraphImpl("x", nodeStore)), new PropertyWriterFactory());
DefinitionsConverter definitionsConverter = new DefinitionsConverter(f, new PropertyWriterFactory());
Definitions definitions = definitionsConverter.toDefinitions();
assertImportsValue(LOCATION, NAMESPACE, definitions);
}
use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory in project kie-wb-common by kiegroup.
the class LanePropertyReaderTest method JBPM_7523_shouldPreserveNameChars.
@Test
public void JBPM_7523_shouldPreserveNameChars() {
PropertyReaderFactory factory = new PropertyReaderFactory(new TestDefinitionsWriter().getDefinitionResolver());
Lane lane = bpmn2.createLane();
PropertyWriterFactory writerFactory = new PropertyWriterFactory();
LanePropertyWriter w = writerFactory.of(lane);
String aWeirdName = " XXX !!@@ <><> ";
String aWeirdDoc = " XXX !!@@ <><> Docs ";
w.setName(aWeirdName);
w.setDocumentation(aWeirdDoc);
LanePropertyReader r = factory.of(lane);
assertThat(r.getName()).isEqualTo(asCData(aWeirdName));
assertThat(r.getDocumentation()).isEqualTo(asCData(aWeirdDoc));
}
use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory in project kie-wb-common by kiegroup.
the class BaseDirectDiagramMarshaller method marshall.
@Override
@SuppressWarnings("unchecked")
public String marshall(final Diagram<Graph, Metadata> diagram) throws IOException {
LOG.debug("Starting diagram marshalling...");
Bpmn2Resource resource = createBpmn2Resource();
// we start converting from the root, then pull out the result
PropertyWriterFactory propertyWriterFactory = new PropertyWriterFactory();
DefinitionsConverter definitionsConverter = new DefinitionsConverter(new ConverterFactory(new DefinitionsBuildingContext(diagram.getGraph(), getDiagramClass()), propertyWriterFactory), propertyWriterFactory);
Definitions definitions = definitionsConverter.toDefinitions();
resource.getContents().add(definitions);
LOG.debug("Diagram marshalling completed successfully.");
String outputString = renderToString(resource);
LOG.trace(outputString);
return outputString;
}
Aggregations