use of org.eclipse.bpmn2.DataOutput in project kie-wb-common by kiegroup.
the class OutputAssignmentReaderTest method mockDataOutputAssociation.
private static DataOutputAssociation mockDataOutputAssociation(String dataOutputName, ItemAwareElement targetRef) {
DataOutputAssociation outputAssociation = mock(DataOutputAssociation.class);
DataOutput dataOutput = mock(DataOutput.class);
when(dataOutput.getName()).thenReturn(dataOutputName);
List<ItemAwareElement> sourceRefs = Collections.singletonList(dataOutput);
when(outputAssociation.getSourceRef()).thenReturn(sourceRefs);
when(outputAssociation.getTargetRef()).thenReturn(targetRef);
return outputAssociation;
}
use of org.eclipse.bpmn2.DataOutput in project kie-wb-common by kiegroup.
the class OutputAssignmentReaderTest method testFromAssociationWithExpression.
@Test
public void testFromAssociationWithExpression() {
DataOutput output = spy(DataOutput.class);
when(output.getName()).thenReturn(TARGET_NAME);
Assignment assignment = spy(Assignment.class);
FormalExpression to = mock(FormalExpression.class);
when(assignment.getTo()).thenReturn(to);
when(to.getBody()).thenReturn(SOURCE_NAME);
List<Assignment> assignments = new ArrayList<Assignment>();
assignments.add(assignment);
DataOutputAssociationImpl out = spy(DataOutputAssociationImpl.class);
when(out.getAssignment()).thenReturn(assignments);
OutputAssignmentReader outputReader = OutputAssignmentReader.fromAssociation(out);
assertNull(outputReader);
List<ItemAwareElement> outputs = new ArrayList<>();
outputs.add(output);
when(out.getSourceRef()).thenReturn(outputs);
outputReader = OutputAssignmentReader.fromAssociation(out);
assertResult(TARGET_NAME, SOURCE_NAME, AssociationDeclaration.Type.FromTo, outputReader.getAssociationDeclaration());
when(to.getBody()).thenReturn("null");
outputReader = OutputAssignmentReader.fromAssociation(out);
assertResult(TARGET_NAME, "", AssociationDeclaration.Type.FromTo, outputReader.getAssociationDeclaration());
}
use of org.eclipse.bpmn2.DataOutput in project kie-wb-common by kiegroup.
the class AssignmentsInfosTest method JBPM_7447_shouldNotFilterOutDataOutputsWithEmptyType.
@Test
public void JBPM_7447_shouldNotFilterOutDataOutputsWithEmptyType() {
DataInput dataInput = bpmn2.createDataInput();
dataInput.setName("InputName");
dataInput.setId("InputID");
DataOutput dataOutput = bpmn2.createDataOutput();
dataOutput.setName("OutputName");
dataOutput.setId("OutputID");
ParsedAssignmentsInfo result = AssignmentsInfos.parsed(Collections.singletonList(dataInput), Collections.emptyList(), Collections.singletonList(dataOutput), Collections.emptyList(), false);
assertThat(result.getOutputs().getDeclarations()).isNotEmpty();
}
use of org.eclipse.bpmn2.DataOutput in project kie-wb-common by kiegroup.
the class ActivityPropertyWriter method setAssignmentsInfo.
public void setAssignmentsInfo(AssignmentsInfo info) {
final ParsedAssignmentsInfo assignmentsInfo = ParsedAssignmentsInfo.of(info);
final List<InitializedInputVariable> inputs = assignmentsInfo.createInitializedInputVariables(getId(), variableScope, dataObjects);
if (!inputs.isEmpty()) {
final InputOutputSpecification ioSpec = getIoSpecification();
for (InitializedInputVariable input : inputs) {
if (isReservedIdentifier(input.getIdentifier())) {
continue;
}
DataInput dataInput = input.getDataInput();
getInputSet(ioSpec).getDataInputRefs().add(dataInput);
ioSpec.getDataInputs().add(dataInput);
this.addItemDefinition(input.getItemDefinition());
DataInputAssociation dataInputAssociation = input.getDataInputAssociation();
if (dataInputAssociation != null) {
activity.getDataInputAssociations().add(dataInputAssociation);
}
}
}
final List<InitializedOutputVariable> outputs = assignmentsInfo.createInitializedOutputVariables(getId(), variableScope, dataObjects);
if (!outputs.isEmpty()) {
final InputOutputSpecification ioSpec = getIoSpecification();
for (InitializedOutputVariable output : outputs) {
DataOutput dataOutput = output.getDataOutput();
getOutputSet(ioSpec).getDataOutputRefs().add(dataOutput);
ioSpec.getDataOutputs().add(dataOutput);
this.addItemDefinition(output.getItemDefinition());
DataOutputAssociation dataOutputAssociation = output.getDataOutputAssociation();
if (dataOutputAssociation != null) {
activity.getDataOutputAssociations().add(dataOutputAssociation);
}
}
}
}
use of org.eclipse.bpmn2.DataOutput in project kie-wb-common by kiegroup.
the class CatchEventPropertyWriter method setAssignmentsInfo.
public void setAssignmentsInfo(AssignmentsInfo info) {
ParsedAssignmentsInfo assignmentsInfo = ParsedAssignmentsInfo.of(info);
List<InitializedOutputVariable> outputs = assignmentsInfo.createInitializedOutputVariables(getId(), variableScope, dataObjects);
if (outputs.isEmpty()) {
return;
}
if (outputs.size() > 1) {
throw new IllegalArgumentException("Output Associations should be at most 1 in Catch Events");
}
InitializedOutputVariable output = outputs.get(0);
DataOutput dataOutput = output.getDataOutput();
event.getDataOutputs().add(dataOutput);
getOutputSet().getDataOutputRefs().add(dataOutput);
this.addItemDefinition(dataOutput.getItemSubjectRef());
DataOutputAssociation dataOutputAssociation = output.getDataOutputAssociation();
if (dataOutputAssociation != null) {
event.getDataOutputAssociation().add(dataOutputAssociation);
}
}
Aggregations