method2testcases
stringlengths 118
6.63k
|
---|
### Question:
AdHocSubProcessPropertyReader extends SubProcessPropertyReader { public boolean isAdHocAutostart() { return CustomElement.autoStart.of(element).get(); } AdHocSubProcessPropertyReader(AdHocSubProcess element, BPMNDiagram diagram, DefinitionResolver definitionResolver); String getAdHocActivationCondition(); ScriptTypeValue getAdHocCompletionCondition(); String getAdHocOrdering(); boolean isAdHocAutostart(); }### Answer:
@Test public void testIsAdHocAutostart_true() { String id = UUID.randomUUID().toString(); AdHocSubProcess adHocSubProcess = bpmn2.createAdHocSubProcess(); adHocSubProcess.setId(id); CustomElement.autoStart.of(adHocSubProcess).set(Boolean.TRUE); tested = new AdHocSubProcessPropertyReader(adHocSubProcess, definitionResolverReal.getDiagram(), definitionResolverReal); assertTrue(tested.isAdHocAutostart()); }
@Test public void testIsAdHocAutostart_false() { String id = UUID.randomUUID().toString(); AdHocSubProcess adHocSubProcess = bpmn2.createAdHocSubProcess(); adHocSubProcess.setId(id); CustomElement.autoStart.of(adHocSubProcess).set(Boolean.FALSE); tested = new AdHocSubProcessPropertyReader(adHocSubProcess, definitionResolverReal.getDiagram(), definitionResolverReal); assertFalse(tested.isAdHocAutostart()); } |
### Question:
AdHocSubProcessPropertyReader extends SubProcessPropertyReader { public String getAdHocActivationCondition() { return CustomElement.customActivationCondition.of(element).get(); } AdHocSubProcessPropertyReader(AdHocSubProcess element, BPMNDiagram diagram, DefinitionResolver definitionResolver); String getAdHocActivationCondition(); ScriptTypeValue getAdHocCompletionCondition(); String getAdHocOrdering(); boolean isAdHocAutostart(); }### Answer:
@Test public void testIsAdHocActivationCondition() { AdHocSubProcess adHocSubProcess = bpmn2.createAdHocSubProcess(); CustomElement.customActivationCondition.of(adHocSubProcess).set("some condition"); tested = new AdHocSubProcessPropertyReader(adHocSubProcess, definitionResolverReal.getDiagram(), definitionResolverReal); assertEquals(asCData("some condition"), tested.getAdHocActivationCondition()); } |
### Question:
ActivityPropertyReader extends FlowElementPropertyReader { public ScriptTypeListValue getOnEntryAction() { return Scripts.onEntry(element.getExtensionValues()); } ActivityPropertyReader(Activity activity, BPMNDiagram diagram, DefinitionResolver definitionResolver); ScriptTypeListValue getOnEntryAction(); ScriptTypeListValue getOnExitAction(); SimulationSet getSimulationSet(); AssignmentsInfo getAssignmentsInfo(); }### Answer:
@Test public void testGetOnEntryScript() { OnEntryScriptType onEntryScript = Mockito.mock(OnEntryScriptType.class); when(onEntryScript.getScript()).thenReturn(SCRIPT); when(onEntryScript.getScriptFormat()).thenReturn(JAVA_FORMAT); List<OnEntryScriptType> onEntryScripts = Collections.singletonList(onEntryScript); List<ExtensionAttributeValue> extensions = mockExtensions(DroolsPackage.Literals.DOCUMENT_ROOT__ON_ENTRY_SCRIPT, onEntryScripts); when(activity.getExtensionValues()).thenReturn(extensions); assertScript(JAVA, SCRIPT, reader.getOnEntryAction()); }
@Test public void testGetOnEntryScript() { OnEntryScriptType onEntryScript = Mockito.mock(OnEntryScriptType.class); when(onEntryScript.getScript()).thenReturn(SCRIPT); when(onEntryScript.getScriptFormat()).thenReturn(JAVA_FORMAT); List<OnEntryScriptType> onEntryScripts = Collections.singletonList(onEntryScript); EList<ExtensionAttributeValue> extensions = mockExtensions(DroolsPackage.Literals.DOCUMENT_ROOT__ON_ENTRY_SCRIPT, onEntryScripts); when(activity.getExtensionValues()).thenReturn(extensions); assertScript(JAVA, SCRIPT, reader.getOnEntryAction()); } |
### Question:
ActivityPropertyReader extends FlowElementPropertyReader { public ScriptTypeListValue getOnExitAction() { return Scripts.onExit(element.getExtensionValues()); } ActivityPropertyReader(Activity activity, BPMNDiagram diagram, DefinitionResolver definitionResolver); ScriptTypeListValue getOnEntryAction(); ScriptTypeListValue getOnExitAction(); SimulationSet getSimulationSet(); AssignmentsInfo getAssignmentsInfo(); }### Answer:
@Test public void testGetOnExitScript() { OnExitScriptType onExitScript = Mockito.mock(OnExitScriptType.class); when(onExitScript.getScript()).thenReturn(SCRIPT); when(onExitScript.getScriptFormat()).thenReturn(JAVA_FORMAT); List<OnExitScriptType> onExitScripts = Collections.singletonList(onExitScript); List<ExtensionAttributeValue> extensions = mockExtensions(DroolsPackage.Literals.DOCUMENT_ROOT__ON_EXIT_SCRIPT, onExitScripts); when(activity.getExtensionValues()).thenReturn(extensions); assertScript(JAVA, SCRIPT, reader.getOnExitAction()); }
@Test public void testGetOnExitScript() { OnExitScriptType onExitScript = Mockito.mock(OnExitScriptType.class); when(onExitScript.getScript()).thenReturn(SCRIPT); when(onExitScript.getScriptFormat()).thenReturn(JAVA_FORMAT); List<OnExitScriptType> onExitScripts = Collections.singletonList(onExitScript); EList<ExtensionAttributeValue> extensions = mockExtensions(DroolsPackage.Literals.DOCUMENT_ROOT__ON_EXIT_SCRIPT, onExitScripts); when(activity.getExtensionValues()).thenReturn(extensions); assertScript(JAVA, SCRIPT, reader.getOnExitAction()); } |
### Question:
DecisionComponents { void applyDrgElementFilterFilter(final String value) { getFilter().setDrgElement(value); applyFilter(); } DecisionComponents(); @Inject DecisionComponents(final View view,
final DMNIncludeModelsClient client,
final ManagedInstance<DecisionComponentsItem> itemManagedInstance,
final DecisionComponentFilter filter,
final DMNDiagramsSession dmnDiagramsSession,
final DMNGraphUtils dmnGraphUtils); @PostConstruct void init(); View getView(); void refresh(); void removeAllItems(); }### Answer:
@Test public void testApplyDrgElementFilterFilter() { final String value = "value"; doNothing().when(decisionComponents).applyFilter(); decisionComponents.applyDrgElementFilterFilter(value); verify(filter).setDrgElement(value); verify(decisionComponents).applyFilter(); } |
### Question:
AssociationConverter implements EdgeConverter<org.eclipse.bpmn2.Association> { public Result<BpmnEdge> convertEdge(org.eclipse.bpmn2.Association association, Map<String, BpmnNode> nodes) { AssociationPropertyReader p = propertyReaderFactory.of(association); Edge<View<Association>, Node> edge = factoryManager.newEdge(association.getId(), p.getAssociationByDirection()); Association definition = edge.getContent().getDefinition(); definition.setGeneral(new BPMNGeneralSet( new Name(""), new Documentation(p.getDocumentation()) )); return result(nodes, edge, p, "Association ignored from " + p.getSourceId() + " to " + p.getTargetId(), MarshallingMessageKeys.associationIgnored); } AssociationConverter(TypedFactoryManager factoryManager,
PropertyReaderFactory propertyReaderFactory); Result<BpmnEdge> convertEdge(org.eclipse.bpmn2.Association association,
Map<String, BpmnNode> nodes); }### Answer:
@Test public void testConvertEdge() { associationConverter.convertEdge(association, nodes); verify(definition).setGeneral(generalSetCaptor.capture()); assertEquals(ASSOCIATION_DOCUMENTATION, generalSetCaptor.getValue().getDocumentation().getValue()); assertEdgeWithConnections(); }
@Test public void testConvertEdgeNonDirectional() { when(factoryManager.newEdge(ASSOCIATION_ID, NonDirectionalAssociation.class)).thenReturn((Edge) edgeNonDirectional); when(associationReader.getAssociationByDirection()).thenAnswer(a -> NonDirectionalAssociation.class); when(edgeNonDirectional.getContent()).thenReturn(contentNonDirectional); when(contentNonDirectional.getDefinition()).thenReturn(definitionNonDirectional); BpmnEdge.Simple result = (BpmnEdge.Simple) associationConverter.convertEdge(association, nodes).value(); assertEquals(edgeNonDirectional, result.getEdge()); }
@Test public void testConvertIgnoredEdge() { assertEdgeWithConnections(); nodes.remove(SOURCE_ID); BpmnEdge.Simple result = (BpmnEdge.Simple) associationConverter.convertEdge(association, nodes).value(); assertNull(result); nodes.put(SOURCE_ID, sourceNode); nodes.remove(TARGET_ID); result = (BpmnEdge.Simple) associationConverter.convertEdge(association, nodes).value(); assertNull(result); nodes.put(SOURCE_ID, sourceNode); nodes.put(TARGET_ID, targetNode); assertEdgeWithConnections(); } |
### Question:
GraphBuilder { public void buildGraph(BpmnNode rootNode) { this.addNode(rootNode.value()); rootNode.getEdges().forEach(this::addEdge); List<BpmnNode> nodes = rootNode.getChildren(); Deque<BpmnNode> workingSet = new ArrayDeque<>(prioritized(nodes)); Set<BpmnNode> workedOff = new HashSet<>(); while (!workingSet.isEmpty()) { BpmnNode current = workingSet.pop(); if (workedOff.contains(current)) { continue; } workedOff.add(current); workingSet.addAll( prioritized(current.getChildren())); logger.debug("{} :: {}", current.getParent().value().getUUID(), current.value().getUUID()); this.addChildNode(current); current.getEdges().forEach(this::addEdge); } } GraphBuilder(
Graph<DefinitionSet, Node> graph,
DefinitionManager definitionManager,
TypedFactoryManager typedFactoryManager,
RuleManager ruleManager,
GraphCommandFactory commandFactory,
GraphCommandManager commandManager); void render(BpmnNode root); void buildGraph(BpmnNode rootNode); }### Answer:
@Test public void testBoundsCalculation() { double subprocess1X = 10; double subprocess1Y = 10; double subprocess1Width = 100; double subprocess1Height = 200; EmbeddedSubprocess subprocess1Definition = mock(EmbeddedSubprocess.class); Node<? extends View<? extends BPMNViewDefinition>, ?> subprocess1 = mockNode(subprocess1Definition, subprocess1X, subprocess1Y, subprocess1Width, subprocess1Height); when(subprocess1.getUUID()).thenReturn(SUBPROCESS1_ID); BpmnNode subprocess1Node = mockBpmnNode(subprocess1); double subprocess2X = 20; double subprocess2Y = 20; double subprocess2Width = 70; double subprocess2Height = 170; EmbeddedSubprocess subprocess2Definition = mock(EmbeddedSubprocess.class); Node<? extends View<? extends BPMNViewDefinition>, ?> subprocess2 = mockNode(subprocess2Definition, subprocess1X + subprocess2X, subprocess1Y + subprocess2Y, subprocess2Width, subprocess2Height); when(subprocess2.getUUID()).thenReturn(SUBPROCESS2_ID); BpmnNode subprocess2Node = mockBpmnNode(subprocess2); double subprocess3X = 30; double subprocess3Y = 30; double subprocess3Width = 30; double subprocess3Height = 120; EmbeddedSubprocess subprocess3Definition = mock(EmbeddedSubprocess.class); Node<? extends View<? extends BPMNViewDefinition>, ?> subprocess3 = mockNode(subprocess3Definition, subprocess1X + subprocess2X + subprocess3X, subprocess1Y + subprocess2Y + subprocess3Y, subprocess3Width, subprocess3Height); when(subprocess3.getUUID()).thenReturn(SUBPROCESS3_ID); BpmnNode subprocess3Node = mockBpmnNode(subprocess3); Node<? extends View<? extends BPMNViewDefinition>, ?> rootDiagram = mockNode(mock(BPMNDiagramImpl.class), 0, 0, 1000, 1000); when(rootDiagram.getUUID()).thenReturn(DIAGRAM_UUID); BpmnNode rootNode = mockBpmnNode(rootDiagram); subprocess1Node.setParent(rootNode); subprocess2Node.setParent(subprocess1Node); subprocess3Node.setParent(subprocess2Node); graphBuilder.buildGraph(rootNode); assertNodePosition(SUBPROCESS1_ID, subprocess1X, subprocess1Y); assertNodePosition(SUBPROCESS2_ID, subprocess2X, subprocess2Y); assertNodePosition(SUBPROCESS3_ID, subprocess3X, subprocess3Y); } |
### Question:
DefinitionResolver { static double obtainResolutionFactor() { final String resolution = System.getProperty(BPMN_DIAGRAM_RESOLUTION_PROPERTY); if (null != resolution && resolution.trim().length() > 0) { try { return Double.parseDouble(resolution); } catch (NumberFormatException e) { LOG.error("Error parsing the BPMN diagram's resolution - marshalling factor... " + "Using as default [" + DEFAULT_RESOLUTION + "].", e); } } return DEFAULT_RESOLUTION; } DefinitionResolver(
Definitions definitions,
Collection<WorkItemDefinition> workItemDefinitions,
boolean jbpm,
Mode mode); DefinitionResolver(Definitions definitions,
Collection<WorkItemDefinition> workItemDefinitions); BPMNDiagram getDiagram(); double getResolutionFactor(); boolean isJbpm(); Definitions getDefinitions(); Process getProcess(); Mode getMode(); Collection<WorkItemDefinition> getWorkItemDefinitions(); Optional<Signal> resolveSignal(String id); String resolveSignalName(String id); Optional<ElementParameters> resolveSimulationParameters(String id); BPMNShape getShape(String elementId); BPMNEdge getEdge(String elementId); }### Answer:
@Test public void testObtainResolutionFactor() { double factor = DefinitionResolver.obtainResolutionFactor(); assertEquals(DefinitionResolver.DEFAULT_RESOLUTION, factor, 0d); System.setProperty(DefinitionResolver.BPMN_DIAGRAM_RESOLUTION_PROPERTY, "0.25"); factor = DefinitionResolver.obtainResolutionFactor(); assertEquals(0.25d, factor, 0d); System.clearProperty(DefinitionResolver.BPMN_DIAGRAM_RESOLUTION_PROPERTY); } |
### Question:
DefinitionResolver { static double calculateResolutionFactor(final BPMNDiagram diagram) { final float resolution = diagram.getResolution(); return resolution == 0 ? 1 : obtainResolutionFactor() / resolution; } DefinitionResolver(
Definitions definitions,
Collection<WorkItemDefinition> workItemDefinitions,
boolean jbpm,
Mode mode); DefinitionResolver(Definitions definitions,
Collection<WorkItemDefinition> workItemDefinitions); BPMNDiagram getDiagram(); double getResolutionFactor(); boolean isJbpm(); Definitions getDefinitions(); Process getProcess(); Mode getMode(); Collection<WorkItemDefinition> getWorkItemDefinitions(); Optional<Signal> resolveSignal(String id); String resolveSignalName(String id); Optional<ElementParameters> resolveSimulationParameters(String id); BPMNShape getShape(String elementId); BPMNEdge getEdge(String elementId); }### Answer:
@Test public void testCalculateResolutionFactor() { BPMNDiagram diagram = mock(BPMNDiagram.class); when(diagram.getResolution()).thenReturn(0f); double factor = DefinitionResolver.calculateResolutionFactor(diagram); assertEquals(1d, factor, 0d); when(diagram.getResolution()).thenReturn(250f); factor = DefinitionResolver.calculateResolutionFactor(diagram); assertEquals(0.45d, factor, 0d); } |
### Question:
DefinitionResolver { public BPMNShape getShape(String elementId) { return definitions.getDiagrams().stream() .map(BPMNDiagram::getPlane) .map(plane -> getShape(plane, elementId)) .filter(Objects::nonNull) .findFirst().orElse(null); } DefinitionResolver(
Definitions definitions,
Collection<WorkItemDefinition> workItemDefinitions,
boolean jbpm,
Mode mode); DefinitionResolver(Definitions definitions,
Collection<WorkItemDefinition> workItemDefinitions); BPMNDiagram getDiagram(); double getResolutionFactor(); boolean isJbpm(); Definitions getDefinitions(); Process getProcess(); Mode getMode(); Collection<WorkItemDefinition> getWorkItemDefinitions(); Optional<Signal> resolveSignal(String id); String resolveSignalName(String id); Optional<ElementParameters> resolveSimulationParameters(String id); BPMNShape getShape(String elementId); BPMNEdge getEdge(String elementId); }### Answer:
@Test public void testGetShape() { BPMNShape shape = mock(BPMNShape.class); BaseElement bpmnElement = mock(BaseElement.class); when(shape.getBpmnElement()).thenReturn(bpmnElement); when(bpmnElement.getId()).thenReturn(ID); planeElement.add(shape); assertEquals(shape, definitionResolver.getShape(ID)); }
@Test public void testGetShape() { BPMNShape shape = mock(BPMNShape.class); BaseElement bpmnElement = mock(BaseElement.class); when(shape.getBpmnElement()).thenReturn(bpmnElement); when(bpmnElement.getId()).thenReturn(ID); planeElements.add(shape); assertEquals(shape, definitionResolver.getShape(ID)); } |
### Question:
DefinitionResolver { public BPMNEdge getEdge(String elementId) { return definitions.getDiagrams().stream() .map(BPMNDiagram::getPlane) .map(plane -> getEdge(plane, elementId)) .filter(Objects::nonNull) .findFirst().orElse(null); } DefinitionResolver(
Definitions definitions,
Collection<WorkItemDefinition> workItemDefinitions,
boolean jbpm,
Mode mode); DefinitionResolver(Definitions definitions,
Collection<WorkItemDefinition> workItemDefinitions); BPMNDiagram getDiagram(); double getResolutionFactor(); boolean isJbpm(); Definitions getDefinitions(); Process getProcess(); Mode getMode(); Collection<WorkItemDefinition> getWorkItemDefinitions(); Optional<Signal> resolveSignal(String id); String resolveSignalName(String id); Optional<ElementParameters> resolveSimulationParameters(String id); BPMNShape getShape(String elementId); BPMNEdge getEdge(String elementId); }### Answer:
@Test public void testGetEdge() { BPMNEdge edge = mock(BPMNEdge.class); BaseElement bpmnElement = mock(BaseElement.class); when(edge.getBpmnElement()).thenReturn(bpmnElement); when(bpmnElement.getId()).thenReturn(ID); planeElement.add(edge); assertEquals(edge, definitionResolver.getEdge(ID)); }
@Test public void testGetEdge() { BPMNEdge edge = mock(BPMNEdge.class); BaseElement bpmnElement = mock(BaseElement.class); when(edge.getBpmnElement()).thenReturn(bpmnElement); when(bpmnElement.getId()).thenReturn(ID); planeElements.add(edge); assertEquals(edge, definitionResolver.getEdge(ID)); } |
### Question:
DecisionComponents { void applyFilter() { hideAllItems(); showFilteredItems(); } DecisionComponents(); @Inject DecisionComponents(final View view,
final DMNIncludeModelsClient client,
final ManagedInstance<DecisionComponentsItem> itemManagedInstance,
final DecisionComponentFilter filter,
final DMNDiagramsSession dmnDiagramsSession,
final DMNGraphUtils dmnGraphUtils); @PostConstruct void init(); View getView(); void refresh(); void removeAllItems(); }### Answer:
@Test public void testApplyFilter() { final DecisionComponentsItem item1 = mock(DecisionComponentsItem.class); final DecisionComponentsItem item2 = mock(DecisionComponentsItem.class); final DecisionComponentsItem item3 = mock(DecisionComponentsItem.class); final DecisionComponent component1 = mock(DecisionComponent.class); final DecisionComponent component2 = mock(DecisionComponent.class); final DecisionComponent component3 = mock(DecisionComponent.class); final List<DecisionComponentsItem> decisionComponentsItems = asList(item1, item2, item3); doReturn(new DecisionComponentFilter()).when(decisionComponents).getFilter(); doReturn(decisionComponentsItems).when(decisionComponents).getDecisionComponentsItems(); when(item1.getDecisionComponent()).thenReturn(component1); when(item2.getDecisionComponent()).thenReturn(component2); when(item3.getDecisionComponent()).thenReturn(component3); when(component1.getName()).thenReturn("name3"); when(component2.getName()).thenReturn("nome!!!"); when(component3.getName()).thenReturn("name1"); decisionComponents.getFilter().setTerm("name"); decisionComponents.applyFilter(); verify(item1).hide(); verify(item2).hide(); verify(item3).hide(); verify(item3).show(); verify(item1).show(); } |
### Question:
DefinitionResolver { public Optional<ElementParameters> resolveSimulationParameters(String id) { return Optional.ofNullable(simulationParameters.get(id)); } DefinitionResolver(
Definitions definitions,
Collection<WorkItemDefinition> workItemDefinitions,
boolean jbpm,
Mode mode); DefinitionResolver(Definitions definitions,
Collection<WorkItemDefinition> workItemDefinitions); BPMNDiagram getDiagram(); double getResolutionFactor(); boolean isJbpm(); Definitions getDefinitions(); Process getProcess(); Mode getMode(); Collection<WorkItemDefinition> getWorkItemDefinitions(); Optional<Signal> resolveSignal(String id); String resolveSignalName(String id); Optional<ElementParameters> resolveSimulationParameters(String id); BPMNShape getShape(String elementId); BPMNEdge getEdge(String elementId); }### Answer:
@Test public void testSimulation() { String elementRef = "some_element_ref"; EList<Scenario> scenarios = mock(EList.class); Scenario scenario = mock(Scenario.class); when(scenarios.get(0)).thenReturn(scenario); EList<ElementParameters> parameters = mock(EList.class); ElementParameters parameter = mock(ElementParameters.class); when(parameter.getElementRef()).thenReturn(elementRef); Iterator<ElementParameters> iterator = mock(Iterator.class); when(parameters.iterator()).thenReturn(iterator); when(iterator.hasNext()).thenReturn(Boolean.TRUE, Boolean.FALSE); when(iterator.next()).thenReturn(parameter); when(scenario.getElementParameters()).thenReturn(parameters); BPSimDataType simDataType = mock(BPSimDataType.class); simData.add(simDataType); when(simDataType.getScenario()).thenReturn(scenarios); setUp(); assertEquals(parameter, definitionResolver.resolveSimulationParameters(elementRef).get()); }
@Test public void testSimulation() { String elementRef = "some_element_ref"; EList<Scenario> scenarios = ECollections.newBasicEList(); Scenario scenario = mock(Scenario.class); scenarios.add(scenario); EList<ElementParameters> parameters = ECollections.newBasicEList(); ElementParameters parameter = mock(ElementParameters.class); when(parameter.getElementRef()).thenReturn(elementRef); parameters.add(parameter); when(scenario.getElementParameters()).thenReturn(parameters); BPSimDataType simDataType = mock(BPSimDataType.class); simData.add(simDataType); when(simDataType.getScenario()).thenReturn(scenarios); setUp(); assertEquals(parameter, definitionResolver.resolveSimulationParameters(elementRef).get()); } |
### Question:
BoundaryEventConverter implements EdgeConverter<BoundaryEvent> { @Override public Result<BpmnEdge> convertEdge(BoundaryEvent event, Map<String, BpmnNode> nodes) { String parentId = event.getAttachedToRef().getId(); String childId = event.getId(); return valid(nodes, parentId, childId) ? Result.success(BpmnEdge.docked(nodes.get(parentId), nodes.get(childId))) : Result.ignored("Boundary ignored", MarshallingMessage.builder() .message("Boundary ignored") .messageKey(MarshallingMessageKeys.boundaryIgnored) .messageArguments(childId, parentId) .type(Violation.Type.WARNING) .build()); } @Override Result<BpmnEdge> convertEdge(BoundaryEvent event, Map<String, BpmnNode> nodes); }### Answer:
@Test public void convertEdge() { Map<String, BpmnNode> nodes = new Maps.Builder<String, BpmnNode>() .put(PARENT_ID, node1) .put(CHILD_ID, node2) .build(); Result<BpmnEdge> result = tested.convertEdge(event, nodes); BpmnEdge value = result.value(); assertTrue(result.isSuccess()); assertEquals(node1, value.getSource()); assertEquals(node2, value.getTarget()); assertTrue(value.isDocked()); }
@Test public void convertMissingNodes() { Map<String, BpmnNode> nodes = new HashMap<>(); Result<BpmnEdge> result = tested.convertEdge(event, nodes); BpmnEdge value = result.value(); assertTrue(result.isIgnored()); assertNull(value); } |
### Question:
FlowElementConverter extends AbstractConverter { public Result<BpmnNode> convertNode(FlowElement flowElement) { return Match.of(FlowElement.class, Result.class) .when(StartEvent.class, converterFactory.startEventConverter()::convert) .when(EndEvent.class, converterFactory.endEventConverter()::convert) .when(BoundaryEvent.class, converterFactory.intermediateCatchEventConverter()::convertBoundaryEvent) .when(IntermediateCatchEvent.class, converterFactory.intermediateCatchEventConverter()::convert) .when(IntermediateThrowEvent.class, converterFactory.intermediateThrowEventConverter()::convert) .when(Task.class, converterFactory.taskConverter()::convert) .when(Gateway.class, converterFactory.gatewayConverter()::convert) .when(SubProcess.class, converterFactory.subProcessConverter()::convertSubProcess) .when(CallActivity.class, converterFactory.callActivityConverter()::convert) .when(TextAnnotation.class, converterFactory.artifactsConverter()::convert) .when(DataObjectReference.class, converterFactory.artifactsConverter()::convert) .ignore(DataStoreReference.class) .ignore(DataStore.class) .ignore(SequenceFlow.class, null) .defaultValue(Result.ignored("FlowElement not found", getNotFoundMessage(flowElement))) .inputDecorator(BPMNElementDecorators.flowElementDecorator()) .outputDecorator(BPMNElementDecorators.resultBpmnDecorator()) .mode(getMode()) .apply(flowElement) .value(); } FlowElementConverter(BaseConverterFactory converterFactory); Result<BpmnNode> convertNode(FlowElement flowElement); }### Answer:
@Test public void convertSupported() { StartEvent startEvent = mock(StartEvent.class); tested.convertNode(startEvent); verify(startEventConverter).convert(startEvent); EndEvent endEvent = mock(EndEvent.class); tested.convertNode(endEvent); verify(endEventConverter).convert(endEvent); BoundaryEvent boundaryEvent = mock(BoundaryEvent.class); tested.convertNode(boundaryEvent); verify(eventConverter).convertBoundaryEvent(boundaryEvent); IntermediateCatchEvent intermediateCatchEvent = mock(IntermediateCatchEvent.class); tested.convertNode(intermediateCatchEvent); verify(eventConverter).convert(intermediateCatchEvent); IntermediateThrowEvent intermediateThrowEvent = mock(IntermediateThrowEvent.class); tested.convertNode(intermediateThrowEvent); verify(throwEventConverter).convert(intermediateThrowEvent); Task task = mock(Task.class); tested.convertNode(task); verify(taskConverter).convert(task); Gateway gateway = mock(Gateway.class); tested.convertNode(gateway); verify(gatewayConverter).convert(gateway); SubProcess subProcess = mock(SubProcess.class); tested.convertNode(subProcess); verify(subProcessConverter).convertSubProcess(subProcess); CallActivity callActivity = mock(CallActivity.class); tested.convertNode(callActivity); verify(callActivityConverter).convert(callActivity); TextAnnotation textAnnotation = mock(TextAnnotation.class); tested.convertNode(textAnnotation); verify(artifactsConverter).convert(textAnnotation); DataObjectReference dataObjectReference = mock(DataObjectReference.class); tested.convertNode(dataObjectReference); verify(artifactsConverter).convert(dataObjectReference); } |
### Question:
RootProcessConverter extends BaseRootProcessConverter<BPMNDiagramImpl, DiagramSet, ProcessData, AdvancedData> { @Override protected Node<View<BPMNDiagramImpl>, Edge> createNode(String id) { return delegate.factoryManager.newNode(id, BPMNDiagramImpl.class); } RootProcessConverter(TypedFactoryManager typedFactoryManager,
PropertyReaderFactory propertyReaderFactory,
DefinitionResolver definitionResolver,
BaseConverterFactory factory); }### Answer:
@Test public void testCreateNode() { assertTrue(tested.createNode("id").getContent().getDefinition() instanceof BPMNDiagramImpl); } |
### Question:
RootProcessConverter extends BaseRootProcessConverter<BPMNDiagramImpl, DiagramSet, ProcessData, AdvancedData> { @Override protected ProcessData createProcessData(String processVariables) { return new ProcessData(new ProcessVariables(processVariables)); } RootProcessConverter(TypedFactoryManager typedFactoryManager,
PropertyReaderFactory propertyReaderFactory,
DefinitionResolver definitionResolver,
BaseConverterFactory factory); }### Answer:
@Test public void testCreateProcessData() { assertNotNull(tested.createProcessData("id")); } |
### Question:
RootProcessConverter extends BaseRootProcessConverter<BPMNDiagramImpl, DiagramSet, ProcessData, AdvancedData> { @Override protected DiagramSet createDiagramSet(Process process, ProcessPropertyReader p, DefinitionsPropertyReader d) { return new DiagramSet(new Name(revertIllegalCharsAttribute(process.getName())), new Documentation(p.getDocumentation()), new Id(revertIllegalCharsAttribute(process.getId())), new Package(p.getPackage()), new ProcessType(p.getProcessType()), new Version(p.getVersion()), new AdHoc(p.isAdHoc()), new ProcessInstanceDescription(p.getDescription()), new Imports(new ImportsValue(p.getDefaultImports(), d.getWSDLImports())), new Executable(process.isIsExecutable()), new SLADueDate(p.getSlaDueDate())); } RootProcessConverter(TypedFactoryManager typedFactoryManager,
PropertyReaderFactory propertyReaderFactory,
DefinitionResolver definitionResolver,
BaseConverterFactory factory); }### Answer:
@Test public void testCreateDiagramSet() { DiagramSet diagramSet = createDiagramSet(); assertNotNull(diagramSet); }
@Test public void testImports() { DiagramSet diagramSet = createDiagramSet(); Imports imports = diagramSet.getImports(); assertNotNull(imports); ImportsValue importsValue = imports.getValue(); assertNotNull(importsValue); List<DefaultImport> defaultImports = importsValue.getDefaultImports(); assertNotNull(defaultImports); assertFalse(defaultImports.isEmpty()); DefaultImport defaultImport = defaultImports.get(0); assertNotNull(defaultImport); assertEquals(getClass().getName(), defaultImport.getClassName()); } |
### Question:
RootProcessConverter extends BaseRootProcessConverter<BPMNDiagramImpl, DiagramSet, ProcessData, AdvancedData> { @Override protected AdvancedData createAdvancedData(String globalVariables, String metaDataAttributes) { return new AdvancedData(new GlobalVariables(globalVariables), new MetaDataAttributes(metaDataAttributes)); } RootProcessConverter(TypedFactoryManager typedFactoryManager,
PropertyReaderFactory propertyReaderFactory,
DefinitionResolver definitionResolver,
BaseConverterFactory factory); }### Answer:
@Test public void createAdvancedData() { assertTrue(AdvancedData.class.isInstance(tested.createAdvancedData("id", "testßval"))); }
@Test public void convertAdvancedData() { tested.createAdvancedData("id", "testßval"); assertTrue(tested.convertProcess().isSuccess()); } |
### Question:
DecisionComponents { public void removeAllItems() { clearDecisionComponents(); } DecisionComponents(); @Inject DecisionComponents(final View view,
final DMNIncludeModelsClient client,
final ManagedInstance<DecisionComponentsItem> itemManagedInstance,
final DecisionComponentFilter filter,
final DMNDiagramsSession dmnDiagramsSession,
final DMNGraphUtils dmnGraphUtils); @PostConstruct void init(); View getView(); void refresh(); void removeAllItems(); }### Answer:
@Test public void testRemoveAllItems() { decisionComponents.removeAllItems(); verify(decisionComponents).clearDecisionComponents(); } |
### Question:
ProcessConverterDelegate { Result<Boolean> convertEdges(BpmnNode processRoot, List<BaseElement> flowElements, Map<String, BpmnNode> nodes) { List<Result<BpmnEdge>> results = flowElements.stream() .map(e -> converterFactory.edgeConverter().convertEdge(e, nodes)) .filter(Result::isSuccess) .collect(Collectors.toList()); boolean value = results.size() > 0 ? results.stream() .map(Result::value) .filter(Objects::nonNull) .map(processRoot::addEdge) .allMatch(Boolean.TRUE::equals) : false; return ResultComposer.compose(value, results); } ProcessConverterDelegate(
TypedFactoryManager typedFactoryManager,
PropertyReaderFactory propertyReaderFactory,
DefinitionResolver definitionResolver,
BaseConverterFactory factory); }### Answer:
@Test public void testConvertEdges() { Task task1 = mockTask("1"); Task task2 = mockTask("2"); BpmnNode task1Node = mockTaskNode(task1); BpmnNode task2Node = mockTaskNode(task2); SequenceFlow sequenceFlow = mockSequenceFlow("seq1", task1, task2); List<BaseElement> elements = Arrays.asList(sequenceFlow, task1, task2); assertFalse(converterDelegate.convertEdges(parentNode, elements, new HashMap<>()).value()); Map<String, BpmnNode> nodes = new Maps.Builder<String, BpmnNode>().put(task1.getId(), task1Node).put(task2.getId(), task2Node).build(); assertTrue(converterDelegate.convertEdges(parentNode, elements, nodes).value()); }
@Test public void testConvertEdgesIgnoredNonEdgeElement() { Map<String, BpmnNode> nodes = new HashMap<>(); List<BaseElement> elements = Arrays.asList(mockTask("1")); assertFalse(converterDelegate.convertEdges(parentNode, elements, nodes).value()); } |
### Question:
SubProcessConverter extends BaseSubProcessConverter<AdHocSubprocess, ProcessData, AdHocSubprocessTaskExecutionSet> { @Override protected Node<View<AdHocSubprocess>, Edge> createNode(String id) { return delegate.factoryManager.newNode(id, AdHocSubprocess.class); } SubProcessConverter(TypedFactoryManager typedFactoryManager,
PropertyReaderFactory propertyReaderFactory,
DefinitionResolver definitionResolver,
ConverterFactory converterFactory); }### Answer:
@Test public void createNode() { assertTrue(AdHocSubprocess.class.isInstance(tested.createNode("id").getContent().getDefinition())); } |
### Question:
SubProcessConverter extends BaseSubProcessConverter<AdHocSubprocess, ProcessData, AdHocSubprocessTaskExecutionSet> { @Override protected ProcessData createProcessData(String processVariables) { return new ProcessData(new ProcessVariables(processVariables)); } SubProcessConverter(TypedFactoryManager typedFactoryManager,
PropertyReaderFactory propertyReaderFactory,
DefinitionResolver definitionResolver,
ConverterFactory converterFactory); }### Answer:
@Test public void createProcessData() { assertTrue(ProcessData.class.isInstance(tested.createProcessData("id"))); } |
### Question:
SubProcessConverter extends BaseSubProcessConverter<AdHocSubprocess, ProcessData, AdHocSubprocessTaskExecutionSet> { @Override protected AdHocSubprocessTaskExecutionSet createAdHocSubprocessTaskExecutionSet(AdHocSubProcessPropertyReader p) { return new AdHocSubprocessTaskExecutionSet(new AdHocActivationCondition(p.getAdHocActivationCondition()), new AdHocCompletionCondition(p.getAdHocCompletionCondition()), new AdHocOrdering(p.getAdHocOrdering()), new AdHocAutostart(p.isAdHocAutostart()), new OnEntryAction(p.getOnEntryAction()), new OnExitAction(p.getOnExitAction()), new IsAsync(p.isAsync()), new SLADueDate(p.getSlaDueDate())); } SubProcessConverter(TypedFactoryManager typedFactoryManager,
PropertyReaderFactory propertyReaderFactory,
DefinitionResolver definitionResolver,
ConverterFactory converterFactory); }### Answer:
@Test public void testCreateAdHocSubprocessTaskExecutionSet() { AdHocSubProcess adHocSubProcess = mock(AdHocSubProcess.class); when(adHocSubProcess.getCompletionCondition()).thenReturn(mock(FormalExpression.class)); when(adHocSubProcess.getOrdering()).thenReturn(AdHocOrdering.SEQUENTIAL); assertTrue(AdHocSubprocessTaskExecutionSet.class.isInstance(tested.createAdHocSubprocessTaskExecutionSet( new AdHocSubProcessPropertyReader(adHocSubProcess, definitionResolver.getDiagram(), definitionResolver)))); } |
### Question:
ResultComposer { public static <T, R> Result compose(T value, Collection<Result<R>>... results) { List<MarshallingMessage> messages = Stream.of(results).flatMap(Collection::stream) .map(Result::messages) .flatMap(List::stream) .collect(Collectors.toList()); return Result.success(value, messages.stream().toArray(MarshallingMessage[]::new)); } static Result compose(T value, Collection<Result<R>>... results); static Result compose(T value, Result... result); }### Answer:
@Test public void compose() { final Result result = ResultComposer.compose(value, result1, result2, result3); assertResult(result); }
@Test public void composeList() { final Result result = ResultComposer.compose(value, Arrays.asList(result1, result2, result3)); assertResult(result); } |
### Question:
DecisionComponents { DMNIncludedModel asDMNIncludedModel(final Import anImport) { final String modelName = anImport.getName().getValue(); final String namespace = anImport.getNamespace(); final String importType = anImport.getImportType(); final String path = FileUtils.getFileName(anImport.getLocationURI().getValue()); return new DMNIncludedModel(modelName, "", path, namespace, importType, 0, 0); } DecisionComponents(); @Inject DecisionComponents(final View view,
final DMNIncludeModelsClient client,
final ManagedInstance<DecisionComponentsItem> itemManagedInstance,
final DecisionComponentFilter filter,
final DMNDiagramsSession dmnDiagramsSession,
final DMNGraphUtils dmnGraphUtils); @PostConstruct void init(); View getView(); void refresh(); void removeAllItems(); }### Answer:
@Test public void testAsDMNIncludedModel() { final String modelName = "Model Name"; final String namespace = "The Namespace"; final String type = "The type"; final String file = "my file.dmn"; final String filePath = " final Import anImport = new Import(); anImport.setName(new Name(modelName)); anImport.setNamespace(namespace); anImport.setImportType(type); anImport.setLocationURI(new LocationURI(filePath)); final DMNIncludedModel includedModel = decisionComponents.asDMNIncludedModel(anImport); assertEquals(modelName, includedModel.getModelName()); assertEquals(namespace, includedModel.getNamespace()); assertEquals(type, includedModel.getImportType()); assertEquals(file, includedModel.getPath()); } |
### Question:
CustomElement { public T get() { return elementDefinition.getValue(element); } CustomElement(ElementDefinition<T> elementDefinition, BaseElement element); T get(); void set(T value); static final MetadataTypeDefinition<Boolean> async; static final MetadataTypeDefinition<Boolean> autoStart; static final MetadataTypeDefinition<Boolean> autoConnectionSource; static final MetadataTypeDefinition<Boolean> autoConnectionTarget; static final MetadataTypeDefinition<String> customTags; static final MetadataTypeDefinition<String> description; static final MetadataTypeDefinition<String> scope; static final MetadataTypeDefinition<String> name; static final MetadataTypeDefinition<String> caseIdPrefix; static final MetadataTypeDefinition<String> caseRole; static final MetadataTypeDefinition<String> slaDueDate; static final GlobalVariablesElement globalVariables; static final MetaDataAttributesElement metaDataAttributes; static final MetadataTypeDefinition<Boolean> isCase; static final MetadataTypeDefinition<String> customActivationCondition; static final MetadataTypeDefinition<Boolean> abortParent; static final DefaultImportsElement defaultImports; }### Answer:
@Test public void testGet() { Object value = new Object(); elementDefinition.setValue(baseElement, value); assertEquals(value, new CustomElement<>(elementDefinition, baseElement).get()); } |
### Question:
CustomElement { public void set(T value) { if (value != null && !value.equals(elementDefinition.getDefaultValue())) { elementDefinition.setValue(element, value); } } CustomElement(ElementDefinition<T> elementDefinition, BaseElement element); T get(); void set(T value); static final MetadataTypeDefinition<Boolean> async; static final MetadataTypeDefinition<Boolean> autoStart; static final MetadataTypeDefinition<Boolean> autoConnectionSource; static final MetadataTypeDefinition<Boolean> autoConnectionTarget; static final MetadataTypeDefinition<String> customTags; static final MetadataTypeDefinition<String> description; static final MetadataTypeDefinition<String> scope; static final MetadataTypeDefinition<String> name; static final MetadataTypeDefinition<String> caseIdPrefix; static final MetadataTypeDefinition<String> caseRole; static final MetadataTypeDefinition<String> slaDueDate; static final GlobalVariablesElement globalVariables; static final MetaDataAttributesElement metaDataAttributes; static final MetadataTypeDefinition<Boolean> isCase; static final MetadataTypeDefinition<String> customActivationCondition; static final MetadataTypeDefinition<Boolean> abortParent; static final DefaultImportsElement defaultImports; }### Answer:
@Test public void testSetNonDefaultValue() { Object newValue = new Object(); CustomElement<Object> customElement = new CustomElement<>(elementDefinition, baseElement); customElement.set(newValue); assertEquals(newValue, elementDefinition.getValue(baseElement)); } |
### Question:
CustomInputDefinition { public CustomInput<T> of(Task element) { return new CustomInput<>(this, element); } CustomInputDefinition(String name, String type, T defaultValue); String name(); String type(); abstract T getValue(Task element); CustomInput<T> of(Task element); }### Answer:
@Test public void shouldReuseInputSet() { Task task = bpmn2.createTask(); StringInput stringInput = new StringInput("BLAH", "ATYPE", "DEFAULTVAL"); stringInput.of(task).set("VALUE"); StringInput stringInput2 = new StringInput("BLAH2", "ATYPE", "DEFAULTVAL"); stringInput.of(task).set("VALUE"); InputOutputSpecification ioSpecification = task.getIoSpecification(); List<InputSet> inputSets = ioSpecification.getInputSets(); assertEquals(1, inputSets.size()); } |
### Question:
DefaultImportsElement extends ElementDefinition<List<DefaultImport>> { @Override public List<DefaultImport> getValue(BaseElement element) { List<ExtensionAttributeValue> extValues = element.getExtensionValues(); List<DefaultImport> defaultImports = extValues.stream() .map(ExtensionAttributeValue::getValue) .flatMap((Function<FeatureMap, Stream<?>>) extensionElements -> { List o = (List) extensionElements.get(DOCUMENT_ROOT__IMPORT, true); return o.stream(); }) .map(m -> new DefaultImport(((ImportType) m).getName())) .collect(Collectors.toList()); return defaultImports; } DefaultImportsElement(String name); @Override List<DefaultImport> getValue(BaseElement element); @Override void setValue(BaseElement element, List<DefaultImport> value); static FeatureMap.Entry extensionOf(DefaultImport defaultImport); static ImportType importTypeDataOf(DefaultImport defaultImport); }### Answer:
@Test public void testGetValue() { BaseElement baseElement = bpmn2.createProcess(); assertEquals(new ArrayList<>(), CustomElement.defaultImports.of(baseElement).get()); } |
### Question:
DefaultImportsElement extends ElementDefinition<List<DefaultImport>> { @Override public void setValue(BaseElement element, List<DefaultImport> value) { value.stream() .map(DefaultImportsElement::extensionOf) .forEach(getExtensionElements(element)::add); } DefaultImportsElement(String name); @Override List<DefaultImport> getValue(BaseElement element); @Override void setValue(BaseElement element, List<DefaultImport> value); static FeatureMap.Entry extensionOf(DefaultImport defaultImport); static ImportType importTypeDataOf(DefaultImport defaultImport); }### Answer:
@Test public void testSetValue() { List<DefaultImport> defaultImports = new ArrayList<>(); defaultImports.add(new DefaultImport(CLASS_NAME + 1)); defaultImports.add(new DefaultImport(CLASS_NAME + 2)); defaultImports.add(new DefaultImport(CLASS_NAME + 3)); BaseElement baseElement = bpmn2.createProcess(); CustomElement.defaultImports.of(baseElement).set(defaultImports); List<DefaultImport> result = CustomElement.defaultImports.of(baseElement).get(); assertEquals(3, result.size()); assertEquals(CLASS_NAME + 1, result.get(0).getClassName()); assertEquals(CLASS_NAME + 2, result.get(1).getClassName()); assertEquals(CLASS_NAME + 3, result.get(2).getClassName()); } |
### Question:
DefaultImportsElement extends ElementDefinition<List<DefaultImport>> { public static FeatureMap.Entry extensionOf(DefaultImport defaultImport) { return new EStructuralFeatureImpl.SimpleFeatureMapEntry( (EStructuralFeature.Internal) DOCUMENT_ROOT__IMPORT, importTypeDataOf(defaultImport)); } DefaultImportsElement(String name); @Override List<DefaultImport> getValue(BaseElement element); @Override void setValue(BaseElement element, List<DefaultImport> value); static FeatureMap.Entry extensionOf(DefaultImport defaultImport); static ImportType importTypeDataOf(DefaultImport defaultImport); }### Answer:
@Test public void extensionOf() { DefaultImportsElement defaultImportsElement = new DefaultImportsElement(NAME); DefaultImport defaultImport = new DefaultImport(CLASS_NAME); ImportType importType = defaultImportsElement.importTypeDataOf(defaultImport); FeatureMap.Entry entry = defaultImportsElement.extensionOf(defaultImport); assertNotNull(entry); assertTrue(entry instanceof EStructuralFeatureImpl.SimpleFeatureMapEntry); assertEquals(DOCUMENT_ROOT__IMPORT, entry.getEStructuralFeature()); assertNotNull((ImportType) entry.getValue()); assertEquals(importType.getName(), ((ImportType) entry.getValue()).getName()); } |
### Question:
DefaultImportsElement extends ElementDefinition<List<DefaultImport>> { public static ImportType importTypeDataOf(DefaultImport defaultImport) { ImportType importType = DroolsFactory.eINSTANCE.createImportType(); importType.setName(defaultImport.getClassName()); return importType; } DefaultImportsElement(String name); @Override List<DefaultImport> getValue(BaseElement element); @Override void setValue(BaseElement element, List<DefaultImport> value); static FeatureMap.Entry extensionOf(DefaultImport defaultImport); static ImportType importTypeDataOf(DefaultImport defaultImport); }### Answer:
@Test public void importTypeDataOf() { DefaultImportsElement defaultImportsElement = new DefaultImportsElement(NAME); DefaultImport defaultImport = new DefaultImport(CLASS_NAME); ImportType importType = defaultImportsElement.importTypeDataOf(defaultImport); assertEquals(CLASS_NAME, importType.getName()); } |
### Question:
MetaDataAttributesElement extends ElementDefinition<String> { @Override public void setValue(BaseElement element, String value) { setStringValue(element, value); } MetaDataAttributesElement(String name); @Override String getValue(BaseElement element); @Override void setValue(BaseElement element, String value); static final String DELIMITER; static final String SEPARATOR; }### Answer:
@Test public void testSetValue() { BaseElement baseElement = bpmn2.createProcess(); CustomElement.metaDataAttributes.of(baseElement).set(ATTRIBUTES); assertEquals("att1ß<![CDATA[val1]]>Øatt2ß<![CDATA[val2]]>Øatt3ß<![CDATA[val3]]>", CustomElement.metaDataAttributes.of(baseElement).get()); } |
### Question:
MetaDataAttributesElement extends ElementDefinition<String> { protected FeatureMap.Entry extensionOf(String metaData) { return new EStructuralFeatureImpl.SimpleFeatureMapEntry( (EStructuralFeature.Internal) DOCUMENT_ROOT__META_DATA, metaDataTypeDataOf(metaData)); } MetaDataAttributesElement(String name); @Override String getValue(BaseElement element); @Override void setValue(BaseElement element, String value); static final String DELIMITER; static final String SEPARATOR; }### Answer:
@Test public void testExtensionOf() { MetaDataAttributesElement metaDataAttributesElement = new MetaDataAttributesElement(NAME); MetaDataType metaDataType = metaDataAttributesElement.metaDataTypeDataOf(ATTRIBUTE); FeatureMap.Entry entry = metaDataAttributesElement.extensionOf(ATTRIBUTE); assertNotNull(entry); assertTrue(entry instanceof EStructuralFeatureImpl.SimpleFeatureMapEntry); assertEquals(DOCUMENT_ROOT__META_DATA, entry.getEStructuralFeature()); assertNotNull(entry.getValue()); assertEquals(metaDataType.getName(), ((MetaDataType) entry.getValue()).getName()); assertEquals(metaDataType.getMetaValue(), ((MetaDataType) entry.getValue()).getMetaValue()); } |
### Question:
MetaDataAttributesElement extends ElementDefinition<String> { protected MetaDataType metaDataTypeDataOf(String metaData) { MetaDataType metaDataType = DroolsFactory.eINSTANCE.createMetaDataType(); String[] properties = metaData.split(SEPARATOR); metaDataType.setName(properties[0]); metaDataType.setMetaValue(properties.length > 1 ? asCData(properties[1]) : null); return metaDataType; } MetaDataAttributesElement(String name); @Override String getValue(BaseElement element); @Override void setValue(BaseElement element, String value); static final String DELIMITER; static final String SEPARATOR; }### Answer:
@Test public void testImportTypeDataOf() { MetaDataAttributesElement metaDataAttributesElement = new MetaDataAttributesElement(NAME); MetaDataType metaDataType = metaDataAttributesElement.metaDataTypeDataOf(ATTRIBUTE); assertTrue("att1ß<![CDATA[val1]]>".startsWith(metaDataType.getName())); assertTrue("att1ß<![CDATA[val1]]>".endsWith(metaDataType.getMetaValue())); } |
### Question:
DecisionComponents { void createDecisionComponentItem(final DecisionComponent component) { final DecisionComponentsItem item = itemManagedInstance.get(); item.setDecisionComponent(component); getDecisionComponentsItems().add(item); view.addListItem(item.getView().getElement()); } DecisionComponents(); @Inject DecisionComponents(final View view,
final DMNIncludeModelsClient client,
final ManagedInstance<DecisionComponentsItem> itemManagedInstance,
final DecisionComponentFilter filter,
final DMNDiagramsSession dmnDiagramsSession,
final DMNGraphUtils dmnGraphUtils); @PostConstruct void init(); View getView(); void refresh(); void removeAllItems(); }### Answer:
@Test public void testCreateDecisionComponentItem() { final DecisionComponentsItem item = mock(DecisionComponentsItem.class); final List<DecisionComponentsItem> decisionComponentsItems = spy(new ArrayList<>()); final DecisionComponentsItem.View decisionComponentsView = mock(DecisionComponentsItem.View.class); final HTMLElement htmlElement = mock(HTMLElement.class); final DecisionComponent component = mock(DecisionComponent.class); when(decisionComponentsView.getElement()).thenReturn(htmlElement); when(itemManagedInstance.get()).thenReturn(item); when(item.getView()).thenReturn(decisionComponentsView); doReturn(decisionComponentsItems).when(decisionComponents).getDecisionComponentsItems(); decisionComponents.createDecisionComponentItem(component); verify(item).setDecisionComponent(any(DecisionComponent.class)); verify(decisionComponentsItems).add(item); verify(view).addListItem(htmlElement); } |
### Question:
GlobalVariablesElement extends ElementDefinition<String> { @Override public String getValue(BaseElement element) { return getStringValue(element) .orElse(getDefaultValue()); } GlobalVariablesElement(String name); @Override String getValue(BaseElement element); @Override void setValue(BaseElement element, String value); }### Answer:
@Test public void testGetValue() { BaseElement baseElement = bpmn2.createProcess(); CustomElement.globalVariables.of(baseElement).set(GLOBAL_VARIABLES); assertEquals(GLOBAL_VARIABLES, CustomElement.globalVariables.of(baseElement).get()); } |
### Question:
GlobalVariablesElement extends ElementDefinition<String> { @Override public void setValue(BaseElement element, String value) { setStringValue(element, value); } GlobalVariablesElement(String name); @Override String getValue(BaseElement element); @Override void setValue(BaseElement element, String value); }### Answer:
@Test public void testSetValue() { BaseElement baseElement = bpmn2.createProcess(); CustomElement.globalVariables.of(baseElement).set(GLOBAL_VARIABLES); assertEquals(GLOBAL_VARIABLES, CustomElement.globalVariables.of(baseElement).get()); } |
### Question:
GlobalVariablesElement extends ElementDefinition<String> { static FeatureMap.Entry extensionOf(String variable) { return new EStructuralFeatureImpl.SimpleFeatureMapEntry( (EStructuralFeature.Internal) DOCUMENT_ROOT__GLOBAL, globalTypeDataOf(variable)); } GlobalVariablesElement(String name); @Override String getValue(BaseElement element); @Override void setValue(BaseElement element, String value); }### Answer:
@Test public void testExtensionOf() { GlobalVariablesElement globalVariablesElement = new GlobalVariablesElement(NAME); GlobalType globalType = globalVariablesElement.globalTypeDataOf(GLOBAL_VARIABLE); FeatureMap.Entry entry = globalVariablesElement.extensionOf(GLOBAL_VARIABLE); assertNotNull(entry); assertTrue(entry instanceof EStructuralFeatureImpl.SimpleFeatureMapEntry); assertEquals(DOCUMENT_ROOT__GLOBAL, entry.getEStructuralFeature()); assertNotNull(entry.getValue()); assertEquals(globalType.getIdentifier(), ((GlobalType) entry.getValue()).getIdentifier()); assertEquals(globalType.getType(), ((GlobalType) entry.getValue()).getType()); } |
### 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:
DecisionComponents { void createDecisionComponentItems(final List<DecisionComponent> decisionComponents) { for (final DecisionComponent component : decisionComponents) { if (!isDRGElementAdded(component)) { createDecisionComponentItem(component); } } } DecisionComponents(); @Inject DecisionComponents(final View view,
final DMNIncludeModelsClient client,
final ManagedInstance<DecisionComponentsItem> itemManagedInstance,
final DecisionComponentFilter filter,
final DMNDiagramsSession dmnDiagramsSession,
final DMNGraphUtils dmnGraphUtils); @PostConstruct void init(); View getView(); void refresh(); void removeAllItems(); }### Answer:
@Test public void testCreateDecisionComponentItems() { final List<DecisionComponent> decisionComponentsItems = new ArrayList<>(); decisionComponentsItems.add(makeDecisionComponent("Decision-1", "uuid1", "ModelName", false)); decisionComponentsItems.add(makeDecisionComponent("Decision-1", "uuid1", "ModelName", false)); decisionComponentsItems.add(makeDecisionComponent("Decision-1", "uuid2", "ModelName", false)); decisionComponentsItems.add(makeDecisionComponent("included.Decision-2", "uuidA", "included.dmn", true)); decisionComponentsItems.add(makeDecisionComponent("included.Decision-2", "uuidA", "included.dmn", true)); decisionComponentsItems.add(makeDecisionComponent("included.Decision-2", "uuidB", "included.dmn", true)); when(itemManagedInstance.get()).then((e) -> new DecisionComponentsItem(decisionComponentsItemView)); decisionComponents.createDecisionComponentItems(decisionComponentsItems); verify(decisionComponents, times(4)).createDecisionComponentItem(decisionComponentArgumentCaptor.capture()); final List<DecisionComponent> createdDecisionComponents = decisionComponentArgumentCaptor.getAllValues(); assertEquals("uuid1", createdDecisionComponents.get(0).getDrgElement().getId().getValue()); assertEquals("uuid2", createdDecisionComponents.get(1).getDrgElement().getId().getValue()); assertEquals("uuidA", createdDecisionComponents.get(2).getDrgElement().getId().getValue()); assertEquals("uuidB", createdDecisionComponents.get(3).getDrgElement().getId().getValue()); } |
### 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:
DMNIncludedNodesFilter { public List<DMNIncludedNode> getNodesFromImports(final Path path, final List<DMNIncludedModel> includedModels) { try { final Diagram<Graph, Metadata> diagram = diagramHelper.getDiagramByPath(path); final Optional<DMNIncludedModel> diagramImport = getDiagramImport(diagram, includedModels); return diagramImport .map(dmn -> diagramHelper .getNodes(diagram) .stream() .map(node -> factory.makeDMNIncludeModel(path, dmn, node)) .collect(Collectors.toList())) .orElse(new ArrayList<>()); } catch (final Exception e) { } return new ArrayList<>(); } @Inject DMNIncludedNodesFilter(final DMNDiagramHelper diagramHelper,
final DMNIncludedNodeFactory factory); List<DMNIncludedNode> getNodesFromImports(final Path path,
final List<DMNIncludedModel> includedModels); }### Answer:
@Test public void testGetNodesFromImports() { final Path path = mock(Path.class); final DMNIncludedModel includedModel1 = mock(DMNIncludedModel.class); final DMNIncludedModel includedModel2 = mock(DMNIncludedModel.class); final DMNIncludedModel includedModel3 = mock(DMNIncludedModel.class); final List<DMNIncludedModel> imports = asList(includedModel1, includedModel2, includedModel3); final DMNIncludedNode dmnNode1 = mock(DMNIncludedNode.class); final DMNIncludedNode dmnNode2 = mock(DMNIncludedNode.class); final Decision node1 = new Decision(); final InputData node2 = new InputData(); final List<DRGElement> diagramNodes = asList(node1, node2); when(includedModel1.getNamespace()).thenReturn(": when(includedModel2.getNamespace()).thenReturn(": when(includedModel3.getNamespace()).thenReturn(": when(diagramHelper.getDiagramByPath(path)).thenReturn(diagram); when(diagramHelper.getNodes(diagram)).thenReturn(diagramNodes); when(diagramHelper.getNamespace(diagram)).thenReturn(": when(factory.makeDMNIncludeModel(path, includedModel1, node1)).thenReturn(dmnNode1); when(factory.makeDMNIncludeModel(path, includedModel1, node2)).thenReturn(dmnNode2); final List<DMNIncludedNode> actualNodes = filter.getNodesFromImports(path, imports); final List<DMNIncludedNode> expectedNodes = asList(dmnNode1, dmnNode2); assertEquals(expectedNodes, actualNodes); }
@Test public void testGetNodesFromImportsWhenPathDoesNotRepresentsAnImportedDiagram() { final Path path = mock(Path.class); final DMNIncludedModel includedModel1 = mock(DMNIncludedModel.class); final DMNIncludedModel includedModel2 = mock(DMNIncludedModel.class); final DMNIncludedModel includedModel3 = mock(DMNIncludedModel.class); final List<DMNIncludedModel> imports = asList(includedModel1, includedModel2, includedModel3); when(includedModel1.getNamespace()).thenReturn(": when(includedModel2.getNamespace()).thenReturn(": when(includedModel3.getNamespace()).thenReturn(": when(diagramHelper.getDiagramByPath(path)).thenReturn(diagram); when(diagramHelper.getNamespace(diagram)).thenReturn(": final List<DMNIncludedNode> actualNodes = filter.getNodesFromImports(path, imports); final List<DMNIncludedNode> expectedNodes = emptyList(); assertEquals(expectedNodes, actualNodes); } |
### Question:
DMNContentServiceImpl extends KieService<String> implements DMNContentService { @Override public DMNContentResource getProjectContent(final Path path, final String defSetId) { final String content = getSource(path); final String title = path.getFileName(); final ProjectMetadata metadata = buildMetadataInstance(path, defSetId, title); return new DMNContentResource(content, metadata); } @Inject DMNContentServiceImpl(final CommentedOptionFactory commentedOptionFactory,
final DMNIOHelper dmnIOHelper,
final DMNPathsHelper pathsHelper,
final PMMLIncludedDocumentFactory pmmlIncludedDocumentFactory); @Override String getContent(final Path path); @Override DMNContentResource getProjectContent(final Path path,
final String defSetId); @Override void saveContent(final Path path,
final String content,
final Metadata metadata,
final String comment); @Override List<Path> getModelsPaths(final WorkspaceProject workspaceProject); @Override List<Path> getDMNModelsPaths(final WorkspaceProject workspaceProject); @Override List<Path> getPMMLModelsPaths(final WorkspaceProject workspaceProject); @Override PMMLDocumentMetadata loadPMMLDocumentMetadata(final Path path); @Override String getSource(final Path path); }### Answer:
@Test public void testGetProjectContent() { final String defSetId = "defSetId"; final String expectedContent = "<xml/>"; final String moduleName = "moduleName"; final Package aPackage = mock(Package.class); final KieModule kieModule = mock(KieModule.class); final Overview overview = mock(Overview.class); doReturn(expectedContent).when(service).getSource(path); when(moduleService.resolvePackage(path)).thenReturn(aPackage); when(moduleService.resolveModule(path)).thenReturn(kieModule); when(overviewLoader.loadOverview(path)).thenReturn(overview); when(kieModule.getModuleName()).thenReturn(moduleName); final DMNContentResource contentResource = service.getProjectContent(path, defSetId); final String actualContent = contentResource.getContent(); final ProjectMetadataImpl metadata = (ProjectMetadataImpl) contentResource.getMetadata(); assertEquals(expectedContent, actualContent); assertEquals(defSetId, metadata.getDefinitionSetId()); assertEquals(moduleName, metadata.getModuleName()); assertEquals(aPackage, metadata.getProjectPackage()); assertEquals(overview, metadata.getOverview()); assertEquals(fileName, metadata.getTitle()); assertEquals(path, metadata.getPath()); } |
### 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 { public static BPMNEdge createBPMNEdge(BasePropertyWriter source, BasePropertyWriter target, Connection sourceConnection, ControlPoint[] mid, Connection targetConnection) { BPMNEdge bpmnEdge = di.createBPMNEdge(); bpmnEdge.setId(Ids.bpmnEdge(source.getShape().getId(), target.getShape().getId())); Point2D sourcePt = getSourceLocation(source, sourceConnection); Point2D targetPt = getTargetLocation(target, targetConnection); org.eclipse.dd.dc.Point sourcePoint = pointOf( source.getShape().getBounds().getX() + sourcePt.getX(), source.getShape().getBounds().getY() + sourcePt.getY()); org.eclipse.dd.dc.Point targetPoint = pointOf( target.getShape().getBounds().getX() + targetPt.getX(), target.getShape().getBounds().getY() + targetPt.getY()); List<Point> waypoints = bpmnEdge.getWaypoint(); waypoints.add(sourcePoint); if (null != mid) { for (ControlPoint controlPoint : mid) { waypoints.add(pointOf(controlPoint.getLocation().getX(), controlPoint.getLocation().getY())); } } waypoints.add(targetPoint); return bpmnEdge; } 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 testCreateBPMNEdge() { BPMNShape sourceShape = mockShape(SOURCE_SHAPE_ID, 1, 1, 4, 4); BPMNShape targetShape = mockShape(TARGET_SHAPE_ID, 10, 10, 4, 4); when(sourceWriter.getShape()).thenReturn(sourceShape); when(targetWriter.getShape()).thenReturn(targetShape); Connection sourceConnection = mockConnection(1, 1); Connection targetConnection = mockConnection(10, 10); ControlPoint[] controlPoints = new ControlPoint[]{ new ControlPoint(Point2D.create(3, 3)), new ControlPoint(Point2D.create(4, 4)), new ControlPoint(Point2D.create(5, 5)) }; BPMNEdge edge = PropertyWriterUtils.createBPMNEdge(sourceWriter, targetWriter, sourceConnection, controlPoints, targetConnection); assertEquals("edge_SOURCE_SHAPE_ID_to_TARGET_SHAPE_ID", edge.getId()); assertWaypoint(2, 2, 0, edge.getWaypoint()); assertWaypoint(3, 3, 1, edge.getWaypoint()); assertWaypoint(4, 4, 2, edge.getWaypoint()); assertWaypoint(5, 5, 3, edge.getWaypoint()); assertWaypoint(20, 20, 4, edge.getWaypoint()); } |
### 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 { public void setCollectionInput(String collectionInput) { if (isEmpty(collectionInput)) { return; } setUpLoopCharacteristics(); String suffix = "IN_COLLECTION"; String id = Ids.dataInput(activity.getId(), suffix); DataInput dataInputElement = createDataInput(id, suffix); ioSpec.getDataInputs().add(dataInputElement); Optional<Property> property = findPropertyById(collectionInput); Optional<DataObject> dataObject = findDataObjectById(collectionInput); if (property.isPresent()) { processDataInput(dataInputElement, property.get()); } else if (dataObject.isPresent()) { processDataInput(dataInputElement, dataObject.get()); } } 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 testSetCollectionInput() { writer.setCollectionInput(PROPERTY_ID); assertInputsInitialized(); String inputId = ACTIVITY_ID + "_" + IN_COLLECTION + "InputX"; assertHasDataInput(activity.getIoSpecification(), inputId, ITEM_ID, IN_COLLECTION); assertHasDataInputAssociation(activity, PROPERTY_ID, inputId); assertEquals(inputId, ((MultiInstanceLoopCharacteristics) activity.getLoopCharacteristics()).getLoopDataInputRef().getId()); when(variableScope.lookup(PROPERTY_ID)).thenReturn(Optional.empty()); Set<DataObject> dataObjects = new HashSet<>(); DataObject dataObject = mockDataObject(PROPERTY_ID); dataObjects.add(dataObject); writer = new MultipleInstanceActivityPropertyWriter(activity, variableScope, dataObjects); writer.setCollectionInput(PROPERTY_ID); assertInputsInitialized(); inputId = ACTIVITY_ID + "_" + IN_COLLECTION + "InputX"; assertHasDataInput(activity.getIoSpecification(), inputId, ITEM_ID, IN_COLLECTION); assertHasDataInputAssociation(activity, PROPERTY_ID, inputId); when(variableScope.lookup(PROPERTY_ID)).thenReturn(Optional.empty()); dataObjects.clear(); dataObject = mockDataObject("SomeOtherId"); dataObjects.add(dataObject); writer = new MultipleInstanceActivityPropertyWriter(activity, variableScope, dataObjects); writer.setCollectionInput(PROPERTY_ID); assertInputsInitialized(); inputId = ACTIVITY_ID + "_" + IN_COLLECTION + "InputX"; assertHasDataInput(activity.getIoSpecification(), inputId, ITEM_ID, IN_COLLECTION); assertHasDataInputAssociation(activity, PROPERTY_ID, inputId); } |
### 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:
MultipleInstanceActivityPropertyWriter extends ActivityPropertyWriter { public void setCollectionOutput(String collectionOutput) { if (isEmpty(collectionOutput)) { return; } setUpLoopCharacteristics(); String suffix = "OUT_COLLECTION"; String id = Ids.dataOutput(activity.getId(), suffix); DataOutput dataOutputElement = createDataOutput(id, suffix); addSafe(ioSpec.getDataOutputs(), dataOutputElement); Optional<Property> property = findPropertyById(collectionOutput); Optional<DataObject> dataObject = findDataObjectById(collectionOutput); if (property.isPresent()) { processDataOutput(dataOutputElement, property.get()); } else if (dataObject.isPresent()) { processDataOutput(dataOutputElement, dataObject.get()); } } 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 testSetCollectionOutput() { writer.setCollectionOutput(PROPERTY_ID); assertOutputsInitialized(); String outputId = ACTIVITY_ID + "_" + OUT_COLLECTION + "OutputX"; assertHasDataOutput(activity.getIoSpecification(), outputId, ITEM_ID, OUT_COLLECTION); assertHasDataOutputAssociation(activity, outputId, PROPERTY_ID); assertEquals(outputId, ((MultiInstanceLoopCharacteristics) activity.getLoopCharacteristics()).getLoopDataOutputRef().getId()); when(variableScope.lookup(PROPERTY_ID)).thenReturn(Optional.empty()); Set<DataObject> dataObjects = new HashSet<>(); DataObject dataObject = mockDataObject(PROPERTY_ID); dataObjects.add(dataObject); writer = new MultipleInstanceActivityPropertyWriter(activity, variableScope, dataObjects); writer.setCollectionOutput(PROPERTY_ID); assertOutputsInitialized(); outputId = ACTIVITY_ID + "_" + OUT_COLLECTION + "OutputX"; assertHasDataOutputAssociation(activity, outputId, PROPERTY_ID); when(variableScope.lookup(PROPERTY_ID)).thenReturn(Optional.empty()); dataObject = mockDataObject(PROPERTY_ID); dataObjects.add(dataObject); writer = new MultipleInstanceActivityPropertyWriter(activity, variableScope, dataObjects); writer.setCollectionOutput(PROPERTY_ID); assertOutputsInitialized(); outputId = ACTIVITY_ID + "_" + OUT_COLLECTION + "OutputX"; assertHasDataOutputAssociation(activity, outputId, PROPERTY_ID); when(variableScope.lookup(PROPERTY_ID)).thenReturn(Optional.empty()); dataObjects.clear(); dataObject = mockDataObject("SomeOtherId"); dataObjects.add(dataObject); writer = new MultipleInstanceActivityPropertyWriter(activity, variableScope, dataObjects); writer.setCollectionOutput(PROPERTY_ID); assertOutputsInitialized(); outputId = ACTIVITY_ID + "_" + OUT_COLLECTION + "OutputX"; assertHasDataOutputAssociation(activity, outputId, PROPERTY_ID); } |
### 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 { protected static void addSafe(List<DataInput> inputs, DataInput dataInput) { inputs.removeIf(existingDataInput -> dataInput.getId().equals(existingDataInput.getId())); inputs.add(dataInput); } 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 testAddSafeCollectionOutput() { List<DataOutputAssociation> associations = new ArrayList<>(); DataOutputAssociation outputAssociation = mock(DataOutputAssociation.class); associations.add(outputAssociation); DataOutputAssociation outputAssociation2 = mock(DataOutputAssociation.class); when(outputAssociation.getSourceRef()).thenReturn(null); writer.addSafe(associations, outputAssociation2); associations.clear(); associations.add(outputAssociation); when(outputAssociation.getSourceRef()).thenReturn(new ArrayList<>()); writer.addSafe(associations, outputAssociation2); associations.clear(); associations.add(outputAssociation); List<ItemAwareElement> list = new ArrayList<>(); ItemAwareElementImpl element = mock(ItemAwareElementImpl.class); when(element.getId()).thenReturn("elementId"); list.add(element); when(outputAssociation.getSourceRef()).thenReturn(list); when(outputAssociation2.getSourceRef()).thenReturn(list); writer.addSafe(associations, outputAssociation2); associations.clear(); associations.add(outputAssociation); list = new ArrayList<>(); element = mock(ItemAwareElementImpl.class); when(element.getId()).thenReturn("elementId"); list.add(element); List<ItemAwareElement> list2 = new ArrayList<>(); ItemAwareElementImpl element2 = mock(ItemAwareElementImpl.class); when(element2.getId()).thenReturn("elementId"); list2.add(element2); when(element.getId()).thenReturn("elementId2"); list.add(element); when(outputAssociation.getSourceRef()).thenReturn(list); when(outputAssociation2.getSourceRef()).thenReturn(list2); writer.addSafe(associations, outputAssociation2); assertTrue(associations.contains(outputAssociation2)); } |
### 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:
ProcessPropertyWriter extends BasePropertyWriter implements ElementContainer { public void addChildElement(BasePropertyWriter p) { Processes.addChildElement( p, childElements, process, simulationParameters, itemDefinitions, rootElements); addChildShape(p.getShape()); addChildEdge(p.getEdge()); if (p instanceof SubProcessPropertyWriter) { addSubProcess((SubProcessPropertyWriter) p); } else if (p instanceof DataObjectPropertyWriter) { DataObject dataObject = ((DataObjectPropertyWriter) p).getElement().getDataObjectRef(); maybeAddDataObjectToItemDefinitions(itemDefinitions, dataObject); } maybeAddDataObjectToItemDefinitions(itemDefinitions, dataObjects); } ProcessPropertyWriter(Process process, VariableScope variableScope, Set<DataObject> dataObjects); void setId(String value); Process getProcess(); void addChildShape(BPMNShape shape); void addChildEdge(BPMNEdge edge); BPMNDiagram getBpmnDiagram(); void addChildElement(BasePropertyWriter p); @Override Collection<BasePropertyWriter> getChildElements(); BasePropertyWriter getChildElement(String id); void setName(String value); void setExecutable(Boolean value); void setPackage(String value); void setType(String value); void setVersion(String value); void setAdHoc(Boolean adHoc); void setDescription(String value); void setProcessVariables(BaseProcessVariables processVariables); void setMetadata(final MetaDataAttributes metaDataAttributes); void setCaseFileVariables(CaseFileVariables caseFileVariables); void setCaseIdPrefix(CaseIdPrefix caseIdPrefix); void setCaseRoles(CaseRoles roles); void setGlobalVariables(GlobalVariables globalVariables); void setDefaultImports(List<DefaultImport> imports); void setSlaDueDate(SLADueDate slaDueDate); void addLaneSet(Collection<LanePropertyWriter> lanes); Collection<ElementParameters> getSimulationParameters(); Relationship getRelationship(); Set<DataObject> getDataObjects(); }### Answer:
@Test public void addChildElement() { Process process = p.getProcess(); BoundaryEventPropertyWriter boundaryEventPropertyWriter = new BoundaryEventPropertyWriter(bpmn2.createBoundaryEvent(), variableScope, new HashSet<>()); UserTaskPropertyWriter userTaskPropertyWriter = new UserTaskPropertyWriter(bpmn2.createUserTask(), variableScope, new HashSet<>()); SubProcessPropertyWriter subProcessPropertyWriter = new SubProcessPropertyWriter(bpmn2.createSubProcess(), variableScope, new HashSet<>()); final DataObjectReference dataObjectReference = bpmn2.createDataObjectReference(); DataObjectPropertyWriter dataObjectPropertyWriter = new DataObjectPropertyWriter(dataObjectReference, variableScope, new HashSet<>()); final DataObject dataObject = dataObjectPropertyWriter.getElement().getDataObjectRef(); dataObject.getItemSubjectRef(); ItemDefinition itemDefinition = mock(ItemDefinition.class); when(itemDefinition.getId()).thenReturn("someId"); dataObject.setItemSubjectRef(itemDefinition); dataObject.getItemSubjectRef(); subProcessPropertyWriter.addChildElement(dataObjectPropertyWriter); p.addChildElement(subProcessPropertyWriter); p.addChildElement(boundaryEventPropertyWriter); p.addChildElement(userTaskPropertyWriter); assertThat(process.getFlowElements().get(0)).isEqualTo(userTaskPropertyWriter.getFlowElement()); assertThat(process.getFlowElements().get(1)).isEqualTo(subProcessPropertyWriter.getFlowElement()); assertThat(process.getFlowElements().get(2)).isEqualTo(boundaryEventPropertyWriter.getFlowElement()); } |
### 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:
EventPropertyWriter extends PropertyWriter { public void addError(ErrorRef errorRef) { Error error = bpmn2.createError(); ErrorEventDefinition errorEventDefinition = bpmn2.createErrorEventDefinition(); addEventDefinition(errorEventDefinition); String errorCode = errorRef.getValue(); String errorId; if (StringUtils.nonEmpty(errorCode)) { error.setErrorCode(errorCode); CustomAttribute.errorName.of(errorEventDefinition).set(errorCode); errorId = errorCode; } else { errorId = UUID.uuid(); } error.setId(errorId); errorEventDefinition.setErrorRef(error); addRootElement(error); } EventPropertyWriter(Event event, VariableScope variableScope); abstract void setAssignmentsInfo(AssignmentsInfo assignmentsInfo); void addMessage(MessageRef messageRef); void addSignal(SignalRef signalRef); void addLink(LinkRef linkRef); void addSignalScope(SignalScope signalScope); void addError(ErrorRef errorRef); void addTerminate(); void addTimer(TimerSettings timerSettings); void addCondition(ConditionExpression condition); void addEscalation(EscalationRef escalationRef); void addCompensation(); void addSlaDueDate(SLADueDate slaDueDate); }### Answer:
@Test public void testAddEmptyError() { final ArgumentCaptor<RootElement> captor = ArgumentCaptor.forClass(RootElement.class); ErrorRef errorRef = new ErrorRef(); propertyWriter.addError(errorRef); ErrorEventDefinition definition = getErrorDefinition(); assertNull(definition.getErrorRef().getErrorCode()); assertFalse(definition.getErrorRef().getId().isEmpty()); verify(propertyWriter).addRootElement(captor.capture()); Error error = (Error) captor.getValue(); assertNull(error.getErrorCode()); assertFalse(error.getId().isEmpty()); }
@Test public void testAddError() { final ArgumentCaptor<RootElement> captor = ArgumentCaptor.forClass(RootElement.class); ErrorRef errorRef = new ErrorRef(); errorRef.setValue(ERROR_CODE); propertyWriter.addError(errorRef); ErrorEventDefinition definition = getErrorDefinition(); assertEquals(ERROR_CODE, definition.getErrorRef().getErrorCode()); assertFalse(definition.getErrorRef().getId().isEmpty()); verify(propertyWriter).addRootElement(captor.capture()); Error error = (Error) captor.getValue(); assertEquals(ERROR_CODE, error.getErrorCode()); assertFalse(error.getId().isEmpty()); } |
### Question:
SubProcessPropertyWriter extends MultipleInstanceActivityPropertyWriter implements ElementContainer { public void addChildElement(BasePropertyWriter p) { p.setParent(this); Processes.addChildElement( p, childElements, process, simulationParameters, itemDefinitions, rootElements); } SubProcessPropertyWriter(SubProcess process, VariableScope variableScope, Set<DataObject> dataObjects); void addChildElement(BasePropertyWriter p); @Override Collection<BasePropertyWriter> getChildElements(); BasePropertyWriter getChildElement(String id); @Override void addChildEdge(BPMNEdge edge); void setDescription(String value); void setSimulationSet(SimulationSet simulations); void setProcessVariables(BaseProcessVariables processVariables); void addLaneSet(Collection<LanePropertyWriter> lanes); void setOnEntryAction(OnEntryAction onEntryAction); void setOnExitAction(OnExitAction onExitAction); void setAsync(Boolean isAsync); void setSlaDueDate(SLADueDate slaDueDate); @Override void setAbsoluteBounds(Node<? extends View, ?> node); }### Answer:
@Test public void addChildElement() { SubProcess process = (SubProcess) propertyWriter.getElement(); List<FlowElement> flowElements = new ArrayList<>(); when(process.getFlowElements()).thenReturn(flowElements); BoundaryEventPropertyWriter boundaryEventPropertyWriter = new BoundaryEventPropertyWriter(bpmn2.createBoundaryEvent(), variableScope, new HashSet<>()); UserTaskPropertyWriter userTaskPropertyWriter = new UserTaskPropertyWriter(bpmn2.createUserTask(), variableScope, new HashSet<>()); propertyWriter.addChildElement(boundaryEventPropertyWriter); propertyWriter.addChildElement(userTaskPropertyWriter); assertThat(process.getFlowElements().get(0)).isEqualTo(userTaskPropertyWriter.getFlowElement()); assertThat(process.getFlowElements().get(1)).isEqualTo(boundaryEventPropertyWriter.getFlowElement()); }
@Test public void addChildElement() { SubProcess process = (SubProcess) propertyWriter.getElement(); when(process.getFlowElements()).thenReturn(ECollections.newBasicEList()); BoundaryEventPropertyWriter boundaryEventPropertyWriter = new BoundaryEventPropertyWriter(bpmn2.createBoundaryEvent(), variableScope, new HashSet<>()); UserTaskPropertyWriter userTaskPropertyWriter = new UserTaskPropertyWriter(bpmn2.createUserTask(), variableScope, new HashSet<>()); propertyWriter.addChildElement(boundaryEventPropertyWriter); propertyWriter.addChildElement(userTaskPropertyWriter); assertThat(process.getFlowElements().get(0)).isEqualTo(userTaskPropertyWriter.getFlowElement()); assertThat(process.getFlowElements().get(1)).isEqualTo(boundaryEventPropertyWriter.getFlowElement()); } |
### 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()); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.