src_fm_fc_ms_ff
stringlengths 43
86.8k
| target
stringlengths 20
276k
|
|---|---|
MultipleInstanceActivityPropertyWriter extends ActivityPropertyWriter { public void setCompletionCondition(String expression) { if (!isEmpty(expression)) { setUpLoopCharacteristics(); FormalExpression formalExpression = bpmn2.createFormalExpression(); formalExpression.setBody(asCData(expression)); miloop.setCompletionCondition(formalExpression); } } MultipleInstanceActivityPropertyWriter(Activity activity,
VariableScope variableScope,
Set<DataObject> dataObjects); void setCollectionInput(String collectionInput); void setCollectionOutput(String collectionOutput); void setInput(String name); void setOutput(String name); void setOutput(String name, boolean addDataOutputAssociation); void setCompletionCondition(String expression); void setIsSequential(boolean sequential); }
|
@Test public void testSetCompletionCondition() { writer.setCompletionCondition(COMPLETION_CONDITION); assertEquals("<![CDATA[COMPLETION_CONDITION]]>", ((FormalExpression) ((MultiInstanceLoopCharacteristics) activity.getLoopCharacteristics()).getCompletionCondition()).getBody()); }
|
MultipleInstanceActivityPropertyWriter extends ActivityPropertyWriter { public void setIsSequential(boolean sequential) { setUpLoopCharacteristics(); miloop.setIsSequential(sequential); } MultipleInstanceActivityPropertyWriter(Activity activity,
VariableScope variableScope,
Set<DataObject> dataObjects); void setCollectionInput(String collectionInput); void setCollectionOutput(String collectionOutput); void setInput(String name); void setOutput(String name); void setOutput(String name, boolean addDataOutputAssociation); void setCompletionCondition(String expression); void setIsSequential(boolean sequential); }
|
@Test public void testSetIsSequentialTrue() { writer.setIsSequential(true); assertTrue(((MultiInstanceLoopCharacteristics) activity.getLoopCharacteristics()).isIsSequential()); }
@Test public void testSetIsSequentialFalse() { writer.setIsSequential(false); assertFalse(((MultiInstanceLoopCharacteristics) activity.getLoopCharacteristics()).isIsSequential()); }
|
DataObjectPropertyWriter extends PropertyWriter { @Override public void setName(String value) { final String escaped = StringUtils.replaceIllegalCharsAttribute(value.trim()); dataObject.setName(escaped); dataObject.setId(escaped); } DataObjectPropertyWriter(DataObjectReference element,
VariableScope variableScope,
Set<DataObject> dataObjects); @Override void setName(String value); void setType(String type); @Override DataObjectReference getElement(); Set<DataObject> getDataObjects(); }
|
@Test public void setName() { tested.setName(NAME); assertEquals(NAME, reference.getDataObjectRef().getName()); tested.setName(NAME); assertEquals(NAME, reference.getDataObjectRef().getName()); }
@Test public void setName() { tested.setName(NAME); assertEquals(NAME, reference.getDataObjectRef().getName()); }
|
DataObjectPropertyWriter extends PropertyWriter { public void setType(String type) { ItemDefinition itemDefinition = bpmn2.createItemDefinition(); itemDefinition.setStructureRef(type); dataObject.setItemSubjectRef(itemDefinition); addDataObjectToProcess(dataObject); } DataObjectPropertyWriter(DataObjectReference element,
VariableScope variableScope,
Set<DataObject> dataObjects); @Override void setName(String value); void setType(String type); @Override DataObjectReference getElement(); Set<DataObject> getDataObjects(); }
|
@Test public void setType() { tested.setType(NAME); assertEquals(NAME, reference.getDataObjectRef().getItemSubjectRef().getStructureRef()); }
|
DataObjectPropertyWriter extends PropertyWriter { public Set<DataObject> getDataObjects() { return dataObjects; } DataObjectPropertyWriter(DataObjectReference element,
VariableScope variableScope,
Set<DataObject> dataObjects); @Override void setName(String value); void setType(String type); @Override DataObjectReference getElement(); Set<DataObject> getDataObjects(); }
|
@Test public void getDataObjects() { assertEquals(0, tested.getDataObjects().size()); }
|
DataObjectPropertyWriter extends PropertyWriter { @Override public DataObjectReference getElement() { return (DataObjectReference) super.getElement(); } DataObjectPropertyWriter(DataObjectReference element,
VariableScope variableScope,
Set<DataObject> dataObjects); @Override void setName(String value); void setType(String type); @Override DataObjectReference getElement(); Set<DataObject> getDataObjects(); }
|
@Test public void getElement() { assertEquals(reference, tested.getElement()); }
|
FlatVariableScope implements VariableScope { public Optional<Variable> lookup(String identifier) { return Optional.ofNullable(variables.get(identifier)); } Variable declare(String scopeId, String identifier, String type); Variable declare(String scopeId, String identifier, String type, String tags); Optional<Variable> lookup(String identifier); Collection<Variable> getVariables(String scopeId); }
|
@Test public void lookupNotFound() { Optional<VariableScope.Variable> variable = tested.lookup(UUID.randomUUID().toString()); assertFalse(variable.isPresent()); }
|
ProcessPropertyWriter extends BasePropertyWriter implements ElementContainer { public void addChildElement(BasePropertyWriter p) { Processes.addChildElement( p, childElements, process, simulationParameters, itemDefinitions, rootElements); addChildShape(p.getShape()); addChildEdge(p.getEdge()); if (p instanceof SubProcessPropertyWriter) { addSubProcess((SubProcessPropertyWriter) p); } else if (p instanceof DataObjectPropertyWriter) { DataObject dataObject = ((DataObjectPropertyWriter) p).getElement().getDataObjectRef(); maybeAddDataObjectToItemDefinitions(itemDefinitions, dataObject); } maybeAddDataObjectToItemDefinitions(itemDefinitions, dataObjects); } ProcessPropertyWriter(Process process, VariableScope variableScope, Set<DataObject> dataObjects); void setId(String value); Process getProcess(); void addChildShape(BPMNShape shape); void addChildEdge(BPMNEdge edge); BPMNDiagram getBpmnDiagram(); void addChildElement(BasePropertyWriter p); @Override Collection<BasePropertyWriter> getChildElements(); BasePropertyWriter getChildElement(String id); void setName(String value); void setExecutable(Boolean value); void setPackage(String value); void setType(String value); void setVersion(String value); void setAdHoc(Boolean adHoc); void setDescription(String value); void setProcessVariables(BaseProcessVariables processVariables); void setMetadata(final MetaDataAttributes metaDataAttributes); void setCaseFileVariables(CaseFileVariables caseFileVariables); void setCaseIdPrefix(CaseIdPrefix caseIdPrefix); void setCaseRoles(CaseRoles roles); void setGlobalVariables(GlobalVariables globalVariables); void setDefaultImports(List<DefaultImport> imports); void setSlaDueDate(SLADueDate slaDueDate); void addLaneSet(Collection<LanePropertyWriter> lanes); Collection<ElementParameters> getSimulationParameters(); Relationship getRelationship(); Set<DataObject> getDataObjects(); }
|
@Test public void addChildElement() { Process process = p.getProcess(); BoundaryEventPropertyWriter boundaryEventPropertyWriter = new BoundaryEventPropertyWriter(bpmn2.createBoundaryEvent(), variableScope, new HashSet<>()); UserTaskPropertyWriter userTaskPropertyWriter = new UserTaskPropertyWriter(bpmn2.createUserTask(), variableScope, new HashSet<>()); SubProcessPropertyWriter subProcessPropertyWriter = new SubProcessPropertyWriter(bpmn2.createSubProcess(), variableScope, new HashSet<>()); final DataObjectReference dataObjectReference = bpmn2.createDataObjectReference(); DataObjectPropertyWriter dataObjectPropertyWriter = new DataObjectPropertyWriter(dataObjectReference, variableScope, new HashSet<>()); final DataObject dataObject = dataObjectPropertyWriter.getElement().getDataObjectRef(); dataObject.getItemSubjectRef(); ItemDefinition itemDefinition = mock(ItemDefinition.class); when(itemDefinition.getId()).thenReturn("someId"); dataObject.setItemSubjectRef(itemDefinition); dataObject.getItemSubjectRef(); subProcessPropertyWriter.addChildElement(dataObjectPropertyWriter); p.addChildElement(subProcessPropertyWriter); p.addChildElement(boundaryEventPropertyWriter); p.addChildElement(userTaskPropertyWriter); assertThat(process.getFlowElements().get(0)).isEqualTo(userTaskPropertyWriter.getFlowElement()); assertThat(process.getFlowElements().get(1)).isEqualTo(subProcessPropertyWriter.getFlowElement()); assertThat(process.getFlowElements().get(2)).isEqualTo(boundaryEventPropertyWriter.getFlowElement()); }
|
DecisionComponentsView implements DecisionComponents.View { @Override public void clear() { RemoveHelper.removeChildren(list); hide(emptyState); } @Inject DecisionComponentsView(final HTMLSelectElement drgElementFilter,
final HTMLInputElement termFilter,
final HTMLDivElement list,
final HTMLDivElement emptyState,
final HTMLDivElement loading,
final HTMLDivElement componentsCounter,
final TranslationService translationService); @PostConstruct void init(); @Override void init(final DecisionComponents presenter); @EventHandler("term-filter") void onTermFilterChange(final KeyUpEvent e); @Override void clear(); @Override void addListItem(final HTMLElement htmlElement); @Override void showEmptyState(); @Override void showLoading(); @Override void hideLoading(); @Override void disableFilterInputs(); @Override void enableFilterInputs(); @Override void setComponentsCounter(final Integer count); }
|
@Test public void testClear() { final Node element = mock(Node.class); emptyState.classList = mock(DOMTokenList.class); list.firstChild = element; when(list.removeChild(element)).then(a -> { list.firstChild = null; return element; }); view.clear(); verify(emptyState.classList).add(HIDDEN_CSS_CLASS); }
|
ProcessPropertyWriter extends BasePropertyWriter implements ElementContainer { public void addChildShape(BPMNShape shape) { if (shape == null) { return; } List<DiagramElement> planeElement = bpmnPlane.getPlaneElement(); if (planeElement.contains(shape)) { throw new IllegalArgumentException("Cannot add the same shape twice: " + shape.getId()); } planeElement.add(shape); } ProcessPropertyWriter(Process process, VariableScope variableScope, Set<DataObject> dataObjects); void setId(String value); Process getProcess(); void addChildShape(BPMNShape shape); void addChildEdge(BPMNEdge edge); BPMNDiagram getBpmnDiagram(); void addChildElement(BasePropertyWriter p); @Override Collection<BasePropertyWriter> getChildElements(); BasePropertyWriter getChildElement(String id); void setName(String value); void setExecutable(Boolean value); void setPackage(String value); void setType(String value); void setVersion(String value); void setAdHoc(Boolean adHoc); void setDescription(String value); void setProcessVariables(BaseProcessVariables processVariables); void setMetadata(final MetaDataAttributes metaDataAttributes); void setCaseFileVariables(CaseFileVariables caseFileVariables); void setCaseIdPrefix(CaseIdPrefix caseIdPrefix); void setCaseRoles(CaseRoles roles); void setGlobalVariables(GlobalVariables globalVariables); void setDefaultImports(List<DefaultImport> imports); void setSlaDueDate(SLADueDate slaDueDate); void addLaneSet(Collection<LanePropertyWriter> lanes); Collection<ElementParameters> getSimulationParameters(); Relationship getRelationship(); Set<DataObject> getDataObjects(); }
|
@Test public void addChildShape() { BPMNShape bpmnShape = di.createBPMNShape(); bpmnShape.setId("a"); p.addChildShape(bpmnShape); assertThatThrownBy(() -> p.addChildShape(bpmnShape)) .isInstanceOf(IllegalArgumentException.class) .hasMessageStartingWith("Cannot add the same shape twice"); }
|
ProcessPropertyWriter extends BasePropertyWriter implements ElementContainer { public void addChildEdge(BPMNEdge edge) { if (edge == null) { return; } List<DiagramElement> planeElement = bpmnPlane.getPlaneElement(); if (planeElement.contains(edge)) { throw new IllegalArgumentException("Cannot add the same edge twice: " + edge.getId()); } planeElement.add(edge); } ProcessPropertyWriter(Process process, VariableScope variableScope, Set<DataObject> dataObjects); void setId(String value); Process getProcess(); void addChildShape(BPMNShape shape); void addChildEdge(BPMNEdge edge); BPMNDiagram getBpmnDiagram(); void addChildElement(BasePropertyWriter p); @Override Collection<BasePropertyWriter> getChildElements(); BasePropertyWriter getChildElement(String id); void setName(String value); void setExecutable(Boolean value); void setPackage(String value); void setType(String value); void setVersion(String value); void setAdHoc(Boolean adHoc); void setDescription(String value); void setProcessVariables(BaseProcessVariables processVariables); void setMetadata(final MetaDataAttributes metaDataAttributes); void setCaseFileVariables(CaseFileVariables caseFileVariables); void setCaseIdPrefix(CaseIdPrefix caseIdPrefix); void setCaseRoles(CaseRoles roles); void setGlobalVariables(GlobalVariables globalVariables); void setDefaultImports(List<DefaultImport> imports); void setSlaDueDate(SLADueDate slaDueDate); void addLaneSet(Collection<LanePropertyWriter> lanes); Collection<ElementParameters> getSimulationParameters(); Relationship getRelationship(); Set<DataObject> getDataObjects(); }
|
@Test public void addChildEdge() { BPMNEdge bpmnEdge = di.createBPMNEdge(); bpmnEdge.setId("a"); p.addChildEdge(bpmnEdge); assertThatThrownBy(() -> p.addChildEdge(bpmnEdge)) .isInstanceOf(IllegalArgumentException.class) .hasMessageStartingWith("Cannot add the same edge twice"); }
|
ProcessPropertyWriter extends BasePropertyWriter implements ElementContainer { public void setCaseFileVariables(CaseFileVariables caseFileVariables) { String value = caseFileVariables.getValue(); DeclarationList declarationList = DeclarationList.fromString(value); List<Property> properties = process.getProperties(); declarationList.getDeclarations().forEach(decl -> { VariableScope.Variable variable = variableScope.declare(this.process.getId(), CaseFileVariables.CASE_FILE_PREFIX + decl.getIdentifier(), decl.getType()); properties.add(variable.getTypedIdentifier()); this.itemDefinitions.add(variable.getTypeDeclaration()); }); } ProcessPropertyWriter(Process process, VariableScope variableScope, Set<DataObject> dataObjects); void setId(String value); Process getProcess(); void addChildShape(BPMNShape shape); void addChildEdge(BPMNEdge edge); BPMNDiagram getBpmnDiagram(); void addChildElement(BasePropertyWriter p); @Override Collection<BasePropertyWriter> getChildElements(); BasePropertyWriter getChildElement(String id); void setName(String value); void setExecutable(Boolean value); void setPackage(String value); void setType(String value); void setVersion(String value); void setAdHoc(Boolean adHoc); void setDescription(String value); void setProcessVariables(BaseProcessVariables processVariables); void setMetadata(final MetaDataAttributes metaDataAttributes); void setCaseFileVariables(CaseFileVariables caseFileVariables); void setCaseIdPrefix(CaseIdPrefix caseIdPrefix); void setCaseRoles(CaseRoles roles); void setGlobalVariables(GlobalVariables globalVariables); void setDefaultImports(List<DefaultImport> imports); void setSlaDueDate(SLADueDate slaDueDate); void addLaneSet(Collection<LanePropertyWriter> lanes); Collection<ElementParameters> getSimulationParameters(); Relationship getRelationship(); Set<DataObject> getDataObjects(); }
|
@Test public void caseFileVariables() { CaseFileVariables caseFileVariables = new CaseFileVariables("CFV1:Boolean,CFV2:Boolean,CFV3:Boolean"); p.setCaseFileVariables(caseFileVariables); assertThat(p.itemDefinitions.size() == 3); }
|
ProcessPropertyWriter extends BasePropertyWriter implements ElementContainer { public Process getProcess() { return process; } ProcessPropertyWriter(Process process, VariableScope variableScope, Set<DataObject> dataObjects); void setId(String value); Process getProcess(); void addChildShape(BPMNShape shape); void addChildEdge(BPMNEdge edge); BPMNDiagram getBpmnDiagram(); void addChildElement(BasePropertyWriter p); @Override Collection<BasePropertyWriter> getChildElements(); BasePropertyWriter getChildElement(String id); void setName(String value); void setExecutable(Boolean value); void setPackage(String value); void setType(String value); void setVersion(String value); void setAdHoc(Boolean adHoc); void setDescription(String value); void setProcessVariables(BaseProcessVariables processVariables); void setMetadata(final MetaDataAttributes metaDataAttributes); void setCaseFileVariables(CaseFileVariables caseFileVariables); void setCaseIdPrefix(CaseIdPrefix caseIdPrefix); void setCaseRoles(CaseRoles roles); void setGlobalVariables(GlobalVariables globalVariables); void setDefaultImports(List<DefaultImport> imports); void setSlaDueDate(SLADueDate slaDueDate); void addLaneSet(Collection<LanePropertyWriter> lanes); Collection<ElementParameters> getSimulationParameters(); Relationship getRelationship(); Set<DataObject> getDataObjects(); }
|
@Test public void testSetDocumentationNotEmpty() { p.setDocumentation("DocumentationValue"); assertNotNull(p.getProcess().getDocumentation()); assertEquals(1, p.getProcess().getDocumentation().size()); assertEquals("<![CDATA[DocumentationValue]]>", p.getProcess().getDocumentation().get(0).getText()); }
|
ProcessPropertyWriter extends BasePropertyWriter implements ElementContainer { public void setMetadata(final MetaDataAttributes metaDataAttributes) { if (null != metaDataAttributes.getValue() && !metaDataAttributes.getValue().isEmpty()) { CustomElement.metaDataAttributes.of(process).set(metaDataAttributes.getValue()); } } ProcessPropertyWriter(Process process, VariableScope variableScope, Set<DataObject> dataObjects); void setId(String value); Process getProcess(); void addChildShape(BPMNShape shape); void addChildEdge(BPMNEdge edge); BPMNDiagram getBpmnDiagram(); void addChildElement(BasePropertyWriter p); @Override Collection<BasePropertyWriter> getChildElements(); BasePropertyWriter getChildElement(String id); void setName(String value); void setExecutable(Boolean value); void setPackage(String value); void setType(String value); void setVersion(String value); void setAdHoc(Boolean adHoc); void setDescription(String value); void setProcessVariables(BaseProcessVariables processVariables); void setMetadata(final MetaDataAttributes metaDataAttributes); void setCaseFileVariables(CaseFileVariables caseFileVariables); void setCaseIdPrefix(CaseIdPrefix caseIdPrefix); void setCaseRoles(CaseRoles roles); void setGlobalVariables(GlobalVariables globalVariables); void setDefaultImports(List<DefaultImport> imports); void setSlaDueDate(SLADueDate slaDueDate); void addLaneSet(Collection<LanePropertyWriter> lanes); Collection<ElementParameters> getSimulationParameters(); Relationship getRelationship(); Set<DataObject> getDataObjects(); }
|
@Test public void testSetMetaData() { MetaDataAttributes metaDataAttributes = new MetaDataAttributes("att1ßval1Øatt2ßval2"); p.setMetadata(metaDataAttributes); String metaDataString = CustomElement.metaDataAttributes.of(p.getProcess()).get(); assertThat(metaDataString).isEqualTo("att1ß<![CDATA[val1]]>Øatt2ß<![CDATA[val2]]>"); }
|
LanePropertyWriter extends BasePropertyWriter { public void setName(String value) { lane.setName(StringEscapeUtils.escapeXml10(value.trim())); CustomElement.name.of(lane).set(value); } LanePropertyWriter(Lane lane, VariableScope variableScope); void setName(String value); @Override Lane getElement(); @Override void addChild(BasePropertyWriter child); }
|
@Test public void JBPM_7523_shouldPreserveNameChars() { 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); assertThat(lane.getName()).isEqualTo(StringEscapeUtils.escapeXml10(aWeirdName.trim())); assertThat(CustomElement.name.of(lane).get()).isEqualTo(asCData(aWeirdName)); assertThat(lane.getDocumentation().get(0).getText()).isEqualTo(asCData(aWeirdDoc)); }
|
BoundaryEventPropertyWriter extends CatchEventPropertyWriter { public void setParentActivity(ActivityPropertyWriter parent) { event.setAttachedToRef(parent.getFlowElement()); } BoundaryEventPropertyWriter(BoundaryEvent event, VariableScope variableScope, Set<DataObject> dataObjects); @Override void setCancelActivity(Boolean value); void setParentActivity(ActivityPropertyWriter parent); @Override void addEventDefinition(EventDefinition eventDefinition); @Override void setAbsoluteBounds(Node<? extends View, ?> node); }
|
@Test public void testSetParentActivity() { ActivityPropertyWriter parentActivityWriter = mock(ActivityPropertyWriter.class); Activity activity = mock(Activity.class); when(parentActivityWriter.getFlowElement()).thenReturn(activity); propertyWriter.setParentActivity(parentActivityWriter); verify(element).setAttachedToRef(activity); }
|
BoundaryEventPropertyWriter extends CatchEventPropertyWriter { @Override public void addEventDefinition(EventDefinition eventDefinition) { this.event.getEventDefinitions().add(eventDefinition); } BoundaryEventPropertyWriter(BoundaryEvent event, VariableScope variableScope, Set<DataObject> dataObjects); @Override void setCancelActivity(Boolean value); void setParentActivity(ActivityPropertyWriter parent); @Override void addEventDefinition(EventDefinition eventDefinition); @Override void setAbsoluteBounds(Node<? extends View, ?> node); }
|
@Test @SuppressWarnings("unchecked") public void testAddEventDefinition() { List<EventDefinition> eventDefinitions = mock(List.class); when(element.getEventDefinitions()).thenReturn(eventDefinitions); EventDefinition eventDefinition = mock(EventDefinition.class); propertyWriter.addEventDefinition(eventDefinition); verify(eventDefinitions).add(eventDefinition); }
@Test @SuppressWarnings("unchecked") public void testAddEventDefinition() { EList<EventDefinition> eventDefinitions = spy(ECollections.newBasicEList()); when(element.getEventDefinitions()).thenReturn(eventDefinitions); EventDefinition eventDefinition = mock(EventDefinition.class); propertyWriter.addEventDefinition(eventDefinition); verify(eventDefinitions).add(eventDefinition); }
|
BoundaryEventPropertyWriter extends CatchEventPropertyWriter { @Override public void setAbsoluteBounds(Node<? extends View, ?> node) { Bound ul = node.getContent().getBounds().getUpperLeft(); setDockerInfo(Point2D.create(ul.getX(), ul.getY())); Optional<Node<View, Edge>> dockSourceNode = getDockSourceNode(node); if (dockSourceNode.isPresent()) { Bounds dockSourceNodeBounds = absoluteBounds(dockSourceNode.get()); Bounds nodeBounds = node.getContent().getBounds(); double x = dockSourceNodeBounds.getX() + nodeBounds.getUpperLeft().getX(); double y = dockSourceNodeBounds.getY() + nodeBounds.getUpperLeft().getY(); super.setBounds(Bounds.create(x, y, x + nodeBounds.getWidth(), y + nodeBounds.getHeight())); } else { super.setAbsoluteBounds(node); } } BoundaryEventPropertyWriter(BoundaryEvent event, VariableScope variableScope, Set<DataObject> dataObjects); @Override void setCancelActivity(Boolean value); void setParentActivity(ActivityPropertyWriter parent); @Override void addEventDefinition(EventDefinition eventDefinition); @Override void setAbsoluteBounds(Node<? extends View, ?> node); }
|
@Test @SuppressWarnings("unchecked") public void testSetAbsoluteBounds() { Node<View, Edge> node = (Node<View, Edge>) super.createNode(); Node<View, ?> dockSourceParentNode = mockNode(new Object(), org.kie.workbench.common.stunner.core.graph.content.Bounds.create(PARENT_ABSOLUTE_X1, PARENT_ABSOLUTE_Y1, PARENT_ABSOLUTE_X2, PARENT_ABSOLUTE_Y2)); double dockSourceRelativeX1 = 15d; double dockSourceRelativeY1 = 20d; double dockSourceRelativeX2 = 50d; double dockSourceAbsoluteY2 = 45d; Node<View, ?> dockSourceNode = mockNode(new Object(), org.kie.workbench.common.stunner.core.graph.content.Bounds.create(dockSourceRelativeX1, dockSourceRelativeY1, dockSourceRelativeX2, dockSourceAbsoluteY2), dockSourceParentNode); Edge dockEdge = mock(Edge.class); when(dockEdge.getSourceNode()).thenReturn(dockSourceNode); Dock dock = mock(Dock.class); when(dockEdge.getContent()).thenReturn(dock); node.getInEdges().clear(); node.getInEdges().add(dockEdge); propertyWriter.setAbsoluteBounds(node); Bounds shapeBounds = propertyWriter.getShape().getBounds(); org.kie.workbench.common.stunner.core.graph.content.Bounds relativeBounds = node.getContent().getBounds(); double dockSourceAbsoluteX = PARENT_ABSOLUTE_X1 + dockSourceRelativeX1; double dockSourceAbsoluteY = PARENT_ABSOLUTE_Y1 + dockSourceRelativeY1; assertEquals(dockSourceAbsoluteX + relativeBounds.getX(), shapeBounds.getX(), 0); assertEquals(dockSourceAbsoluteY + relativeBounds.getY(), shapeBounds.getY(), 0); assertEquals(relativeBounds.getWidth(), shapeBounds.getWidth(), 0); assertEquals(relativeBounds.getHeight(), shapeBounds.getHeight(), 0); verifyDockerInfoWasSet(relativeBounds); }
@Test @SuppressWarnings("unchecked") public void testSetAbsoluteBoundsWhenDockedSourceNodeIsNotPresent() { Node<View, Edge> node = (Node<View, Edge>) super.createNode(); org.kie.workbench.common.stunner.core.graph.content.Bounds relativeBounds = node.getContent().getBounds(); double absoluteX = PARENT_ABSOLUTE_X1 + relativeBounds.getUpperLeft().getX(); double absoluteY = PARENT_ABSOLUTE_Y1 + relativeBounds.getUpperLeft().getY(); propertyWriter.setAbsoluteBounds(node); Bounds shapeBounds = propertyWriter.getShape().getBounds(); assertEquals(absoluteX, shapeBounds.getX(), 0); assertEquals(absoluteY, shapeBounds.getY(), 0); assertEquals(relativeBounds.getWidth(), shapeBounds.getWidth(), 0); assertEquals(relativeBounds.getHeight(), shapeBounds.getHeight(), 0); verifyDockerInfoWasSet(relativeBounds); }
|
DecisionComponentsView implements DecisionComponents.View { @Override public void addListItem(final HTMLElement htmlElement) { list.appendChild(htmlElement); } @Inject DecisionComponentsView(final HTMLSelectElement drgElementFilter,
final HTMLInputElement termFilter,
final HTMLDivElement list,
final HTMLDivElement emptyState,
final HTMLDivElement loading,
final HTMLDivElement componentsCounter,
final TranslationService translationService); @PostConstruct void init(); @Override void init(final DecisionComponents presenter); @EventHandler("term-filter") void onTermFilterChange(final KeyUpEvent e); @Override void clear(); @Override void addListItem(final HTMLElement htmlElement); @Override void showEmptyState(); @Override void showLoading(); @Override void hideLoading(); @Override void disableFilterInputs(); @Override void enableFilterInputs(); @Override void setComponentsCounter(final Integer count); }
|
@Test public void testAddListItem() { final HTMLElement listItemElement = mock(HTMLElement.class); view.addListItem(listItemElement); verify(list).appendChild(listItemElement); }
|
EventPropertyWriter extends PropertyWriter { public void addError(ErrorRef errorRef) { Error error = bpmn2.createError(); ErrorEventDefinition errorEventDefinition = bpmn2.createErrorEventDefinition(); addEventDefinition(errorEventDefinition); String errorCode = errorRef.getValue(); String errorId; if (StringUtils.nonEmpty(errorCode)) { error.setErrorCode(errorCode); CustomAttribute.errorName.of(errorEventDefinition).set(errorCode); errorId = errorCode; } else { errorId = UUID.uuid(); } error.setId(errorId); errorEventDefinition.setErrorRef(error); addRootElement(error); } EventPropertyWriter(Event event, VariableScope variableScope); abstract void setAssignmentsInfo(AssignmentsInfo assignmentsInfo); void addMessage(MessageRef messageRef); void addSignal(SignalRef signalRef); void addLink(LinkRef linkRef); void addSignalScope(SignalScope signalScope); void addError(ErrorRef errorRef); void addTerminate(); void addTimer(TimerSettings timerSettings); void addCondition(ConditionExpression condition); void addEscalation(EscalationRef escalationRef); void addCompensation(); void addSlaDueDate(SLADueDate slaDueDate); }
|
@Test public void testAddEmptyError() { final ArgumentCaptor<RootElement> captor = ArgumentCaptor.forClass(RootElement.class); ErrorRef errorRef = new ErrorRef(); propertyWriter.addError(errorRef); ErrorEventDefinition definition = getErrorDefinition(); assertNull(definition.getErrorRef().getErrorCode()); assertFalse(definition.getErrorRef().getId().isEmpty()); verify(propertyWriter).addRootElement(captor.capture()); Error error = (Error) captor.getValue(); assertNull(error.getErrorCode()); assertFalse(error.getId().isEmpty()); }
@Test public void testAddError() { final ArgumentCaptor<RootElement> captor = ArgumentCaptor.forClass(RootElement.class); ErrorRef errorRef = new ErrorRef(); errorRef.setValue(ERROR_CODE); propertyWriter.addError(errorRef); ErrorEventDefinition definition = getErrorDefinition(); assertEquals(ERROR_CODE, definition.getErrorRef().getErrorCode()); assertFalse(definition.getErrorRef().getId().isEmpty()); verify(propertyWriter).addRootElement(captor.capture()); Error error = (Error) captor.getValue(); assertEquals(ERROR_CODE, error.getErrorCode()); assertFalse(error.getId().isEmpty()); }
|
SubProcessPropertyWriter extends MultipleInstanceActivityPropertyWriter implements ElementContainer { public void addChildElement(BasePropertyWriter p) { p.setParent(this); Processes.addChildElement( p, childElements, process, simulationParameters, itemDefinitions, rootElements); } SubProcessPropertyWriter(SubProcess process, VariableScope variableScope, Set<DataObject> dataObjects); void addChildElement(BasePropertyWriter p); @Override Collection<BasePropertyWriter> getChildElements(); BasePropertyWriter getChildElement(String id); @Override void addChildEdge(BPMNEdge edge); void setDescription(String value); void setSimulationSet(SimulationSet simulations); void setProcessVariables(BaseProcessVariables processVariables); void addLaneSet(Collection<LanePropertyWriter> lanes); void setOnEntryAction(OnEntryAction onEntryAction); void setOnExitAction(OnExitAction onExitAction); void setAsync(Boolean isAsync); void setSlaDueDate(SLADueDate slaDueDate); @Override void setAbsoluteBounds(Node<? extends View, ?> node); }
|
@Test public void addChildElement() { SubProcess process = (SubProcess) propertyWriter.getElement(); List<FlowElement> flowElements = new ArrayList<>(); when(process.getFlowElements()).thenReturn(flowElements); BoundaryEventPropertyWriter boundaryEventPropertyWriter = new BoundaryEventPropertyWriter(bpmn2.createBoundaryEvent(), variableScope, new HashSet<>()); UserTaskPropertyWriter userTaskPropertyWriter = new UserTaskPropertyWriter(bpmn2.createUserTask(), variableScope, new HashSet<>()); propertyWriter.addChildElement(boundaryEventPropertyWriter); propertyWriter.addChildElement(userTaskPropertyWriter); assertThat(process.getFlowElements().get(0)).isEqualTo(userTaskPropertyWriter.getFlowElement()); assertThat(process.getFlowElements().get(1)).isEqualTo(boundaryEventPropertyWriter.getFlowElement()); }
@Test public void addChildElement() { SubProcess process = (SubProcess) propertyWriter.getElement(); when(process.getFlowElements()).thenReturn(ECollections.newBasicEList()); BoundaryEventPropertyWriter boundaryEventPropertyWriter = new BoundaryEventPropertyWriter(bpmn2.createBoundaryEvent(), variableScope, new HashSet<>()); UserTaskPropertyWriter userTaskPropertyWriter = new UserTaskPropertyWriter(bpmn2.createUserTask(), variableScope, new HashSet<>()); propertyWriter.addChildElement(boundaryEventPropertyWriter); propertyWriter.addChildElement(userTaskPropertyWriter); assertThat(process.getFlowElements().get(0)).isEqualTo(userTaskPropertyWriter.getFlowElement()); assertThat(process.getFlowElements().get(1)).isEqualTo(boundaryEventPropertyWriter.getFlowElement()); }
|
GatewayPropertyWriter extends PropertyWriter { public void setDefaultRoute(String defaultRouteExpression) { if (defaultRouteExpression == null) { return; } CustomAttribute.dg.of(gateway).set(defaultRouteExpression); String[] split = defaultRouteExpression.split(" : "); this.defaultGatewayId = (split.length == 1) ? split[0] : split[1]; } GatewayPropertyWriter(Gateway gateway, VariableScope variableScope); void setDefaultRoute(String defaultRouteExpression); void setSource(BasePropertyWriter source); void setTarget(BasePropertyWriter target); void setGatewayDirection(Node n); void setGatewayDirection(GatewayDirection direction); }
|
@Test public void testSetDefaultRoute() { testSetDefaultRoute("defaultRoute", "defaultRoute"); }
@Test public void testSetDefaultRouteNull() { propertyWriter.setDefaultRoute(null); verify(featureMap, never()).add(any()); }
|
GatewayPropertyWriter extends PropertyWriter { public void setSource(BasePropertyWriter source) { setDefaultGateway(source); } GatewayPropertyWriter(Gateway gateway, VariableScope variableScope); void setDefaultRoute(String defaultRouteExpression); void setSource(BasePropertyWriter source); void setTarget(BasePropertyWriter target); void setGatewayDirection(Node n); void setGatewayDirection(GatewayDirection direction); }
|
@Test public void testSetSourceForExclusiveGateway() { ExclusiveGateway exclusiveGateway = mockGateway(ExclusiveGateway.class, ID); prepareTestSetSourceOrTarget(exclusiveGateway); propertyWriter.setSource(anotherPropertyWriter); verify(exclusiveGateway).setDefault(sequenceFlow); }
@Test public void testSetSourceForInclusiveGateway() { InclusiveGateway inclusiveGateway = mockGateway(InclusiveGateway.class, ID); prepareTestSetSourceOrTarget(inclusiveGateway); propertyWriter.setSource(anotherPropertyWriter); verify(inclusiveGateway).setDefault(sequenceFlow); }
|
GatewayPropertyWriter extends PropertyWriter { public void setTarget(BasePropertyWriter target) { setDefaultGateway(target); } GatewayPropertyWriter(Gateway gateway, VariableScope variableScope); void setDefaultRoute(String defaultRouteExpression); void setSource(BasePropertyWriter source); void setTarget(BasePropertyWriter target); void setGatewayDirection(Node n); void setGatewayDirection(GatewayDirection direction); }
|
@Test public void testSetTargetForExclusiveGateway() { ExclusiveGateway exclusiveGateway = mockGateway(ExclusiveGateway.class, ID); prepareTestSetSourceOrTarget(exclusiveGateway); propertyWriter.setTarget(anotherPropertyWriter); verify(exclusiveGateway).setDefault(sequenceFlow); }
@Test public void testSetTargetForInclusiveGateway() { InclusiveGateway inclusiveGateway = mockGateway(InclusiveGateway.class, ID); prepareTestSetSourceOrTarget(inclusiveGateway); propertyWriter.setTarget(anotherPropertyWriter); verify(inclusiveGateway).setDefault(sequenceFlow); }
|
GatewayPropertyWriter extends PropertyWriter { public void setGatewayDirection(Node n) { long incoming = countEdges(n.getInEdges()); long outgoing = countEdges(n.getOutEdges()); if (incoming <= 1 && outgoing > 1) { gateway.setGatewayDirection(GatewayDirection.DIVERGING); } else if (incoming > 1 && outgoing <= 1) { gateway.setGatewayDirection(GatewayDirection.CONVERGING); } else { gateway.setGatewayDirection(GatewayDirection.UNSPECIFIED); } } GatewayPropertyWriter(Gateway gateway, VariableScope variableScope); void setDefaultRoute(String defaultRouteExpression); void setSource(BasePropertyWriter source); void setTarget(BasePropertyWriter target); void setGatewayDirection(Node n); void setGatewayDirection(GatewayDirection direction); }
|
@Test public void testSetGatewayDirectionWithDivergingNode() { Node node = mockNode(1, 2); propertyWriter.setGatewayDirection(node); verify(element).setGatewayDirection(GatewayDirection.DIVERGING); }
@Test public void testSetGatewayDirectionWithConvergingNode() { Node node = mockNode(2, 1); propertyWriter.setGatewayDirection(node); verify(element).setGatewayDirection(GatewayDirection.CONVERGING); }
@Test public void testSetGatewayDirectionWithNotConfiguredNode() { Node node = mockNode(0, 0); propertyWriter.setGatewayDirection(node); verify(element).setGatewayDirection(GatewayDirection.UNSPECIFIED); }
@Test public void testSetGatewayDirection() { GatewayDirection randomDirection = GatewayDirection.CONVERGING; propertyWriter.setGatewayDirection(randomDirection); verify(element).setGatewayDirection(randomDirection); }
|
DecisionComponentsView implements DecisionComponents.View { @Override public void showEmptyState() { show(emptyState); } @Inject DecisionComponentsView(final HTMLSelectElement drgElementFilter,
final HTMLInputElement termFilter,
final HTMLDivElement list,
final HTMLDivElement emptyState,
final HTMLDivElement loading,
final HTMLDivElement componentsCounter,
final TranslationService translationService); @PostConstruct void init(); @Override void init(final DecisionComponents presenter); @EventHandler("term-filter") void onTermFilterChange(final KeyUpEvent e); @Override void clear(); @Override void addListItem(final HTMLElement htmlElement); @Override void showEmptyState(); @Override void showLoading(); @Override void hideLoading(); @Override void disableFilterInputs(); @Override void enableFilterInputs(); @Override void setComponentsCounter(final Integer count); }
|
@Test public void testShowEmptyState() { emptyState.classList = mock(DOMTokenList.class); view.showEmptyState(); verify(emptyState.classList).remove(HIDDEN_CSS_CLASS); }
|
UserTaskPropertyWriter extends MultipleInstanceActivityPropertyWriter { public void setActors(Actors actors) { for (String actor : fromActorString(actors.getValue())) { PotentialOwner potentialOwner = bpmn2.createPotentialOwner(); potentialOwner.setId("_"+UUID.randomUUID().toString()); FormalExpression formalExpression = bpmn2.createFormalExpression(); formalExpression.setBody(actor); ResourceAssignmentExpression resourceAssignmentExpression = bpmn2.createResourceAssignmentExpression(); resourceAssignmentExpression.setExpression(formalExpression); potentialOwner.setResourceAssignmentExpression(resourceAssignmentExpression); task.getResources().add(potentialOwner); } } UserTaskPropertyWriter(UserTask task, VariableScope variableScope, Set<DataObject> dataObjects); void setAsync(boolean async); void setSkippable(boolean skippable); void setPriority(String priority); void setSubject(String subject); void setDescription(String description); void setCreatedBy(String createdBy); void setAdHocAutostart(boolean autoStart); void setTaskName(String taskName); void setActors(Actors actors); void setReassignments(ReassignmentsInfo reassignments); void setGroupId(String value); void setOnEntryAction(OnEntryAction onEntryAction); void setOnExitAction(OnExitAction onExitAction); void setContent(String content); void setSLADueDate(String slaDueDate); void setNotifications(NotificationsInfo notificationsInfo); }
|
@Test public void startsFromUnderscore() { UserTask userTask = bpmn2.createUserTask(); UserTaskPropertyWriter userTaskPropertyWriter = new UserTaskPropertyWriter(userTask, variableScope, new HashSet<>()); Actors actor = new Actors(); actor.setValue("startsFromUnderscore"); userTaskPropertyWriter.setActors(actor); assertEquals("startsFromUnderscore", getActors(userTask).get(0).a); assertTrue(getActors(userTask).get(0).b.startsWith("_")); }
|
TextAnnotationPropertyWriter extends PropertyWriter { public void setName(String value) { final String escaped = StringEscapeUtils.escapeXml10(value.trim()); element.setText(escaped); element.setName(escaped); CustomElement.name.of(element).set(value); } TextAnnotationPropertyWriter(TextAnnotation element, VariableScope variableScope); void setName(String value); @Override TextAnnotation getElement(); }
|
@Test public void setName() { tested.setName(NAME); verify(element).setText(NAME); verify(element).setName(NAME); verify(valueMap).add(entryArgumentCaptor.capture()); final MetaDataTypeImpl value = (MetaDataTypeImpl) entryArgumentCaptor.getValue().getValue(); assertEquals(NAME, CustomElement.name.stripCData(value.getMetaValue())); }
|
TextAnnotationPropertyWriter extends PropertyWriter { @Override public TextAnnotation getElement() { return (TextAnnotation) super.getElement(); } TextAnnotationPropertyWriter(TextAnnotation element, VariableScope variableScope); void setName(String value); @Override TextAnnotation getElement(); }
|
@Test public void getElement() { assertEquals(element, tested.getElement()); }
|
AdHocSubProcessPropertyWriter extends SubProcessPropertyWriter { public void setAdHocAutostart(boolean autoStart) { CustomElement.autoStart.of(flowElement).set(autoStart); } AdHocSubProcessPropertyWriter(AdHocSubProcess process, VariableScope variableScope, Set<DataObject> dataObjects); void setAdHocActivationCondition(BaseAdHocActivationCondition adHocActivationCondition); void setAdHocOrdering(org.kie.workbench.common.stunner.bpmn.definition.property.task.AdHocOrdering value); void setAdHocCompletionCondition(BaseAdHocCompletionCondition adHocCompletionCondition); void setAdHocAutostart(boolean autoStart); }
|
@Test public void testSetAdHocAutostart_true() throws Exception { tested.setAdHocAutostart(Boolean.TRUE); assertTrue(CustomElement.autoStart.of(tested.getFlowElement()).get()); }
@Test public void testSetAdHocAutostart_false() throws Exception { tested.setAdHocAutostart(Boolean.FALSE); assertFalse(CustomElement.autoStart.of(tested.getFlowElement()).get()); }
|
AdHocSubProcessPropertyWriter extends SubProcessPropertyWriter { public void setAdHocActivationCondition(BaseAdHocActivationCondition adHocActivationCondition) { if (StringUtils.nonEmpty(adHocActivationCondition.getValue())) { CustomElement.customActivationCondition.of(flowElement).set(adHocActivationCondition.getValue()); } } AdHocSubProcessPropertyWriter(AdHocSubProcess process, VariableScope variableScope, Set<DataObject> dataObjects); void setAdHocActivationCondition(BaseAdHocActivationCondition adHocActivationCondition); void setAdHocOrdering(org.kie.workbench.common.stunner.bpmn.definition.property.task.AdHocOrdering value); void setAdHocCompletionCondition(BaseAdHocCompletionCondition adHocCompletionCondition); void setAdHocAutostart(boolean autoStart); }
|
@Test public void testSetAdHocActivationCondition() { tested.setAdHocActivationCondition(new AdHocActivationCondition("condition expression")); assertEquals(asCData("condition expression"), CustomElement.customActivationCondition.of(tested.getFlowElement()).get()); }
@Test public void testSetAdHocActivationConditionNull() { tested.setAdHocActivationCondition(new AdHocActivationCondition(null)); assertEquals("", CustomElement.customActivationCondition.of(tested.getFlowElement()).get()); }
@Test public void testSetAdHocActivationConditionEmpty() { tested.setAdHocActivationCondition(new AdHocActivationCondition("")); assertEquals("", CustomElement.customActivationCondition.of(tested.getFlowElement()).get()); }
|
DecisionComponentsView implements DecisionComponents.View { @Override public void showLoading() { show(loading); } @Inject DecisionComponentsView(final HTMLSelectElement drgElementFilter,
final HTMLInputElement termFilter,
final HTMLDivElement list,
final HTMLDivElement emptyState,
final HTMLDivElement loading,
final HTMLDivElement componentsCounter,
final TranslationService translationService); @PostConstruct void init(); @Override void init(final DecisionComponents presenter); @EventHandler("term-filter") void onTermFilterChange(final KeyUpEvent e); @Override void clear(); @Override void addListItem(final HTMLElement htmlElement); @Override void showEmptyState(); @Override void showLoading(); @Override void hideLoading(); @Override void disableFilterInputs(); @Override void enableFilterInputs(); @Override void setComponentsCounter(final Integer count); }
|
@Test public void testShowLoading() { loading.classList = mock(DOMTokenList.class); view.showLoading(); verify(loading.classList).remove(HIDDEN_CSS_CLASS); }
|
AdHocSubProcessPropertyWriter extends SubProcessPropertyWriter { public void setAdHocOrdering(org.kie.workbench.common.stunner.bpmn.definition.property.task.AdHocOrdering value) { process.setOrdering(AdHocOrdering.getByName(value.getValue())); } AdHocSubProcessPropertyWriter(AdHocSubProcess process, VariableScope variableScope, Set<DataObject> dataObjects); void setAdHocActivationCondition(BaseAdHocActivationCondition adHocActivationCondition); void setAdHocOrdering(org.kie.workbench.common.stunner.bpmn.definition.property.task.AdHocOrdering value); void setAdHocCompletionCondition(BaseAdHocCompletionCondition adHocCompletionCondition); void setAdHocAutostart(boolean autoStart); }
|
@Test public void testSetAdHocOrderingSequential() { tested.setAdHocOrdering(new AdHocOrdering("Sequential")); assertEquals(org.eclipse.bpmn2.AdHocOrdering.SEQUENTIAL, ((AdHocSubProcess) tested.getFlowElement()).getOrdering()); }
@Test public void testSetAdHocOrderingParallel() { tested.setAdHocOrdering(new AdHocOrdering("Parallel")); assertEquals(org.eclipse.bpmn2.AdHocOrdering.PARALLEL, ((AdHocSubProcess) tested.getFlowElement()).getOrdering()); }
|
AdHocSubProcessPropertyWriter extends SubProcessPropertyWriter { public void setAdHocCompletionCondition(BaseAdHocCompletionCondition adHocCompletionCondition) { FormalExpression e = bpmn2.createFormalExpression(); ScriptTypeValue s = adHocCompletionCondition.getValue(); e.setLanguage(scriptLanguageToUri(s.getLanguage())); e.setBody(asCData(s.getScript())); process.setCompletionCondition(e); } AdHocSubProcessPropertyWriter(AdHocSubProcess process, VariableScope variableScope, Set<DataObject> dataObjects); void setAdHocActivationCondition(BaseAdHocActivationCondition adHocActivationCondition); void setAdHocOrdering(org.kie.workbench.common.stunner.bpmn.definition.property.task.AdHocOrdering value); void setAdHocCompletionCondition(BaseAdHocCompletionCondition adHocCompletionCondition); void setAdHocAutostart(boolean autoStart); }
|
@Test public void testSetAdHocCompletionCondition() { AdHocCompletionCondition condition = new AdHocCompletionCondition(new ScriptTypeValue("java", "some code")); tested.setAdHocCompletionCondition(condition); FormalExpression expression = (FormalExpression) ((AdHocSubProcess) tested.getFlowElement()).getCompletionCondition(); assertEquals(condition.getValue().getLanguage(), Scripts.scriptLanguageFromUri(expression.getLanguage())); assertEquals(asCData(condition.getValue().getScript()), expression.getBody()); }
|
GatewayConverter { private PropertyWriter inclusive(Node<View<InclusiveGateway>, ?> n) { GatewayPropertyWriter p = propertyWriterFactory.of(bpmn2.createInclusiveGateway()); p.setId(n.getUUID()); InclusiveGateway definition = n.getContent().getDefinition(); p.setGatewayDirection(n); BPMNGeneralSet general = definition.getGeneral(); p.setName(general.getName().getValue()); p.setDocumentation(general.getDocumentation().getValue()); GatewayExecutionSet executionSet = definition.getExecutionSet(); p.setDefaultRoute(executionSet.getDefaultRoute().getValue()); p.setAbsoluteBounds(n); return p; } GatewayConverter(PropertyWriterFactory propertyWriterFactory); PropertyWriter toFlowElement(Node<View<BaseGateway>, ?> node); }
|
@Test public void testInclusive() { InclusiveGateway gateway = new InclusiveGateway(); gateway.getGeneral().getName().setValue(NAME); gateway.getGeneral().getDocumentation().setValue(DOCUMENTATION); gateway.getExecutionSet().getDefaultRoute().setValue(DEFAULT_ROUTE); Node<View<BaseGateway>, ?> node = newNode(UUID, gateway); when(propertyWriterFactory.of(any(org.eclipse.bpmn2.InclusiveGateway.class))).thenReturn(gatewayPropertyWriter); assertEquals(gatewayPropertyWriter, converter.toFlowElement(node)); verifyCommonValues(gatewayPropertyWriter, node); verify(gatewayPropertyWriter).setDefaultRoute(DEFAULT_ROUTE); verify(gatewayPropertyWriter).setGatewayDirection(node); }
|
GatewayConverter { private PropertyWriter exclusive(Node<View<ExclusiveGateway>, ?> n) { GatewayPropertyWriter p = propertyWriterFactory.of(bpmn2.createExclusiveGateway()); p.setId(n.getUUID()); ExclusiveGateway definition = n.getContent().getDefinition(); p.setGatewayDirection(n); BPMNGeneralSet general = definition.getGeneral(); p.setName(general.getName().getValue()); p.setDocumentation(general.getDocumentation().getValue()); GatewayExecutionSet executionSet = definition.getExecutionSet(); p.setDefaultRoute(executionSet.getDefaultRoute().getValue()); p.setAbsoluteBounds(n); return p; } GatewayConverter(PropertyWriterFactory propertyWriterFactory); PropertyWriter toFlowElement(Node<View<BaseGateway>, ?> node); }
|
@Test public void testExclusive() { ExclusiveGateway gateway = new ExclusiveGateway(); gateway.getGeneral().getName().setValue(NAME); gateway.getGeneral().getDocumentation().setValue(DOCUMENTATION); gateway.getExecutionSet().getDefaultRoute().setValue(DEFAULT_ROUTE); Node<View<BaseGateway>, ?> node = newNode(UUID, gateway); when(propertyWriterFactory.of(any(org.eclipse.bpmn2.ExclusiveGateway.class))).thenReturn(gatewayPropertyWriter); assertEquals(gatewayPropertyWriter, converter.toFlowElement(node)); verifyCommonValues(gatewayPropertyWriter, node); verify(gatewayPropertyWriter).setDefaultRoute(DEFAULT_ROUTE); verify(gatewayPropertyWriter).setGatewayDirection(node); }
|
GatewayConverter { private PropertyWriter parallel(Node<View<ParallelGateway>, ?> n) { GatewayPropertyWriter p = propertyWriterFactory.of(bpmn2.createParallelGateway()); p.setId(n.getUUID()); ParallelGateway definition = n.getContent().getDefinition(); p.setGatewayDirection(n); BPMNGeneralSet general = definition.getGeneral(); p.setName(general.getName().getValue()); p.setDocumentation(general.getDocumentation().getValue()); p.setAbsoluteBounds(n); return p; } GatewayConverter(PropertyWriterFactory propertyWriterFactory); PropertyWriter toFlowElement(Node<View<BaseGateway>, ?> node); }
|
@Test public void testParallel() { ParallelGateway gateway = new ParallelGateway(); gateway.getGeneral().getName().setValue(NAME); gateway.getGeneral().getDocumentation().setValue(DOCUMENTATION); Node<View<BaseGateway>, ?> node = newNode(UUID, gateway); when(propertyWriterFactory.of(any(org.eclipse.bpmn2.ParallelGateway.class))).thenReturn(gatewayPropertyWriter); assertEquals(gatewayPropertyWriter, converter.toFlowElement(node)); verifyCommonValues(gatewayPropertyWriter, node); verify(gatewayPropertyWriter).setGatewayDirection(node); }
|
GatewayConverter { private PropertyWriter event(Node<View<EventGateway>, ?> n) { GatewayPropertyWriter p = propertyWriterFactory.of(bpmn2.createEventBasedGateway()); p.setId(n.getUUID()); p.setGatewayDirection(GatewayDirection.DIVERGING); EventGateway definition = n.getContent().getDefinition(); BPMNGeneralSet general = definition.getGeneral(); p.setName(general.getName().getValue()); p.setDocumentation(general.getDocumentation().getValue()); p.setAbsoluteBounds(n); return p; } GatewayConverter(PropertyWriterFactory propertyWriterFactory); PropertyWriter toFlowElement(Node<View<BaseGateway>, ?> node); }
|
@Test public void testEvent() { EventGateway gateway = new EventGateway(); gateway.getGeneral().getName().setValue(NAME); gateway.getGeneral().getDocumentation().setValue(DOCUMENTATION); Node<View<BaseGateway>, ?> node = newNode(UUID, gateway); when(propertyWriterFactory.of(any(org.eclipse.bpmn2.EventBasedGateway.class))).thenReturn(gatewayPropertyWriter); assertEquals(gatewayPropertyWriter, converter.toFlowElement(node)); verifyCommonValues(gatewayPropertyWriter, node); }
|
ReusableSubprocessConverter { public PropertyWriter toFlowElement(Node<View<BaseReusableSubprocess>, ?> n) { CallActivity activity = bpmn2.createCallActivity(); activity.setId(n.getUUID()); CallActivityPropertyWriter p = propertyWriterFactory.of(activity); BaseReusableSubprocess definition = n.getContent().getDefinition(); BPMNGeneralSet general = definition.getGeneral(); p.setName(general.getName().getValue()); p.setDocumentation(general.getDocumentation().getValue()); BaseReusableSubprocessTaskExecutionSet executionSet = definition.getExecutionSet(); p.setOnEntryAction(executionSet.getOnEntryAction()); p.setOnExitAction(executionSet.getOnExitAction()); p.setCalledElement(replaceIllegalCharsAttribute(executionSet.getCalledElement().getValue())); p.setAsync(executionSet.getIsAsync().getValue()); p.setIndependent(executionSet.getIndependent().getValue()); if (Boolean.FALSE.equals(executionSet.getIndependent().getValue())) { p.setAbortParent(executionSet.getAbortParent().getValue()); } p.setWaitForCompletion(executionSet.getWaitForCompletion().getValue()); p.setSlaDueDate(executionSet.getSlaDueDate()); p.setAssignmentsInfo(definition.getDataIOSet().getAssignmentsinfo()); if (Boolean.TRUE.equals(executionSet.getIsMultipleInstance().getValue())) { p.setIsSequential(executionSet.getMultipleInstanceExecutionMode().isSequential()); p.setCollectionInput(executionSet.getMultipleInstanceCollectionInput().getValue()); p.setInput(executionSet.getMultipleInstanceDataInput().getValue()); p.setCollectionOutput(executionSet.getMultipleInstanceCollectionOutput().getValue()); p.setOutput(executionSet.getMultipleInstanceDataOutput().getValue()); p.setCompletionCondition(executionSet.getMultipleInstanceCompletionCondition().getValue()); } p.setSimulationSet(definition.getSimulationSet()); p.setAbsoluteBounds(n); p.setCase(executionSet.getIsCase().getValue()); p.setAdHocAutostart(executionSet.getAdHocAutostart().getValue()); return p; } ReusableSubprocessConverter(PropertyWriterFactory propertyWriterFactory); PropertyWriter toFlowElement(Node<View<BaseReusableSubprocess>, ?> n); }
|
@Test public void testToFlowElementMI() { assertEquals(propertyWriter, converter.toFlowElement(node)); verifyCommonValues(); verify(propertyWriter).setIsSequential(SEQUENTIAL); verify(propertyWriter).setCollectionInput(COLLECTION_INPUT); verify(propertyWriter).setInput(DATA_INPUT); verify(propertyWriter).setCollectionOutput(COLLECTION_OUTPUT); verify(propertyWriter).setOutput(DATA_OUTPUT); verify(propertyWriter).setCompletionCondition(COMPLETION_CONDITION); }
@Test public void testToFlowElementNonMI() { node.getContent().getDefinition().getExecutionSet().getIsMultipleInstance().setValue(false); assertEquals(propertyWriter, converter.toFlowElement(node)); verifyCommonValues(); verify(propertyWriter, never()).setIsSequential(anyBoolean()); verify(propertyWriter, never()).setCollectionInput(anyString()); verify(propertyWriter, never()).setInput(anyString()); verify(propertyWriter, never()).setCollectionOutput(anyString()); verify(propertyWriter, never()).setOutput(anyString()); verify(propertyWriter, never()).setCompletionCondition(anyString()); }
@Test public void testToFlowElement_case() { final BaseReusableSubprocess definition = new ReusableSubprocess(); definition.getExecutionSet().setIsCase(new IsCase(true)); final View<BaseReusableSubprocess> view = new ViewImpl<>(definition, Bounds.create()); final Node<View<BaseReusableSubprocess>, ?> node = new NodeImpl<>(java.util.UUID.randomUUID().toString()); node.setContent(view); final PropertyWriter propertyWriter = tested.toFlowElement(node); assertTrue(CallActivityPropertyWriter.class.isInstance(propertyWriter)); assertTrue(CustomElement.isCase.of(propertyWriter.getFlowElement()).get()); }
@Test public void testToFlowElement_process() { final BaseReusableSubprocess definition = new ReusableSubprocess(); final View<BaseReusableSubprocess> view = new ViewImpl<>(definition, Bounds.create()); final Node<View<BaseReusableSubprocess>, ?> node = new NodeImpl<>(java.util.UUID.randomUUID().toString()); node.setContent(view); final PropertyWriter propertyWriter = tested.toFlowElement(node); assertTrue(CallActivityPropertyWriter.class.isInstance(propertyWriter)); assertFalse(CustomElement.isCase.of(propertyWriter.getFlowElement()).get()); }
@Test public void testToFlowElement_autostart() { final ReusableSubprocess definition = new ReusableSubprocess(); definition.getExecutionSet().setAdHocAutostart(new AdHocAutostart(true)); final View<BaseReusableSubprocess> view = new ViewImpl<>(definition, Bounds.create()); final Node<View<BaseReusableSubprocess>, ?> node = new NodeImpl<>(java.util.UUID.randomUUID().toString()); node.setContent(view); final PropertyWriter propertyWriter = tested.toFlowElement(node); assertTrue(CallActivityPropertyWriter.class.isInstance(propertyWriter)); assertTrue(CustomElement.autoStart.of(propertyWriter.getFlowElement()).get()); }
@Test public void testToFlowElement_notautostart() { final ReusableSubprocess definition = new ReusableSubprocess(); definition.getExecutionSet().setAdHocAutostart(new AdHocAutostart(false)); final View<BaseReusableSubprocess> view = new ViewImpl<>(definition, Bounds.create()); final Node<View<BaseReusableSubprocess>, ?> node = new NodeImpl<>(java.util.UUID.randomUUID().toString()); node.setContent(view); final PropertyWriter propertyWriter = tested.toFlowElement(node); assertTrue(CallActivityPropertyWriter.class.isInstance(propertyWriter)); assertFalse(CustomElement.autoStart.of(propertyWriter.getFlowElement()).get()); }
@Test public void testToFlowElement() { final ReusableSubprocess definition = new ReusableSubprocess(); definition.getExecutionSet().setSlaDueDate(new SLADueDate(SLA_DUE_DATE)); definition.getExecutionSet().setIsAsync(new IsAsync(Boolean.TRUE)); final View<BaseReusableSubprocess> view = new ViewImpl<>(definition, Bounds.create()); final Node<View<BaseReusableSubprocess>, ?> node = new NodeImpl<>(java.util.UUID.randomUUID().toString()); node.setContent(view); final PropertyWriter propertyWriter = tested.toFlowElement(node); assertTrue(CallActivityPropertyWriter.class.isInstance(propertyWriter)); assertTrue(CustomElement.async.of(propertyWriter.getFlowElement()).get()); assertTrue(CallActivityPropertyWriter.class.isInstance(propertyWriter)); assertTrue(CustomElement.slaDueDate.of(propertyWriter.getFlowElement()).get().contains(SLA_DUE_DATE)); }
|
DecisionComponentsView implements DecisionComponents.View { @Override public void hideLoading() { hide(loading); } @Inject DecisionComponentsView(final HTMLSelectElement drgElementFilter,
final HTMLInputElement termFilter,
final HTMLDivElement list,
final HTMLDivElement emptyState,
final HTMLDivElement loading,
final HTMLDivElement componentsCounter,
final TranslationService translationService); @PostConstruct void init(); @Override void init(final DecisionComponents presenter); @EventHandler("term-filter") void onTermFilterChange(final KeyUpEvent e); @Override void clear(); @Override void addListItem(final HTMLElement htmlElement); @Override void showEmptyState(); @Override void showLoading(); @Override void hideLoading(); @Override void disableFilterInputs(); @Override void enableFilterInputs(); @Override void setComponentsCounter(final Integer count); }
|
@Test public void testHideLoading() { loading.classList = mock(DOMTokenList.class); view.hideLoading(); verify(loading.classList).add(HIDDEN_CSS_CLASS); }
|
ArtifactsConverter { public PropertyWriter toElement(Node<View<BaseArtifacts>, ?> node) { return NodeMatch.fromNode(BaseArtifacts.class, PropertyWriter.class) .when(TextAnnotation.class, this::toTextAnnotation) .when(DataObject.class, this::toDataObjectAnnotation) .ignore(Object.class) .apply(node) .value(); } ArtifactsConverter(PropertyWriterFactory propertyWriterFactory); PropertyWriter toElement(Node<View<BaseArtifacts>, ?> node); }
|
@Test public void toTextAnnotationElement() { textAnnotation = new TextAnnotation(); textAnnotation.getGeneral().getDocumentation().setValue(DOC); textAnnotation.getGeneral().getName().setValue(NAME); textAnnotationNode = new NodeImpl<>(UUID.uuid()); textAnnotationNode.setContent(textAnnotationView); when(textAnnotationView.getDefinition()).thenReturn(textAnnotation); when(propertyWriterFactory.of(any(org.eclipse.bpmn2.TextAnnotation.class))).thenReturn(textAnnotationWriter); artifactsConverter = new ArtifactsConverter(propertyWriterFactory); PropertyWriter propertyWriter = artifactsConverter.toElement(((NodeImpl) textAnnotationNode)); verify(textAnnotationWriter).setName(NAME); verify(textAnnotationWriter).setDocumentation(DOC); verify(textAnnotationWriter).setAbsoluteBounds(textAnnotationNode); assertEquals(textAnnotationWriter, propertyWriter); }
@Test public void toDataObjectElement() { dataObject = new DataObject(); dataObject.getGeneral().getDocumentation().setValue(DOC); dataObject.setName(new Name(NAME)); dataObject.setType(new DataObjectType(new DataObjectTypeValue(NAME))); dataObjectNode = new NodeImpl<>(UUID.uuid()); dataObjectNode.setContent(dataObjectView); when(dataObjectView.getDefinition()).thenReturn(dataObject); when(propertyWriterFactory.of(any(org.eclipse.bpmn2.DataObjectReference.class))).thenReturn(dataObjectWriter); artifactsConverter = new ArtifactsConverter(propertyWriterFactory); PropertyWriter propertyWriter = artifactsConverter.toElement(((NodeImpl) dataObjectNode)); verify(dataObjectWriter).setName(NAME); verify(dataObjectWriter).setType(NAME); verify(dataObjectWriter).setAbsoluteBounds(dataObjectNode); assertEquals(dataObjectWriter, propertyWriter); }
|
AssociationConverter { public Result<BasePropertyWriter> toFlowElement(Edge<?, ?> edge, ElementContainer process) { ViewConnector<Association> connector = (ViewConnector<Association>) edge.getContent(); Association definition = connector.getDefinition(); org.eclipse.bpmn2.Association association = bpmn2.createAssociation(); AssociationPropertyWriter p = propertyWriterFactory.of(association); association.setId(edge.getUUID()); BasePropertyWriter pSrc = process.getChildElement(edge.getSourceNode().getUUID()); BasePropertyWriter pTgt = process.getChildElement(edge.getTargetNode().getUUID()); if (pSrc == null || pTgt == null) { String msg = String.format("BasePropertyWriter was not found for source node or target node at edge: %s, pSrc = %s, pTgt = %s", edge.getUUID(), pSrc, pTgt); LOG.debug(msg); return Result.failure(msg); } p.setSource(pSrc); p.setTarget(pTgt); p.setConnection(connector); BPMNGeneralSet general = definition.getGeneral(); p.setDocumentation(general.getDocumentation().getValue()); p.setDirectionAssociation(definition); return Result.of(p); } AssociationConverter(PropertyWriterFactory propertyWriterFactory); Result<BasePropertyWriter> toFlowElement(Edge<?, ?> edge, ElementContainer process); }
|
@Test public void testToFlowElementSuccess() { org.kie.workbench.common.stunner.bpmn.definition.Association association = new org.kie.workbench.common.stunner.bpmn.definition.DirectionalAssociation(); association.setGeneral(new BPMNGeneralSet("nameValue", "documentationValue")); when(connector.getDefinition()).thenReturn(association); Result<BasePropertyWriter> result = converter.toFlowElement(edge, process); assertTrue(result.isSuccess()); verify(propertyWriterFactory).of(argumentCaptor.capture()); assertEquals(EDGE_ID, argumentCaptor.getValue().getId()); verify(associationPropertyWriter).setSource(pSrc); verify(associationPropertyWriter).setTarget(pTgt); verify(associationPropertyWriter).setConnection(connector); verify(associationPropertyWriter).setDocumentation("documentationValue"); verify(associationPropertyWriter).setDirectionAssociation(association); }
@Test public void testToFlowElementWithSourceMissingFailure() { when(process.getChildElement(SOURCE_NODE_ID)).thenReturn(null); Result<BasePropertyWriter> result = converter.toFlowElement(edge, process); verifyFailure(String.format(ERROR_PATTERN, EDGE_ID, null, pTgt), result); }
@Test public void testToFlowElementWithTargetMissingFailure() { when(process.getChildElement(TARGET_NODE_ID)).thenReturn(null); Result<BasePropertyWriter> result = converter.toFlowElement(edge, process); verifyFailure(String.format(ERROR_PATTERN, EDGE_ID, pSrc, null), result); }
@Test public void testToFlowElementWithSourceAndTargetMissingFailure() { when(process.getChildElement(SOURCE_NODE_ID)).thenReturn(null); when(process.getChildElement(TARGET_NODE_ID)).thenReturn(null); Result<BasePropertyWriter> result = converter.toFlowElement(edge, process); verifyFailure(String.format(ERROR_PATTERN, EDGE_ID, null, null), result); }
|
DecisionComponentsView implements DecisionComponents.View { @Override public void disableFilterInputs() { termFilter.value = ""; getDrgElementFilter().selectpicker("val", ""); disableFilterInputs(true); } @Inject DecisionComponentsView(final HTMLSelectElement drgElementFilter,
final HTMLInputElement termFilter,
final HTMLDivElement list,
final HTMLDivElement emptyState,
final HTMLDivElement loading,
final HTMLDivElement componentsCounter,
final TranslationService translationService); @PostConstruct void init(); @Override void init(final DecisionComponents presenter); @EventHandler("term-filter") void onTermFilterChange(final KeyUpEvent e); @Override void clear(); @Override void addListItem(final HTMLElement htmlElement); @Override void showEmptyState(); @Override void showLoading(); @Override void hideLoading(); @Override void disableFilterInputs(); @Override void enableFilterInputs(); @Override void setComponentsCounter(final Integer count); }
|
@Test public void testDisableFilterInputs() { final JQuerySelectPicker selectPicker = mock(JQuerySelectPicker.class); doReturn(selectPicker).when(view).getDrgElementFilter(); termFilter.value = "something"; view.disableFilterInputs(); assertEquals("", termFilter.value); assertTrue(termFilter.disabled); assertTrue(drgElementFilter.disabled); verify(selectPicker).selectpicker("val", ""); verify(selectPicker).selectpicker("refresh"); }
|
RootProcessConverter { public ProcessPropertyWriter convertProcess() { ProcessPropertyWriter processRoot = convertProcessNode(context.firstNode()); delegate.convertChildNodes(processRoot, context); delegate.convertEdges(processRoot, context); delegate.postConvertChildNodes(processRoot, context); return processRoot; } RootProcessConverter(DefinitionsBuildingContext context,
PropertyWriterFactory propertyWriterFactory,
ConverterFactory converterFactory); ProcessPropertyWriter convertProcess(); }
|
@Test public void convertProcessWithCaseProperties() { final ProcessPropertyWriter propertyWriter = converter.convertProcess(); verify(propertyWriter).setCaseIdPrefix(caseIdPrefix); verify(propertyWriter).setCaseRoles(caseRoles); verify(propertyWriter).setCaseFileVariables(caseFileVariables); }
@Test public void convertProcessWithExecutable() { final ProcessPropertyWriter propertyWriter = converter.convertProcess(); verify(propertyWriter).setExecutable(anyBoolean()); }
@Test public void convertProcessWithGlobalVariables() { final ProcessPropertyWriter propertyWriter = converter.convertProcess(); verify(propertyWriter).setGlobalVariables(any(GlobalVariables.class)); }
@Test public void convertProcessWithImports() { final ProcessPropertyWriter propertyWriter = converter.convertProcess(); verify(propertyWriter).setDefaultImports(anyListOf(DefaultImport.class)); }
@Test public void convertProcessWithSlaDueDate() { final ProcessPropertyWriter propertyWriter = converter.convertProcess(); verify(propertyWriter).setSlaDueDate(any(SLADueDate.class)); }
|
ProcessConverterDelegate { void postConvertChildNodes(ProcessPropertyWriter processWriter, DefinitionsBuildingContext context) { final Map<String, BasePropertyWriter> propertyWriters = collectPropertyWriters(processWriter); context.nodes().forEach(node -> converterFactory.flowElementPostConverter().postConvert(processWriter, propertyWriters.get(node.getUUID()), node)); } ProcessConverterDelegate(ConverterFactory converterFactory); }
|
@Test @SuppressWarnings("unchecked") public void testPostConvertNodes() { TestingGraphMockHandler graphTestHandler = new TestingGraphMockHandler(); BPMNDiagramImpl bpmnDiagram = new BPMNDiagramImpl(); StartNoneEvent level0StartNode = new StartNoneEvent(); EndNoneEvent level0EndNode = new EndNoneEvent(); UserTask level0Node1 = new UserTask(); UserTask level0Node2 = new UserTask(); EmbeddedSubprocess level1SubProcess1 = new EmbeddedSubprocess(); ScriptTask level1Node1 = new ScriptTask(); IntermediateSignalEventThrowing level1Node2 = new IntermediateSignalEventThrowing(); AdHocSubprocess level2SubProcess1 = new AdHocSubprocess(); BusinessRuleTask level2Node1 = new BusinessRuleTask(); EndCompensationEvent level2Node2 = new EndCompensationEvent(); TestingGraphInstanceBuilder2.Level2Graph level2Graph = TestingGraphInstanceBuilder2.buildLevel2Graph(graphTestHandler, bpmnDiagram, level0StartNode, level0Node1, level0Node2, level0EndNode, level1SubProcess1, level1Node1, level1Node2, level2SubProcess1, level2Node1, level2Node2); DefinitionsBuildingContext ctx = new DefinitionsBuildingContext(level2Graph.graph); PropertyWriterFactory writerFactory = new PropertyWriterFactory(); ConverterFactory factory = spy(new ConverterFactory(ctx, writerFactory)); FlowElementPostConverter flowElementPostConverter = mock(FlowElementPostConverter.class); when(factory.flowElementPostConverter()).thenReturn(flowElementPostConverter); MyProcessConverter abstractProcessConverter = new MyProcessConverter(factory); ProcessPropertyWriter processWriter = writerFactory.of(bpmn2.createProcess()); abstractProcessConverter.postConvertChildNodes(processWriter, ctx); verify(flowElementPostConverter, times(10)).postConvert(anyObject(), anyObject(), nodeCaptor.capture()); Map<String, BPMNViewDefinition> nodes = new HashMap<>(); nodes.put(LEVEL0_START_NODE.uuid(), level0StartNode); nodes.put(LEVEL0_NODE1.uuid(), level0Node1); nodes.put(LEVEL0_NODE2.uuid(), level0Node2); nodes.put(LEVEL0_END_NODE.uuid(), level0EndNode); nodes.put(LEVEL1_SUB_PROCESS1.uuid(), level1SubProcess1); nodes.put(LEVEL1_NODE1.uuid(), level1Node1); nodes.put(LEVEL1_NODE2.uuid(), level1Node2); nodes.put(LEVEL2_SUB_PROCESS1.uuid(), level2SubProcess1); nodes.put(LEVEL2_NODE1.uuid(), level2Node1); nodes.put(LEVEL2_NODE2.uuid(), level2Node2); assertEquals(nodes.size(), nodeCaptor.getAllValues().size()); nodes.entrySet().forEach(entry -> { Optional<Node<View<? extends BPMNViewDefinition>, ?>> processed = nodeCaptor.getAllValues() .stream() .filter(captured -> entry.getKey().equals(captured.getUUID())) .findFirst(); assertTrue("Node: " + entry.getKey() + " was not present in result", processed.isPresent()); assertEquals(entry.getValue(), processed.get().getContent().getDefinition()); }); }
|
EventSubProcessPostConverter implements PostConverterProcessor { @Override public void process(ProcessPropertyWriter processWriter, BasePropertyWriter nodeWriter, Node<View<? extends BPMNViewDefinition>, ?> node) { boolean isForCompensation = GraphUtils.getChildNodes(node).stream() .filter(currentNode -> currentNode.getContent() instanceof View && ((View) currentNode.getContent()).getDefinition() instanceof StartCompensationEvent) .findFirst() .isPresent(); if (isForCompensation) { ((SubProcess) nodeWriter.getElement()).setIsForCompensation(true); } } @Override void process(ProcessPropertyWriter processWriter,
BasePropertyWriter nodeWriter,
Node<View<? extends BPMNViewDefinition>, ?> node); }
|
@Test @SuppressWarnings("unchecked") public void testProcessWhenIsForCompensation() { outEdges.add(mockEdge(mock(Node.class), newNode(new StartCompensationEvent()))); converter.process(processWriter, nodeWriter, eventSubprocessNode); verify(subProcess).setIsForCompensation(true); }
@Test @SuppressWarnings("unchecked") public void testProcessWhenIsNotForCompensation() { converter.process(processWriter, nodeWriter, eventSubprocessNode); verify(subProcess, never()).setIsForCompensation(true); }
|
SubProcessConverter extends ProcessConverterDelegate { protected SubProcessPropertyWriter convertAdHocSubprocessNode(Node<View<BaseAdHocSubprocess>, ?> n) { org.eclipse.bpmn2.AdHocSubProcess process = bpmn2.createAdHocSubProcess(); process.setId(n.getUUID()); AdHocSubProcessPropertyWriter p = propertyWriterFactory.of(process); BaseAdHocSubprocess definition = n.getContent().getDefinition(); BPMNGeneralSet general = definition.getGeneral(); p.setName(general.getName().getValue()); p.setDocumentation(general.getDocumentation().getValue()); BaseProcessData processData = definition.getProcessData(); p.setProcessVariables(processData.getProcessVariables()); BaseAdHocSubprocessTaskExecutionSet executionSet = definition.getExecutionSet(); p.setAdHocActivationCondition(executionSet.getAdHocActivationCondition()); p.setAdHocCompletionCondition(executionSet.getAdHocCompletionCondition()); p.setAdHocOrdering(executionSet.getAdHocOrdering()); p.setOnEntryAction(executionSet.getOnEntryAction()); p.setOnExitAction(executionSet.getOnExitAction()); p.setAsync(executionSet.getIsAsync().getValue()); p.setSlaDueDate(executionSet.getSlaDueDate()); p.setSimulationSet(definition.getSimulationSet()); p.setAbsoluteBounds(n); p.setAdHocAutostart(executionSet.getAdHocAutostart().getValue()); return p; } SubProcessConverter(DefinitionsBuildingContext context,
PropertyWriterFactory propertyWriterFactory,
ConverterFactory converterFactory); Result<SubProcessPropertyWriter> convertSubProcess(Node<View<? extends BPMNViewDefinition>, ?> node); }
|
@Test public void testConvertAdHocSubprocessNode_autostart() { final AdHocSubprocess definition = new AdHocSubprocess(); definition.getExecutionSet().setAdHocAutostart(new AdHocAutostart(true)); final View<BaseAdHocSubprocess> view = new ViewImpl<>(definition, Bounds.create()); final Node<View<BaseAdHocSubprocess>, ?> node = new NodeImpl<>(UUID.randomUUID().toString()); node.setContent(view); SubProcessPropertyWriter writer = tested.convertAdHocSubprocessNode(node); assertTrue(AdHocSubProcessPropertyWriter.class.isInstance(writer)); assertTrue(CustomElement.autoStart.of(writer.getFlowElement()).get()); }
@Test public void testConvertAdHocSubprocessNode_notautostart() { final AdHocSubprocess definition = new AdHocSubprocess(); definition.getExecutionSet().setAdHocAutostart(new AdHocAutostart(false)); final View<BaseAdHocSubprocess> view = new ViewImpl<>(definition, Bounds.create()); final Node<View<BaseAdHocSubprocess>, ?> node = new NodeImpl<>(UUID.randomUUID().toString()); node.setContent(view); SubProcessPropertyWriter writer = tested.convertAdHocSubprocessNode(node); assertTrue(AdHocSubProcessPropertyWriter.class.isInstance(writer)); assertFalse(CustomElement.autoStart.of(writer.getFlowElement()).get()); }
|
DecisionComponentsView implements DecisionComponents.View { @Override public void enableFilterInputs() { disableFilterInputs(false); } @Inject DecisionComponentsView(final HTMLSelectElement drgElementFilter,
final HTMLInputElement termFilter,
final HTMLDivElement list,
final HTMLDivElement emptyState,
final HTMLDivElement loading,
final HTMLDivElement componentsCounter,
final TranslationService translationService); @PostConstruct void init(); @Override void init(final DecisionComponents presenter); @EventHandler("term-filter") void onTermFilterChange(final KeyUpEvent e); @Override void clear(); @Override void addListItem(final HTMLElement htmlElement); @Override void showEmptyState(); @Override void showLoading(); @Override void hideLoading(); @Override void disableFilterInputs(); @Override void enableFilterInputs(); @Override void setComponentsCounter(final Integer count); }
|
@Test public void testEnableFilterInputs() { final JQuerySelectPicker selectPicker = mock(JQuerySelectPicker.class); doReturn(selectPicker).when(view).getDrgElementFilter(); view.enableFilterInputs(); assertFalse(termFilter.disabled); assertFalse(drgElementFilter.disabled); verify(selectPicker).selectpicker("refresh"); }
|
SubProcessConverter extends ProcessConverterDelegate { public Result<SubProcessPropertyWriter> convertSubProcess(Node<View<? extends BPMNViewDefinition>, ?> node) { Result<SubProcessPropertyWriter> processRootResult = NodeMatch.fromNode(BaseSubprocess.class, SubProcessPropertyWriter.class) .when(EmbeddedSubprocess.class, this::convertEmbeddedSubprocessNode) .when(EventSubprocess.class, this::convertEventSubprocessNode) .when(BaseAdHocSubprocess.class, this::convertAdHocSubprocessNode) .when(MultipleInstanceSubprocess.class, this::convertMultipleInstanceSubprocessNode) .ignore(BPMNViewDefinition.class) .apply(node); if (processRootResult.isIgnored()) { return processRootResult; } DefinitionsBuildingContext subContext = context.withRootNode(node); SubProcessPropertyWriter processRoot = processRootResult.value(); super.convertChildNodes(processRoot, subContext); super.convertEdges(processRoot, subContext); return processRootResult; } SubProcessConverter(DefinitionsBuildingContext context,
PropertyWriterFactory propertyWriterFactory,
ConverterFactory converterFactory); Result<SubProcessPropertyWriter> convertSubProcess(Node<View<? extends BPMNViewDefinition>, ?> node); }
|
@Test public void testConvertAdhocSubprocess() { AdHocSubprocess definition = new AdHocSubprocess(); String adHocOrdering = "Parallel"; boolean adHocAutostart = true; String processVariables = "processVar1:Object,processVar2:Integer"; definition.getGeneral().getName().setValue(NAME); definition.getGeneral().getDocumentation().setValue(DOCUMENTATION); definition.getProcessData().getProcessVariables().setValue(processVariables); definition.getExecutionSet().getAdHocOrdering().setValue(adHocOrdering); definition.getExecutionSet().getAdHocAutostart().setValue(adHocAutostart); definition.getExecutionSet().getAdHocActivationCondition().setValue(ACTIVATION_CONDITION); definition.getExecutionSet().getAdHocCompletionCondition().setValue(COMPLETION_CONDITION); definition.getExecutionSet().getOnEntryAction().getValue().addValue(ON_ENTRY_ACTION); definition.getExecutionSet().getOnExitAction().getValue().addValue(ON_EXIT_ACTION); setBaseSubprocessExecutionSetValues(definition.getExecutionSet()); double nodeX1 = 10; double nodeY1 = 20; double nodeX2 = 40; double nodeY2 = 60; View<BaseAdHocSubprocess> view = new ViewImpl<>(definition, Bounds.create(nodeX1, nodeY1, nodeX2, nodeY2)); Node<View<? extends BPMNViewDefinition>, Edge> node = new NodeImpl<>(ELEMENT_ID); node.setContent(view); double parentX1 = 30; double parentY1 = 40; double parentX2 = 60; double parentY2 = 100; Node<View<? extends BPMNViewDefinition>, ?> parent = new NodeImpl<>("parentId"); View<? extends BPMNViewDefinition> parentView = new ViewImpl<>(null, Bounds.create(parentX1, parentY1, parentX2, parentY2)); parent.setContent(parentView); Edge<Child, Node> edge = new EdgeImpl("edgeId"); edge.setContent(mock(Child.class)); node.getInEdges().add(edge); edge.setSourceNode(parent); edge.setTargetNode(node); Result<SubProcessPropertyWriter> result = tested.convertSubProcess(node); assertTrue(result.isSuccess()); AdHocSubProcess adHocSubProcess = (AdHocSubProcess) result.value().getElement(); assertEquals(ELEMENT_ID, adHocSubProcess.getId()); assertEquals(NAME, adHocSubProcess.getName()); assertEquals(asCData(NAME), CustomElement.name.of(adHocSubProcess).get()); assertEquals(asCData(DOCUMENTATION), adHocSubProcess.getDocumentation().get(0).getText()); assertEquals(adHocOrdering, adHocSubProcess.getOrdering().getName()); assertEquals(adHocAutostart, CustomElement.autoStart.of(adHocSubProcess).get()); assertEquals(asCData(ACTIVATION_CONDITION), CustomElement.customActivationCondition.of(adHocSubProcess).get()); assertEquals(Scripts.LANGUAGE.valueOf(COMPLETION_CONDITION.getLanguage().toUpperCase()).format(), ((FormalExpression) adHocSubProcess.getCompletionCondition()).getLanguage()); assertEquals(asCData(COMPLETION_CONDITION.getScript()), ((FormalExpression) adHocSubProcess.getCompletionCondition()).getBody()); assertEquals(ON_ENTRY_ACTION.getLanguage(), Scripts.onEntry(adHocSubProcess.getExtensionValues()).getValues().get(0).getLanguage()); assertEquals(asCData(ON_ENTRY_ACTION.getScript()), Scripts.onEntry(adHocSubProcess.getExtensionValues()).getValues().get(0).getScript()); assertEquals(ON_EXIT_ACTION.getLanguage(), Scripts.onExit(adHocSubProcess.getExtensionValues()).getValues().get(0).getLanguage()); assertEquals(asCData(ON_EXIT_ACTION.getScript()), Scripts.onExit(adHocSubProcess.getExtensionValues()).getValues().get(0).getScript()); assertVariables(Arrays.asList(new Pair<>("processVar1", "Object"), new Pair<>("processVar2", "Integer")), adHocSubProcess.getProperties()); BPMNShape shape = result.value().getShape(); assertEquals(parentX1 + nodeX1, shape.getBounds().getX(), 0); assertEquals(parentY1 + nodeY1, shape.getBounds().getY(), 0); assertEquals(nodeX2 - nodeX1, shape.getBounds().getWidth(), 0); assertEquals(nodeY2 - nodeY1, shape.getBounds().getHeight(), 0); assertBaseSubprocessExecutionSet(result.value()); }
|
SubProcessConverter extends ProcessConverterDelegate { protected SubProcessPropertyWriter convertMultipleInstanceSubprocessNode(Node<View<MultipleInstanceSubprocess>, ?> n) { SubProcess process = bpmn2.createSubProcess(); process.setId(n.getUUID()); MultipleInstanceSubProcessPropertyWriter p = propertyWriterFactory.ofMultipleInstanceSubProcess(process); MultipleInstanceSubprocess definition = n.getContent().getDefinition(); BPMNGeneralSet general = definition.getGeneral(); p.setName(general.getName().getValue()); p.setDocumentation(general.getDocumentation().getValue()); ProcessData processData = definition.getProcessData(); p.setProcessVariables(processData.getProcessVariables()); MultipleInstanceSubprocessTaskExecutionSet executionSet = definition.getExecutionSet(); p.setIsSequential(executionSet.getMultipleInstanceExecutionMode().isSequential()); p.setCollectionInput(executionSet.getMultipleInstanceCollectionInput().getValue()); p.setInput(executionSet.getMultipleInstanceDataInput().getValue()); p.setCollectionOutput(executionSet.getMultipleInstanceCollectionOutput().getValue()); p.setOutput(executionSet.getMultipleInstanceDataOutput().getValue()); p.setCompletionCondition(executionSet.getMultipleInstanceCompletionCondition().getValue()); p.setOnEntryAction(executionSet.getOnEntryAction()); p.setOnExitAction(executionSet.getOnExitAction()); p.setAsync(executionSet.getIsAsync().getValue()); p.setSlaDueDate(executionSet.getSlaDueDate()); p.setSimulationSet(definition.getSimulationSet()); p.setAbsoluteBounds(n); return p; } SubProcessConverter(DefinitionsBuildingContext context,
PropertyWriterFactory propertyWriterFactory,
ConverterFactory converterFactory); Result<SubProcessPropertyWriter> convertSubProcess(Node<View<? extends BPMNViewDefinition>, ?> node); }
|
@Test public void testConvertMultipleIntanceSubprocess() { final MultipleInstanceSubprocess definition = new MultipleInstanceSubprocess(); setBaseSubprocessExecutionSetValues(definition.getExecutionSet()); final View<MultipleInstanceSubprocess> view = new ViewImpl<>(definition, Bounds.create()); final Node<View<MultipleInstanceSubprocess>, ?> node = new NodeImpl<>(UUID.randomUUID().toString()); node.setContent(view); SubProcessPropertyWriter writer = tested.convertMultipleInstanceSubprocessNode(node); assertBaseSubprocessExecutionSet(writer); }
|
SubProcessConverter extends ProcessConverterDelegate { protected SubProcessPropertyWriter convertEmbeddedSubprocessNode(Node<View<EmbeddedSubprocess>, ?> n) { SubProcess process = bpmn2.createSubProcess(); process.setId(n.getUUID()); SubProcessPropertyWriter p = propertyWriterFactory.of(process); EmbeddedSubprocess definition = n.getContent().getDefinition(); BPMNGeneralSet general = definition.getGeneral(); p.setName(general.getName().getValue()); p.setDocumentation(general.getDocumentation().getValue()); EmbeddedSubprocessExecutionSet executionSet = definition.getExecutionSet(); p.setOnEntryAction(executionSet.getOnEntryAction()); p.setOnExitAction(executionSet.getOnExitAction()); p.setAsync(executionSet.getIsAsync().getValue()); p.setSlaDueDate(executionSet.getSlaDueDate()); ProcessData processData = definition.getProcessData(); p.setProcessVariables(processData.getProcessVariables()); p.setSimulationSet(definition.getSimulationSet()); p.setAbsoluteBounds(n); return p; } SubProcessConverter(DefinitionsBuildingContext context,
PropertyWriterFactory propertyWriterFactory,
ConverterFactory converterFactory); Result<SubProcessPropertyWriter> convertSubProcess(Node<View<? extends BPMNViewDefinition>, ?> node); }
|
@Test public void testConvertEmbeddedSubprocess() { final EmbeddedSubprocess definition = new EmbeddedSubprocess(); setBaseSubprocessExecutionSetValues(definition.getExecutionSet()); final View<EmbeddedSubprocess> view = new ViewImpl<>(definition, Bounds.create()); final Node<View<EmbeddedSubprocess>, ?> node = new NodeImpl<>(UUID.randomUUID().toString()); node.setContent(view); SubProcessPropertyWriter writer = tested.convertEmbeddedSubprocessNode(node); assertBaseSubprocessExecutionSet(writer); }
|
SubProcessConverter extends ProcessConverterDelegate { protected SubProcessPropertyWriter convertEventSubprocessNode(Node<View<EventSubprocess>, ?> n) { SubProcess process = bpmn2.createSubProcess(); process.setId(n.getUUID()); SubProcessPropertyWriter p = propertyWriterFactory.of(process); EventSubprocess definition = n.getContent().getDefinition(); process.setTriggeredByEvent(true); BPMNGeneralSet general = definition.getGeneral(); p.setName(general.getName().getValue()); p.setDocumentation(general.getDocumentation().getValue()); ProcessData processData = definition.getProcessData(); p.setProcessVariables(processData.getProcessVariables()); EventSubprocessExecutionSet executionSet = definition.getExecutionSet(); p.setAsync(executionSet.getIsAsync().getValue()); p.setSlaDueDate(executionSet.getSlaDueDate()); p.setSimulationSet(definition.getSimulationSet()); p.setAbsoluteBounds(n); return p; } SubProcessConverter(DefinitionsBuildingContext context,
PropertyWriterFactory propertyWriterFactory,
ConverterFactory converterFactory); Result<SubProcessPropertyWriter> convertSubProcess(Node<View<? extends BPMNViewDefinition>, ?> node); }
|
@Test public void testConvertEventSubprocess() { final EventSubprocess definition = new EventSubprocess(); setBaseSubprocessExecutionSetValues(definition.getExecutionSet()); final View<EventSubprocess> view = new ViewImpl<>(definition, Bounds.create()); final Node<View<EventSubprocess>, ?> node = new NodeImpl<>(UUID.randomUUID().toString()); node.setContent(view); SubProcessPropertyWriter writer = tested.convertEventSubprocessNode(node); assertBaseSubprocessExecutionSet(writer); }
|
DefinitionsConverter { public Definitions toDefinitions() { Definitions definitions = bpmn2.createDefinitions(); DefinitionsPropertyWriter p = propertyWriterFactory.of(definitions); ProcessPropertyWriter pp = processConverter.convertProcess(); Node<Definition<BPMNDiagram>, ?> node = converterFactory.context.firstNode(); BPMNDiagram definition = node.getContent().getDefinition(); BaseDiagramSet diagramSet = definition.getDiagramSet(); p.setExporter("jBPM Process Modeler"); p.setExporterVersion("2.0"); p.setProcess(pp.getProcess()); p.setDiagram(pp.getBpmnDiagram()); p.setRelationship(pp.getRelationship()); p.setWSDLImports(diagramSet.getImports().getValue().getWSDLImports()); p.addAllRootElements(pp.getItemDefinitions()); p.addAllRootElements(pp.getRootElements()); p.addAllRootElements(pp.getInterfaces()); return definitions; } DefinitionsConverter(ConverterFactory converterFactory, PropertyWriterFactory propertyWriterFactory); DefinitionsConverter(Graph graph); Definitions toDefinitions(); }
|
@Test public void JBPM_7526_shouldSetExporter() { GraphNodeStoreImpl nodeStore = new GraphNodeStoreImpl(); NodeImpl x = new NodeImpl("x"); BPMNDiagramImpl diag = new BPMNDiagramImpl(); diag.setDiagramSet(new DiagramSet( new Name("x"), new Documentation("doc"), new Id("x"), new Package("org.jbpm"), new ProcessType(), new Version("1.0"), new AdHoc(false), new ProcessInstanceDescription("descr"), new Imports(), new Executable(true), new SLADueDate("") )); 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(); assertThat(definitions.getExporter()).isNotBlank(); assertThat(definitions.getExporterVersion()).isNotBlank(); }
@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); }
|
WorkItemDefinitionRemoteService implements WorkItemDefinitionService<WorkItemDefinitionRemoteRequest> { @Override public Collection<WorkItemDefinition> execute(final WorkItemDefinitionRemoteRequest request) { return fetch(lookupService, request.getUri(), request.getNames()); } WorkItemDefinitionRemoteService(); WorkItemDefinitionRemoteService(Function<String, WorkItemsHolder> lookupService); @Override Collection<WorkItemDefinition> execute(final WorkItemDefinitionRemoteRequest request); static Collection<WorkItemDefinition> fetch(final Function<String, WorkItemsHolder> lookupService,
final String serviceRepoUrl,
final String[] names); static Function<String, WorkItemsHolder> DEFAULT_LOOKUP_SERVICE; }
|
@Test public void testExecute() { Collection<WorkItemDefinition> result = tested.execute(WorkItemDefinitionRemoteRequest.build(URL, new String[]{WD1_NAME, WD2_NAME})); assertFalse(result.isEmpty()); assertEquals(2, result.size()); assertTrue(result.stream().anyMatch(w -> WD1_NAME.equals(w.getName()))); assertTrue(result.stream().anyMatch(w -> WD2_NAME.equals(w.getName()))); }
@Test public void testExecuteFiltered1() { Collection<WorkItemDefinition> result = tested.execute(WorkItemDefinitionRemoteRequest.build(URL, new String[]{WD1_NAME})); assertFalse(result.isEmpty()); assertEquals(1, result.size()); assertTrue(result.stream().anyMatch(w -> WD1_NAME.equals(w.getName()))); }
@Test public void testExecuteFiltered2() { Collection<WorkItemDefinition> result = tested.execute(WorkItemDefinitionRemoteRequest.build(URL, new String[]{WD2_NAME})); assertFalse(result.isEmpty()); assertEquals(1, result.size()); assertTrue(result.stream().anyMatch(w -> WD2_NAME.equals(w.getName()))); }
|
DecisionComponentsView implements DecisionComponents.View { @Override public void setComponentsCounter(final Integer count) { componentsCounter.textContent = count.toString(); } @Inject DecisionComponentsView(final HTMLSelectElement drgElementFilter,
final HTMLInputElement termFilter,
final HTMLDivElement list,
final HTMLDivElement emptyState,
final HTMLDivElement loading,
final HTMLDivElement componentsCounter,
final TranslationService translationService); @PostConstruct void init(); @Override void init(final DecisionComponents presenter); @EventHandler("term-filter") void onTermFilterChange(final KeyUpEvent e); @Override void clear(); @Override void addListItem(final HTMLElement htmlElement); @Override void showEmptyState(); @Override void showLoading(); @Override void hideLoading(); @Override void disableFilterInputs(); @Override void enableFilterInputs(); @Override void setComponentsCounter(final Integer count); }
|
@Test public void testSetComponentsCounter() { view.setComponentsCounter(123); assertEquals("123", componentsCounter.textContent); }
|
WorkItemDefinitionVFSLookupService implements WorkItemDefinitionService<Metadata> { @Override public Collection<WorkItemDefinition> execute(final Metadata metadata) { return search(metadata); } protected WorkItemDefinitionVFSLookupService(); @Inject WorkItemDefinitionVFSLookupService(final VFSService vfsService,
final WorkItemDefinitionResources resources); @Override Collection<WorkItemDefinition> execute(final Metadata metadata); Collection<WorkItemDefinition> search(final Metadata metadata); Collection<WorkItemDefinition> search(final Metadata metadata,
final Path root); Collection<WorkItemDefinition> get(final Metadata metadata,
final Path resource); }
|
@Test @SuppressWarnings("unchecked") public void testFilter() { Collection<WorkItemDefinition> result = tested.execute(metadata); ArgumentCaptor<DirectoryStream.Filter> filterCaptor = ArgumentCaptor.forClass(DirectoryStream.Filter.class); verify(vfsService, times(1)) .newDirectoryStream(eq(path), filterCaptor.capture()); DirectoryStream.Filter<Path> filter = filterCaptor.getValue(); Path path1 = mock(Path.class); when(path1.getFileName()).thenReturn("someFile.wid"); assertTrue(filter.accept(path1)); when(path1.getFileName()).thenReturn("someFile.bpmn"); assertFalse(filter.accept(path1)); when(path1.getFileName()).thenReturn("someFile.WID"); assertTrue(filter.accept(path1)); when(path1.getFileName()).thenReturn("someFile.WiD"); assertTrue(filter.accept(path1)); }
@Test @SuppressWarnings("unchecked") public void testExecute() { Collection<WorkItemDefinition> result = tested.execute(metadata); ArgumentCaptor<DirectoryStream.Filter> filterCaptor = ArgumentCaptor.forClass(DirectoryStream.Filter.class); verify(vfsService, times(1)) .newDirectoryStream(eq(path), any(DirectoryStream.Filter.class)); assertFalse(result.isEmpty()); assertEquals(1, result.size()); WorkItemDefinition wid = result.iterator().next(); assertEquals("Email", wid.getName()); }
|
WorkItemDefinitionDeployServices { @SuppressWarnings("all") public void deploy(final Metadata metadata) { final Path root = metadata.getRoot(); final Path deployedPath = getDeployedRoot(metadata); final Path path = null != deployedPath ? deployedPath : root; synchronized (path) { if (null == getDeployedRoot(metadata)) { deployed.put(root.toURI(), root); deployServices.forEach(s -> s.deploy(metadata)); } } } protected WorkItemDefinitionDeployServices(); @Inject WorkItemDefinitionDeployServices(final @Any Instance<WorkItemDefinitionDeployService> deployServices); WorkItemDefinitionDeployServices(final Iterable<WorkItemDefinitionDeployService> deployServices,
final Map<String, Path> deployed); @SuppressWarnings("all") void deploy(final Metadata metadata); }
|
@Test public void testDeploy() { tested.deploy(METADATA1); tested.deploy(METADATA2); tested.deploy(METADATA1); tested.deploy(METADATA2); verify(service1, times(1)).deploy(eq(METADATA1)); verify(service2, times(1)).deploy(eq(METADATA1)); verify(service1, times(1)).deploy(eq(METADATA2)); verify(service2, times(1)).deploy(eq(METADATA2)); }
|
WorkItemDefinitionDefaultDeployService implements WorkItemDefinitionDeployService { @Override public void deploy(final Metadata metadata) { backendFileSystemManager .deploy(resources.resolveGlobalPath(metadata), new Assets(Arrays.stream(ASSETS) .map(asset -> assetBuilder.apply(asset, ASSETS_ROOT + asset)) .collect(Collectors.toList())), DEPLOY_MESSAGE); } protected WorkItemDefinitionDefaultDeployService(); @Inject WorkItemDefinitionDefaultDeployService(final WorkItemDefinitionResources resources,
final BackendFileSystemManager backendFileSystemManager); WorkItemDefinitionDefaultDeployService(final WorkItemDefinitionResources resources,
final BackendFileSystemManager backendFileSystemManager,
final BiFunction<String, String, Asset> assetBuilder); @Override void deploy(final Metadata metadata); }
|
@Test public void testDeployAssets() { ArgumentCaptor<Assets> assetsArgumentCaptor = ArgumentCaptor.forClass(Assets.class); tested.deploy(metadata); verify(backendFileSystemManager, times(1)) .deploy(eq(globalPath), assetsArgumentCaptor.capture(), anyString()); Collection<Asset> assets = assetsArgumentCaptor.getValue().getAssets(); assertEquals(WorkItemDefinitionDefaultDeployService.ASSETS.length, assets.size()); assertTrue(assets.contains(widAsset)); assertTrue(assets.contains(emailIcon)); assertTrue(assets.contains(brIcon)); assertTrue(assets.contains(decisionIcon)); assertTrue(assets.contains(logIcon)); assertTrue(assets.contains(serviceNodeIcon)); assertTrue(assets.contains(milestoneNodeIcon)); }
|
WorkItemDefinitionParser { public static Collection<WorkItemDefinition> parse(final String content, final Function<WorkDefinitionImpl, String> uriProvider, final Function<String, String> dataUriProvider) throws Exception { final Map<String, WorkDefinitionImpl> definitionMap = parseJBPMWorkItemDefinitions(content, dataUriProvider); return definitionMap.values().stream() .map(wid -> parse(wid, uriProvider, dataUriProvider)) .collect(Collectors.toList()); } static Collection<WorkItemDefinition> parse(final String content,
final Function<WorkDefinitionImpl, String> uriProvider,
final Function<String, String> dataUriProvider); static WorkItemDefinition parse(final WorkDefinitionImpl workDefinition,
final Function<WorkDefinitionImpl, String> uriProvider,
final Function<String, String> dataUriProvider); static String buildDataURIFromURL(final String url); static final Map<Class<?>, Function<Object, String>> DATA_TYPE_FORMATTERS; static final String ENCODING; }
|
@Test public void testParseJBPMWorkDefinition() { WorkItemDefinition workItemDefinition = WorkItemDefinitionParser.parse(jbpmWorkDefinition, w -> "uri", dataUriProvider); assertNotNull(workItemDefinition); assertEquals(NAME, workItemDefinition.getName()); assertEquals(CATWGORY, workItemDefinition.getCategory()); assertEquals(DESC, workItemDefinition.getDescription()); assertEquals(DISPLAY_NAME, workItemDefinition.getDisplayName()); assertEquals(DOC, workItemDefinition.getDocumentation()); assertEquals(HANDLER, workItemDefinition.getDefaultHandler()); assertEquals(ICON_DATA, workItemDefinition.getIconDefinition().getIconData()); assertEquals("|param1:String,param2:String|", workItemDefinition.getParameters()); assertEquals("||", workItemDefinition.getResults()); }
@Test public void testEmailWorkItemDefinition() throws Exception { when(dataUriProvider.apply(eq("email.gif"))).thenReturn(ICON_DATA); String raw = loadStream(WID_EMAIL); Collection<WorkItemDefinition> workItemDefinitions = WorkItemDefinitionParser.parse(raw, w -> "uri", dataUriProvider); assertNotNull(workItemDefinitions); assertEquals(1, workItemDefinitions.size()); WorkItemDefinition workItemDefinition = workItemDefinitions.iterator().next(); assertNotNull(workItemDefinition); assertEquals("Email", workItemDefinition.getName()); assertEquals("Communication", workItemDefinition.getCategory()); assertEquals("Sending emails", workItemDefinition.getDescription()); assertEquals("Email", workItemDefinition.getDisplayName()); assertEquals("index.html", workItemDefinition.getDocumentation()); assertEquals("org.jbpm.process.workitem.email.EmailWorkItemHandler", workItemDefinition.getDefaultHandler()); assertEquals(ICON_DATA, workItemDefinition.getIconDefinition().getIconData()); assertEquals("|Body:String,From:String,Subject:String,To:String|", workItemDefinition.getParameters()); assertEquals("||", workItemDefinition.getResults()); }
@Test public void testFTPWorkItemDefinition() throws Exception { when(dataUriProvider.apply(eq("ftp.gif"))).thenReturn(ICON_DATA); String raw = loadStream(WID_FTP); Collection<WorkItemDefinition> workItemDefinitions = WorkItemDefinitionParser.parse(raw, w -> "uri", dataUriProvider); assertNotNull(workItemDefinitions); assertEquals(1, workItemDefinitions.size()); WorkItemDefinition workItemDefinition = workItemDefinitions.iterator().next(); assertNotNull(workItemDefinition); assertEquals("FTP", workItemDefinition.getName()); assertEquals("File System", workItemDefinition.getCategory()); assertEquals("Sending files using FTP", workItemDefinition.getDescription()); assertEquals("FTP", workItemDefinition.getDisplayName()); assertEquals("", workItemDefinition.getDocumentation()); assertEquals("org.jbpm.process.workitem.ftp.FTPUploadWorkItemHandler", workItemDefinition.getDefaultHandler()); assertEquals(ICON_DATA, workItemDefinition.getIconDefinition().getIconData()); assertEquals("|Body:String,FilePath:String,Password:String,User:String|", workItemDefinition.getParameters()); assertEquals("||", workItemDefinition.getResults()); }
|
BPMNRuleFlowProjectProfile extends BPMNRuleFlowProfile implements ProjectProfile { @Override public String getProjectProfileName() { return Profile.PLANNER_AND_RULES.getName(); } @Override String getProjectProfileName(); }
|
@Test public void testProfile() { BPMNRuleFlowProjectProfile profile = new BPMNRuleFlowProjectProfile(); assertEquals(new BPMNRuleFlowProfile().getProfileId(), profile.getProfileId()); assertEquals(Profile.PLANNER_AND_RULES.getName(), profile.getProjectProfileName()); }
|
FindBpmnProcessIdsQuery extends AbstractFindIdsQuery { @Override protected ResourceType getProcessIdResourceType() { return ResourceType.BPMN2; } @Override String getName(); static final String NAME; }
|
@Test public void testGetProcessIdResourceType() throws Exception { assertEquals(tested.getProcessIdResourceType(), ResourceType.BPMN2); }
|
CaseGraphFactoryImpl extends BPMNGraphFactoryImpl { @Override public Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata) { workItemDefinitionService.execute(metadata); return super.build(uuid, definition); } CaseGraphFactoryImpl(); @Inject CaseGraphFactoryImpl(DefinitionManager definitionManager, FactoryManager factoryManager,
RuleManager ruleManager, GraphCommandManager graphCommandManager,
GraphCommandFactory graphCommandFactory, GraphIndexBuilder<?> indexBuilder,
CustomTaskFactory customTaskFactory,
WorkItemDefinitionLookupService workItemDefinitionService); @Override Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata); }
|
@Test public void build() { tested.build("uuid", "def", projectMetadata); verify(workItemDefinitionService).execute(projectMetadata); }
|
DecisionComponentsItemView implements DecisionComponentsItem.View { @Override public void setIcon(final String iconURI) { icon.src = iconURI; } @Inject DecisionComponentsItemView(final HTMLImageElement icon,
final @Named("h5") HTMLHeadingElement name,
final HTMLParagraphElement file,
final DMNShapeSet dmnShapeSet,
final SessionManager sessionManager,
final ShapeGlyphDragHandler shapeGlyphDragHandler,
final Event<BuildCanvasShapeEvent> buildCanvasShapeEvent,
final HTMLDivElement decisionComponentItem,
final Event<NotificationEvent> notificationEvent,
final ClientTranslationService clientTranslationService); @Override void init(final DecisionComponentsItem presenter); @Override void setIcon(final String iconURI); @Override void setName(final String name); @Override void setFile(final String file); @Override void setIsImported(final boolean imported); @EventHandler("decision-component-item") void decisionComponentItemMouseDown(final MouseDownEvent mouseDownEvent); }
|
@Test public void testSetIcon() { final String iconURI = "http: icon.src = "something"; view.setIcon(iconURI); assertEquals(iconURI, icon.src); }
|
CaseGraphFactoryImpl extends BPMNGraphFactoryImpl { @Override protected List<Command> buildInitialisationCommands() { final List<Command> commands = new ArrayList<>(); final Node<Definition<BPMNDiagram>, Edge> diagramNode = (Node<Definition<BPMNDiagram>, Edge>) factoryManager.newElement(UUID.uuid(), getDefinitionId(getDiagramType())); commands.add(graphCommandFactory.addNode(diagramNode)); final AdHoc adHoc = diagramNode.getContent().getDefinition().getDiagramSet().getAdHoc(); adHoc.setValue(true); return commands; } CaseGraphFactoryImpl(); @Inject CaseGraphFactoryImpl(DefinitionManager definitionManager, FactoryManager factoryManager,
RuleManager ruleManager, GraphCommandManager graphCommandManager,
GraphCommandFactory graphCommandFactory, GraphIndexBuilder<?> indexBuilder,
CustomTaskFactory customTaskFactory,
WorkItemDefinitionLookupService workItemDefinitionService); @Override Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata); }
|
@Test @SuppressWarnings("all") public void buildInitialisationCommands() { final List<Command> commands = tested.buildInitialisationCommands(); assertEquals(1, commands.size()); final AddNodeCommand addNodeCommand = (AddNodeCommand) commands.get(0); assertEquals(addNodeCommand.getCandidate(), diagramNode); }
|
BPMNDelegateGraphFactory implements BPMNGraphFactory { @Override public void setDiagramType(Class<? extends BPMNDiagram> diagramType) { bpmnGraphFactory.setDiagramType(diagramType); caseGraphFactory.setDiagramType(diagramType); } @Inject BPMNDelegateGraphFactory(final BPMNGraphFactoryImpl bpmnGraphFactory,
final CaseGraphFactoryImpl caseGraphFactory); @Override boolean isDelegateFactory(); @Override void setDiagramType(Class<? extends BPMNDiagram> diagramType); @Override Class<? extends ElementFactory> getFactoryType(); @Override Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata); @Override Graph<DefinitionSet, Node> build(String uuid, String definition); @Override boolean accepts(String source); }
|
@Test public void setDiagramType() { tested.setDiagramType(BPMNDiagramImpl.class); verify(bpmnGraphFactory).setDiagramType(BPMNDiagramImpl.class); verify(caseGraphFactory).setDiagramType(BPMNDiagramImpl.class); }
|
BPMNDelegateGraphFactory implements BPMNGraphFactory { @Override public Class<? extends ElementFactory> getFactoryType() { return BPMNGraphFactory.class; } @Inject BPMNDelegateGraphFactory(final BPMNGraphFactoryImpl bpmnGraphFactory,
final CaseGraphFactoryImpl caseGraphFactory); @Override boolean isDelegateFactory(); @Override void setDiagramType(Class<? extends BPMNDiagram> diagramType); @Override Class<? extends ElementFactory> getFactoryType(); @Override Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata); @Override Graph<DefinitionSet, Node> build(String uuid, String definition); @Override boolean accepts(String source); }
|
@Test public void getFactoryType() { assertEquals(tested.getFactoryType(), BPMNGraphFactory.class); }
|
BPMNDelegateGraphFactory implements BPMNGraphFactory { @Override public Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata) { final Optional<ProjectType> projectType = (Objects.nonNull(metadata) && metadata instanceof ProjectMetadata) ? Optional.ofNullable(((ProjectMetadata) metadata).getProjectType()).map(ProjectType::valueOf) : Optional.empty(); return graphFactoryDelegation.get(projectType).build(uuid, definition, metadata); } @Inject BPMNDelegateGraphFactory(final BPMNGraphFactoryImpl bpmnGraphFactory,
final CaseGraphFactoryImpl caseGraphFactory); @Override boolean isDelegateFactory(); @Override void setDiagramType(Class<? extends BPMNDiagram> diagramType); @Override Class<? extends ElementFactory> getFactoryType(); @Override Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata); @Override Graph<DefinitionSet, Node> build(String uuid, String definition); @Override boolean accepts(String source); }
|
@Test public void buildCase() { when(projectMetadata.getProjectType()).thenReturn(ProjectType.CASE.name()); tested.build(GRAPH_UUID, DEFINITION, projectMetadata); verify(caseGraphFactory).build(GRAPH_UUID, DEFINITION, projectMetadata); verify(bpmnGraphFactory, never()).build(GRAPH_UUID, DEFINITION, projectMetadata); }
@Test public void buildBPMN() { when(projectMetadata.getProjectType()).thenReturn(ProjectType.BPMN.name()); tested.build(GRAPH_UUID, DEFINITION, projectMetadata); verify(caseGraphFactory, never()).build(GRAPH_UUID, DEFINITION, projectMetadata); verify(bpmnGraphFactory).build(GRAPH_UUID, DEFINITION, projectMetadata); }
@Test public void buildDefault() { tested.build(GRAPH_UUID, DEFINITION, projectMetadata); verify(caseGraphFactory, never()).build(GRAPH_UUID, DEFINITION, projectMetadata); verify(bpmnGraphFactory).build(GRAPH_UUID, DEFINITION, projectMetadata); tested.build(GRAPH_UUID, DEFINITION); verify(caseGraphFactory, never()).build(GRAPH_UUID, DEFINITION, projectMetadata); verify(bpmnGraphFactory).build(GRAPH_UUID, DEFINITION, null); final Metadata metadata = mock(Metadata.class); tested.build(GRAPH_UUID, DEFINITION, metadata); verify(caseGraphFactory, never()).build(GRAPH_UUID, DEFINITION, projectMetadata); verify(bpmnGraphFactory).build(GRAPH_UUID, DEFINITION, metadata); }
@Test public void build() { tested.build(GRAPH_UUID, DEFINITION); verify(tested).build(GRAPH_UUID, DEFINITION, null); }
|
BPMNDelegateGraphFactory implements BPMNGraphFactory { @Override public boolean accepts(String source) { return bpmnGraphFactory.accepts(source) && caseGraphFactory.accepts(source); } @Inject BPMNDelegateGraphFactory(final BPMNGraphFactoryImpl bpmnGraphFactory,
final CaseGraphFactoryImpl caseGraphFactory); @Override boolean isDelegateFactory(); @Override void setDiagramType(Class<? extends BPMNDiagram> diagramType); @Override Class<? extends ElementFactory> getFactoryType(); @Override Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata); @Override Graph<DefinitionSet, Node> build(String uuid, String definition); @Override boolean accepts(String source); }
|
@Test public void accepts() { assertTrue(tested.accepts(SOURCE)); verify(bpmnGraphFactory).accepts(SOURCE); verify(caseGraphFactory).accepts(SOURCE); }
|
BPMNDelegateGraphFactory implements BPMNGraphFactory { @Override public boolean isDelegateFactory() { return true; } @Inject BPMNDelegateGraphFactory(final BPMNGraphFactoryImpl bpmnGraphFactory,
final CaseGraphFactoryImpl caseGraphFactory); @Override boolean isDelegateFactory(); @Override void setDiagramType(Class<? extends BPMNDiagram> diagramType); @Override Class<? extends ElementFactory> getFactoryType(); @Override Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata); @Override Graph<DefinitionSet, Node> build(String uuid, String definition); @Override boolean accepts(String source); }
|
@Test public void isDelegateFactory() { assertTrue(tested.isDelegateFactory()); }
|
ConditionParser { public Condition parse() throws ParseException { parseReturnSentence(); functionName = parseFunctionName(); functionName = functionName.substring(KIE_FUNCTIONS.length()); List<FunctionDef> functionDefs = FunctionsRegistry.getInstance().getFunctions(functionName); if (functionDefs.isEmpty()) { throw new ParseException(errorMessage(FUNCTION_NAME_NOT_RECOGNIZED_ERROR, functionName), parseIndex); } ParseException lastTryException = null; for (FunctionDef functionDef : functionDefs) { try { reset(); return parse(functionDef); } catch (ParseException e) { lastTryException = e; } } throw lastTryException; } ConditionParser(String expression); Condition parse(); static final String KIE_FUNCTIONS; }
|
@Test public void testWhiteSpaces() throws Exception { Condition expectedCondition = new Condition("between", Arrays.asList("someVariable", "value1", "value2")); char[] whiteSpaceChars = {'\n', '\t', ' ', '\r'}; String conditionTemplate = "%sreturn%sKieFunctions.between(%ssomeVariable%s,%s\"value1\"%s,%s\"value2\"%s)%s;"; String condition; for (char whiteSpace : whiteSpaceChars) { condition = String.format(conditionTemplate, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace); assertEquals(expectedCondition, new ConditionParser(condition).parse()); } conditionTemplate = "%sreturn%sKieFunctions.between(%ssomeVariable%s.%ssomeMethod%s(%s)%s,%s\"value1\"%s,%s\"value2\"%s)%s;"; for (char whiteSpace : whiteSpaceChars) { condition = String.format(conditionTemplate, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace); expectedCondition = new Condition("between", Arrays.asList("someVariable.someMethod()", "value1", "value2")); assertEquals(expectedCondition, new ConditionParser(condition).parse()); } }
|
DecisionComponentsItemView implements DecisionComponentsItem.View { @Override public void setName(final String name) { this.name.textContent = name; } @Inject DecisionComponentsItemView(final HTMLImageElement icon,
final @Named("h5") HTMLHeadingElement name,
final HTMLParagraphElement file,
final DMNShapeSet dmnShapeSet,
final SessionManager sessionManager,
final ShapeGlyphDragHandler shapeGlyphDragHandler,
final Event<BuildCanvasShapeEvent> buildCanvasShapeEvent,
final HTMLDivElement decisionComponentItem,
final Event<NotificationEvent> notificationEvent,
final ClientTranslationService clientTranslationService); @Override void init(final DecisionComponentsItem presenter); @Override void setIcon(final String iconURI); @Override void setName(final String name); @Override void setFile(final String file); @Override void setIsImported(final boolean imported); @EventHandler("decision-component-item") void decisionComponentItemMouseDown(final MouseDownEvent mouseDownEvent); }
|
@Test public void testSetName() { final String name = "name"; this.name.textContent = "something"; view.setName(name); assertEquals(name, this.name.textContent); }
|
ConditionGenerator { public String generateScript(Condition condition) throws GenerateConditionException { if (condition == null) { throw new GenerateConditionException(MISSING_CONDITION_ERROR); } if (!isValidFunction(condition.getFunction())) { throw new GenerateConditionException(MessageFormat.format(FUNCTION_NOT_FOUND_ERROR, condition.getFunction())); } final String function = condition.getFunction().trim(); final StringBuilder script = new StringBuilder(); script.append("return "); script.append(ConditionParser.KIE_FUNCTIONS); script.append(function); script.append("("); boolean first = true; for (String param : condition.getParams()) { if (param == null || param.isEmpty()) { throw new GenerateConditionException(PARAMETER_NULL_EMPTY); } if (first) { script.append(param); first = false; } else { script.append(", "); script.append("\""); script.append(escapeJavaNonUTFChars(param)); script.append("\""); } } script.append(");"); return script.toString(); } String generateScript(Condition condition); }
|
@Test public void testMissingConditionError() throws Exception { ConditionGenerator generator = new ConditionGenerator(); expectedException.expectMessage("A condition must be provided"); generator.generateScript(null); }
@Test public void testFunctionNotFoundError() throws Exception { ConditionGenerator generator = new ConditionGenerator(); Condition condition = new Condition("SomeNonExistingFunction"); expectedException.expectMessage("Function SomeNonExistingFunction was not found in current functions definitions"); generator.generateScript(condition); }
@Test public void testParamIsNullError() throws Exception { ConditionGenerator generator = new ConditionGenerator(); Condition condition = new Condition("startsWith"); condition.addParam("variable"); condition.addParam(null); expectedException.expectMessage("Parameter can not be null nor empty"); generator.generateScript(condition); }
|
ParsingUtils { public static String parseJavaName(final String token, final int startIndex, final char[] stopCharacters) throws ParseException { if (startIndex < 0 || startIndex >= token.length()) { throw new IndexOutOfBoundsException("startIndex: " + startIndex + " exceeds token bounds: " + token); } final StringBuilder javaName = new StringBuilder(); char currentChar; int currentIndex = startIndex; while (currentIndex < token.length()) { currentChar = token.charAt(currentIndex); if (ArrayUtils.contains(stopCharacters, currentChar)) { break; } else { javaName.append(currentChar); } currentIndex++; } if (javaName.length() == 0) { throw new ParseException("Expected java name was not found at position: " + startIndex, startIndex); } else if (!SourceVersion.isName(javaName)) { throw new ParseException("Invalid java name was found at position: " + startIndex, startIndex); } return javaName.toString(); } static String parseJavaName(final String token, final int startIndex, final char[] stopCharacters); }
|
@Test(expected = IndexOutOfBoundsException.class) public void testParseJavaNameWithLowerOutOfBounds() throws ParseException { String someString = "a1234"; char[] someStopCharacters = {}; ParsingUtils.parseJavaName(someString, -1, someStopCharacters); }
@Test(expected = IndexOutOfBoundsException.class) public void testParseJavaNameWithHigherOutOfBounds() throws ParseException { String someString = "a1234"; char[] someStopCharacters = {}; ParsingUtils.parseJavaName(someString, someString.length(), someStopCharacters); }
|
FormGenerationModelProviderHelper { @SuppressWarnings("unchecked") public Definitions generate(final Diagram diagram) throws IOException { DiagramMarshaller diagramMarshaller = backendService.getDiagramMarshaller(); return ((BaseDirectDiagramMarshaller) diagramMarshaller).marshallToBpmn2Definitions(diagram); } FormGenerationModelProviderHelper(final AbstractDefinitionSetService backendService); @SuppressWarnings("unchecked") Definitions generate(final Diagram diagram); }
|
@Test @SuppressWarnings("unchecked") public void testGenerate_masharller() throws Exception { when(backendService.getDiagramMarshaller()).thenReturn(newMarshaller); tested.generate(diagram); verify(newMarshaller, times(1)).marshallToBpmn2Definitions(eq(diagram)); }
|
BPMNFormGenerationModelProvider implements FormGenerationModelProvider<Definitions> { @Override public boolean accepts(final Diagram diagram) { return this.definitionSetId.equals(diagram.getMetadata().getDefinitionSetId()); } protected BPMNFormGenerationModelProvider(); @Inject BPMNFormGenerationModelProvider(final DefinitionUtils definitionUtils,
final BPMNFormGenerationModelProviderHelper formGenerationModelProviderHelper); @PostConstruct void init(); @Override boolean accepts(final Diagram diagram); @Override Definitions generate(final Diagram diagram); }
|
@Test public void testAccepts() { assertTrue(tested.accepts(diagram)); }
|
BPMNFormGenerationModelProvider implements FormGenerationModelProvider<Definitions> { @Override public Definitions generate(final Diagram diagram) throws IOException { return formGenerationModelProviderHelper.generate(diagram); } protected BPMNFormGenerationModelProvider(); @Inject BPMNFormGenerationModelProvider(final DefinitionUtils definitionUtils,
final BPMNFormGenerationModelProviderHelper formGenerationModelProviderHelper); @PostConstruct void init(); @Override boolean accepts(final Diagram diagram); @Override Definitions generate(final Diagram diagram); }
|
@Test @SuppressWarnings("unchecked") public void testGenerateForBPMNDDirectDiagramMarshaller() throws Exception { when(bpmnDirectDiagramMarshaller.marshallToBpmn2Definitions(diagram)).thenReturn(definitions); when(bpmnBackendService.getDiagramMarshaller()).thenReturn(bpmnDirectDiagramMarshaller); Definitions result = tested.generate(diagram); verify(bpmnDirectDiagramMarshaller, times(1)).marshallToBpmn2Definitions(eq(diagram)); assertEquals(result, definitions); }
|
RuleFlowGroupDataService { public List<RuleFlowGroup> getRuleFlowGroupNames() { return queryService.getRuleFlowGroupNames(); } @Inject RuleFlowGroupDataService(final RuleFlowGroupQueryService queryService,
final Event<RuleFlowGroupDataEvent> dataChangedEvent); List<RuleFlowGroup> getRuleFlowGroupNames(); }
|
@Test public void testGetRuleFlowGroupNames() { List<RuleFlowGroup> names = tested.getRuleFlowGroupNames(); assertRightRuleFlowGroupNames(names); }
|
RuleFlowGroupDataService { void fireData() { final RuleFlowGroup[] groupNames = getRuleFlowGroupNames().toArray(new RuleFlowGroup[0]); dataChangedEvent.fire(new RuleFlowGroupDataEvent(groupNames)); } @Inject RuleFlowGroupDataService(final RuleFlowGroupQueryService queryService,
final Event<RuleFlowGroupDataEvent> dataChangedEvent); List<RuleFlowGroup> getRuleFlowGroupNames(); }
|
@Test public void testFireData() { tested.fireData(); ArgumentCaptor<RuleFlowGroupDataEvent> ec = ArgumentCaptor.forClass(RuleFlowGroupDataEvent.class); verify(dataChangedEvent, times(1)).fire(ec.capture()); RuleFlowGroupDataEvent event = ec.getValue(); assertRightRuleFlowGroups(event.getGroups()); }
|
DecisionComponentsItemView implements DecisionComponentsItem.View { @Override public void setFile(final String file) { this.file.textContent = file; } @Inject DecisionComponentsItemView(final HTMLImageElement icon,
final @Named("h5") HTMLHeadingElement name,
final HTMLParagraphElement file,
final DMNShapeSet dmnShapeSet,
final SessionManager sessionManager,
final ShapeGlyphDragHandler shapeGlyphDragHandler,
final Event<BuildCanvasShapeEvent> buildCanvasShapeEvent,
final HTMLDivElement decisionComponentItem,
final Event<NotificationEvent> notificationEvent,
final ClientTranslationService clientTranslationService); @Override void init(final DecisionComponentsItem presenter); @Override void setIcon(final String iconURI); @Override void setName(final String name); @Override void setFile(final String file); @Override void setIsImported(final boolean imported); @EventHandler("decision-component-item") void decisionComponentItemMouseDown(final MouseDownEvent mouseDownEvent); }
|
@Test public void testSetFile() { final String file = "file"; this.file.textContent = "something"; view.setFile(file); assertEquals(file, this.file.textContent); }
|
RuleFlowGroupDataService { @Inject public RuleFlowGroupDataService(final RuleFlowGroupQueryService queryService, final Event<RuleFlowGroupDataEvent> dataChangedEvent) { this.queryService = queryService; this.dataChangedEvent = dataChangedEvent; } @Inject RuleFlowGroupDataService(final RuleFlowGroupQueryService queryService,
final Event<RuleFlowGroupDataEvent> dataChangedEvent); List<RuleFlowGroup> getRuleFlowGroupNames(); }
|
@Test public void testRuleFlowGroupDataService() { RuleFlowGroupDataService tested = spy(new RuleFlowGroupDataService(queryService, dataChangedEvent)); tested.onRequestRuleFlowGroupDataEvent(new RequestRuleFlowGroupDataEvent()); verify(tested).fireData(); }
|
BPMNDiagramProjectService implements BPMNDiagramService { @Override public ProjectType getProjectType(Path projectRootPath) { try (DirectoryStream<org.uberfire.java.nio.file.Path> paths = ioService.newDirectoryStream(Paths.convert(projectRootPath), f -> f.getFileName().toString().startsWith("."))) { return ProjectType.fromFileName(StreamSupport.stream(paths.spliterator(), false) .map(Paths::convert) .map(Path::getFileName) .findFirst() ).orElse(null); } } @Inject BPMNDiagramProjectService(final @Named("ioStrategy") IOService ioService); BPMNDiagramProjectService(); @Override ProjectType getProjectType(Path projectRootPath); }
|
@Test public void getProjectTypeCase() { final ProjectType projectType = tested.getProjectType(projectPath); assertEquals(ProjectType.CASE, projectType); }
@Test public void getProjectTypeNull() { when(directoryStream.spliterator()).thenReturn(Collections.<Path>emptyList().spliterator()); final ProjectType projectType = tested.getProjectType(projectPath); assertNull(projectType); }
|
RuleFlowGroupQueryService { @SuppressWarnings("unchecked") private static RuleFlowGroup getValue(final RefactoringPageRow row) { Map<String, String> values = (Map<String, String>) row.getValue(); String name = values.get("name"); if (StringUtils.isEmpty(name)) { return null; } RuleFlowGroup group = new RuleFlowGroup(name); group.setFileName(values.get("filename")); group.setPathUri(values.get("pathuri")); return group; } RuleFlowGroupQueryService(); @Inject RuleFlowGroupQueryService(final RefactoringQueryService queryService); RuleFlowGroupQueryService(final RefactoringQueryService queryService,
final Function<List<RefactoringPageRow>, List<RuleFlowGroup>> resultToSelectorData); List<RuleFlowGroup> getRuleFlowGroupNames(); static final Function<List<RefactoringPageRow>, List<RuleFlowGroup>> DEFAULT_RESULT_CONVERTER; }
|
@Test @SuppressWarnings("unchecked") public void testDefaultResultConverter() { RefactoringPageRow row1 = mock(RefactoringPageRow.class); when(row1.getValue()).thenReturn(asMap("row1")); RefactoringPageRow row2 = mock(RefactoringPageRow.class); when(row2.getValue()).thenReturn(asMap("row2")); RefactoringPageRow row3 = mock(RefactoringPageRow.class); when(row3.getValue()).thenReturn(asMap("row3")); RefactoringPageRow row4 = mock(RefactoringPageRow.class); when(row4.getValue()).thenReturn(asMap("row4")); RefactoringPageRow row4_2 = mock(RefactoringPageRow.class); when(row4_2.getValue()).thenReturn(asMap("row4")); RefactoringPageRow emptyRow1 = mock(RefactoringPageRow.class); when(emptyRow1.getValue()).thenReturn(asMap("")); RefactoringPageRow emptyRow2 = mock(RefactoringPageRow.class); when(emptyRow2.getValue()).thenReturn(asMap("")); List<RefactoringPageRow> rows = Arrays.asList(row1, row2, row3, row4, row4_2, emptyRow1, emptyRow2); List<RuleFlowGroup> result = RuleFlowGroupQueryService.DEFAULT_RESULT_CONVERTER.apply(rows); assertEquals(5, result.size()); RuleFlowGroup group1 = new RuleFlowGroup("row1"); RuleFlowGroup group2 = new RuleFlowGroup("row2"); RuleFlowGroup group3 = new RuleFlowGroup("row3"); RuleFlowGroup group4 = new RuleFlowGroup("row4"); assertTrue(result.contains(group1)); assertTrue(result.contains(group2)); assertTrue(result.contains(group3)); assertTrue(result.contains(group4)); }
|
BpmnProcessDataEventListener extends AbstractBpmnProcessDataEventListener { protected ResourceType getProcessIdResourceType() { return ResourceType.BPMN2; } }
|
@Test public void testGetProcessIdResourceType() throws Exception { assertEquals(tested.getProcessIdResourceType(), ResourceType.BPMN2); }
|
BpmnProcessDataEventListener extends AbstractBpmnProcessDataEventListener { protected ResourceType getProcessNameResourceType() { return ResourceType.BPMN2_NAME; } }
|
@Test public void testGetProcessNameResourceType() throws Exception { assertEquals(tested.getProcessNameResourceType(), ResourceType.BPMN2_NAME); }
|
WorkItemDefinitionProjectService implements WorkItemDefinitionLookupService { @Produces @Default public WorkItemDefinitionRegistry getRegistry() { return registry; } @SuppressWarnings("all") protected WorkItemDefinitionProjectService(); @Inject WorkItemDefinitionProjectService(final WorkItemDefinitionCacheRegistry registry,
final WorkItemDefinitionVFSLookupService vfsService,
final WorkItemDefinitionDeployServices deployServices); WorkItemDefinitionProjectService(final WorkItemDefinitionCacheRegistry registry,
final WorkItemDefinitionVFSLookupService vfsService,
final WorkItemDefinitionDeployServices deployServices,
final BiPredicate<Metadata, Collection<WorkItemDefinition>> deployPredicate); @Produces @Default WorkItemDefinitionRegistry getRegistry(); @Override Collection<WorkItemDefinition> execute(final Metadata metadata); @PreDestroy void destroy(); }
|
@Test public void testGetRegistry() { assertEquals(registry, tested.getRegistry()); }
|
WorkItemDefinitionProjectService implements WorkItemDefinitionLookupService { @Override public Collection<WorkItemDefinition> execute(final Metadata metadata) { return load(metadata).items(); } @SuppressWarnings("all") protected WorkItemDefinitionProjectService(); @Inject WorkItemDefinitionProjectService(final WorkItemDefinitionCacheRegistry registry,
final WorkItemDefinitionVFSLookupService vfsService,
final WorkItemDefinitionDeployServices deployServices); WorkItemDefinitionProjectService(final WorkItemDefinitionCacheRegistry registry,
final WorkItemDefinitionVFSLookupService vfsService,
final WorkItemDefinitionDeployServices deployServices,
final BiPredicate<Metadata, Collection<WorkItemDefinition>> deployPredicate); @Produces @Default WorkItemDefinitionRegistry getRegistry(); @Override Collection<WorkItemDefinition> execute(final Metadata metadata); @PreDestroy void destroy(); }
|
@Test public void testExecute() { Collection<WorkItemDefinition> result = tested.execute(metadata); assertFalse(result.isEmpty()); assertEquals(2, result.size()); assertTrue(result.contains(wid1)); assertTrue(result.contains(wid2)); }
|
WorkItemDefinitionProjectService implements WorkItemDefinitionLookupService { @PreDestroy public void destroy() { registry.destroy(); } @SuppressWarnings("all") protected WorkItemDefinitionProjectService(); @Inject WorkItemDefinitionProjectService(final WorkItemDefinitionCacheRegistry registry,
final WorkItemDefinitionVFSLookupService vfsService,
final WorkItemDefinitionDeployServices deployServices); WorkItemDefinitionProjectService(final WorkItemDefinitionCacheRegistry registry,
final WorkItemDefinitionVFSLookupService vfsService,
final WorkItemDefinitionDeployServices deployServices,
final BiPredicate<Metadata, Collection<WorkItemDefinition>> deployPredicate); @Produces @Default WorkItemDefinitionRegistry getRegistry(); @Override Collection<WorkItemDefinition> execute(final Metadata metadata); @PreDestroy void destroy(); }
|
@Test public void testDestroy() { tested.execute(metadata); assertFalse(registry.isEmpty()); tested.destroy(); assertTrue(registry.isEmpty()); }
|
WorkItemDefinitionRemoteDeployService implements WorkItemDefinitionDeployService { @Override public void deploy(final Metadata metadata) { deploy(metadata, System.getProperty(PROPERTY_SERVICE_REPO), System.getProperty(PROPERTY_SERVICE_REPO_TASKNAMES)); } protected WorkItemDefinitionRemoteDeployService(); @Inject WorkItemDefinitionRemoteDeployService(final WorkItemDefinitionService<WorkItemDefinitionRemoteRequest> remoteLookupService,
final BackendFileSystemManager backendFileSystemManager,
final WorkItemDefinitionResources resources,
final WorkItemDefinitionProjectInstaller projectInstaller); WorkItemDefinitionRemoteDeployService(final WorkItemDefinitionService<WorkItemDefinitionRemoteRequest> remoteLookupService,
final BackendFileSystemManager backendFileSystemManager,
final WorkItemDefinitionResources resources,
final WorkItemDefinitionProjectInstaller projectInstaller,
final Function<WorkItemDefinition, Asset> widAssetBuilder,
final Function<WorkItemDefinition, Asset> iconAssetBuilder); @Override void deploy(final Metadata metadata); static final String PROPERTY_SERVICE_REPO; static final String PROPERTY_SERVICE_REPO_TASKNAMES; }
|
@Test public void testDeploy() { org.uberfire.java.nio.file.Path resourcePath = mock(org.uberfire.java.nio.file.Path.class); when(resources.resolveResourcesPath(eq(metadata))).thenReturn(resourcePath); tested.deploy(metadata, URL); ArgumentCaptor<Assets> assetsArgumentCaptor = ArgumentCaptor.forClass(Assets.class); verify(backendFileSystemManager, times(1)) .deploy(eq(resourcePath), assetsArgumentCaptor.capture(), anyString()); Assets assets = assetsArgumentCaptor.getValue(); assertNotNull(assets); assertEquals(2, assets.getAssets().size()); assertTrue(assets.getAssets().contains(widAsset)); assertTrue(assets.getAssets().contains(iconAsset)); }
|
DecisionComponentsItemView implements DecisionComponentsItem.View { @EventHandler("decision-component-item") public void decisionComponentItemMouseDown(final MouseDownEvent mouseDownEvent) { final DRGElement drgElement = presenter.getDrgElement(); final ShapeFactory factory = dmnShapeSet.getShapeFactory(); final Glyph glyph = factory.getGlyph(drgElement.getClass().getName()); final ShapeGlyphDragHandler.Item item = makeDragHandler(glyph); final Callback proxy = makeDragProxyCallbackImpl(drgElement, factory); shapeGlyphDragHandler.show(item, mouseDownEvent.getX(), mouseDownEvent.getY(), proxy); } @Inject DecisionComponentsItemView(final HTMLImageElement icon,
final @Named("h5") HTMLHeadingElement name,
final HTMLParagraphElement file,
final DMNShapeSet dmnShapeSet,
final SessionManager sessionManager,
final ShapeGlyphDragHandler shapeGlyphDragHandler,
final Event<BuildCanvasShapeEvent> buildCanvasShapeEvent,
final HTMLDivElement decisionComponentItem,
final Event<NotificationEvent> notificationEvent,
final ClientTranslationService clientTranslationService); @Override void init(final DecisionComponentsItem presenter); @Override void setIcon(final String iconURI); @Override void setName(final String name); @Override void setFile(final String file); @Override void setIsImported(final boolean imported); @EventHandler("decision-component-item") void decisionComponentItemMouseDown(final MouseDownEvent mouseDownEvent); }
|
@Test public void testDecisionComponentItemMouseDown() { final MouseDownEvent mouseDownEvent = mock(MouseDownEvent.class); final Callback proxy = mock(Callback.class); final DRGElement drgElement = mock(DRGElement.class); final DMNShapeFactory factory = mock(DMNShapeFactory.class); final ShapeGlyphDragHandler.Item item = mock(ShapeGlyphDragHandler.Item.class); final Glyph glyph = mock(Glyph.class); final int x = 10; final int y = 20; when(dmnShapeSet.getShapeFactory()).thenReturn(factory); when(presenter.getDrgElement()).thenReturn(drgElement); when(factory.getGlyph(any())).thenReturn(glyph); when(mouseDownEvent.getX()).thenReturn(x); when(mouseDownEvent.getY()).thenReturn(y); doReturn(proxy).when(view).makeDragProxyCallbackImpl(drgElement, factory); doReturn(item).when(view).makeDragHandler(glyph); view.decisionComponentItemMouseDown(mouseDownEvent); verify(shapeGlyphDragHandler).show(item, x, y, proxy); }
|
WorkItemDefinitionProjectInstaller { @SuppressWarnings("all") public void install(final Collection<WorkItemDefinition> items, final Metadata metadata) { final Module module = moduleService.resolveModule(metadata.getRoot()); final Path pomXMLPath = module.getPomXMLPath(); final POM projectPOM = pomService.load(pomXMLPath); if (projectPOM != null) { final Dependencies projectDependencies = projectPOM.getDependencies(); final Set<Dependency> widDependencies = items.stream() .flatMap(wid -> wid.getDependencies().stream()) .filter(d -> !projectDependencies.contains(d)) .collect(Collectors.toSet()); projectDependencies.addAll(widDependencies); pomService.save(pomXMLPath, projectPOM, metadataService.getMetadata(pomXMLPath), INSALL_MESSAGE, false); } } protected WorkItemDefinitionProjectInstaller(); @Inject WorkItemDefinitionProjectInstaller(final POMService pomService,
final MetadataService metadataService,
final KieModuleService moduleService); @SuppressWarnings("all") void install(final Collection<WorkItemDefinition> items,
final Metadata metadata); }
|
@Test public void testInstall() { KieModule module = mock(KieModule.class); Path pomXMLPath = mock(Path.class); POM pom = mock(POM.class); when(moduleService.resolveModule(eq(root))).thenReturn(module); when(module.getPomXMLPath()).thenReturn(pomXMLPath); when(pomService.load(eq(pomXMLPath))).thenReturn(pom); Dependencies dependencies = new Dependencies(Collections.emptyList()); when(pom.getDependencies()).thenReturn(dependencies); org.guvnor.common.services.shared.metadata.model.Metadata projMetadata = mock(org.guvnor.common.services.shared.metadata.model.Metadata.class); when(metadataService.getMetadata(pomXMLPath)).thenReturn(projMetadata); tested.install(Collections.singleton(WID), this.metadata); verify(pomService, times(1)) .save(eq(pomXMLPath), eq(pom), eq(projMetadata), anyString(), eq(false)); }
|
DataObjectConverter implements NodeConverter<org.eclipse.bpmn2.DataObjectReference> { @Override public Result<BpmnNode> convert(org.eclipse.bpmn2.DataObjectReference element) { return convert(element, propertyReaderFactory.of(element)); } DataObjectConverter(TypedFactoryManager typedFactoryManager, PropertyReaderFactory propertyReaderFactory); @Override Result<BpmnNode> convert(org.eclipse.bpmn2.DataObjectReference element); }
|
@Test public void convert() { final Result<BpmnNode> node = tested.convert(element); final Node<? extends View<? extends BPMNViewDefinition>, ?> value = node.value().value(); assertEquals(content, value.getContent()); assertEquals(def, value.getContent().getDefinition()); }
|
TextAnnotationConverter implements NodeConverter<org.eclipse.bpmn2.TextAnnotation> { @Override public Result<BpmnNode> convert(org.eclipse.bpmn2.TextAnnotation element) { return convert(element, propertyReaderFactory.of(element)); } TextAnnotationConverter(TypedFactoryManager typedFactoryManager, PropertyReaderFactory propertyReaderFactory); @Override Result<BpmnNode> convert(org.eclipse.bpmn2.TextAnnotation element); }
|
@Test public void convert() { final Result<BpmnNode> node = tested.convert(element); final Node<? extends View<? extends BPMNViewDefinition>, ?> value = node.value().value(); assertEquals(content, value.getContent()); assertEquals(def, value.getContent().getDefinition()); }
|
DecisionComponentsItemView implements DecisionComponentsItem.View { ShapeGlyphDragHandler.Item makeDragHandler(final Glyph glyph) { return new DragHandler(glyph); } @Inject DecisionComponentsItemView(final HTMLImageElement icon,
final @Named("h5") HTMLHeadingElement name,
final HTMLParagraphElement file,
final DMNShapeSet dmnShapeSet,
final SessionManager sessionManager,
final ShapeGlyphDragHandler shapeGlyphDragHandler,
final Event<BuildCanvasShapeEvent> buildCanvasShapeEvent,
final HTMLDivElement decisionComponentItem,
final Event<NotificationEvent> notificationEvent,
final ClientTranslationService clientTranslationService); @Override void init(final DecisionComponentsItem presenter); @Override void setIcon(final String iconURI); @Override void setName(final String name); @Override void setFile(final String file); @Override void setIsImported(final boolean imported); @EventHandler("decision-component-item") void decisionComponentItemMouseDown(final MouseDownEvent mouseDownEvent); }
|
@Test public void testMakeDragHandler() { final Glyph glyph = mock(Glyph.class); final Item item = view.makeDragHandler(glyph); assertEquals(16, item.getHeight()); assertEquals(16, item.getWidth()); assertEquals(glyph, item.getShape()); }
|
InputAssignmentReader { public AssociationDeclaration getAssociationDeclaration() { return associationDeclaration; } InputAssignmentReader(Assignment assignment, String targetName); InputAssignmentReader(ItemAwareElement source, String targetName); static Optional<InputAssignmentReader> fromAssociation(DataInputAssociation in); AssociationDeclaration getAssociationDeclaration(); }
|
@Test public void testNullBody() { final Assignment assignment = createAssignment(null); final InputAssignmentReader iar = new InputAssignmentReader(assignment, ID); final AssociationDeclaration associationDeclaration = iar.getAssociationDeclaration(); assertEquals(AssociationDeclaration.Type.FromTo, associationDeclaration.getType()); assertEquals("", associationDeclaration.getSource()); }
|
InputAssignmentReader { public static Optional<InputAssignmentReader> fromAssociation(DataInputAssociation in) { List<ItemAwareElement> sourceList = in.getSourceRef(); List<Assignment> assignmentList = in.getAssignment(); String targetName = ((DataInput) in.getTargetRef()).getName(); if (isReservedIdentifier(targetName)) { return Optional.empty(); } if (!sourceList.isEmpty()) { return Optional.of(new InputAssignmentReader(sourceList.get(0), targetName)); } else if (!assignmentList.isEmpty()) { return Optional.of(new InputAssignmentReader(assignmentList.get(0), targetName)); } else { logger.log(Level.SEVERE, MarshallingMessage.builder().message("Cannot find SourceRef or Assignment for Target ").toString() + targetName); return Optional.empty(); } } InputAssignmentReader(Assignment assignment, String targetName); InputAssignmentReader(ItemAwareElement source, String targetName); static Optional<InputAssignmentReader> fromAssociation(DataInputAssociation in); AssociationDeclaration getAssociationDeclaration(); }
|
@Test public void testNullAssociations() { when(association.getSourceRef()).thenReturn(new ArrayDelegatingEList<ItemAwareElement>() { @Override public Object[] data() { return null; } }); when(association.getAssignment()).thenReturn(new ArrayDelegatingEList<Assignment>() { @Override public Object[] data() { return null; } }); when(association.getTargetRef()).thenReturn(element); when(element.getName()).thenReturn("someName"); final Optional<InputAssignmentReader> reader = InputAssignmentReader.fromAssociation(association); assertEquals(false, reader.isPresent()); }
|
SimulationAttributeSets { public static SimulationAttributeSet of(ElementParameters eleType) { TimeParameters timeParams = eleType.getTimeParameters(); if (timeParams == null) { return new SimulationAttributeSet(); } Parameter processingTime = timeParams.getProcessingTime(); if (processingTime == null || processingTime.getParameterValue() == null || processingTime.getParameterValue().isEmpty()) { return new SimulationAttributeSet(); } ParameterValue paramValue = processingTime.getParameterValue().get(0); return Match.<ParameterValue, SimulationAttributeSet>of() .<NormalDistributionType>when(e -> e instanceof NormalDistributionType, ndt -> { SimulationAttributeSet simulationSet = new SimulationAttributeSet(); simulationSet.getMean().setValue(ndt.getMean()); simulationSet.getStandardDeviation().setValue(ndt.getStandardDeviation()); simulationSet.getDistributionType().setValue("normal"); return simulationSet; }) .<UniformDistributionType>when(e -> e instanceof UniformDistributionType, udt -> { SimulationAttributeSet simulationSet = new SimulationAttributeSet(); simulationSet.getMin().setValue(udt.getMin()); simulationSet.getMax().setValue(udt.getMax()); simulationSet.getDistributionType().setValue("uniform"); return simulationSet; }) .<PoissonDistributionType>when(e -> e instanceof PoissonDistributionType, pdt -> { SimulationAttributeSet simulationSet = new SimulationAttributeSet(); simulationSet.getMean().setValue(pdt.getMean()); simulationSet.getDistributionType().setValue("poisson"); return simulationSet; }) .apply(paramValue) .asSuccess() .value(); } static SimulationAttributeSet of(ElementParameters eleType); static ElementParameters toElementParameters(SimulationAttributeSet simulationSet); }
|
@Test public void testNullTimeParameters() { assertEquals(new SimulationAttributeSet(), SimulationAttributeSets.of(simulationParameters)); }
@Test public void testTimeParamsWithNullValue() { TimeParameters timeParameters = factory.createTimeParameters(); simulationParameters.setTimeParameters(timeParameters); assertEquals(new SimulationAttributeSet(), SimulationAttributeSets.of(simulationParameters)); }
@Test public void testTimeParamsWithEmptyParameter() { TimeParameters timeParameters = factory.createTimeParameters(); Parameter parameter = factory.createParameter(); timeParameters.setProcessingTime(parameter); simulationParameters.setTimeParameters(timeParameters); assertEquals(new SimulationAttributeSet(), SimulationAttributeSets.of(simulationParameters)); }
|
DMNDiagramsSession implements GraphsProvider { public void destroyState(final Metadata metadata) { dmnSessionStatesByPathURI.remove(getSessionKey(metadata)); } DMNDiagramsSession(); @Inject DMNDiagramsSession(final ManagedInstance<DMNDiagramsSessionState> dmnDiagramsSessionStates,
final SessionManager sessionManager,
final DMNDiagramUtils dmnDiagramUtils); void destroyState(final Metadata metadata); DMNDiagramsSessionState setState(final Metadata metadata,
final Map<String, Diagram> diagramsByDiagramElementId,
final Map<String, DMNDiagramElement> dmnDiagramsByDiagramElementId); boolean isSessionStatePresent(); DMNDiagramsSessionState getSessionState(); String getCurrentSessionKey(); String getSessionKey(final Metadata metadata); void add(final DMNDiagramElement dmnDiagram,
final Diagram stunnerDiagram); void remove(final DMNDiagramElement dmnDiagram); @Override Diagram getDiagram(final String dmnDiagramElementId); @Override String getCurrentDiagramId(); DMNDiagramElement getDMNDiagramElement(final String dmnDiagramElementId); DMNDiagramTuple getDiagramTuple(final String dmnDiagramElementId); List<DMNDiagramTuple> getDMNDiagrams(); void onDMNDiagramSelected(final @Observes DMNDiagramSelected selected); boolean belongsToCurrentSessionState(final DMNDiagramElement diagramElement); Optional<DMNDiagramElement> getCurrentDMNDiagramElement(); Optional<Diagram> getCurrentDiagram(); Diagram getDRGDiagram(); DMNDiagramElement getDRGDiagramElement(); void clear(); List<DRGElement> getModelDRGElements(); List<Import> getModelImports(); @Override boolean isGlobalGraphSelected(); @Override List<Graph> getGraphs(); List<Node> getAllNodes(); Diagram getCurrentGraphDiagram(); }
|
@Test public void testDestroyState() { assertNotNull(dmnDiagramsSession.getSessionState()); dmnDiagramsSession.destroyState(metadata); assertNull(dmnDiagramsSession.getSessionState()); }
|
TextAnnotationPropertyReader extends BasePropertyReader { public String getName() { String extendedName = CustomElement.name.of(element).get(); return ConverterUtils.isEmpty(extendedName) ? Optional.ofNullable(element.getText()).orElse("") : extendedName; } TextAnnotationPropertyReader(TextAnnotation element, BPMNDiagram diagram,
BPMNShape shape,
double resolutionFactor); String getName(); }
|
@Test public void getExtendedName() { String name = tested.getName(); assertEquals("custom", name); }
@Test public void getName() { when(element.getExtensionValues()).thenReturn(ECollections.emptyEList()); String name = tested.getName(); assertEquals("name", name); }
@Test public void getTextName() { when(element.getExtensionValues()).thenReturn(ECollections.emptyEList()); when(element.getName()).thenReturn(null); String name = tested.getName(); assertEquals("text", name); }
@Test public void getNameNull() { when(element.getExtensionValues()).thenReturn(ECollections.emptyEList()); when(element.getName()).thenReturn(null); when(element.getText()).thenReturn(null); String name = tested.getName(); assertEquals("", name); }
|
DMNDiagramsSession implements GraphsProvider { public String getCurrentSessionKey() { return Optional .ofNullable(getCurrentGraphDiagram()) .map(diagram -> getSessionKey(diagram.getMetadata())) .orElse(""); } DMNDiagramsSession(); @Inject DMNDiagramsSession(final ManagedInstance<DMNDiagramsSessionState> dmnDiagramsSessionStates,
final SessionManager sessionManager,
final DMNDiagramUtils dmnDiagramUtils); void destroyState(final Metadata metadata); DMNDiagramsSessionState setState(final Metadata metadata,
final Map<String, Diagram> diagramsByDiagramElementId,
final Map<String, DMNDiagramElement> dmnDiagramsByDiagramElementId); boolean isSessionStatePresent(); DMNDiagramsSessionState getSessionState(); String getCurrentSessionKey(); String getSessionKey(final Metadata metadata); void add(final DMNDiagramElement dmnDiagram,
final Diagram stunnerDiagram); void remove(final DMNDiagramElement dmnDiagram); @Override Diagram getDiagram(final String dmnDiagramElementId); @Override String getCurrentDiagramId(); DMNDiagramElement getDMNDiagramElement(final String dmnDiagramElementId); DMNDiagramTuple getDiagramTuple(final String dmnDiagramElementId); List<DMNDiagramTuple> getDMNDiagrams(); void onDMNDiagramSelected(final @Observes DMNDiagramSelected selected); boolean belongsToCurrentSessionState(final DMNDiagramElement diagramElement); Optional<DMNDiagramElement> getCurrentDMNDiagramElement(); Optional<Diagram> getCurrentDiagram(); Diagram getDRGDiagram(); DMNDiagramElement getDRGDiagramElement(); void clear(); List<DRGElement> getModelDRGElements(); List<Import> getModelImports(); @Override boolean isGlobalGraphSelected(); @Override List<Graph> getGraphs(); List<Node> getAllNodes(); Diagram getCurrentGraphDiagram(); }
|
@Test public void testGetCurrentSessionKey() { assertEquals(uri, dmnDiagramsSession.getCurrentSessionKey()); }
|
DMNDiagramsSession implements GraphsProvider { public List<DMNDiagramTuple> getDMNDiagrams() { return getSessionState().getDMNDiagrams(); } DMNDiagramsSession(); @Inject DMNDiagramsSession(final ManagedInstance<DMNDiagramsSessionState> dmnDiagramsSessionStates,
final SessionManager sessionManager,
final DMNDiagramUtils dmnDiagramUtils); void destroyState(final Metadata metadata); DMNDiagramsSessionState setState(final Metadata metadata,
final Map<String, Diagram> diagramsByDiagramElementId,
final Map<String, DMNDiagramElement> dmnDiagramsByDiagramElementId); boolean isSessionStatePresent(); DMNDiagramsSessionState getSessionState(); String getCurrentSessionKey(); String getSessionKey(final Metadata metadata); void add(final DMNDiagramElement dmnDiagram,
final Diagram stunnerDiagram); void remove(final DMNDiagramElement dmnDiagram); @Override Diagram getDiagram(final String dmnDiagramElementId); @Override String getCurrentDiagramId(); DMNDiagramElement getDMNDiagramElement(final String dmnDiagramElementId); DMNDiagramTuple getDiagramTuple(final String dmnDiagramElementId); List<DMNDiagramTuple> getDMNDiagrams(); void onDMNDiagramSelected(final @Observes DMNDiagramSelected selected); boolean belongsToCurrentSessionState(final DMNDiagramElement diagramElement); Optional<DMNDiagramElement> getCurrentDMNDiagramElement(); Optional<Diagram> getCurrentDiagram(); Diagram getDRGDiagram(); DMNDiagramElement getDRGDiagramElement(); void clear(); List<DRGElement> getModelDRGElements(); List<Import> getModelImports(); @Override boolean isGlobalGraphSelected(); @Override List<Graph> getGraphs(); List<Node> getAllNodes(); Diagram getCurrentGraphDiagram(); }
|
@Test public void testGetDMNDiagrams() { final List<DMNDiagramTuple> expected = asList(mock(DMNDiagramTuple.class), mock(DMNDiagramTuple.class)); doReturn(expected).when(dmnDiagramsSessionState).getDMNDiagrams(); final List<DMNDiagramTuple> actual = dmnDiagramsSession.getDMNDiagrams(); assertEquals(expected, actual); }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.