Search in sources :

Example 1 with PropertyWriterFactory

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());
}
Also used : Description(org.kie.workbench.common.stunner.bpmn.definition.property.task.Description) TaskPriority(org.kie.workbench.common.stunner.bpmn.definition.property.task.TaskPriority) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) AdHocAutostart(org.kie.workbench.common.stunner.bpmn.definition.property.task.AdHocAutostart) PropertyWriterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory) NotificationsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationsInfo) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name) TaskName(org.kie.workbench.common.stunner.bpmn.definition.property.task.TaskName) Groupid(org.kie.workbench.common.stunner.bpmn.definition.property.assignee.Groupid) SLADueDate(org.kie.workbench.common.stunner.bpmn.definition.property.general.SLADueDate) UserTaskPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.UserTaskPropertyWriter) CreatedBy(org.kie.workbench.common.stunner.bpmn.definition.property.task.CreatedBy) Documentation(org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation) Actors(org.kie.workbench.common.stunner.bpmn.definition.property.assignee.Actors) OnExitAction(org.kie.workbench.common.stunner.bpmn.definition.property.task.OnExitAction) OnEntryAction(org.kie.workbench.common.stunner.bpmn.definition.property.task.OnEntryAction) Subject(org.kie.workbench.common.stunner.bpmn.definition.property.task.Subject) MetaDataAttributes(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.MetaDataAttributes) AdvancedData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.AdvancedData) SimulationSet(org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet) TaskName(org.kie.workbench.common.stunner.bpmn.definition.property.task.TaskName) Content(org.kie.workbench.common.stunner.bpmn.definition.property.task.Content) ReassignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentsInfo) IsMultipleInstance(org.kie.workbench.common.stunner.bpmn.definition.property.task.IsMultipleInstance) Skippable(org.kie.workbench.common.stunner.bpmn.definition.property.task.Skippable) IsAsync(org.kie.workbench.common.stunner.bpmn.definition.property.task.IsAsync) ScriptTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeListValue) ScriptTypeValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue) Test(org.junit.Test)

Example 2 with PropertyWriterFactory

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));
}
Also used : SignalRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.SignalRef) TimerSettings(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettings) BoundaryEvent(org.eclipse.bpmn2.BoundaryEvent) TimerSettingsValue(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettingsValue) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) MessageRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) CatchEvent(org.eclipse.bpmn2.CatchEvent) IntermediateCatchEvent(org.eclipse.bpmn2.IntermediateCatchEvent) PropertyWriterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory) DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) SLADueDate(org.kie.workbench.common.stunner.bpmn.definition.property.general.SLADueDate) AdvancedData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.AdvancedData) CatchEventPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.CatchEventPropertyWriter) ConditionExpression(org.kie.workbench.common.stunner.bpmn.definition.property.common.ConditionExpression) IntermediateCompensationEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateCompensationEvent) BaseCatchingIntermediateEvent(org.kie.workbench.common.stunner.bpmn.definition.BaseCatchingIntermediateEvent) Event(org.eclipse.bpmn2.Event) IntermediateTimerEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateTimerEvent) CatchEvent(org.eclipse.bpmn2.CatchEvent) BoundaryEvent(org.eclipse.bpmn2.BoundaryEvent) IntermediateConditionalEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateConditionalEvent) IntermediateCatchEvent(org.eclipse.bpmn2.IntermediateCatchEvent) IntermediateEscalationEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateEscalationEvent) FlatVariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope) ErrorRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.error.ErrorRef) EscalationRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.escalation.EscalationRef) BoundaryEventPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.BoundaryEventPropertyWriter) LinkRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.link.LinkRef) ScriptTypeValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue) Before(org.junit.Before)

Example 3 with 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);
}
Also used : Imports(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.imports.Imports) PropertyWriterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name) SLADueDate(org.kie.workbench.common.stunner.bpmn.definition.property.general.SLADueDate) ProcessType(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.ProcessType) Version(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.Version) ImportsValue(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.imports.ImportsValue) GraphImpl(org.kie.workbench.common.stunner.core.graph.impl.GraphImpl) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) Executable(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.Executable) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) Documentation(org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation) Definitions(org.eclipse.bpmn2.Definitions) ProcessInstanceDescription(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.ProcessInstanceDescription) GraphNodeStoreImpl(org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl) DiagramSet(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.DiagramSet) Id(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.Id) Package(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.Package) AdHoc(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.AdHoc) WSDLImport(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.imports.WSDLImport) Test(org.junit.Test)

Example 4 with PropertyWriterFactory

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));
}
Also used : LanePropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.LanePropertyWriter) Lane(org.eclipse.bpmn2.Lane) TestDefinitionsWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.TestDefinitionsWriter) PropertyWriterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory) Test(org.junit.Test)

Example 5 with PropertyWriterFactory

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;
}
Also used : JBPMBpmn2Resource(org.kie.workbench.common.stunner.bpmn.backend.resource.JBPMBpmn2Resource) Bpmn2Resource(org.eclipse.bpmn2.util.Bpmn2Resource) Definitions(org.eclipse.bpmn2.Definitions) DefinitionsBuildingContext(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsBuildingContext) ConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.ConverterFactory) BaseConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BaseConverterFactory) DefinitionsConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter) PropertyWriterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory)

Aggregations

PropertyWriterFactory (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory)12 Test (org.junit.Test)8 ConverterFactory (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.ConverterFactory)5 DefinitionsBuildingContext (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsBuildingContext)5 SLADueDate (org.kie.workbench.common.stunner.bpmn.definition.property.general.SLADueDate)5 GraphImpl (org.kie.workbench.common.stunner.core.graph.impl.GraphImpl)5 GraphNodeStoreImpl (org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl)5 BPMNDiagramImpl (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl)4 AssignmentsInfo (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo)4 Documentation (org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation)4 Name (org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)4 AdvancedData (org.kie.workbench.common.stunner.bpmn.definition.property.variables.AdvancedData)4 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)4 Definitions (org.eclipse.bpmn2.Definitions)3 Before (org.junit.Before)3 Event (org.eclipse.bpmn2.Event)2 FlatVariableScope (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope)2 ProcessPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.ProcessPropertyWriter)2 BPMNViewDefinition (org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition)2 EmbeddedSubprocess (org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess)2