method2testcases
stringlengths 118
3.08k
|
---|
### Question:
GlobalVariablesElement extends ElementDefinition<String> { static GlobalType globalTypeDataOf(String variable) { GlobalType globalType = DroolsFactory.eINSTANCE.createGlobalType(); String[] properties = variable.split(":", -1); globalType.setIdentifier(properties[0]); globalType.setType(properties[1]); return globalType; } GlobalVariablesElement(String name); @Override String getValue(BaseElement element); @Override void setValue(BaseElement element, String value); }### Answer:
@Test public void testGlobalTypeDataOf() { GlobalVariablesElement globalVariablesElement = new GlobalVariablesElement(NAME); GlobalType globalType = globalVariablesElement.globalTypeDataOf(GLOBAL_VARIABLE); assertTrue(GLOBAL_VARIABLE.startsWith(globalType.getIdentifier())); assertTrue(GLOBAL_VARIABLE.endsWith(globalType.getType())); } |
### Question:
AssociationDeclaration { public static AssociationDeclaration fromString(String encoded) { return AssociationParser.parse(encoded); } AssociationDeclaration(Direction direction, Type type, String source, String target); static AssociationDeclaration fromString(String encoded); String getSource(); void setSource(String source); String getTarget(); void setTarget(String target); Direction getDirection(); void setDirection(Direction direction); void setType(Type type); Type getType(); @Override String toString(); }### Answer:
@Test(expected = IllegalArgumentException.class) public void testFromStringNull() { AssociationDeclaration.fromString(null); }
@Test(expected = IllegalArgumentException.class) public void testFromStringEmpty() { AssociationDeclaration.fromString(""); } |
### Question:
VariableDeclaration { public String getIdentifier() { return identifier; } VariableDeclaration(String identifier, String type); VariableDeclaration(String identifier, String type, String tags); static VariableDeclaration fromString(String encoded); String getTags(); void setTags(String tags); String getIdentifier(); void setIdentifier(String identifier); String getType(); void setType(String type); ItemDefinition getTypeDeclaration(); Property getTypedIdentifier(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }### Answer:
@Test public void testIdentifier() { String identifier = tested.getIdentifier(); assertEquals(identifier, VAR_IDENTIFIER); }
@Test public void testIdentifier() { String identifier = tested.getIdentifier(); assertEquals(VAR_IDENTIFIER, identifier); } |
### Question:
VariableDeclaration { public Property getTypedIdentifier() { return typedIdentifier; } VariableDeclaration(String identifier, String type); VariableDeclaration(String identifier, String type, String tags); static VariableDeclaration fromString(String encoded); String getTags(); void setTags(String tags); String getIdentifier(); void setIdentifier(String identifier); String getType(); void setType(String type); ItemDefinition getTypeDeclaration(); Property getTypedIdentifier(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }### Answer:
@Test public void testName() { String name = tested.getTypedIdentifier().getName(); assertEquals(name, VAR_NAME); }
@Test public void testName() { String name = tested.getTypedIdentifier().getName(); assertEquals(VAR_NAME, name); } |
### Question:
VariableDeclaration { public String getTags() { return tags; } VariableDeclaration(String identifier, String type); VariableDeclaration(String identifier, String type, String tags); static VariableDeclaration fromString(String encoded); String getTags(); void setTags(String tags); String getIdentifier(); void setIdentifier(String identifier); String getType(); void setType(String type); ItemDefinition getTypeDeclaration(); Property getTypedIdentifier(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }### Answer:
@Test public void testTags() { String tags = tested.getTags(); assertEquals(CONSTRUCTOR_TAGS, tags); } |
### Question:
VariableDeclaration { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } VariableDeclaration that = (VariableDeclaration) o; return Objects.equals(identifier, that.identifier) && Objects.equals(type, that.type) && Objects.equals(tags, that.tags); } VariableDeclaration(String identifier, String type); VariableDeclaration(String identifier, String type, String tags); static VariableDeclaration fromString(String encoded); String getTags(); void setTags(String tags); String getIdentifier(); void setIdentifier(String identifier); String getType(); void setType(String type); ItemDefinition getTypeDeclaration(); Property getTypedIdentifier(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }### Answer:
@Test public void testEquals() { VariableDeclaration comparable = new VariableDeclaration(CONSTRUCTOR_IDENTIFIER, CONSTRUCTOR_TYPE, CONSTRUCTOR_TAGS); assertEquals(tested, comparable); }
@Test public void testDataObjectEquals() { DataObject dataObject1 = mockDataObject("dataObject1"); DataObject dataObject2 = mockDataObject("dataObject2"); DataObjectImpl dataObject1Cast = (DataObjectImpl) dataObject1; DataObjectImpl dataObject2Cast = (DataObjectImpl) dataObject2; assertFalse(dataObject1Cast.equals(dataObject2Cast)); assertTrue(dataObject1Cast.equals(dataObject1Cast)); assertFalse(dataObject1Cast.equals("someString")); dataObject2 = mockDataObject("dataObject1"); dataObject2Cast = (DataObjectImpl) dataObject2; assertFalse(dataObject1Cast.equals(dataObject2Cast)); } |
### Question:
VariableDeclaration { @Override public String toString() { String tagsString = ""; if (!Strings.isNullOrEmpty(tags)) { tagsString = ":" + tags; } if (type == null || type.isEmpty()) { return typedIdentifier.getName() + tagsString; } else { return typedIdentifier.getName() + ":" + type + tagsString; } } VariableDeclaration(String identifier, String type); VariableDeclaration(String identifier, String type, String tags); static VariableDeclaration fromString(String encoded); String getTags(); void setTags(String tags); String getIdentifier(); void setIdentifier(String identifier); String getType(); void setType(String type); ItemDefinition getTypeDeclaration(); Property getTypedIdentifier(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }### Answer:
@Test public void testToString() { assertEquals(tested.toString(), CONSTRUCTOR_IDENTIFIER + ":" + CONSTRUCTOR_TYPE + ":" + CONSTRUCTOR_TAGS); assertNotEquals(tested.toString(), CONSTRUCTOR_IDENTIFIER + ":" + CONSTRUCTOR_TYPE + ":" + "[myCustomTag]"); VariableDeclaration comparable = new VariableDeclaration(CONSTRUCTOR_IDENTIFIER, CONSTRUCTOR_TYPE, null); assertEquals(comparable.toString(), CONSTRUCTOR_IDENTIFIER + ":" + CONSTRUCTOR_TYPE); comparable = new VariableDeclaration(CONSTRUCTOR_IDENTIFIER, CONSTRUCTOR_TYPE, ""); assertEquals(comparable.toString(), CONSTRUCTOR_IDENTIFIER + ":" + CONSTRUCTOR_TYPE); } |
### Question:
AssociationList { public static AssociationList fromString(String encoded) { return Optional.ofNullable(encoded) .filter(StringUtils::nonEmpty) .map(s -> new AssociationList( Arrays.stream(s.replaceAll(REGEX_DELIMITER, REPLACE_DELIMITER_AVOID_CONFLICTS) .split(REPLACED_DELIMITER)) .map(AssociationDeclaration::fromString) .collect(toList()))) .orElse(new AssociationList()); } AssociationList(List<AssociationDeclaration> inputs, List<AssociationDeclaration> outputs); AssociationList(List<AssociationDeclaration> all); AssociationList(); static AssociationList fromString(String encoded); List<AssociationDeclaration> getInputs(); AssociationDeclaration lookupInput(String id); List<AssociationDeclaration> lookupOutputs(String id); List<AssociationDeclaration> getOutputs(); @Override String toString(); static final String REGEX_DELIMITER; static final String RANDOM_DELIMITER; static final String REPLACE_DELIMITER_AVOID_CONFLICTS; static final String REPLACED_DELIMITER; }### Answer:
@Test public void fromString() { AssociationList list = tested.fromString(VALUE); assertEquals(2, list.getInputs().size()); assertEquals(2, list.getOutputs().size()); } |
### Question:
DefinitionsPropertyWriter { public void setWSDLImports(List<WSDLImport> wsdlImports) { wsdlImports.stream() .map(PropertyWriterUtils::toImport) .forEach(definitions.getImports()::add); } DefinitionsPropertyWriter(Definitions definitions); void setExporter(String exporter); void setExporterVersion(String version); void setProcess(Process process); void setDiagram(BPMNDiagram bpmnDiagram); void setRelationship(Relationship relationship); void setWSDLImports(List<WSDLImport> wsdlImports); void addAllRootElements(Collection<? extends RootElement> rootElements); Definitions getDefinitions(); }### Answer:
@Test public void setWSDLImports() { final String LOCATION = "location"; final String NAMESPACE = "namespace"; final int QTY = 10; List<WSDLImport> wsdlImports = new ArrayList<>(); for (int i = 0; i < QTY; i++) { wsdlImports.add(new WSDLImport(LOCATION + i, NAMESPACE + i)); } tested.setWSDLImports(wsdlImports); List<Import> imports = definitions.getImports(); assertEquals(QTY, imports.size()); for (int i = 0; i < QTY; i++) { assertEquals(LOCATION + i, imports.get(i).getLocation()); assertEquals(NAMESPACE + i, imports.get(i).getNamespace()); } } |
### Question:
CallActivityPropertyWriter extends MultipleInstanceActivityPropertyWriter { public void setCase(Boolean isCase) { CustomElement.isCase.of(flowElement).set(isCase); } CallActivityPropertyWriter(CallActivity activity, VariableScope variableScope, Set<DataObject> dataObjects); void setOnEntryAction(OnEntryAction onEntryAction); void setOnExitAction(OnExitAction onExitAction); void setIndependent(Boolean independent); void setAbortParent(Boolean abortParent); void setWaitForCompletion(Boolean waitForCompletion); void setAsync(Boolean async); void setCalledElement(String value); void setCase(Boolean isCase); void setAdHocAutostart(boolean autoStart); void setSlaDueDate(SLADueDate slaDueDate); }### Answer:
@Test public void testSetCase_true() throws Exception { tested.setCase(Boolean.TRUE); assertTrue(CustomElement.isCase.of(tested.getFlowElement()).get()); }
@Test public void testSetCase_false() throws Exception { tested.setCase(Boolean.FALSE); assertFalse(CustomElement.isCase.of(tested.getFlowElement()).get()); } |
### Question:
CallActivityPropertyWriter extends MultipleInstanceActivityPropertyWriter { public void setAdHocAutostart(boolean autoStart) { CustomElement.autoStart.of(flowElement).set(autoStart); } CallActivityPropertyWriter(CallActivity activity, VariableScope variableScope, Set<DataObject> dataObjects); void setOnEntryAction(OnEntryAction onEntryAction); void setOnExitAction(OnExitAction onExitAction); void setIndependent(Boolean independent); void setAbortParent(Boolean abortParent); void setWaitForCompletion(Boolean waitForCompletion); void setAsync(Boolean async); void setCalledElement(String value); void setCase(Boolean isCase); void setAdHocAutostart(boolean autoStart); void setSlaDueDate(SLADueDate slaDueDate); }### Answer:
@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()); } |
### Question:
CallActivityPropertyWriter extends MultipleInstanceActivityPropertyWriter { public void setAbortParent(Boolean abortParent) { CustomElement.abortParent.of(activity).set(abortParent); } CallActivityPropertyWriter(CallActivity activity, VariableScope variableScope, Set<DataObject> dataObjects); void setOnEntryAction(OnEntryAction onEntryAction); void setOnExitAction(OnExitAction onExitAction); void setIndependent(Boolean independent); void setAbortParent(Boolean abortParent); void setWaitForCompletion(Boolean waitForCompletion); void setAsync(Boolean async); void setCalledElement(String value); void setCase(Boolean isCase); void setAdHocAutostart(boolean autoStart); void setSlaDueDate(SLADueDate slaDueDate); }### Answer:
@Test public void testAbortParentTrue() { tested.setAbortParent(true); }
@Test public void testAbortParentFalse() { tested.setAbortParent(false); } |
### Question:
CallActivityPropertyWriter extends MultipleInstanceActivityPropertyWriter { public void setAsync(Boolean async) { CustomElement.async.of(activity).set(async); } CallActivityPropertyWriter(CallActivity activity, VariableScope variableScope, Set<DataObject> dataObjects); void setOnEntryAction(OnEntryAction onEntryAction); void setOnExitAction(OnExitAction onExitAction); void setIndependent(Boolean independent); void setAbortParent(Boolean abortParent); void setWaitForCompletion(Boolean waitForCompletion); void setAsync(Boolean async); void setCalledElement(String value); void setCase(Boolean isCase); void setAdHocAutostart(boolean autoStart); void setSlaDueDate(SLADueDate slaDueDate); }### Answer:
@Test public void testSetIsAsync() { tested.setAsync(Boolean.TRUE); assertTrue(CustomElement.async.of(tested.getFlowElement()).get()); } |
### Question:
DecisionComponentsView implements DecisionComponents.View { @PostConstruct public void init() { getDrgElementFilter().selectpicker("refresh"); getDrgElementFilter().on("hidden.bs.select", onDrgElementFilterChange()); setupTermFilterPlaceholder(); } @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); }### Answer:
@Test public void testInit() { final JQuerySelectPicker selectPicker = mock(JQuerySelectPicker.class); final CallbackFunction callback = mock(CallbackFunction.class); final String placeholder = "placeholder"; doReturn(selectPicker).when(view).getDrgElementFilter(); when(view.onDrgElementFilterChange()).thenReturn(callback); when(translationService.format(DecisionComponentsView_EnterText)).thenReturn(placeholder); termFilter.placeholder = "something"; view.init(); verify(selectPicker).selectpicker("refresh"); verify(selectPicker).on("hidden.bs.select", callback); assertEquals(placeholder, termFilter.placeholder); } |
### Question:
CallActivityPropertyWriter extends MultipleInstanceActivityPropertyWriter { public void setSlaDueDate(SLADueDate slaDueDate) { CustomElement.slaDueDate.of(flowElement).set(slaDueDate.getValue()); } CallActivityPropertyWriter(CallActivity activity, VariableScope variableScope, Set<DataObject> dataObjects); void setOnEntryAction(OnEntryAction onEntryAction); void setOnExitAction(OnExitAction onExitAction); void setIndependent(Boolean independent); void setAbortParent(Boolean abortParent); void setWaitForCompletion(Boolean waitForCompletion); void setAsync(Boolean async); void setCalledElement(String value); void setCase(Boolean isCase); void setAdHocAutostart(boolean autoStart); void setSlaDueDate(SLADueDate slaDueDate); }### Answer:
@Test public void testSetSlaDueDate() { String slaDueDate = "12/25/1983"; tested.setSlaDueDate(new SLADueDate(slaDueDate)); assertTrue(CustomElement.slaDueDate.of(tested.getFlowElement()).get().contains(slaDueDate)); } |
### Question:
PropertyWriterUtils { @SuppressWarnings("unchecked") public static Optional<Node<View, Edge>> getDockSourceNode(final Node<? extends View, ?> node) { return node.getInEdges().stream() .filter(PropertyWriterUtils::isDockEdge) .map(Edge::getSourceNode) .map(n -> (Node<View, Edge>) n) .findFirst(); } static BPMNEdge createBPMNEdge(BasePropertyWriter source,
BasePropertyWriter target,
Connection sourceConnection,
ControlPoint[] mid,
Connection targetConnection); @SuppressWarnings("unchecked") static Optional<Node<View, Edge>> getDockSourceNode(final Node<? extends View, ?> node); static Import toImport(WSDLImport wsdlImport); }### Answer:
@Test public void testGetDockSourceNodeWhenDocked() { Node<? extends View, Edge> dockSourceNode = mock(Node.class); Node<? extends View, Edge> node = mockDockedNode(dockSourceNode); Optional<Node<View, Edge>> result = PropertyWriterUtils.getDockSourceNode(node); assertTrue(result.isPresent()); assertEquals(dockSourceNode, result.get()); }
@Test public void testGetDockSourceNodeWhenNotDocked() { Node<? extends View, Edge> node = mock(Node.class); List<Edge> edges = new ArrayList<>(); when(node.getInEdges()).thenReturn(edges); Optional<Node<View, Edge>> result = PropertyWriterUtils.getDockSourceNode(node); assertFalse(result.isPresent()); } |
### Question:
PropertyWriterUtils { public static Import toImport(WSDLImport wsdlImport) { Import imp = Bpmn2Factory.eINSTANCE.createImport(); imp.setImportType("http: imp.setLocation(wsdlImport.getLocation()); imp.setNamespace(wsdlImport.getNamespace()); return imp; } static BPMNEdge createBPMNEdge(BasePropertyWriter source,
BasePropertyWriter target,
Connection sourceConnection,
ControlPoint[] mid,
Connection targetConnection); @SuppressWarnings("unchecked") static Optional<Node<View, Edge>> getDockSourceNode(final Node<? extends View, ?> node); static Import toImport(WSDLImport wsdlImport); }### Answer:
@Test public void toImport() { final String LOCATION = "location"; final String NAMESPACE = "namespace"; WSDLImport wsdlImport = new WSDLImport(LOCATION, NAMESPACE); Import imp = PropertyWriterUtils.toImport(wsdlImport); assertEquals(LOCATION, imp.getLocation()); assertEquals(NAMESPACE, imp.getNamespace()); } |
### Question:
MultipleInstanceActivityPropertyWriter extends ActivityPropertyWriter { protected ItemDefinition createItemDefinition(String name, String type) { ItemDefinition item = bpmn2.createItemDefinition(); item.setId(Ids.multiInstanceItemType(activity.getId(), name)); String varType = type.isEmpty() ? Object.class.getName() : type; item.setStructureRef(varType); return item; } 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); }### Answer:
@Test public void testCreateItemDefinitionNoType() { ItemDefinition definition = writer.createItemDefinition("variableOne", ""); assertEquals("Must Be Object Type", Object.class.getName(), definition.getStructureRef()); definition = writer.createItemDefinition("variableTwo", "java.lang.String"); assertEquals("Must Be String Type", String.class.getName(), definition.getStructureRef()); } |
### Question:
MultipleInstanceActivityPropertyWriter extends ActivityPropertyWriter { public void setInput(String name) { setInput(name, true); } 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); }### Answer:
@Test public void testSetInputNotFailed() { writer.setInput(null, false); writer.setInput("", false); assertNull(activity.getIoSpecification()); assertTrue(activity.getDataInputAssociations().isEmpty()); assertNull(activity.getLoopCharacteristics()); }
@Test public void testSetEmptyVariable() { final String emptyName = ""; writer.setInput(":", false); assertInputsInitialized(); String inputId = ACTIVITY_ID + "_" + "InputX"; String itemSubjectRef = ACTIVITY_ID + "_multiInstanceItemType_"; assertHasDataInput(activity.getIoSpecification(), inputId, itemSubjectRef, emptyName); assertDontHasDataInputAssociation(activity, INPUT_VARIABLE_ID, inputId); } |
### Question:
DecisionComponentsView implements DecisionComponents.View { @EventHandler("term-filter") public void onTermFilterChange(final KeyUpEvent e) { presenter.applyTermFilter(termFilter.value); } @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); }### Answer:
@Test public void testOnTermFilterChange() { final KeyUpEvent event = mock(KeyUpEvent.class); final String term = "term"; termFilter.value = term; view.onTermFilterChange(event); verify(presenter).applyTermFilter(term); } |
### Question:
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); }### Answer:
@Test public void testSetCompletionCondition() { writer.setCompletionCondition(COMPLETION_CONDITION); assertEquals("<![CDATA[COMPLETION_CONDITION]]>", ((FormalExpression) ((MultiInstanceLoopCharacteristics) activity.getLoopCharacteristics()).getCompletionCondition()).getBody()); } |
### Question:
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); }### Answer:
@Test public void testSetIsSequentialTrue() { writer.setIsSequential(true); assertTrue(((MultiInstanceLoopCharacteristics) activity.getLoopCharacteristics()).isIsSequential()); }
@Test public void testSetIsSequentialFalse() { writer.setIsSequential(false); assertFalse(((MultiInstanceLoopCharacteristics) activity.getLoopCharacteristics()).isIsSequential()); } |
### Question:
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(); }### Answer:
@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()); } |
### Question:
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(); }### Answer:
@Test public void setType() { tested.setType(NAME); assertEquals(NAME, reference.getDataObjectRef().getItemSubjectRef().getStructureRef()); } |
### Question:
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(); }### Answer:
@Test public void getDataObjects() { assertEquals(0, tested.getDataObjects().size()); } |
### Question:
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(); }### Answer:
@Test public void getElement() { assertEquals(reference, tested.getElement()); } |
### Question:
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); }### Answer:
@Test public void lookupNotFound() { Optional<VariableScope.Variable> variable = tested.lookup(UUID.randomUUID().toString()); assertFalse(variable.isPresent()); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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(); }### Answer:
@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"); } |
### Question:
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(); }### Answer:
@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"); } |
### Question:
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(); }### Answer:
@Test public void caseFileVariables() { CaseFileVariables caseFileVariables = new CaseFileVariables("CFV1:Boolean,CFV2:Boolean,CFV3:Boolean"); p.setCaseFileVariables(caseFileVariables); assertThat(p.itemDefinitions.size() == 3); } |
### Question:
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(); }### Answer:
@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()); } |
### Question:
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(); }### Answer:
@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]]>"); } |
### Question:
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); }### Answer:
@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)); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@Test public void testAddListItem() { final HTMLElement listItemElement = mock(HTMLElement.class); view.addListItem(listItemElement); verify(list).appendChild(listItemElement); } |
### Question:
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); }### Answer:
@Test public void testSetDefaultRoute() { testSetDefaultRoute("defaultRoute", "defaultRoute"); }
@Test public void testSetDefaultRouteNull() { propertyWriter.setDefaultRoute(null); verify(featureMap, never()).add(any()); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@Test public void testShowEmptyState() { emptyState.classList = mock(DOMTokenList.class); view.showEmptyState(); verify(emptyState.classList).remove(HIDDEN_CSS_CLASS); } |
### Question:
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); }### Answer:
@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("_")); } |
### Question:
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(); }### Answer:
@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())); } |
### Question:
TextAnnotationPropertyWriter extends PropertyWriter { @Override public TextAnnotation getElement() { return (TextAnnotation) super.getElement(); } TextAnnotationPropertyWriter(TextAnnotation element, VariableScope variableScope); void setName(String value); @Override TextAnnotation getElement(); }### Answer:
@Test public void getElement() { assertEquals(element, tested.getElement()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@Test public void testShowLoading() { loading.classList = mock(DOMTokenList.class); view.showLoading(); verify(loading.classList).remove(HIDDEN_CSS_CLASS); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@Test public void testHideLoading() { loading.classList = mock(DOMTokenList.class); view.hideLoading(); verify(loading.classList).add(HIDDEN_CSS_CLASS); } |
### Question:
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); }### Answer:
@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"); } |
### Question:
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(); }### Answer:
@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)); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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"); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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; }### Answer:
@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()))); } |
### Question:
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); }### Answer:
@Test public void testSetComponentsCounter() { view.setComponentsCounter(123); assertEquals("123", componentsCounter.textContent); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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)); } |
### Question:
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); }### Answer:
@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)); } |
### Question:
BPMNRuleFlowProjectProfile extends BPMNRuleFlowProfile implements ProjectProfile { @Override public String getProjectProfileName() { return Profile.PLANNER_AND_RULES.getName(); } @Override String getProjectProfileName(); }### Answer:
@Test public void testProfile() { BPMNRuleFlowProjectProfile profile = new BPMNRuleFlowProjectProfile(); assertEquals(new BPMNRuleFlowProfile().getProfileId(), profile.getProfileId()); assertEquals(Profile.PLANNER_AND_RULES.getName(), profile.getProjectProfileName()); } |
### Question:
FindBpmnProcessIdsQuery extends AbstractFindIdsQuery { @Override protected ResourceType getProcessIdResourceType() { return ResourceType.BPMN2; } @Override String getName(); static final String NAME; }### Answer:
@Test public void testGetProcessIdResourceType() throws Exception { assertEquals(tested.getProcessIdResourceType(), ResourceType.BPMN2); } |
### Question:
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); }### Answer:
@Test public void build() { tested.build("uuid", "def", projectMetadata); verify(workItemDefinitionService).execute(projectMetadata); } |
### Question:
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); }### Answer:
@Test public void testSetIcon() { final String iconURI = "http: icon.src = "something"; view.setIcon(iconURI); assertEquals(iconURI, icon.src); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@Test public void setDiagramType() { tested.setDiagramType(BPMNDiagramImpl.class); verify(bpmnGraphFactory).setDiagramType(BPMNDiagramImpl.class); verify(caseGraphFactory).setDiagramType(BPMNDiagramImpl.class); } |
### Question:
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); }### Answer:
@Test public void getFactoryType() { assertEquals(tested.getFactoryType(), BPMNGraphFactory.class); } |
### Question:
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); }### Answer:
@Test public void accepts() { assertTrue(tested.accepts(SOURCE)); verify(bpmnGraphFactory).accepts(SOURCE); verify(caseGraphFactory).accepts(SOURCE); } |
### Question:
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); }### Answer:
@Test public void isDelegateFactory() { assertTrue(tested.isDelegateFactory()); } |
### Question:
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; }### Answer:
@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()); } } |
### Question:
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); }### Answer:
@Test public void testSetName() { final String name = "name"; this.name.textContent = "something"; view.setName(name); assertEquals(name, this.name.textContent); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@Test @SuppressWarnings("unchecked") public void testGenerate_masharller() throws Exception { when(backendService.getDiagramMarshaller()).thenReturn(newMarshaller); tested.generate(diagram); verify(newMarshaller, times(1)).marshallToBpmn2Definitions(eq(diagram)); } |
### Question:
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); }### Answer:
@Test public void testAccepts() { assertTrue(tested.accepts(diagram)); } |
### Question:
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); }### Answer:
@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); } |
### Question:
RuleFlowGroupDataService { public List<RuleFlowGroup> getRuleFlowGroupNames() { return queryService.getRuleFlowGroupNames(); } @Inject RuleFlowGroupDataService(final RuleFlowGroupQueryService queryService,
final Event<RuleFlowGroupDataEvent> dataChangedEvent); List<RuleFlowGroup> getRuleFlowGroupNames(); }### Answer:
@Test public void testGetRuleFlowGroupNames() { List<RuleFlowGroup> names = tested.getRuleFlowGroupNames(); assertRightRuleFlowGroupNames(names); } |
### Question:
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(); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@Test public void testSetFile() { final String file = "file"; this.file.textContent = "something"; view.setFile(file); assertEquals(file, this.file.textContent); } |
### Question:
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(); }### Answer:
@Test public void testRuleFlowGroupDataService() { RuleFlowGroupDataService tested = spy(new RuleFlowGroupDataService(queryService, dataChangedEvent)); tested.onRequestRuleFlowGroupDataEvent(new RequestRuleFlowGroupDataEvent()); verify(tested).fireData(); } |
### Question:
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); }### Answer:
@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); } |
### Question:
BpmnProcessDataEventListener extends AbstractBpmnProcessDataEventListener { protected ResourceType getProcessIdResourceType() { return ResourceType.BPMN2; } }### Answer:
@Test public void testGetProcessIdResourceType() throws Exception { assertEquals(tested.getProcessIdResourceType(), ResourceType.BPMN2); } |
### Question:
BpmnProcessDataEventListener extends AbstractBpmnProcessDataEventListener { protected ResourceType getProcessNameResourceType() { return ResourceType.BPMN2_NAME; } }### Answer:
@Test public void testGetProcessNameResourceType() throws Exception { assertEquals(tested.getProcessNameResourceType(), ResourceType.BPMN2_NAME); } |
### Question:
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(); }### Answer:
@Test public void testGetRegistry() { assertEquals(registry, tested.getRegistry()); } |
### Question:
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(); }### Answer:
@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)); } |
### Question:
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(); }### Answer:
@Test public void testDestroy() { tested.execute(metadata); assertFalse(registry.isEmpty()); tested.destroy(); assertTrue(registry.isEmpty()); } |
### Question:
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; }### Answer:
@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)); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
InputAssignmentReader { public AssociationDeclaration getAssociationDeclaration() { return associationDeclaration; } InputAssignmentReader(Assignment assignment, String targetName); InputAssignmentReader(ItemAwareElement source, String targetName); static Optional<InputAssignmentReader> fromAssociation(DataInputAssociation in); AssociationDeclaration getAssociationDeclaration(); }### Answer:
@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()); } |
### Question:
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(); }### Answer:
@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()); } |
### Question:
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(); }### Answer:
@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); } |
### Question:
AssociationPropertyReader extends BasePropertyReader implements EdgePropertyReader { @Override public String getSourceId() { return association.getSourceRef().getId(); } AssociationPropertyReader(Association association,
BPMNDiagram diagram,
DefinitionResolver definitionResolver); @Override String getSourceId(); @Override String getTargetId(); Class getAssociationByDirection(); @Override Connection getSourceConnection(); @Override Connection getTargetConnection(); @Override List<Point2D> getControlPoints(); @Override DefinitionResolver getDefinitionResolver(); }### Answer:
@Test public void testGetSourceId() { assertEquals(SOURCE_ID, propertyReader.getSourceId()); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.