method2testcases
stringlengths 118
6.63k
|
---|
### Question:
GatewayConverter { private PropertyWriter inclusive(Node<View<InclusiveGateway>, ?> n) { GatewayPropertyWriter p = propertyWriterFactory.of(bpmn2.createInclusiveGateway()); p.setId(n.getUUID()); InclusiveGateway definition = n.getContent().getDefinition(); p.setGatewayDirection(n); BPMNGeneralSet general = definition.getGeneral(); p.setName(general.getName().getValue()); p.setDocumentation(general.getDocumentation().getValue()); GatewayExecutionSet executionSet = definition.getExecutionSet(); p.setDefaultRoute(executionSet.getDefaultRoute().getValue()); p.setAbsoluteBounds(n); return p; } GatewayConverter(PropertyWriterFactory propertyWriterFactory); PropertyWriter toFlowElement(Node<View<BaseGateway>, ?> node); }### Answer:
@Test public void testInclusive() { InclusiveGateway gateway = new InclusiveGateway(); gateway.getGeneral().getName().setValue(NAME); gateway.getGeneral().getDocumentation().setValue(DOCUMENTATION); gateway.getExecutionSet().getDefaultRoute().setValue(DEFAULT_ROUTE); Node<View<BaseGateway>, ?> node = newNode(UUID, gateway); when(propertyWriterFactory.of(any(org.eclipse.bpmn2.InclusiveGateway.class))).thenReturn(gatewayPropertyWriter); assertEquals(gatewayPropertyWriter, converter.toFlowElement(node)); verifyCommonValues(gatewayPropertyWriter, node); verify(gatewayPropertyWriter).setDefaultRoute(DEFAULT_ROUTE); verify(gatewayPropertyWriter).setGatewayDirection(node); } |
### Question:
GatewayConverter { private PropertyWriter exclusive(Node<View<ExclusiveGateway>, ?> n) { GatewayPropertyWriter p = propertyWriterFactory.of(bpmn2.createExclusiveGateway()); p.setId(n.getUUID()); ExclusiveGateway definition = n.getContent().getDefinition(); p.setGatewayDirection(n); BPMNGeneralSet general = definition.getGeneral(); p.setName(general.getName().getValue()); p.setDocumentation(general.getDocumentation().getValue()); GatewayExecutionSet executionSet = definition.getExecutionSet(); p.setDefaultRoute(executionSet.getDefaultRoute().getValue()); p.setAbsoluteBounds(n); return p; } GatewayConverter(PropertyWriterFactory propertyWriterFactory); PropertyWriter toFlowElement(Node<View<BaseGateway>, ?> node); }### Answer:
@Test public void testExclusive() { ExclusiveGateway gateway = new ExclusiveGateway(); gateway.getGeneral().getName().setValue(NAME); gateway.getGeneral().getDocumentation().setValue(DOCUMENTATION); gateway.getExecutionSet().getDefaultRoute().setValue(DEFAULT_ROUTE); Node<View<BaseGateway>, ?> node = newNode(UUID, gateway); when(propertyWriterFactory.of(any(org.eclipse.bpmn2.ExclusiveGateway.class))).thenReturn(gatewayPropertyWriter); assertEquals(gatewayPropertyWriter, converter.toFlowElement(node)); verifyCommonValues(gatewayPropertyWriter, node); verify(gatewayPropertyWriter).setDefaultRoute(DEFAULT_ROUTE); verify(gatewayPropertyWriter).setGatewayDirection(node); } |
### Question:
GatewayConverter { private PropertyWriter parallel(Node<View<ParallelGateway>, ?> n) { GatewayPropertyWriter p = propertyWriterFactory.of(bpmn2.createParallelGateway()); p.setId(n.getUUID()); ParallelGateway definition = n.getContent().getDefinition(); p.setGatewayDirection(n); BPMNGeneralSet general = definition.getGeneral(); p.setName(general.getName().getValue()); p.setDocumentation(general.getDocumentation().getValue()); p.setAbsoluteBounds(n); return p; } GatewayConverter(PropertyWriterFactory propertyWriterFactory); PropertyWriter toFlowElement(Node<View<BaseGateway>, ?> node); }### Answer:
@Test public void testParallel() { ParallelGateway gateway = new ParallelGateway(); gateway.getGeneral().getName().setValue(NAME); gateway.getGeneral().getDocumentation().setValue(DOCUMENTATION); Node<View<BaseGateway>, ?> node = newNode(UUID, gateway); when(propertyWriterFactory.of(any(org.eclipse.bpmn2.ParallelGateway.class))).thenReturn(gatewayPropertyWriter); assertEquals(gatewayPropertyWriter, converter.toFlowElement(node)); verifyCommonValues(gatewayPropertyWriter, node); verify(gatewayPropertyWriter).setGatewayDirection(node); } |
### Question:
GatewayConverter { private PropertyWriter event(Node<View<EventGateway>, ?> n) { GatewayPropertyWriter p = propertyWriterFactory.of(bpmn2.createEventBasedGateway()); p.setId(n.getUUID()); p.setGatewayDirection(GatewayDirection.DIVERGING); EventGateway definition = n.getContent().getDefinition(); BPMNGeneralSet general = definition.getGeneral(); p.setName(general.getName().getValue()); p.setDocumentation(general.getDocumentation().getValue()); p.setAbsoluteBounds(n); return p; } GatewayConverter(PropertyWriterFactory propertyWriterFactory); PropertyWriter toFlowElement(Node<View<BaseGateway>, ?> node); }### Answer:
@Test public void testEvent() { EventGateway gateway = new EventGateway(); gateway.getGeneral().getName().setValue(NAME); gateway.getGeneral().getDocumentation().setValue(DOCUMENTATION); Node<View<BaseGateway>, ?> node = newNode(UUID, gateway); when(propertyWriterFactory.of(any(org.eclipse.bpmn2.EventBasedGateway.class))).thenReturn(gatewayPropertyWriter); assertEquals(gatewayPropertyWriter, converter.toFlowElement(node)); verifyCommonValues(gatewayPropertyWriter, node); } |
### Question:
DecisionComponentsView implements DecisionComponents.View { @Override public void hideLoading() { hide(loading); } @Inject DecisionComponentsView(final HTMLSelectElement drgElementFilter,
final HTMLInputElement termFilter,
final HTMLDivElement list,
final HTMLDivElement emptyState,
final HTMLDivElement loading,
final HTMLDivElement componentsCounter,
final TranslationService translationService); @PostConstruct void init(); @Override void init(final DecisionComponents presenter); @EventHandler("term-filter") void onTermFilterChange(final KeyUpEvent e); @Override void clear(); @Override void addListItem(final HTMLElement htmlElement); @Override void showEmptyState(); @Override void showLoading(); @Override void hideLoading(); @Override void disableFilterInputs(); @Override void enableFilterInputs(); @Override void setComponentsCounter(final Integer count); }### Answer:
@Test public void testHideLoading() { loading.classList = mock(DOMTokenList.class); view.hideLoading(); verify(loading.classList).add(HIDDEN_CSS_CLASS); } |
### Question:
ArtifactsConverter { public PropertyWriter toElement(Node<View<BaseArtifacts>, ?> node) { return NodeMatch.fromNode(BaseArtifacts.class, PropertyWriter.class) .when(TextAnnotation.class, this::toTextAnnotation) .when(DataObject.class, this::toDataObjectAnnotation) .ignore(Object.class) .apply(node) .value(); } ArtifactsConverter(PropertyWriterFactory propertyWriterFactory); PropertyWriter toElement(Node<View<BaseArtifacts>, ?> node); }### Answer:
@Test public void toTextAnnotationElement() { textAnnotation = new TextAnnotation(); textAnnotation.getGeneral().getDocumentation().setValue(DOC); textAnnotation.getGeneral().getName().setValue(NAME); textAnnotationNode = new NodeImpl<>(UUID.uuid()); textAnnotationNode.setContent(textAnnotationView); when(textAnnotationView.getDefinition()).thenReturn(textAnnotation); when(propertyWriterFactory.of(any(org.eclipse.bpmn2.TextAnnotation.class))).thenReturn(textAnnotationWriter); artifactsConverter = new ArtifactsConverter(propertyWriterFactory); PropertyWriter propertyWriter = artifactsConverter.toElement(((NodeImpl) textAnnotationNode)); verify(textAnnotationWriter).setName(NAME); verify(textAnnotationWriter).setDocumentation(DOC); verify(textAnnotationWriter).setAbsoluteBounds(textAnnotationNode); assertEquals(textAnnotationWriter, propertyWriter); }
@Test public void toDataObjectElement() { dataObject = new DataObject(); dataObject.getGeneral().getDocumentation().setValue(DOC); dataObject.setName(new Name(NAME)); dataObject.setType(new DataObjectType(new DataObjectTypeValue(NAME))); dataObjectNode = new NodeImpl<>(UUID.uuid()); dataObjectNode.setContent(dataObjectView); when(dataObjectView.getDefinition()).thenReturn(dataObject); when(propertyWriterFactory.of(any(org.eclipse.bpmn2.DataObjectReference.class))).thenReturn(dataObjectWriter); artifactsConverter = new ArtifactsConverter(propertyWriterFactory); PropertyWriter propertyWriter = artifactsConverter.toElement(((NodeImpl) dataObjectNode)); verify(dataObjectWriter).setName(NAME); verify(dataObjectWriter).setType(NAME); verify(dataObjectWriter).setAbsoluteBounds(dataObjectNode); assertEquals(dataObjectWriter, propertyWriter); } |
### Question:
AssociationConverter { public Result<BasePropertyWriter> toFlowElement(Edge<?, ?> edge, ElementContainer process) { ViewConnector<Association> connector = (ViewConnector<Association>) edge.getContent(); Association definition = connector.getDefinition(); org.eclipse.bpmn2.Association association = bpmn2.createAssociation(); AssociationPropertyWriter p = propertyWriterFactory.of(association); association.setId(edge.getUUID()); BasePropertyWriter pSrc = process.getChildElement(edge.getSourceNode().getUUID()); BasePropertyWriter pTgt = process.getChildElement(edge.getTargetNode().getUUID()); if (pSrc == null || pTgt == null) { String msg = String.format("BasePropertyWriter was not found for source node or target node at edge: %s, pSrc = %s, pTgt = %s", edge.getUUID(), pSrc, pTgt); LOG.debug(msg); return Result.failure(msg); } p.setSource(pSrc); p.setTarget(pTgt); p.setConnection(connector); BPMNGeneralSet general = definition.getGeneral(); p.setDocumentation(general.getDocumentation().getValue()); p.setDirectionAssociation(definition); return Result.of(p); } AssociationConverter(PropertyWriterFactory propertyWriterFactory); Result<BasePropertyWriter> toFlowElement(Edge<?, ?> edge, ElementContainer process); }### Answer:
@Test public void testToFlowElementSuccess() { org.kie.workbench.common.stunner.bpmn.definition.Association association = new org.kie.workbench.common.stunner.bpmn.definition.DirectionalAssociation(); association.setGeneral(new BPMNGeneralSet("nameValue", "documentationValue")); when(connector.getDefinition()).thenReturn(association); Result<BasePropertyWriter> result = converter.toFlowElement(edge, process); assertTrue(result.isSuccess()); verify(propertyWriterFactory).of(argumentCaptor.capture()); assertEquals(EDGE_ID, argumentCaptor.getValue().getId()); verify(associationPropertyWriter).setSource(pSrc); verify(associationPropertyWriter).setTarget(pTgt); verify(associationPropertyWriter).setConnection(connector); verify(associationPropertyWriter).setDocumentation("documentationValue"); verify(associationPropertyWriter).setDirectionAssociation(association); }
@Test public void testToFlowElementWithSourceMissingFailure() { when(process.getChildElement(SOURCE_NODE_ID)).thenReturn(null); Result<BasePropertyWriter> result = converter.toFlowElement(edge, process); verifyFailure(String.format(ERROR_PATTERN, EDGE_ID, null, pTgt), result); }
@Test public void testToFlowElementWithTargetMissingFailure() { when(process.getChildElement(TARGET_NODE_ID)).thenReturn(null); Result<BasePropertyWriter> result = converter.toFlowElement(edge, process); verifyFailure(String.format(ERROR_PATTERN, EDGE_ID, pSrc, null), result); }
@Test public void testToFlowElementWithSourceAndTargetMissingFailure() { when(process.getChildElement(SOURCE_NODE_ID)).thenReturn(null); when(process.getChildElement(TARGET_NODE_ID)).thenReturn(null); Result<BasePropertyWriter> result = converter.toFlowElement(edge, process); verifyFailure(String.format(ERROR_PATTERN, EDGE_ID, null, null), result); } |
### Question:
DecisionComponentsView implements DecisionComponents.View { @Override public void disableFilterInputs() { termFilter.value = ""; getDrgElementFilter().selectpicker("val", ""); disableFilterInputs(true); } @Inject DecisionComponentsView(final HTMLSelectElement drgElementFilter,
final HTMLInputElement termFilter,
final HTMLDivElement list,
final HTMLDivElement emptyState,
final HTMLDivElement loading,
final HTMLDivElement componentsCounter,
final TranslationService translationService); @PostConstruct void init(); @Override void init(final DecisionComponents presenter); @EventHandler("term-filter") void onTermFilterChange(final KeyUpEvent e); @Override void clear(); @Override void addListItem(final HTMLElement htmlElement); @Override void showEmptyState(); @Override void showLoading(); @Override void hideLoading(); @Override void disableFilterInputs(); @Override void enableFilterInputs(); @Override void setComponentsCounter(final Integer count); }### Answer:
@Test public void testDisableFilterInputs() { final JQuerySelectPicker selectPicker = mock(JQuerySelectPicker.class); doReturn(selectPicker).when(view).getDrgElementFilter(); termFilter.value = "something"; view.disableFilterInputs(); assertEquals("", termFilter.value); assertTrue(termFilter.disabled); assertTrue(drgElementFilter.disabled); verify(selectPicker).selectpicker("val", ""); verify(selectPicker).selectpicker("refresh"); } |
### Question:
RootProcessConverter { public ProcessPropertyWriter convertProcess() { ProcessPropertyWriter processRoot = convertProcessNode(context.firstNode()); delegate.convertChildNodes(processRoot, context); delegate.convertEdges(processRoot, context); delegate.postConvertChildNodes(processRoot, context); return processRoot; } RootProcessConverter(DefinitionsBuildingContext context,
PropertyWriterFactory propertyWriterFactory,
ConverterFactory converterFactory); ProcessPropertyWriter convertProcess(); }### Answer:
@Test public void convertProcessWithCaseProperties() { final ProcessPropertyWriter propertyWriter = converter.convertProcess(); verify(propertyWriter).setCaseIdPrefix(caseIdPrefix); verify(propertyWriter).setCaseRoles(caseRoles); verify(propertyWriter).setCaseFileVariables(caseFileVariables); }
@Test public void convertProcessWithExecutable() { final ProcessPropertyWriter propertyWriter = converter.convertProcess(); verify(propertyWriter).setExecutable(anyBoolean()); }
@Test public void convertProcessWithGlobalVariables() { final ProcessPropertyWriter propertyWriter = converter.convertProcess(); verify(propertyWriter).setGlobalVariables(any(GlobalVariables.class)); }
@Test public void convertProcessWithImports() { final ProcessPropertyWriter propertyWriter = converter.convertProcess(); verify(propertyWriter).setDefaultImports(anyListOf(DefaultImport.class)); }
@Test public void convertProcessWithSlaDueDate() { final ProcessPropertyWriter propertyWriter = converter.convertProcess(); verify(propertyWriter).setSlaDueDate(any(SLADueDate.class)); } |
### Question:
ProcessConverterDelegate { void postConvertChildNodes(ProcessPropertyWriter processWriter, DefinitionsBuildingContext context) { final Map<String, BasePropertyWriter> propertyWriters = collectPropertyWriters(processWriter); context.nodes().forEach(node -> converterFactory.flowElementPostConverter().postConvert(processWriter, propertyWriters.get(node.getUUID()), node)); } ProcessConverterDelegate(ConverterFactory converterFactory); }### Answer:
@Test @SuppressWarnings("unchecked") public void testPostConvertNodes() { TestingGraphMockHandler graphTestHandler = new TestingGraphMockHandler(); BPMNDiagramImpl bpmnDiagram = new BPMNDiagramImpl(); StartNoneEvent level0StartNode = new StartNoneEvent(); EndNoneEvent level0EndNode = new EndNoneEvent(); UserTask level0Node1 = new UserTask(); UserTask level0Node2 = new UserTask(); EmbeddedSubprocess level1SubProcess1 = new EmbeddedSubprocess(); ScriptTask level1Node1 = new ScriptTask(); IntermediateSignalEventThrowing level1Node2 = new IntermediateSignalEventThrowing(); AdHocSubprocess level2SubProcess1 = new AdHocSubprocess(); BusinessRuleTask level2Node1 = new BusinessRuleTask(); EndCompensationEvent level2Node2 = new EndCompensationEvent(); TestingGraphInstanceBuilder2.Level2Graph level2Graph = TestingGraphInstanceBuilder2.buildLevel2Graph(graphTestHandler, bpmnDiagram, level0StartNode, level0Node1, level0Node2, level0EndNode, level1SubProcess1, level1Node1, level1Node2, level2SubProcess1, level2Node1, level2Node2); DefinitionsBuildingContext ctx = new DefinitionsBuildingContext(level2Graph.graph); PropertyWriterFactory writerFactory = new PropertyWriterFactory(); ConverterFactory factory = spy(new ConverterFactory(ctx, writerFactory)); FlowElementPostConverter flowElementPostConverter = mock(FlowElementPostConverter.class); when(factory.flowElementPostConverter()).thenReturn(flowElementPostConverter); MyProcessConverter abstractProcessConverter = new MyProcessConverter(factory); ProcessPropertyWriter processWriter = writerFactory.of(bpmn2.createProcess()); abstractProcessConverter.postConvertChildNodes(processWriter, ctx); verify(flowElementPostConverter, times(10)).postConvert(anyObject(), anyObject(), nodeCaptor.capture()); Map<String, BPMNViewDefinition> nodes = new HashMap<>(); nodes.put(LEVEL0_START_NODE.uuid(), level0StartNode); nodes.put(LEVEL0_NODE1.uuid(), level0Node1); nodes.put(LEVEL0_NODE2.uuid(), level0Node2); nodes.put(LEVEL0_END_NODE.uuid(), level0EndNode); nodes.put(LEVEL1_SUB_PROCESS1.uuid(), level1SubProcess1); nodes.put(LEVEL1_NODE1.uuid(), level1Node1); nodes.put(LEVEL1_NODE2.uuid(), level1Node2); nodes.put(LEVEL2_SUB_PROCESS1.uuid(), level2SubProcess1); nodes.put(LEVEL2_NODE1.uuid(), level2Node1); nodes.put(LEVEL2_NODE2.uuid(), level2Node2); assertEquals(nodes.size(), nodeCaptor.getAllValues().size()); nodes.entrySet().forEach(entry -> { Optional<Node<View<? extends BPMNViewDefinition>, ?>> processed = nodeCaptor.getAllValues() .stream() .filter(captured -> entry.getKey().equals(captured.getUUID())) .findFirst(); assertTrue("Node: " + entry.getKey() + " was not present in result", processed.isPresent()); assertEquals(entry.getValue(), processed.get().getContent().getDefinition()); }); } |
### Question:
EventSubProcessPostConverter implements PostConverterProcessor { @Override public void process(ProcessPropertyWriter processWriter, BasePropertyWriter nodeWriter, Node<View<? extends BPMNViewDefinition>, ?> node) { boolean isForCompensation = GraphUtils.getChildNodes(node).stream() .filter(currentNode -> currentNode.getContent() instanceof View && ((View) currentNode.getContent()).getDefinition() instanceof StartCompensationEvent) .findFirst() .isPresent(); if (isForCompensation) { ((SubProcess) nodeWriter.getElement()).setIsForCompensation(true); } } @Override void process(ProcessPropertyWriter processWriter,
BasePropertyWriter nodeWriter,
Node<View<? extends BPMNViewDefinition>, ?> node); }### Answer:
@Test @SuppressWarnings("unchecked") public void testProcessWhenIsForCompensation() { outEdges.add(mockEdge(mock(Node.class), newNode(new StartCompensationEvent()))); converter.process(processWriter, nodeWriter, eventSubprocessNode); verify(subProcess).setIsForCompensation(true); }
@Test @SuppressWarnings("unchecked") public void testProcessWhenIsNotForCompensation() { converter.process(processWriter, nodeWriter, eventSubprocessNode); verify(subProcess, never()).setIsForCompensation(true); } |
### Question:
SubProcessConverter extends ProcessConverterDelegate { protected SubProcessPropertyWriter convertAdHocSubprocessNode(Node<View<BaseAdHocSubprocess>, ?> n) { org.eclipse.bpmn2.AdHocSubProcess process = bpmn2.createAdHocSubProcess(); process.setId(n.getUUID()); AdHocSubProcessPropertyWriter p = propertyWriterFactory.of(process); BaseAdHocSubprocess definition = n.getContent().getDefinition(); BPMNGeneralSet general = definition.getGeneral(); p.setName(general.getName().getValue()); p.setDocumentation(general.getDocumentation().getValue()); BaseProcessData processData = definition.getProcessData(); p.setProcessVariables(processData.getProcessVariables()); BaseAdHocSubprocessTaskExecutionSet executionSet = definition.getExecutionSet(); p.setAdHocActivationCondition(executionSet.getAdHocActivationCondition()); p.setAdHocCompletionCondition(executionSet.getAdHocCompletionCondition()); p.setAdHocOrdering(executionSet.getAdHocOrdering()); p.setOnEntryAction(executionSet.getOnEntryAction()); p.setOnExitAction(executionSet.getOnExitAction()); p.setAsync(executionSet.getIsAsync().getValue()); p.setSlaDueDate(executionSet.getSlaDueDate()); p.setSimulationSet(definition.getSimulationSet()); p.setAbsoluteBounds(n); p.setAdHocAutostart(executionSet.getAdHocAutostart().getValue()); return p; } SubProcessConverter(DefinitionsBuildingContext context,
PropertyWriterFactory propertyWriterFactory,
ConverterFactory converterFactory); Result<SubProcessPropertyWriter> convertSubProcess(Node<View<? extends BPMNViewDefinition>, ?> node); }### Answer:
@Test public void testConvertAdHocSubprocessNode_autostart() { final AdHocSubprocess definition = new AdHocSubprocess(); definition.getExecutionSet().setAdHocAutostart(new AdHocAutostart(true)); final View<BaseAdHocSubprocess> view = new ViewImpl<>(definition, Bounds.create()); final Node<View<BaseAdHocSubprocess>, ?> node = new NodeImpl<>(UUID.randomUUID().toString()); node.setContent(view); SubProcessPropertyWriter writer = tested.convertAdHocSubprocessNode(node); assertTrue(AdHocSubProcessPropertyWriter.class.isInstance(writer)); assertTrue(CustomElement.autoStart.of(writer.getFlowElement()).get()); }
@Test public void testConvertAdHocSubprocessNode_notautostart() { final AdHocSubprocess definition = new AdHocSubprocess(); definition.getExecutionSet().setAdHocAutostart(new AdHocAutostart(false)); final View<BaseAdHocSubprocess> view = new ViewImpl<>(definition, Bounds.create()); final Node<View<BaseAdHocSubprocess>, ?> node = new NodeImpl<>(UUID.randomUUID().toString()); node.setContent(view); SubProcessPropertyWriter writer = tested.convertAdHocSubprocessNode(node); assertTrue(AdHocSubProcessPropertyWriter.class.isInstance(writer)); assertFalse(CustomElement.autoStart.of(writer.getFlowElement()).get()); } |
### Question:
DecisionComponentsView implements DecisionComponents.View { @Override public void enableFilterInputs() { disableFilterInputs(false); } @Inject DecisionComponentsView(final HTMLSelectElement drgElementFilter,
final HTMLInputElement termFilter,
final HTMLDivElement list,
final HTMLDivElement emptyState,
final HTMLDivElement loading,
final HTMLDivElement componentsCounter,
final TranslationService translationService); @PostConstruct void init(); @Override void init(final DecisionComponents presenter); @EventHandler("term-filter") void onTermFilterChange(final KeyUpEvent e); @Override void clear(); @Override void addListItem(final HTMLElement htmlElement); @Override void showEmptyState(); @Override void showLoading(); @Override void hideLoading(); @Override void disableFilterInputs(); @Override void enableFilterInputs(); @Override void setComponentsCounter(final Integer count); }### Answer:
@Test public void testEnableFilterInputs() { final JQuerySelectPicker selectPicker = mock(JQuerySelectPicker.class); doReturn(selectPicker).when(view).getDrgElementFilter(); view.enableFilterInputs(); assertFalse(termFilter.disabled); assertFalse(drgElementFilter.disabled); verify(selectPicker).selectpicker("refresh"); } |
### Question:
SubProcessConverter extends ProcessConverterDelegate { protected SubProcessPropertyWriter convertMultipleInstanceSubprocessNode(Node<View<MultipleInstanceSubprocess>, ?> n) { SubProcess process = bpmn2.createSubProcess(); process.setId(n.getUUID()); MultipleInstanceSubProcessPropertyWriter p = propertyWriterFactory.ofMultipleInstanceSubProcess(process); MultipleInstanceSubprocess definition = n.getContent().getDefinition(); BPMNGeneralSet general = definition.getGeneral(); p.setName(general.getName().getValue()); p.setDocumentation(general.getDocumentation().getValue()); ProcessData processData = definition.getProcessData(); p.setProcessVariables(processData.getProcessVariables()); MultipleInstanceSubprocessTaskExecutionSet executionSet = definition.getExecutionSet(); p.setIsSequential(executionSet.getMultipleInstanceExecutionMode().isSequential()); p.setCollectionInput(executionSet.getMultipleInstanceCollectionInput().getValue()); p.setInput(executionSet.getMultipleInstanceDataInput().getValue()); p.setCollectionOutput(executionSet.getMultipleInstanceCollectionOutput().getValue()); p.setOutput(executionSet.getMultipleInstanceDataOutput().getValue()); p.setCompletionCondition(executionSet.getMultipleInstanceCompletionCondition().getValue()); p.setOnEntryAction(executionSet.getOnEntryAction()); p.setOnExitAction(executionSet.getOnExitAction()); p.setAsync(executionSet.getIsAsync().getValue()); p.setSlaDueDate(executionSet.getSlaDueDate()); p.setSimulationSet(definition.getSimulationSet()); p.setAbsoluteBounds(n); return p; } SubProcessConverter(DefinitionsBuildingContext context,
PropertyWriterFactory propertyWriterFactory,
ConverterFactory converterFactory); Result<SubProcessPropertyWriter> convertSubProcess(Node<View<? extends BPMNViewDefinition>, ?> node); }### Answer:
@Test public void testConvertMultipleIntanceSubprocess() { final MultipleInstanceSubprocess definition = new MultipleInstanceSubprocess(); setBaseSubprocessExecutionSetValues(definition.getExecutionSet()); final View<MultipleInstanceSubprocess> view = new ViewImpl<>(definition, Bounds.create()); final Node<View<MultipleInstanceSubprocess>, ?> node = new NodeImpl<>(UUID.randomUUID().toString()); node.setContent(view); SubProcessPropertyWriter writer = tested.convertMultipleInstanceSubprocessNode(node); assertBaseSubprocessExecutionSet(writer); } |
### Question:
SubProcessConverter extends ProcessConverterDelegate { protected SubProcessPropertyWriter convertEmbeddedSubprocessNode(Node<View<EmbeddedSubprocess>, ?> n) { SubProcess process = bpmn2.createSubProcess(); process.setId(n.getUUID()); SubProcessPropertyWriter p = propertyWriterFactory.of(process); EmbeddedSubprocess definition = n.getContent().getDefinition(); BPMNGeneralSet general = definition.getGeneral(); p.setName(general.getName().getValue()); p.setDocumentation(general.getDocumentation().getValue()); EmbeddedSubprocessExecutionSet executionSet = definition.getExecutionSet(); p.setOnEntryAction(executionSet.getOnEntryAction()); p.setOnExitAction(executionSet.getOnExitAction()); p.setAsync(executionSet.getIsAsync().getValue()); p.setSlaDueDate(executionSet.getSlaDueDate()); ProcessData processData = definition.getProcessData(); p.setProcessVariables(processData.getProcessVariables()); p.setSimulationSet(definition.getSimulationSet()); p.setAbsoluteBounds(n); return p; } SubProcessConverter(DefinitionsBuildingContext context,
PropertyWriterFactory propertyWriterFactory,
ConverterFactory converterFactory); Result<SubProcessPropertyWriter> convertSubProcess(Node<View<? extends BPMNViewDefinition>, ?> node); }### Answer:
@Test public void testConvertEmbeddedSubprocess() { final EmbeddedSubprocess definition = new EmbeddedSubprocess(); setBaseSubprocessExecutionSetValues(definition.getExecutionSet()); final View<EmbeddedSubprocess> view = new ViewImpl<>(definition, Bounds.create()); final Node<View<EmbeddedSubprocess>, ?> node = new NodeImpl<>(UUID.randomUUID().toString()); node.setContent(view); SubProcessPropertyWriter writer = tested.convertEmbeddedSubprocessNode(node); assertBaseSubprocessExecutionSet(writer); } |
### Question:
SubProcessConverter extends ProcessConverterDelegate { protected SubProcessPropertyWriter convertEventSubprocessNode(Node<View<EventSubprocess>, ?> n) { SubProcess process = bpmn2.createSubProcess(); process.setId(n.getUUID()); SubProcessPropertyWriter p = propertyWriterFactory.of(process); EventSubprocess definition = n.getContent().getDefinition(); process.setTriggeredByEvent(true); BPMNGeneralSet general = definition.getGeneral(); p.setName(general.getName().getValue()); p.setDocumentation(general.getDocumentation().getValue()); ProcessData processData = definition.getProcessData(); p.setProcessVariables(processData.getProcessVariables()); EventSubprocessExecutionSet executionSet = definition.getExecutionSet(); p.setAsync(executionSet.getIsAsync().getValue()); p.setSlaDueDate(executionSet.getSlaDueDate()); p.setSimulationSet(definition.getSimulationSet()); p.setAbsoluteBounds(n); return p; } SubProcessConverter(DefinitionsBuildingContext context,
PropertyWriterFactory propertyWriterFactory,
ConverterFactory converterFactory); Result<SubProcessPropertyWriter> convertSubProcess(Node<View<? extends BPMNViewDefinition>, ?> node); }### Answer:
@Test public void testConvertEventSubprocess() { final EventSubprocess definition = new EventSubprocess(); setBaseSubprocessExecutionSetValues(definition.getExecutionSet()); final View<EventSubprocess> view = new ViewImpl<>(definition, Bounds.create()); final Node<View<EventSubprocess>, ?> node = new NodeImpl<>(UUID.randomUUID().toString()); node.setContent(view); SubProcessPropertyWriter writer = tested.convertEventSubprocessNode(node); assertBaseSubprocessExecutionSet(writer); } |
### Question:
DefinitionsConverter { public Definitions toDefinitions() { Definitions definitions = bpmn2.createDefinitions(); DefinitionsPropertyWriter p = propertyWriterFactory.of(definitions); ProcessPropertyWriter pp = processConverter.convertProcess(); Node<Definition<BPMNDiagram>, ?> node = converterFactory.context.firstNode(); BPMNDiagram definition = node.getContent().getDefinition(); BaseDiagramSet diagramSet = definition.getDiagramSet(); p.setExporter("jBPM Process Modeler"); p.setExporterVersion("2.0"); p.setProcess(pp.getProcess()); p.setDiagram(pp.getBpmnDiagram()); p.setRelationship(pp.getRelationship()); p.setWSDLImports(diagramSet.getImports().getValue().getWSDLImports()); p.addAllRootElements(pp.getItemDefinitions()); p.addAllRootElements(pp.getRootElements()); p.addAllRootElements(pp.getInterfaces()); return definitions; } DefinitionsConverter(ConverterFactory converterFactory, PropertyWriterFactory propertyWriterFactory); DefinitionsConverter(Graph graph); Definitions toDefinitions(); }### Answer:
@Test public void JBPM_7526_shouldSetExporter() { GraphNodeStoreImpl nodeStore = new GraphNodeStoreImpl(); NodeImpl x = new NodeImpl("x"); BPMNDiagramImpl diag = new BPMNDiagramImpl(); diag.setDiagramSet(new DiagramSet( new Name("x"), new Documentation("doc"), new Id("x"), new Package("org.jbpm"), new ProcessType(), new Version("1.0"), new AdHoc(false), new ProcessInstanceDescription("descr"), new Imports(), new Executable(true), new SLADueDate("") )); x.setContent(new ViewImpl<>(diag, Bounds.create())); nodeStore.add(x); ConverterFactory f = new ConverterFactory(new DefinitionsBuildingContext( new GraphImpl("x", nodeStore)), new PropertyWriterFactory()); DefinitionsConverter definitionsConverter = new DefinitionsConverter(f, new PropertyWriterFactory()); Definitions definitions = definitionsConverter.toDefinitions(); assertThat(definitions.getExporter()).isNotBlank(); assertThat(definitions.getExporterVersion()).isNotBlank(); }
@Test public void toDefinitions() { final String LOCATION = "Location"; final String NAMESPACE = "Namespace"; ImportsValue importsValue = new ImportsValue(); importsValue.addImport(new WSDLImport(LOCATION, NAMESPACE)); BPMNDiagramImpl diag = new BPMNDiagramImpl(); diag.setDiagramSet(new DiagramSet( new Name(), new Documentation(), new Id(), new Package(), new ProcessType(), new Version(), new AdHoc(false), new ProcessInstanceDescription(), new Imports(importsValue), new Executable(true), new SLADueDate() )); GraphNodeStoreImpl nodeStore = new GraphNodeStoreImpl(); NodeImpl x = new NodeImpl("x"); x.setContent(new ViewImpl<>(diag, Bounds.create())); nodeStore.add(x); ConverterFactory f = new ConverterFactory(new DefinitionsBuildingContext(new GraphImpl("x", nodeStore)), new PropertyWriterFactory()); DefinitionsConverter definitionsConverter = new DefinitionsConverter(f, new PropertyWriterFactory()); Definitions definitions = definitionsConverter.toDefinitions(); assertImportsValue(LOCATION, NAMESPACE, definitions); } |
### Question:
WorkItemDefinitionRemoteService implements WorkItemDefinitionService<WorkItemDefinitionRemoteRequest> { @Override public Collection<WorkItemDefinition> execute(final WorkItemDefinitionRemoteRequest request) { return fetch(lookupService, request.getUri(), request.getNames()); } WorkItemDefinitionRemoteService(); WorkItemDefinitionRemoteService(Function<String, WorkItemsHolder> lookupService); @Override Collection<WorkItemDefinition> execute(final WorkItemDefinitionRemoteRequest request); static Collection<WorkItemDefinition> fetch(final Function<String, WorkItemsHolder> lookupService,
final String serviceRepoUrl,
final String[] names); static Function<String, WorkItemsHolder> DEFAULT_LOOKUP_SERVICE; }### Answer:
@Test public void testExecute() { Collection<WorkItemDefinition> result = tested.execute(WorkItemDefinitionRemoteRequest.build(URL, new String[]{WD1_NAME, WD2_NAME})); assertFalse(result.isEmpty()); assertEquals(2, result.size()); assertTrue(result.stream().anyMatch(w -> WD1_NAME.equals(w.getName()))); assertTrue(result.stream().anyMatch(w -> WD2_NAME.equals(w.getName()))); }
@Test public void testExecuteFiltered1() { Collection<WorkItemDefinition> result = tested.execute(WorkItemDefinitionRemoteRequest.build(URL, new String[]{WD1_NAME})); assertFalse(result.isEmpty()); assertEquals(1, result.size()); assertTrue(result.stream().anyMatch(w -> WD1_NAME.equals(w.getName()))); }
@Test public void testExecuteFiltered2() { Collection<WorkItemDefinition> result = tested.execute(WorkItemDefinitionRemoteRequest.build(URL, new String[]{WD2_NAME})); assertFalse(result.isEmpty()); assertEquals(1, result.size()); assertTrue(result.stream().anyMatch(w -> WD2_NAME.equals(w.getName()))); } |
### Question:
DecisionComponentsView implements DecisionComponents.View { @Override public void setComponentsCounter(final Integer count) { componentsCounter.textContent = count.toString(); } @Inject DecisionComponentsView(final HTMLSelectElement drgElementFilter,
final HTMLInputElement termFilter,
final HTMLDivElement list,
final HTMLDivElement emptyState,
final HTMLDivElement loading,
final HTMLDivElement componentsCounter,
final TranslationService translationService); @PostConstruct void init(); @Override void init(final DecisionComponents presenter); @EventHandler("term-filter") void onTermFilterChange(final KeyUpEvent e); @Override void clear(); @Override void addListItem(final HTMLElement htmlElement); @Override void showEmptyState(); @Override void showLoading(); @Override void hideLoading(); @Override void disableFilterInputs(); @Override void enableFilterInputs(); @Override void setComponentsCounter(final Integer count); }### Answer:
@Test public void testSetComponentsCounter() { view.setComponentsCounter(123); assertEquals("123", componentsCounter.textContent); } |
### Question:
WorkItemDefinitionVFSLookupService implements WorkItemDefinitionService<Metadata> { @Override public Collection<WorkItemDefinition> execute(final Metadata metadata) { return search(metadata); } protected WorkItemDefinitionVFSLookupService(); @Inject WorkItemDefinitionVFSLookupService(final VFSService vfsService,
final WorkItemDefinitionResources resources); @Override Collection<WorkItemDefinition> execute(final Metadata metadata); Collection<WorkItemDefinition> search(final Metadata metadata); Collection<WorkItemDefinition> search(final Metadata metadata,
final Path root); Collection<WorkItemDefinition> get(final Metadata metadata,
final Path resource); }### Answer:
@Test @SuppressWarnings("unchecked") public void testFilter() { Collection<WorkItemDefinition> result = tested.execute(metadata); ArgumentCaptor<DirectoryStream.Filter> filterCaptor = ArgumentCaptor.forClass(DirectoryStream.Filter.class); verify(vfsService, times(1)) .newDirectoryStream(eq(path), filterCaptor.capture()); DirectoryStream.Filter<Path> filter = filterCaptor.getValue(); Path path1 = mock(Path.class); when(path1.getFileName()).thenReturn("someFile.wid"); assertTrue(filter.accept(path1)); when(path1.getFileName()).thenReturn("someFile.bpmn"); assertFalse(filter.accept(path1)); when(path1.getFileName()).thenReturn("someFile.WID"); assertTrue(filter.accept(path1)); when(path1.getFileName()).thenReturn("someFile.WiD"); assertTrue(filter.accept(path1)); }
@Test @SuppressWarnings("unchecked") public void testExecute() { Collection<WorkItemDefinition> result = tested.execute(metadata); ArgumentCaptor<DirectoryStream.Filter> filterCaptor = ArgumentCaptor.forClass(DirectoryStream.Filter.class); verify(vfsService, times(1)) .newDirectoryStream(eq(path), any(DirectoryStream.Filter.class)); assertFalse(result.isEmpty()); assertEquals(1, result.size()); WorkItemDefinition wid = result.iterator().next(); assertEquals("Email", wid.getName()); } |
### Question:
WorkItemDefinitionDeployServices { @SuppressWarnings("all") public void deploy(final Metadata metadata) { final Path root = metadata.getRoot(); final Path deployedPath = getDeployedRoot(metadata); final Path path = null != deployedPath ? deployedPath : root; synchronized (path) { if (null == getDeployedRoot(metadata)) { deployed.put(root.toURI(), root); deployServices.forEach(s -> s.deploy(metadata)); } } } protected WorkItemDefinitionDeployServices(); @Inject WorkItemDefinitionDeployServices(final @Any Instance<WorkItemDefinitionDeployService> deployServices); WorkItemDefinitionDeployServices(final Iterable<WorkItemDefinitionDeployService> deployServices,
final Map<String, Path> deployed); @SuppressWarnings("all") void deploy(final Metadata metadata); }### Answer:
@Test public void testDeploy() { tested.deploy(METADATA1); tested.deploy(METADATA2); tested.deploy(METADATA1); tested.deploy(METADATA2); verify(service1, times(1)).deploy(eq(METADATA1)); verify(service2, times(1)).deploy(eq(METADATA1)); verify(service1, times(1)).deploy(eq(METADATA2)); verify(service2, times(1)).deploy(eq(METADATA2)); } |
### Question:
WorkItemDefinitionDefaultDeployService implements WorkItemDefinitionDeployService { @Override public void deploy(final Metadata metadata) { backendFileSystemManager .deploy(resources.resolveGlobalPath(metadata), new Assets(Arrays.stream(ASSETS) .map(asset -> assetBuilder.apply(asset, ASSETS_ROOT + asset)) .collect(Collectors.toList())), DEPLOY_MESSAGE); } protected WorkItemDefinitionDefaultDeployService(); @Inject WorkItemDefinitionDefaultDeployService(final WorkItemDefinitionResources resources,
final BackendFileSystemManager backendFileSystemManager); WorkItemDefinitionDefaultDeployService(final WorkItemDefinitionResources resources,
final BackendFileSystemManager backendFileSystemManager,
final BiFunction<String, String, Asset> assetBuilder); @Override void deploy(final Metadata metadata); }### Answer:
@Test public void testDeployAssets() { ArgumentCaptor<Assets> assetsArgumentCaptor = ArgumentCaptor.forClass(Assets.class); tested.deploy(metadata); verify(backendFileSystemManager, times(1)) .deploy(eq(globalPath), assetsArgumentCaptor.capture(), anyString()); Collection<Asset> assets = assetsArgumentCaptor.getValue().getAssets(); assertEquals(WorkItemDefinitionDefaultDeployService.ASSETS.length, assets.size()); assertTrue(assets.contains(widAsset)); assertTrue(assets.contains(emailIcon)); assertTrue(assets.contains(brIcon)); assertTrue(assets.contains(decisionIcon)); assertTrue(assets.contains(logIcon)); assertTrue(assets.contains(serviceNodeIcon)); assertTrue(assets.contains(milestoneNodeIcon)); } |
### Question:
WorkItemDefinitionParser { public static Collection<WorkItemDefinition> parse(final String content, final Function<WorkDefinitionImpl, String> uriProvider, final Function<String, String> dataUriProvider) throws Exception { final Map<String, WorkDefinitionImpl> definitionMap = parseJBPMWorkItemDefinitions(content, dataUriProvider); return definitionMap.values().stream() .map(wid -> parse(wid, uriProvider, dataUriProvider)) .collect(Collectors.toList()); } static Collection<WorkItemDefinition> parse(final String content,
final Function<WorkDefinitionImpl, String> uriProvider,
final Function<String, String> dataUriProvider); static WorkItemDefinition parse(final WorkDefinitionImpl workDefinition,
final Function<WorkDefinitionImpl, String> uriProvider,
final Function<String, String> dataUriProvider); static String buildDataURIFromURL(final String url); static final Map<Class<?>, Function<Object, String>> DATA_TYPE_FORMATTERS; static final String ENCODING; }### Answer:
@Test public void testParseJBPMWorkDefinition() { WorkItemDefinition workItemDefinition = WorkItemDefinitionParser.parse(jbpmWorkDefinition, w -> "uri", dataUriProvider); assertNotNull(workItemDefinition); assertEquals(NAME, workItemDefinition.getName()); assertEquals(CATWGORY, workItemDefinition.getCategory()); assertEquals(DESC, workItemDefinition.getDescription()); assertEquals(DISPLAY_NAME, workItemDefinition.getDisplayName()); assertEquals(DOC, workItemDefinition.getDocumentation()); assertEquals(HANDLER, workItemDefinition.getDefaultHandler()); assertEquals(ICON_DATA, workItemDefinition.getIconDefinition().getIconData()); assertEquals("|param1:String,param2:String|", workItemDefinition.getParameters()); assertEquals("||", workItemDefinition.getResults()); }
@Test public void testEmailWorkItemDefinition() throws Exception { when(dataUriProvider.apply(eq("email.gif"))).thenReturn(ICON_DATA); String raw = loadStream(WID_EMAIL); Collection<WorkItemDefinition> workItemDefinitions = WorkItemDefinitionParser.parse(raw, w -> "uri", dataUriProvider); assertNotNull(workItemDefinitions); assertEquals(1, workItemDefinitions.size()); WorkItemDefinition workItemDefinition = workItemDefinitions.iterator().next(); assertNotNull(workItemDefinition); assertEquals("Email", workItemDefinition.getName()); assertEquals("Communication", workItemDefinition.getCategory()); assertEquals("Sending emails", workItemDefinition.getDescription()); assertEquals("Email", workItemDefinition.getDisplayName()); assertEquals("index.html", workItemDefinition.getDocumentation()); assertEquals("org.jbpm.process.workitem.email.EmailWorkItemHandler", workItemDefinition.getDefaultHandler()); assertEquals(ICON_DATA, workItemDefinition.getIconDefinition().getIconData()); assertEquals("|Body:String,From:String,Subject:String,To:String|", workItemDefinition.getParameters()); assertEquals("||", workItemDefinition.getResults()); }
@Test public void testFTPWorkItemDefinition() throws Exception { when(dataUriProvider.apply(eq("ftp.gif"))).thenReturn(ICON_DATA); String raw = loadStream(WID_FTP); Collection<WorkItemDefinition> workItemDefinitions = WorkItemDefinitionParser.parse(raw, w -> "uri", dataUriProvider); assertNotNull(workItemDefinitions); assertEquals(1, workItemDefinitions.size()); WorkItemDefinition workItemDefinition = workItemDefinitions.iterator().next(); assertNotNull(workItemDefinition); assertEquals("FTP", workItemDefinition.getName()); assertEquals("File System", workItemDefinition.getCategory()); assertEquals("Sending files using FTP", workItemDefinition.getDescription()); assertEquals("FTP", workItemDefinition.getDisplayName()); assertEquals("", workItemDefinition.getDocumentation()); assertEquals("org.jbpm.process.workitem.ftp.FTPUploadWorkItemHandler", workItemDefinition.getDefaultHandler()); assertEquals(ICON_DATA, workItemDefinition.getIconDefinition().getIconData()); assertEquals("|Body:String,FilePath:String,Password:String,User:String|", workItemDefinition.getParameters()); assertEquals("||", workItemDefinition.getResults()); } |
### Question:
BPMNRuleFlowProjectProfile extends BPMNRuleFlowProfile implements ProjectProfile { @Override public String getProjectProfileName() { return Profile.PLANNER_AND_RULES.getName(); } @Override String getProjectProfileName(); }### Answer:
@Test public void testProfile() { BPMNRuleFlowProjectProfile profile = new BPMNRuleFlowProjectProfile(); assertEquals(new BPMNRuleFlowProfile().getProfileId(), profile.getProfileId()); assertEquals(Profile.PLANNER_AND_RULES.getName(), profile.getProjectProfileName()); } |
### Question:
FindBpmnProcessIdsQuery extends AbstractFindIdsQuery { @Override protected ResourceType getProcessIdResourceType() { return ResourceType.BPMN2; } @Override String getName(); static final String NAME; }### Answer:
@Test public void testGetProcessIdResourceType() throws Exception { assertEquals(tested.getProcessIdResourceType(), ResourceType.BPMN2); } |
### Question:
CaseGraphFactoryImpl extends BPMNGraphFactoryImpl { @Override public Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata) { workItemDefinitionService.execute(metadata); return super.build(uuid, definition); } CaseGraphFactoryImpl(); @Inject CaseGraphFactoryImpl(DefinitionManager definitionManager, FactoryManager factoryManager,
RuleManager ruleManager, GraphCommandManager graphCommandManager,
GraphCommandFactory graphCommandFactory, GraphIndexBuilder<?> indexBuilder,
CustomTaskFactory customTaskFactory,
WorkItemDefinitionLookupService workItemDefinitionService); @Override Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata); }### Answer:
@Test public void build() { tested.build("uuid", "def", projectMetadata); verify(workItemDefinitionService).execute(projectMetadata); } |
### Question:
DecisionComponentsItemView implements DecisionComponentsItem.View { @Override public void setIcon(final String iconURI) { icon.src = iconURI; } @Inject DecisionComponentsItemView(final HTMLImageElement icon,
final @Named("h5") HTMLHeadingElement name,
final HTMLParagraphElement file,
final DMNShapeSet dmnShapeSet,
final SessionManager sessionManager,
final ShapeGlyphDragHandler shapeGlyphDragHandler,
final Event<BuildCanvasShapeEvent> buildCanvasShapeEvent,
final HTMLDivElement decisionComponentItem,
final Event<NotificationEvent> notificationEvent,
final ClientTranslationService clientTranslationService); @Override void init(final DecisionComponentsItem presenter); @Override void setIcon(final String iconURI); @Override void setName(final String name); @Override void setFile(final String file); @Override void setIsImported(final boolean imported); @EventHandler("decision-component-item") void decisionComponentItemMouseDown(final MouseDownEvent mouseDownEvent); }### Answer:
@Test public void testSetIcon() { final String iconURI = "http: icon.src = "something"; view.setIcon(iconURI); assertEquals(iconURI, icon.src); } |
### Question:
CaseGraphFactoryImpl extends BPMNGraphFactoryImpl { @Override protected List<Command> buildInitialisationCommands() { final List<Command> commands = new ArrayList<>(); final Node<Definition<BPMNDiagram>, Edge> diagramNode = (Node<Definition<BPMNDiagram>, Edge>) factoryManager.newElement(UUID.uuid(), getDefinitionId(getDiagramType())); commands.add(graphCommandFactory.addNode(diagramNode)); final AdHoc adHoc = diagramNode.getContent().getDefinition().getDiagramSet().getAdHoc(); adHoc.setValue(true); return commands; } CaseGraphFactoryImpl(); @Inject CaseGraphFactoryImpl(DefinitionManager definitionManager, FactoryManager factoryManager,
RuleManager ruleManager, GraphCommandManager graphCommandManager,
GraphCommandFactory graphCommandFactory, GraphIndexBuilder<?> indexBuilder,
CustomTaskFactory customTaskFactory,
WorkItemDefinitionLookupService workItemDefinitionService); @Override Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata); }### Answer:
@Test @SuppressWarnings("all") public void buildInitialisationCommands() { final List<Command> commands = tested.buildInitialisationCommands(); assertEquals(1, commands.size()); final AddNodeCommand addNodeCommand = (AddNodeCommand) commands.get(0); assertEquals(addNodeCommand.getCandidate(), diagramNode); } |
### Question:
BPMNDelegateGraphFactory implements BPMNGraphFactory { @Override public void setDiagramType(Class<? extends BPMNDiagram> diagramType) { bpmnGraphFactory.setDiagramType(diagramType); caseGraphFactory.setDiagramType(diagramType); } @Inject BPMNDelegateGraphFactory(final BPMNGraphFactoryImpl bpmnGraphFactory,
final CaseGraphFactoryImpl caseGraphFactory); @Override boolean isDelegateFactory(); @Override void setDiagramType(Class<? extends BPMNDiagram> diagramType); @Override Class<? extends ElementFactory> getFactoryType(); @Override Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata); @Override Graph<DefinitionSet, Node> build(String uuid, String definition); @Override boolean accepts(String source); }### Answer:
@Test public void setDiagramType() { tested.setDiagramType(BPMNDiagramImpl.class); verify(bpmnGraphFactory).setDiagramType(BPMNDiagramImpl.class); verify(caseGraphFactory).setDiagramType(BPMNDiagramImpl.class); } |
### Question:
BPMNDelegateGraphFactory implements BPMNGraphFactory { @Override public Class<? extends ElementFactory> getFactoryType() { return BPMNGraphFactory.class; } @Inject BPMNDelegateGraphFactory(final BPMNGraphFactoryImpl bpmnGraphFactory,
final CaseGraphFactoryImpl caseGraphFactory); @Override boolean isDelegateFactory(); @Override void setDiagramType(Class<? extends BPMNDiagram> diagramType); @Override Class<? extends ElementFactory> getFactoryType(); @Override Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata); @Override Graph<DefinitionSet, Node> build(String uuid, String definition); @Override boolean accepts(String source); }### Answer:
@Test public void getFactoryType() { assertEquals(tested.getFactoryType(), BPMNGraphFactory.class); } |
### Question:
BPMNDelegateGraphFactory implements BPMNGraphFactory { @Override public Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata) { final Optional<ProjectType> projectType = (Objects.nonNull(metadata) && metadata instanceof ProjectMetadata) ? Optional.ofNullable(((ProjectMetadata) metadata).getProjectType()).map(ProjectType::valueOf) : Optional.empty(); return graphFactoryDelegation.get(projectType).build(uuid, definition, metadata); } @Inject BPMNDelegateGraphFactory(final BPMNGraphFactoryImpl bpmnGraphFactory,
final CaseGraphFactoryImpl caseGraphFactory); @Override boolean isDelegateFactory(); @Override void setDiagramType(Class<? extends BPMNDiagram> diagramType); @Override Class<? extends ElementFactory> getFactoryType(); @Override Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata); @Override Graph<DefinitionSet, Node> build(String uuid, String definition); @Override boolean accepts(String source); }### Answer:
@Test public void buildCase() { when(projectMetadata.getProjectType()).thenReturn(ProjectType.CASE.name()); tested.build(GRAPH_UUID, DEFINITION, projectMetadata); verify(caseGraphFactory).build(GRAPH_UUID, DEFINITION, projectMetadata); verify(bpmnGraphFactory, never()).build(GRAPH_UUID, DEFINITION, projectMetadata); }
@Test public void buildBPMN() { when(projectMetadata.getProjectType()).thenReturn(ProjectType.BPMN.name()); tested.build(GRAPH_UUID, DEFINITION, projectMetadata); verify(caseGraphFactory, never()).build(GRAPH_UUID, DEFINITION, projectMetadata); verify(bpmnGraphFactory).build(GRAPH_UUID, DEFINITION, projectMetadata); }
@Test public void buildDefault() { tested.build(GRAPH_UUID, DEFINITION, projectMetadata); verify(caseGraphFactory, never()).build(GRAPH_UUID, DEFINITION, projectMetadata); verify(bpmnGraphFactory).build(GRAPH_UUID, DEFINITION, projectMetadata); tested.build(GRAPH_UUID, DEFINITION); verify(caseGraphFactory, never()).build(GRAPH_UUID, DEFINITION, projectMetadata); verify(bpmnGraphFactory).build(GRAPH_UUID, DEFINITION, null); final Metadata metadata = mock(Metadata.class); tested.build(GRAPH_UUID, DEFINITION, metadata); verify(caseGraphFactory, never()).build(GRAPH_UUID, DEFINITION, projectMetadata); verify(bpmnGraphFactory).build(GRAPH_UUID, DEFINITION, metadata); }
@Test public void build() { tested.build(GRAPH_UUID, DEFINITION); verify(tested).build(GRAPH_UUID, DEFINITION, null); } |
### Question:
BPMNDelegateGraphFactory implements BPMNGraphFactory { @Override public boolean accepts(String source) { return bpmnGraphFactory.accepts(source) && caseGraphFactory.accepts(source); } @Inject BPMNDelegateGraphFactory(final BPMNGraphFactoryImpl bpmnGraphFactory,
final CaseGraphFactoryImpl caseGraphFactory); @Override boolean isDelegateFactory(); @Override void setDiagramType(Class<? extends BPMNDiagram> diagramType); @Override Class<? extends ElementFactory> getFactoryType(); @Override Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata); @Override Graph<DefinitionSet, Node> build(String uuid, String definition); @Override boolean accepts(String source); }### Answer:
@Test public void accepts() { assertTrue(tested.accepts(SOURCE)); verify(bpmnGraphFactory).accepts(SOURCE); verify(caseGraphFactory).accepts(SOURCE); } |
### Question:
BPMNDelegateGraphFactory implements BPMNGraphFactory { @Override public boolean isDelegateFactory() { return true; } @Inject BPMNDelegateGraphFactory(final BPMNGraphFactoryImpl bpmnGraphFactory,
final CaseGraphFactoryImpl caseGraphFactory); @Override boolean isDelegateFactory(); @Override void setDiagramType(Class<? extends BPMNDiagram> diagramType); @Override Class<? extends ElementFactory> getFactoryType(); @Override Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata); @Override Graph<DefinitionSet, Node> build(String uuid, String definition); @Override boolean accepts(String source); }### Answer:
@Test public void isDelegateFactory() { assertTrue(tested.isDelegateFactory()); } |
### Question:
ConditionParser { public Condition parse() throws ParseException { parseReturnSentence(); functionName = parseFunctionName(); functionName = functionName.substring(KIE_FUNCTIONS.length()); List<FunctionDef> functionDefs = FunctionsRegistry.getInstance().getFunctions(functionName); if (functionDefs.isEmpty()) { throw new ParseException(errorMessage(FUNCTION_NAME_NOT_RECOGNIZED_ERROR, functionName), parseIndex); } ParseException lastTryException = null; for (FunctionDef functionDef : functionDefs) { try { reset(); return parse(functionDef); } catch (ParseException e) { lastTryException = e; } } throw lastTryException; } ConditionParser(String expression); Condition parse(); static final String KIE_FUNCTIONS; }### Answer:
@Test public void testWhiteSpaces() throws Exception { Condition expectedCondition = new Condition("between", Arrays.asList("someVariable", "value1", "value2")); char[] whiteSpaceChars = {'\n', '\t', ' ', '\r'}; String conditionTemplate = "%sreturn%sKieFunctions.between(%ssomeVariable%s,%s\"value1\"%s,%s\"value2\"%s)%s;"; String condition; for (char whiteSpace : whiteSpaceChars) { condition = String.format(conditionTemplate, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace); assertEquals(expectedCondition, new ConditionParser(condition).parse()); } conditionTemplate = "%sreturn%sKieFunctions.between(%ssomeVariable%s.%ssomeMethod%s(%s)%s,%s\"value1\"%s,%s\"value2\"%s)%s;"; for (char whiteSpace : whiteSpaceChars) { condition = String.format(conditionTemplate, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace, whiteSpace); expectedCondition = new Condition("between", Arrays.asList("someVariable.someMethod()", "value1", "value2")); assertEquals(expectedCondition, new ConditionParser(condition).parse()); } } |
### Question:
DecisionComponentsItemView implements DecisionComponentsItem.View { @Override public void setName(final String name) { this.name.textContent = name; } @Inject DecisionComponentsItemView(final HTMLImageElement icon,
final @Named("h5") HTMLHeadingElement name,
final HTMLParagraphElement file,
final DMNShapeSet dmnShapeSet,
final SessionManager sessionManager,
final ShapeGlyphDragHandler shapeGlyphDragHandler,
final Event<BuildCanvasShapeEvent> buildCanvasShapeEvent,
final HTMLDivElement decisionComponentItem,
final Event<NotificationEvent> notificationEvent,
final ClientTranslationService clientTranslationService); @Override void init(final DecisionComponentsItem presenter); @Override void setIcon(final String iconURI); @Override void setName(final String name); @Override void setFile(final String file); @Override void setIsImported(final boolean imported); @EventHandler("decision-component-item") void decisionComponentItemMouseDown(final MouseDownEvent mouseDownEvent); }### Answer:
@Test public void testSetName() { final String name = "name"; this.name.textContent = "something"; view.setName(name); assertEquals(name, this.name.textContent); } |
### Question:
ConditionGenerator { public String generateScript(Condition condition) throws GenerateConditionException { if (condition == null) { throw new GenerateConditionException(MISSING_CONDITION_ERROR); } if (!isValidFunction(condition.getFunction())) { throw new GenerateConditionException(MessageFormat.format(FUNCTION_NOT_FOUND_ERROR, condition.getFunction())); } final String function = condition.getFunction().trim(); final StringBuilder script = new StringBuilder(); script.append("return "); script.append(ConditionParser.KIE_FUNCTIONS); script.append(function); script.append("("); boolean first = true; for (String param : condition.getParams()) { if (param == null || param.isEmpty()) { throw new GenerateConditionException(PARAMETER_NULL_EMPTY); } if (first) { script.append(param); first = false; } else { script.append(", "); script.append("\""); script.append(escapeJavaNonUTFChars(param)); script.append("\""); } } script.append(");"); return script.toString(); } String generateScript(Condition condition); }### Answer:
@Test public void testMissingConditionError() throws Exception { ConditionGenerator generator = new ConditionGenerator(); expectedException.expectMessage("A condition must be provided"); generator.generateScript(null); }
@Test public void testFunctionNotFoundError() throws Exception { ConditionGenerator generator = new ConditionGenerator(); Condition condition = new Condition("SomeNonExistingFunction"); expectedException.expectMessage("Function SomeNonExistingFunction was not found in current functions definitions"); generator.generateScript(condition); }
@Test public void testParamIsNullError() throws Exception { ConditionGenerator generator = new ConditionGenerator(); Condition condition = new Condition("startsWith"); condition.addParam("variable"); condition.addParam(null); expectedException.expectMessage("Parameter can not be null nor empty"); generator.generateScript(condition); } |
### Question:
ParsingUtils { public static String parseJavaName(final String token, final int startIndex, final char[] stopCharacters) throws ParseException { if (startIndex < 0 || startIndex >= token.length()) { throw new IndexOutOfBoundsException("startIndex: " + startIndex + " exceeds token bounds: " + token); } final StringBuilder javaName = new StringBuilder(); char currentChar; int currentIndex = startIndex; while (currentIndex < token.length()) { currentChar = token.charAt(currentIndex); if (ArrayUtils.contains(stopCharacters, currentChar)) { break; } else { javaName.append(currentChar); } currentIndex++; } if (javaName.length() == 0) { throw new ParseException("Expected java name was not found at position: " + startIndex, startIndex); } else if (!SourceVersion.isName(javaName)) { throw new ParseException("Invalid java name was found at position: " + startIndex, startIndex); } return javaName.toString(); } static String parseJavaName(final String token, final int startIndex, final char[] stopCharacters); }### Answer:
@Test(expected = IndexOutOfBoundsException.class) public void testParseJavaNameWithLowerOutOfBounds() throws ParseException { String someString = "a1234"; char[] someStopCharacters = {}; ParsingUtils.parseJavaName(someString, -1, someStopCharacters); }
@Test(expected = IndexOutOfBoundsException.class) public void testParseJavaNameWithHigherOutOfBounds() throws ParseException { String someString = "a1234"; char[] someStopCharacters = {}; ParsingUtils.parseJavaName(someString, someString.length(), someStopCharacters); } |
### Question:
FormGenerationModelProviderHelper { @SuppressWarnings("unchecked") public Definitions generate(final Diagram diagram) throws IOException { DiagramMarshaller diagramMarshaller = backendService.getDiagramMarshaller(); return ((BaseDirectDiagramMarshaller) diagramMarshaller).marshallToBpmn2Definitions(diagram); } FormGenerationModelProviderHelper(final AbstractDefinitionSetService backendService); @SuppressWarnings("unchecked") Definitions generate(final Diagram diagram); }### Answer:
@Test @SuppressWarnings("unchecked") public void testGenerate_masharller() throws Exception { when(backendService.getDiagramMarshaller()).thenReturn(newMarshaller); tested.generate(diagram); verify(newMarshaller, times(1)).marshallToBpmn2Definitions(eq(diagram)); } |
### Question:
BPMNFormGenerationModelProvider implements FormGenerationModelProvider<Definitions> { @Override public boolean accepts(final Diagram diagram) { return this.definitionSetId.equals(diagram.getMetadata().getDefinitionSetId()); } protected BPMNFormGenerationModelProvider(); @Inject BPMNFormGenerationModelProvider(final DefinitionUtils definitionUtils,
final BPMNFormGenerationModelProviderHelper formGenerationModelProviderHelper); @PostConstruct void init(); @Override boolean accepts(final Diagram diagram); @Override Definitions generate(final Diagram diagram); }### Answer:
@Test public void testAccepts() { assertTrue(tested.accepts(diagram)); } |
### Question:
BPMNFormGenerationModelProvider implements FormGenerationModelProvider<Definitions> { @Override public Definitions generate(final Diagram diagram) throws IOException { return formGenerationModelProviderHelper.generate(diagram); } protected BPMNFormGenerationModelProvider(); @Inject BPMNFormGenerationModelProvider(final DefinitionUtils definitionUtils,
final BPMNFormGenerationModelProviderHelper formGenerationModelProviderHelper); @PostConstruct void init(); @Override boolean accepts(final Diagram diagram); @Override Definitions generate(final Diagram diagram); }### Answer:
@Test @SuppressWarnings("unchecked") public void testGenerateForBPMNDDirectDiagramMarshaller() throws Exception { when(bpmnDirectDiagramMarshaller.marshallToBpmn2Definitions(diagram)).thenReturn(definitions); when(bpmnBackendService.getDiagramMarshaller()).thenReturn(bpmnDirectDiagramMarshaller); Definitions result = tested.generate(diagram); verify(bpmnDirectDiagramMarshaller, times(1)).marshallToBpmn2Definitions(eq(diagram)); assertEquals(result, definitions); } |
### Question:
RuleFlowGroupDataService { public List<RuleFlowGroup> getRuleFlowGroupNames() { return queryService.getRuleFlowGroupNames(); } @Inject RuleFlowGroupDataService(final RuleFlowGroupQueryService queryService,
final Event<RuleFlowGroupDataEvent> dataChangedEvent); List<RuleFlowGroup> getRuleFlowGroupNames(); }### Answer:
@Test public void testGetRuleFlowGroupNames() { List<RuleFlowGroup> names = tested.getRuleFlowGroupNames(); assertRightRuleFlowGroupNames(names); } |
### Question:
RuleFlowGroupDataService { void fireData() { final RuleFlowGroup[] groupNames = getRuleFlowGroupNames().toArray(new RuleFlowGroup[0]); dataChangedEvent.fire(new RuleFlowGroupDataEvent(groupNames)); } @Inject RuleFlowGroupDataService(final RuleFlowGroupQueryService queryService,
final Event<RuleFlowGroupDataEvent> dataChangedEvent); List<RuleFlowGroup> getRuleFlowGroupNames(); }### Answer:
@Test public void testFireData() { tested.fireData(); ArgumentCaptor<RuleFlowGroupDataEvent> ec = ArgumentCaptor.forClass(RuleFlowGroupDataEvent.class); verify(dataChangedEvent, times(1)).fire(ec.capture()); RuleFlowGroupDataEvent event = ec.getValue(); assertRightRuleFlowGroups(event.getGroups()); } |
### Question:
DecisionComponentsItemView implements DecisionComponentsItem.View { @Override public void setFile(final String file) { this.file.textContent = file; } @Inject DecisionComponentsItemView(final HTMLImageElement icon,
final @Named("h5") HTMLHeadingElement name,
final HTMLParagraphElement file,
final DMNShapeSet dmnShapeSet,
final SessionManager sessionManager,
final ShapeGlyphDragHandler shapeGlyphDragHandler,
final Event<BuildCanvasShapeEvent> buildCanvasShapeEvent,
final HTMLDivElement decisionComponentItem,
final Event<NotificationEvent> notificationEvent,
final ClientTranslationService clientTranslationService); @Override void init(final DecisionComponentsItem presenter); @Override void setIcon(final String iconURI); @Override void setName(final String name); @Override void setFile(final String file); @Override void setIsImported(final boolean imported); @EventHandler("decision-component-item") void decisionComponentItemMouseDown(final MouseDownEvent mouseDownEvent); }### Answer:
@Test public void testSetFile() { final String file = "file"; this.file.textContent = "something"; view.setFile(file); assertEquals(file, this.file.textContent); } |
### Question:
RuleFlowGroupDataService { @Inject public RuleFlowGroupDataService(final RuleFlowGroupQueryService queryService, final Event<RuleFlowGroupDataEvent> dataChangedEvent) { this.queryService = queryService; this.dataChangedEvent = dataChangedEvent; } @Inject RuleFlowGroupDataService(final RuleFlowGroupQueryService queryService,
final Event<RuleFlowGroupDataEvent> dataChangedEvent); List<RuleFlowGroup> getRuleFlowGroupNames(); }### Answer:
@Test public void testRuleFlowGroupDataService() { RuleFlowGroupDataService tested = spy(new RuleFlowGroupDataService(queryService, dataChangedEvent)); tested.onRequestRuleFlowGroupDataEvent(new RequestRuleFlowGroupDataEvent()); verify(tested).fireData(); } |
### Question:
BPMNDiagramProjectService implements BPMNDiagramService { @Override public ProjectType getProjectType(Path projectRootPath) { try (DirectoryStream<org.uberfire.java.nio.file.Path> paths = ioService.newDirectoryStream(Paths.convert(projectRootPath), f -> f.getFileName().toString().startsWith("."))) { return ProjectType.fromFileName(StreamSupport.stream(paths.spliterator(), false) .map(Paths::convert) .map(Path::getFileName) .findFirst() ).orElse(null); } } @Inject BPMNDiagramProjectService(final @Named("ioStrategy") IOService ioService); BPMNDiagramProjectService(); @Override ProjectType getProjectType(Path projectRootPath); }### Answer:
@Test public void getProjectTypeCase() { final ProjectType projectType = tested.getProjectType(projectPath); assertEquals(ProjectType.CASE, projectType); }
@Test public void getProjectTypeNull() { when(directoryStream.spliterator()).thenReturn(Collections.<Path>emptyList().spliterator()); final ProjectType projectType = tested.getProjectType(projectPath); assertNull(projectType); } |
### Question:
RuleFlowGroupQueryService { @SuppressWarnings("unchecked") private static RuleFlowGroup getValue(final RefactoringPageRow row) { Map<String, String> values = (Map<String, String>) row.getValue(); String name = values.get("name"); if (StringUtils.isEmpty(name)) { return null; } RuleFlowGroup group = new RuleFlowGroup(name); group.setFileName(values.get("filename")); group.setPathUri(values.get("pathuri")); return group; } RuleFlowGroupQueryService(); @Inject RuleFlowGroupQueryService(final RefactoringQueryService queryService); RuleFlowGroupQueryService(final RefactoringQueryService queryService,
final Function<List<RefactoringPageRow>, List<RuleFlowGroup>> resultToSelectorData); List<RuleFlowGroup> getRuleFlowGroupNames(); static final Function<List<RefactoringPageRow>, List<RuleFlowGroup>> DEFAULT_RESULT_CONVERTER; }### Answer:
@Test @SuppressWarnings("unchecked") public void testDefaultResultConverter() { RefactoringPageRow row1 = mock(RefactoringPageRow.class); when(row1.getValue()).thenReturn(asMap("row1")); RefactoringPageRow row2 = mock(RefactoringPageRow.class); when(row2.getValue()).thenReturn(asMap("row2")); RefactoringPageRow row3 = mock(RefactoringPageRow.class); when(row3.getValue()).thenReturn(asMap("row3")); RefactoringPageRow row4 = mock(RefactoringPageRow.class); when(row4.getValue()).thenReturn(asMap("row4")); RefactoringPageRow row4_2 = mock(RefactoringPageRow.class); when(row4_2.getValue()).thenReturn(asMap("row4")); RefactoringPageRow emptyRow1 = mock(RefactoringPageRow.class); when(emptyRow1.getValue()).thenReturn(asMap("")); RefactoringPageRow emptyRow2 = mock(RefactoringPageRow.class); when(emptyRow2.getValue()).thenReturn(asMap("")); List<RefactoringPageRow> rows = Arrays.asList(row1, row2, row3, row4, row4_2, emptyRow1, emptyRow2); List<RuleFlowGroup> result = RuleFlowGroupQueryService.DEFAULT_RESULT_CONVERTER.apply(rows); assertEquals(5, result.size()); RuleFlowGroup group1 = new RuleFlowGroup("row1"); RuleFlowGroup group2 = new RuleFlowGroup("row2"); RuleFlowGroup group3 = new RuleFlowGroup("row3"); RuleFlowGroup group4 = new RuleFlowGroup("row4"); assertTrue(result.contains(group1)); assertTrue(result.contains(group2)); assertTrue(result.contains(group3)); assertTrue(result.contains(group4)); } |
### Question:
BpmnProcessDataEventListener extends AbstractBpmnProcessDataEventListener { protected ResourceType getProcessIdResourceType() { return ResourceType.BPMN2; } }### Answer:
@Test public void testGetProcessIdResourceType() throws Exception { assertEquals(tested.getProcessIdResourceType(), ResourceType.BPMN2); } |
### Question:
BpmnProcessDataEventListener extends AbstractBpmnProcessDataEventListener { protected ResourceType getProcessNameResourceType() { return ResourceType.BPMN2_NAME; } }### Answer:
@Test public void testGetProcessNameResourceType() throws Exception { assertEquals(tested.getProcessNameResourceType(), ResourceType.BPMN2_NAME); } |
### Question:
WorkItemDefinitionProjectService implements WorkItemDefinitionLookupService { @Produces @Default public WorkItemDefinitionRegistry getRegistry() { return registry; } @SuppressWarnings("all") protected WorkItemDefinitionProjectService(); @Inject WorkItemDefinitionProjectService(final WorkItemDefinitionCacheRegistry registry,
final WorkItemDefinitionVFSLookupService vfsService,
final WorkItemDefinitionDeployServices deployServices); WorkItemDefinitionProjectService(final WorkItemDefinitionCacheRegistry registry,
final WorkItemDefinitionVFSLookupService vfsService,
final WorkItemDefinitionDeployServices deployServices,
final BiPredicate<Metadata, Collection<WorkItemDefinition>> deployPredicate); @Produces @Default WorkItemDefinitionRegistry getRegistry(); @Override Collection<WorkItemDefinition> execute(final Metadata metadata); @PreDestroy void destroy(); }### Answer:
@Test public void testGetRegistry() { assertEquals(registry, tested.getRegistry()); } |
### Question:
WorkItemDefinitionProjectService implements WorkItemDefinitionLookupService { @Override public Collection<WorkItemDefinition> execute(final Metadata metadata) { return load(metadata).items(); } @SuppressWarnings("all") protected WorkItemDefinitionProjectService(); @Inject WorkItemDefinitionProjectService(final WorkItemDefinitionCacheRegistry registry,
final WorkItemDefinitionVFSLookupService vfsService,
final WorkItemDefinitionDeployServices deployServices); WorkItemDefinitionProjectService(final WorkItemDefinitionCacheRegistry registry,
final WorkItemDefinitionVFSLookupService vfsService,
final WorkItemDefinitionDeployServices deployServices,
final BiPredicate<Metadata, Collection<WorkItemDefinition>> deployPredicate); @Produces @Default WorkItemDefinitionRegistry getRegistry(); @Override Collection<WorkItemDefinition> execute(final Metadata metadata); @PreDestroy void destroy(); }### Answer:
@Test public void testExecute() { Collection<WorkItemDefinition> result = tested.execute(metadata); assertFalse(result.isEmpty()); assertEquals(2, result.size()); assertTrue(result.contains(wid1)); assertTrue(result.contains(wid2)); } |
### Question:
WorkItemDefinitionProjectService implements WorkItemDefinitionLookupService { @PreDestroy public void destroy() { registry.destroy(); } @SuppressWarnings("all") protected WorkItemDefinitionProjectService(); @Inject WorkItemDefinitionProjectService(final WorkItemDefinitionCacheRegistry registry,
final WorkItemDefinitionVFSLookupService vfsService,
final WorkItemDefinitionDeployServices deployServices); WorkItemDefinitionProjectService(final WorkItemDefinitionCacheRegistry registry,
final WorkItemDefinitionVFSLookupService vfsService,
final WorkItemDefinitionDeployServices deployServices,
final BiPredicate<Metadata, Collection<WorkItemDefinition>> deployPredicate); @Produces @Default WorkItemDefinitionRegistry getRegistry(); @Override Collection<WorkItemDefinition> execute(final Metadata metadata); @PreDestroy void destroy(); }### Answer:
@Test public void testDestroy() { tested.execute(metadata); assertFalse(registry.isEmpty()); tested.destroy(); assertTrue(registry.isEmpty()); } |
### Question:
WorkItemDefinitionRemoteDeployService implements WorkItemDefinitionDeployService { @Override public void deploy(final Metadata metadata) { deploy(metadata, System.getProperty(PROPERTY_SERVICE_REPO), System.getProperty(PROPERTY_SERVICE_REPO_TASKNAMES)); } protected WorkItemDefinitionRemoteDeployService(); @Inject WorkItemDefinitionRemoteDeployService(final WorkItemDefinitionService<WorkItemDefinitionRemoteRequest> remoteLookupService,
final BackendFileSystemManager backendFileSystemManager,
final WorkItemDefinitionResources resources,
final WorkItemDefinitionProjectInstaller projectInstaller); WorkItemDefinitionRemoteDeployService(final WorkItemDefinitionService<WorkItemDefinitionRemoteRequest> remoteLookupService,
final BackendFileSystemManager backendFileSystemManager,
final WorkItemDefinitionResources resources,
final WorkItemDefinitionProjectInstaller projectInstaller,
final Function<WorkItemDefinition, Asset> widAssetBuilder,
final Function<WorkItemDefinition, Asset> iconAssetBuilder); @Override void deploy(final Metadata metadata); static final String PROPERTY_SERVICE_REPO; static final String PROPERTY_SERVICE_REPO_TASKNAMES; }### Answer:
@Test public void testDeploy() { org.uberfire.java.nio.file.Path resourcePath = mock(org.uberfire.java.nio.file.Path.class); when(resources.resolveResourcesPath(eq(metadata))).thenReturn(resourcePath); tested.deploy(metadata, URL); ArgumentCaptor<Assets> assetsArgumentCaptor = ArgumentCaptor.forClass(Assets.class); verify(backendFileSystemManager, times(1)) .deploy(eq(resourcePath), assetsArgumentCaptor.capture(), anyString()); Assets assets = assetsArgumentCaptor.getValue(); assertNotNull(assets); assertEquals(2, assets.getAssets().size()); assertTrue(assets.getAssets().contains(widAsset)); assertTrue(assets.getAssets().contains(iconAsset)); } |
### Question:
DecisionComponentsItemView implements DecisionComponentsItem.View { @EventHandler("decision-component-item") public void decisionComponentItemMouseDown(final MouseDownEvent mouseDownEvent) { final DRGElement drgElement = presenter.getDrgElement(); final ShapeFactory factory = dmnShapeSet.getShapeFactory(); final Glyph glyph = factory.getGlyph(drgElement.getClass().getName()); final ShapeGlyphDragHandler.Item item = makeDragHandler(glyph); final Callback proxy = makeDragProxyCallbackImpl(drgElement, factory); shapeGlyphDragHandler.show(item, mouseDownEvent.getX(), mouseDownEvent.getY(), proxy); } @Inject DecisionComponentsItemView(final HTMLImageElement icon,
final @Named("h5") HTMLHeadingElement name,
final HTMLParagraphElement file,
final DMNShapeSet dmnShapeSet,
final SessionManager sessionManager,
final ShapeGlyphDragHandler shapeGlyphDragHandler,
final Event<BuildCanvasShapeEvent> buildCanvasShapeEvent,
final HTMLDivElement decisionComponentItem,
final Event<NotificationEvent> notificationEvent,
final ClientTranslationService clientTranslationService); @Override void init(final DecisionComponentsItem presenter); @Override void setIcon(final String iconURI); @Override void setName(final String name); @Override void setFile(final String file); @Override void setIsImported(final boolean imported); @EventHandler("decision-component-item") void decisionComponentItemMouseDown(final MouseDownEvent mouseDownEvent); }### Answer:
@Test public void testDecisionComponentItemMouseDown() { final MouseDownEvent mouseDownEvent = mock(MouseDownEvent.class); final Callback proxy = mock(Callback.class); final DRGElement drgElement = mock(DRGElement.class); final DMNShapeFactory factory = mock(DMNShapeFactory.class); final ShapeGlyphDragHandler.Item item = mock(ShapeGlyphDragHandler.Item.class); final Glyph glyph = mock(Glyph.class); final int x = 10; final int y = 20; when(dmnShapeSet.getShapeFactory()).thenReturn(factory); when(presenter.getDrgElement()).thenReturn(drgElement); when(factory.getGlyph(any())).thenReturn(glyph); when(mouseDownEvent.getX()).thenReturn(x); when(mouseDownEvent.getY()).thenReturn(y); doReturn(proxy).when(view).makeDragProxyCallbackImpl(drgElement, factory); doReturn(item).when(view).makeDragHandler(glyph); view.decisionComponentItemMouseDown(mouseDownEvent); verify(shapeGlyphDragHandler).show(item, x, y, proxy); } |
### Question:
WorkItemDefinitionProjectInstaller { @SuppressWarnings("all") public void install(final Collection<WorkItemDefinition> items, final Metadata metadata) { final Module module = moduleService.resolveModule(metadata.getRoot()); final Path pomXMLPath = module.getPomXMLPath(); final POM projectPOM = pomService.load(pomXMLPath); if (projectPOM != null) { final Dependencies projectDependencies = projectPOM.getDependencies(); final Set<Dependency> widDependencies = items.stream() .flatMap(wid -> wid.getDependencies().stream()) .filter(d -> !projectDependencies.contains(d)) .collect(Collectors.toSet()); projectDependencies.addAll(widDependencies); pomService.save(pomXMLPath, projectPOM, metadataService.getMetadata(pomXMLPath), INSALL_MESSAGE, false); } } protected WorkItemDefinitionProjectInstaller(); @Inject WorkItemDefinitionProjectInstaller(final POMService pomService,
final MetadataService metadataService,
final KieModuleService moduleService); @SuppressWarnings("all") void install(final Collection<WorkItemDefinition> items,
final Metadata metadata); }### Answer:
@Test public void testInstall() { KieModule module = mock(KieModule.class); Path pomXMLPath = mock(Path.class); POM pom = mock(POM.class); when(moduleService.resolveModule(eq(root))).thenReturn(module); when(module.getPomXMLPath()).thenReturn(pomXMLPath); when(pomService.load(eq(pomXMLPath))).thenReturn(pom); Dependencies dependencies = new Dependencies(Collections.emptyList()); when(pom.getDependencies()).thenReturn(dependencies); org.guvnor.common.services.shared.metadata.model.Metadata projMetadata = mock(org.guvnor.common.services.shared.metadata.model.Metadata.class); when(metadataService.getMetadata(pomXMLPath)).thenReturn(projMetadata); tested.install(Collections.singleton(WID), this.metadata); verify(pomService, times(1)) .save(eq(pomXMLPath), eq(pom), eq(projMetadata), anyString(), eq(false)); } |
### Question:
DataObjectConverter implements NodeConverter<org.eclipse.bpmn2.DataObjectReference> { @Override public Result<BpmnNode> convert(org.eclipse.bpmn2.DataObjectReference element) { return convert(element, propertyReaderFactory.of(element)); } DataObjectConverter(TypedFactoryManager typedFactoryManager, PropertyReaderFactory propertyReaderFactory); @Override Result<BpmnNode> convert(org.eclipse.bpmn2.DataObjectReference element); }### Answer:
@Test public void convert() { final Result<BpmnNode> node = tested.convert(element); final Node<? extends View<? extends BPMNViewDefinition>, ?> value = node.value().value(); assertEquals(content, value.getContent()); assertEquals(def, value.getContent().getDefinition()); } |
### Question:
TextAnnotationConverter implements NodeConverter<org.eclipse.bpmn2.TextAnnotation> { @Override public Result<BpmnNode> convert(org.eclipse.bpmn2.TextAnnotation element) { return convert(element, propertyReaderFactory.of(element)); } TextAnnotationConverter(TypedFactoryManager typedFactoryManager, PropertyReaderFactory propertyReaderFactory); @Override Result<BpmnNode> convert(org.eclipse.bpmn2.TextAnnotation element); }### Answer:
@Test public void convert() { final Result<BpmnNode> node = tested.convert(element); final Node<? extends View<? extends BPMNViewDefinition>, ?> value = node.value().value(); assertEquals(content, value.getContent()); assertEquals(def, value.getContent().getDefinition()); } |
### Question:
DecisionComponentsItemView implements DecisionComponentsItem.View { ShapeGlyphDragHandler.Item makeDragHandler(final Glyph glyph) { return new DragHandler(glyph); } @Inject DecisionComponentsItemView(final HTMLImageElement icon,
final @Named("h5") HTMLHeadingElement name,
final HTMLParagraphElement file,
final DMNShapeSet dmnShapeSet,
final SessionManager sessionManager,
final ShapeGlyphDragHandler shapeGlyphDragHandler,
final Event<BuildCanvasShapeEvent> buildCanvasShapeEvent,
final HTMLDivElement decisionComponentItem,
final Event<NotificationEvent> notificationEvent,
final ClientTranslationService clientTranslationService); @Override void init(final DecisionComponentsItem presenter); @Override void setIcon(final String iconURI); @Override void setName(final String name); @Override void setFile(final String file); @Override void setIsImported(final boolean imported); @EventHandler("decision-component-item") void decisionComponentItemMouseDown(final MouseDownEvent mouseDownEvent); }### Answer:
@Test public void testMakeDragHandler() { final Glyph glyph = mock(Glyph.class); final Item item = view.makeDragHandler(glyph); assertEquals(16, item.getHeight()); assertEquals(16, item.getWidth()); assertEquals(glyph, item.getShape()); } |
### Question:
InputAssignmentReader { public AssociationDeclaration getAssociationDeclaration() { return associationDeclaration; } InputAssignmentReader(Assignment assignment, String targetName); InputAssignmentReader(ItemAwareElement source, String targetName); static Optional<InputAssignmentReader> fromAssociation(DataInputAssociation in); AssociationDeclaration getAssociationDeclaration(); }### Answer:
@Test public void testNullBody() { final Assignment assignment = createAssignment(null); final InputAssignmentReader iar = new InputAssignmentReader(assignment, ID); final AssociationDeclaration associationDeclaration = iar.getAssociationDeclaration(); assertEquals(AssociationDeclaration.Type.FromTo, associationDeclaration.getType()); assertEquals("", associationDeclaration.getSource()); } |
### Question:
InputAssignmentReader { public static Optional<InputAssignmentReader> fromAssociation(DataInputAssociation in) { List<ItemAwareElement> sourceList = in.getSourceRef(); List<Assignment> assignmentList = in.getAssignment(); String targetName = ((DataInput) in.getTargetRef()).getName(); if (isReservedIdentifier(targetName)) { return Optional.empty(); } if (!sourceList.isEmpty()) { return Optional.of(new InputAssignmentReader(sourceList.get(0), targetName)); } else if (!assignmentList.isEmpty()) { return Optional.of(new InputAssignmentReader(assignmentList.get(0), targetName)); } else { logger.log(Level.SEVERE, MarshallingMessage.builder().message("Cannot find SourceRef or Assignment for Target ").toString() + targetName); return Optional.empty(); } } InputAssignmentReader(Assignment assignment, String targetName); InputAssignmentReader(ItemAwareElement source, String targetName); static Optional<InputAssignmentReader> fromAssociation(DataInputAssociation in); AssociationDeclaration getAssociationDeclaration(); }### Answer:
@Test public void testNullAssociations() { when(association.getSourceRef()).thenReturn(new ArrayDelegatingEList<ItemAwareElement>() { @Override public Object[] data() { return null; } }); when(association.getAssignment()).thenReturn(new ArrayDelegatingEList<Assignment>() { @Override public Object[] data() { return null; } }); when(association.getTargetRef()).thenReturn(element); when(element.getName()).thenReturn("someName"); final Optional<InputAssignmentReader> reader = InputAssignmentReader.fromAssociation(association); assertEquals(false, reader.isPresent()); } |
### Question:
SimulationAttributeSets { public static SimulationAttributeSet of(ElementParameters eleType) { TimeParameters timeParams = eleType.getTimeParameters(); if (timeParams == null) { return new SimulationAttributeSet(); } Parameter processingTime = timeParams.getProcessingTime(); if (processingTime == null || processingTime.getParameterValue() == null || processingTime.getParameterValue().isEmpty()) { return new SimulationAttributeSet(); } ParameterValue paramValue = processingTime.getParameterValue().get(0); return Match.<ParameterValue, SimulationAttributeSet>of() .<NormalDistributionType>when(e -> e instanceof NormalDistributionType, ndt -> { SimulationAttributeSet simulationSet = new SimulationAttributeSet(); simulationSet.getMean().setValue(ndt.getMean()); simulationSet.getStandardDeviation().setValue(ndt.getStandardDeviation()); simulationSet.getDistributionType().setValue("normal"); return simulationSet; }) .<UniformDistributionType>when(e -> e instanceof UniformDistributionType, udt -> { SimulationAttributeSet simulationSet = new SimulationAttributeSet(); simulationSet.getMin().setValue(udt.getMin()); simulationSet.getMax().setValue(udt.getMax()); simulationSet.getDistributionType().setValue("uniform"); return simulationSet; }) .<PoissonDistributionType>when(e -> e instanceof PoissonDistributionType, pdt -> { SimulationAttributeSet simulationSet = new SimulationAttributeSet(); simulationSet.getMean().setValue(pdt.getMean()); simulationSet.getDistributionType().setValue("poisson"); return simulationSet; }) .apply(paramValue) .asSuccess() .value(); } static SimulationAttributeSet of(ElementParameters eleType); static ElementParameters toElementParameters(SimulationAttributeSet simulationSet); }### Answer:
@Test public void testNullTimeParameters() { assertEquals(new SimulationAttributeSet(), SimulationAttributeSets.of(simulationParameters)); }
@Test public void testTimeParamsWithNullValue() { TimeParameters timeParameters = factory.createTimeParameters(); simulationParameters.setTimeParameters(timeParameters); assertEquals(new SimulationAttributeSet(), SimulationAttributeSets.of(simulationParameters)); }
@Test public void testTimeParamsWithEmptyParameter() { TimeParameters timeParameters = factory.createTimeParameters(); Parameter parameter = factory.createParameter(); timeParameters.setProcessingTime(parameter); simulationParameters.setTimeParameters(timeParameters); assertEquals(new SimulationAttributeSet(), SimulationAttributeSets.of(simulationParameters)); } |
### Question:
DMNDiagramsSession implements GraphsProvider { public void destroyState(final Metadata metadata) { dmnSessionStatesByPathURI.remove(getSessionKey(metadata)); } DMNDiagramsSession(); @Inject DMNDiagramsSession(final ManagedInstance<DMNDiagramsSessionState> dmnDiagramsSessionStates,
final SessionManager sessionManager,
final DMNDiagramUtils dmnDiagramUtils); void destroyState(final Metadata metadata); DMNDiagramsSessionState setState(final Metadata metadata,
final Map<String, Diagram> diagramsByDiagramElementId,
final Map<String, DMNDiagramElement> dmnDiagramsByDiagramElementId); boolean isSessionStatePresent(); DMNDiagramsSessionState getSessionState(); String getCurrentSessionKey(); String getSessionKey(final Metadata metadata); void add(final DMNDiagramElement dmnDiagram,
final Diagram stunnerDiagram); void remove(final DMNDiagramElement dmnDiagram); @Override Diagram getDiagram(final String dmnDiagramElementId); @Override String getCurrentDiagramId(); DMNDiagramElement getDMNDiagramElement(final String dmnDiagramElementId); DMNDiagramTuple getDiagramTuple(final String dmnDiagramElementId); List<DMNDiagramTuple> getDMNDiagrams(); void onDMNDiagramSelected(final @Observes DMNDiagramSelected selected); boolean belongsToCurrentSessionState(final DMNDiagramElement diagramElement); Optional<DMNDiagramElement> getCurrentDMNDiagramElement(); Optional<Diagram> getCurrentDiagram(); Diagram getDRGDiagram(); DMNDiagramElement getDRGDiagramElement(); void clear(); List<DRGElement> getModelDRGElements(); List<Import> getModelImports(); @Override boolean isGlobalGraphSelected(); @Override List<Graph> getGraphs(); List<Node> getAllNodes(); Diagram getCurrentGraphDiagram(); }### Answer:
@Test public void testDestroyState() { assertNotNull(dmnDiagramsSession.getSessionState()); dmnDiagramsSession.destroyState(metadata); assertNull(dmnDiagramsSession.getSessionState()); } |
### Question:
TextAnnotationPropertyReader extends BasePropertyReader { public String getName() { String extendedName = CustomElement.name.of(element).get(); return ConverterUtils.isEmpty(extendedName) ? Optional.ofNullable(element.getText()).orElse("") : extendedName; } TextAnnotationPropertyReader(TextAnnotation element, BPMNDiagram diagram,
BPMNShape shape,
double resolutionFactor); String getName(); }### Answer:
@Test public void getExtendedName() { String name = tested.getName(); assertEquals("custom", name); }
@Test public void getName() { when(element.getExtensionValues()).thenReturn(ECollections.emptyEList()); String name = tested.getName(); assertEquals("name", name); }
@Test public void getTextName() { when(element.getExtensionValues()).thenReturn(ECollections.emptyEList()); when(element.getName()).thenReturn(null); String name = tested.getName(); assertEquals("text", name); }
@Test public void getNameNull() { when(element.getExtensionValues()).thenReturn(ECollections.emptyEList()); when(element.getName()).thenReturn(null); when(element.getText()).thenReturn(null); String name = tested.getName(); assertEquals("", name); } |
### Question:
DMNDiagramsSession implements GraphsProvider { public String getCurrentSessionKey() { return Optional .ofNullable(getCurrentGraphDiagram()) .map(diagram -> getSessionKey(diagram.getMetadata())) .orElse(""); } DMNDiagramsSession(); @Inject DMNDiagramsSession(final ManagedInstance<DMNDiagramsSessionState> dmnDiagramsSessionStates,
final SessionManager sessionManager,
final DMNDiagramUtils dmnDiagramUtils); void destroyState(final Metadata metadata); DMNDiagramsSessionState setState(final Metadata metadata,
final Map<String, Diagram> diagramsByDiagramElementId,
final Map<String, DMNDiagramElement> dmnDiagramsByDiagramElementId); boolean isSessionStatePresent(); DMNDiagramsSessionState getSessionState(); String getCurrentSessionKey(); String getSessionKey(final Metadata metadata); void add(final DMNDiagramElement dmnDiagram,
final Diagram stunnerDiagram); void remove(final DMNDiagramElement dmnDiagram); @Override Diagram getDiagram(final String dmnDiagramElementId); @Override String getCurrentDiagramId(); DMNDiagramElement getDMNDiagramElement(final String dmnDiagramElementId); DMNDiagramTuple getDiagramTuple(final String dmnDiagramElementId); List<DMNDiagramTuple> getDMNDiagrams(); void onDMNDiagramSelected(final @Observes DMNDiagramSelected selected); boolean belongsToCurrentSessionState(final DMNDiagramElement diagramElement); Optional<DMNDiagramElement> getCurrentDMNDiagramElement(); Optional<Diagram> getCurrentDiagram(); Diagram getDRGDiagram(); DMNDiagramElement getDRGDiagramElement(); void clear(); List<DRGElement> getModelDRGElements(); List<Import> getModelImports(); @Override boolean isGlobalGraphSelected(); @Override List<Graph> getGraphs(); List<Node> getAllNodes(); Diagram getCurrentGraphDiagram(); }### Answer:
@Test public void testGetCurrentSessionKey() { assertEquals(uri, dmnDiagramsSession.getCurrentSessionKey()); } |
### Question:
DMNDiagramsSession implements GraphsProvider { public List<DMNDiagramTuple> getDMNDiagrams() { return getSessionState().getDMNDiagrams(); } DMNDiagramsSession(); @Inject DMNDiagramsSession(final ManagedInstance<DMNDiagramsSessionState> dmnDiagramsSessionStates,
final SessionManager sessionManager,
final DMNDiagramUtils dmnDiagramUtils); void destroyState(final Metadata metadata); DMNDiagramsSessionState setState(final Metadata metadata,
final Map<String, Diagram> diagramsByDiagramElementId,
final Map<String, DMNDiagramElement> dmnDiagramsByDiagramElementId); boolean isSessionStatePresent(); DMNDiagramsSessionState getSessionState(); String getCurrentSessionKey(); String getSessionKey(final Metadata metadata); void add(final DMNDiagramElement dmnDiagram,
final Diagram stunnerDiagram); void remove(final DMNDiagramElement dmnDiagram); @Override Diagram getDiagram(final String dmnDiagramElementId); @Override String getCurrentDiagramId(); DMNDiagramElement getDMNDiagramElement(final String dmnDiagramElementId); DMNDiagramTuple getDiagramTuple(final String dmnDiagramElementId); List<DMNDiagramTuple> getDMNDiagrams(); void onDMNDiagramSelected(final @Observes DMNDiagramSelected selected); boolean belongsToCurrentSessionState(final DMNDiagramElement diagramElement); Optional<DMNDiagramElement> getCurrentDMNDiagramElement(); Optional<Diagram> getCurrentDiagram(); Diagram getDRGDiagram(); DMNDiagramElement getDRGDiagramElement(); void clear(); List<DRGElement> getModelDRGElements(); List<Import> getModelImports(); @Override boolean isGlobalGraphSelected(); @Override List<Graph> getGraphs(); List<Node> getAllNodes(); Diagram getCurrentGraphDiagram(); }### Answer:
@Test public void testGetDMNDiagrams() { final List<DMNDiagramTuple> expected = asList(mock(DMNDiagramTuple.class), mock(DMNDiagramTuple.class)); doReturn(expected).when(dmnDiagramsSessionState).getDMNDiagrams(); final List<DMNDiagramTuple> actual = dmnDiagramsSession.getDMNDiagrams(); assertEquals(expected, actual); } |
### Question:
AssociationPropertyReader extends BasePropertyReader implements EdgePropertyReader { @Override public String getSourceId() { return association.getSourceRef().getId(); } AssociationPropertyReader(Association association,
BPMNDiagram diagram,
DefinitionResolver definitionResolver); @Override String getSourceId(); @Override String getTargetId(); Class getAssociationByDirection(); @Override Connection getSourceConnection(); @Override Connection getTargetConnection(); @Override List<Point2D> getControlPoints(); @Override DefinitionResolver getDefinitionResolver(); }### Answer:
@Test public void testGetSourceId() { assertEquals(SOURCE_ID, propertyReader.getSourceId()); } |
### Question:
AssociationPropertyReader extends BasePropertyReader implements EdgePropertyReader { @Override public String getTargetId() { return association.getTargetRef().getId(); } AssociationPropertyReader(Association association,
BPMNDiagram diagram,
DefinitionResolver definitionResolver); @Override String getSourceId(); @Override String getTargetId(); Class getAssociationByDirection(); @Override Connection getSourceConnection(); @Override Connection getTargetConnection(); @Override List<Point2D> getControlPoints(); @Override DefinitionResolver getDefinitionResolver(); }### Answer:
@Test public void testGetTargetId() { assertEquals(TARGET_ID, propertyReader.getTargetId()); } |
### Question:
AssociationPropertyReader extends BasePropertyReader implements EdgePropertyReader { @Override public Connection getSourceConnection() { Point2D sourcePosition = PropertyReaderUtils.getSourcePosition(definitionResolver, element.getId(), getSourceId()); return MagnetConnection.Builder .at(sourcePosition.getX(), sourcePosition.getY()) .setAuto(PropertyReaderUtils.isAutoConnectionSource(element)); } AssociationPropertyReader(Association association,
BPMNDiagram diagram,
DefinitionResolver definitionResolver); @Override String getSourceId(); @Override String getTargetId(); Class getAssociationByDirection(); @Override Connection getSourceConnection(); @Override Connection getTargetConnection(); @Override List<Point2D> getControlPoints(); @Override DefinitionResolver getDefinitionResolver(); }### Answer:
@Test public void testGetSourceConnection() { mockStatic(PropertyReaderUtils.class); PowerMockito.when(PropertyReaderUtils.getSourcePosition(definitionResolver, ASSOCIATION_ID, SOURCE_ID)).thenReturn(position); boolean arbitraryBoolean = true; PowerMockito.when(PropertyReaderUtils.isAutoConnectionSource(association)).thenReturn(arbitraryBoolean); Connection result = propertyReader.getSourceConnection(); assertEquals(X, result.getLocation().getX(), 0); assertEquals(Y, result.getLocation().getY(), 0); } |
### Question:
AssociationPropertyReader extends BasePropertyReader implements EdgePropertyReader { @Override public Connection getTargetConnection() { Point2D targetPosition = PropertyReaderUtils.getTargetPosition(definitionResolver, element.getId(), getTargetId()); return MagnetConnection.Builder .at(targetPosition.getX(), targetPosition.getY()) .setAuto(PropertyReaderUtils.isAutoConnectionTarget(element)); } AssociationPropertyReader(Association association,
BPMNDiagram diagram,
DefinitionResolver definitionResolver); @Override String getSourceId(); @Override String getTargetId(); Class getAssociationByDirection(); @Override Connection getSourceConnection(); @Override Connection getTargetConnection(); @Override List<Point2D> getControlPoints(); @Override DefinitionResolver getDefinitionResolver(); }### Answer:
@Test public void testGetTargetConnection() { mockStatic(PropertyReaderUtils.class); PowerMockito.when(PropertyReaderUtils.getTargetPosition(definitionResolver, ASSOCIATION_ID, TARGET_ID)).thenReturn(position); boolean arbitraryBoolean = true; PowerMockito.when(PropertyReaderUtils.isAutoConnectionSource(association)).thenReturn(arbitraryBoolean); Connection result = propertyReader.getTargetConnection(); assertEquals(X, result.getLocation().getX(), 0); assertEquals(Y, result.getLocation().getY(), 0); } |
### Question:
AssociationPropertyReader extends BasePropertyReader implements EdgePropertyReader { public Class getAssociationByDirection() { AssociationDirection d = association.getAssociationDirection(); if (!AssociationDirection.NONE.equals(d)) { return DirectionalAssociation.class; } return NonDirectionalAssociation.class; } AssociationPropertyReader(Association association,
BPMNDiagram diagram,
DefinitionResolver definitionResolver); @Override String getSourceId(); @Override String getTargetId(); Class getAssociationByDirection(); @Override Connection getSourceConnection(); @Override Connection getTargetConnection(); @Override List<Point2D> getControlPoints(); @Override DefinitionResolver getDefinitionResolver(); }### Answer:
@Test public void testGetAssociationByDirection() { final Association association = Bpmn2Factory.eINSTANCE.createAssociation(); association.setAssociationDirection(null); propertyReader = new AssociationPropertyReader(association, bpmnDiagram, definitionResolver); assertEquals(NonDirectionalAssociation.class, propertyReader.getAssociationByDirection()); association.setAssociationDirection(AssociationDirection.NONE); assertEquals(NonDirectionalAssociation.class, propertyReader.getAssociationByDirection()); association.setAssociationDirection(AssociationDirection.ONE); assertEquals(DirectionalAssociation.class, propertyReader.getAssociationByDirection()); } |
### Question:
AssociationPropertyReader extends BasePropertyReader implements EdgePropertyReader { @Override public List<Point2D> getControlPoints() { return PropertyReaderUtils.getControlPoints(definitionResolver, element.getId()); } AssociationPropertyReader(Association association,
BPMNDiagram diagram,
DefinitionResolver definitionResolver); @Override String getSourceId(); @Override String getTargetId(); Class getAssociationByDirection(); @Override Connection getSourceConnection(); @Override Connection getTargetConnection(); @Override List<Point2D> getControlPoints(); @Override DefinitionResolver getDefinitionResolver(); }### Answer:
@Test @SuppressWarnings("unchecked") public void testGetControlPoints() { List<Point2D> controlPoints = mock(List.class); mockStatic(PropertyReaderUtils.class); PowerMockito.when(PropertyReaderUtils.getControlPoints(definitionResolver, ASSOCIATION_ID)).thenReturn(controlPoints); assertEquals(controlPoints, propertyReader.getControlPoints()); } |
### Question:
DMNDiagramsSession implements GraphsProvider { public Optional<DMNDiagramElement> getCurrentDMNDiagramElement() { return getSessionState().getCurrentDMNDiagramElement(); } DMNDiagramsSession(); @Inject DMNDiagramsSession(final ManagedInstance<DMNDiagramsSessionState> dmnDiagramsSessionStates,
final SessionManager sessionManager,
final DMNDiagramUtils dmnDiagramUtils); void destroyState(final Metadata metadata); DMNDiagramsSessionState setState(final Metadata metadata,
final Map<String, Diagram> diagramsByDiagramElementId,
final Map<String, DMNDiagramElement> dmnDiagramsByDiagramElementId); boolean isSessionStatePresent(); DMNDiagramsSessionState getSessionState(); String getCurrentSessionKey(); String getSessionKey(final Metadata metadata); void add(final DMNDiagramElement dmnDiagram,
final Diagram stunnerDiagram); void remove(final DMNDiagramElement dmnDiagram); @Override Diagram getDiagram(final String dmnDiagramElementId); @Override String getCurrentDiagramId(); DMNDiagramElement getDMNDiagramElement(final String dmnDiagramElementId); DMNDiagramTuple getDiagramTuple(final String dmnDiagramElementId); List<DMNDiagramTuple> getDMNDiagrams(); void onDMNDiagramSelected(final @Observes DMNDiagramSelected selected); boolean belongsToCurrentSessionState(final DMNDiagramElement diagramElement); Optional<DMNDiagramElement> getCurrentDMNDiagramElement(); Optional<Diagram> getCurrentDiagram(); Diagram getDRGDiagram(); DMNDiagramElement getDRGDiagramElement(); void clear(); List<DRGElement> getModelDRGElements(); List<Import> getModelImports(); @Override boolean isGlobalGraphSelected(); @Override List<Graph> getGraphs(); List<Node> getAllNodes(); Diagram getCurrentGraphDiagram(); }### Answer:
@Test public void testGetCurrentDMNDiagramElement() { final DMNDiagramElement diagramElement = new DMNDiagramElement(); final Diagram stunnerDiagram = mock(Diagram.class); final DMNDiagramSelected selectedDiagram = new DMNDiagramSelected(diagramElement); dmnDiagramsSession.add(diagramElement, stunnerDiagram); dmnDiagramsSession.onDMNDiagramSelected(selectedDiagram); final Optional<DMNDiagramElement> currentDMNDiagramElement = dmnDiagramsSession.getCurrentDMNDiagramElement(); assertTrue(currentDMNDiagramElement.isPresent()); assertEquals(diagramElement, currentDMNDiagramElement.get()); } |
### Question:
AdHocSubProcessPropertyReader extends SubProcessPropertyReader { public ScriptTypeValue getAdHocCompletionCondition() { if (process.getCompletionCondition() instanceof FormalExpression) { FormalExpression completionCondition = (FormalExpression) process.getCompletionCondition(); return new ScriptTypeValue( Scripts.scriptLanguageFromUri(completionCondition.getLanguage(), Scripts.LANGUAGE.MVEL.language()), FormalExpressionBodyHandler.of(completionCondition).getBody() ); } else { return new ScriptTypeValue(Scripts.LANGUAGE.MVEL.language(), "autocomplete"); } } AdHocSubProcessPropertyReader(AdHocSubProcess element, BPMNDiagram diagram, DefinitionResolver definitionResolver); String getAdHocActivationCondition(); ScriptTypeValue getAdHocCompletionCondition(); String getAdHocOrdering(); boolean isAdHocAutostart(); }### Answer:
@Test public void testGetAdHocCompletionConditionWithoutFormalExpression() { when(process.getCompletionCondition()).thenReturn(null); assertEquals(new ScriptTypeValue(Scripts.LANGUAGE.MVEL.language(), "autocomplete"), propertyReader.getAdHocCompletionCondition()); } |
### Question:
DMNDiagramsSession implements GraphsProvider { public Optional<Diagram> getCurrentDiagram() { return getSessionState().getCurrentDiagram(); } DMNDiagramsSession(); @Inject DMNDiagramsSession(final ManagedInstance<DMNDiagramsSessionState> dmnDiagramsSessionStates,
final SessionManager sessionManager,
final DMNDiagramUtils dmnDiagramUtils); void destroyState(final Metadata metadata); DMNDiagramsSessionState setState(final Metadata metadata,
final Map<String, Diagram> diagramsByDiagramElementId,
final Map<String, DMNDiagramElement> dmnDiagramsByDiagramElementId); boolean isSessionStatePresent(); DMNDiagramsSessionState getSessionState(); String getCurrentSessionKey(); String getSessionKey(final Metadata metadata); void add(final DMNDiagramElement dmnDiagram,
final Diagram stunnerDiagram); void remove(final DMNDiagramElement dmnDiagram); @Override Diagram getDiagram(final String dmnDiagramElementId); @Override String getCurrentDiagramId(); DMNDiagramElement getDMNDiagramElement(final String dmnDiagramElementId); DMNDiagramTuple getDiagramTuple(final String dmnDiagramElementId); List<DMNDiagramTuple> getDMNDiagrams(); void onDMNDiagramSelected(final @Observes DMNDiagramSelected selected); boolean belongsToCurrentSessionState(final DMNDiagramElement diagramElement); Optional<DMNDiagramElement> getCurrentDMNDiagramElement(); Optional<Diagram> getCurrentDiagram(); Diagram getDRGDiagram(); DMNDiagramElement getDRGDiagramElement(); void clear(); List<DRGElement> getModelDRGElements(); List<Import> getModelImports(); @Override boolean isGlobalGraphSelected(); @Override List<Graph> getGraphs(); List<Node> getAllNodes(); Diagram getCurrentGraphDiagram(); }### Answer:
@Test public void testGetCurrentDiagram() { final DMNDiagramElement diagramElement = new DMNDiagramElement(); final Diagram stunnerDiagram = mock(Diagram.class); final DMNDiagramSelected selectedDiagram = new DMNDiagramSelected(diagramElement); dmnDiagramsSession.add(diagramElement, stunnerDiagram); dmnDiagramsSession.onDMNDiagramSelected(selectedDiagram); final Optional<Diagram> currentDiagram = dmnDiagramsSession.getCurrentDiagram(); assertTrue(currentDiagram.isPresent()); assertEquals(stunnerDiagram, currentDiagram.get()); } |
### Question:
AssociationConverter implements EdgeConverter<org.eclipse.bpmn2.Association> { @Override @SuppressWarnings("unchecked") 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); @Override @SuppressWarnings("unchecked") 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())); 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:
DMNDiagramsSession implements GraphsProvider { public Diagram getDRGDiagram() { return Optional.ofNullable(getSessionState()).map(DMNDiagramsSessionState::getDRGDiagram).orElse(null); } DMNDiagramsSession(); @Inject DMNDiagramsSession(final ManagedInstance<DMNDiagramsSessionState> dmnDiagramsSessionStates,
final SessionManager sessionManager,
final DMNDiagramUtils dmnDiagramUtils); void destroyState(final Metadata metadata); DMNDiagramsSessionState setState(final Metadata metadata,
final Map<String, Diagram> diagramsByDiagramElementId,
final Map<String, DMNDiagramElement> dmnDiagramsByDiagramElementId); boolean isSessionStatePresent(); DMNDiagramsSessionState getSessionState(); String getCurrentSessionKey(); String getSessionKey(final Metadata metadata); void add(final DMNDiagramElement dmnDiagram,
final Diagram stunnerDiagram); void remove(final DMNDiagramElement dmnDiagram); @Override Diagram getDiagram(final String dmnDiagramElementId); @Override String getCurrentDiagramId(); DMNDiagramElement getDMNDiagramElement(final String dmnDiagramElementId); DMNDiagramTuple getDiagramTuple(final String dmnDiagramElementId); List<DMNDiagramTuple> getDMNDiagrams(); void onDMNDiagramSelected(final @Observes DMNDiagramSelected selected); boolean belongsToCurrentSessionState(final DMNDiagramElement diagramElement); Optional<DMNDiagramElement> getCurrentDMNDiagramElement(); Optional<Diagram> getCurrentDiagram(); Diagram getDRGDiagram(); DMNDiagramElement getDRGDiagramElement(); void clear(); List<DRGElement> getModelDRGElements(); List<Import> getModelImports(); @Override boolean isGlobalGraphSelected(); @Override List<Graph> getGraphs(); List<Node> getAllNodes(); Diagram getCurrentGraphDiagram(); }### Answer:
@Test public void testGetDRGDiagram() { final Diagram expected = mock(Diagram.class); doReturn(expected).when(dmnDiagramsSessionState).getDRGDiagram(); final Diagram actual = dmnDiagramsSession.getDRGDiagram(); assertEquals(expected, actual); } |
### Question:
DMNDiagramHelper { public List<DRGElement> getNodes(final Diagram diagram) { return dmnDiagramUtils.getDRGElements(diagram); } @Inject DMNDiagramHelper(final DiagramService diagramService,
final DMNDiagramUtils dmnDiagramUtils); List<DRGElement> getNodes(final Diagram diagram); List<ItemDefinition> getItemDefinitions(final Diagram diagram); String getNamespace(final Path path); String getNamespace(final Diagram diagram); Diagram<Graph, Metadata> getDiagramByPath(final Path path); }### Answer:
@Test public void testGetNodes() { final DRGElement drgElement = mock(DRGElement.class); final List<DRGElement> expectedNodes = singletonList(drgElement); when(dmnDiagramUtils.getDRGElements(diagram)).thenReturn(expectedNodes); final List<DRGElement> actualNodes = helper.getNodes(diagram); assertEquals(expectedNodes, actualNodes); } |
### Question:
FlowElementConverter extends AbstractConverter { public Result<BpmnNode> convertNode(FlowElement flowElement) { return Match.<FlowElement, Result<BpmnNode>>of() .<StartEvent>when(e -> e instanceof StartEvent, converterFactory.startEventConverter()::convert) .<EndEvent>when(e -> e instanceof EndEvent, converterFactory.endEventConverter()::convert) .<BoundaryEvent>when(e -> e instanceof BoundaryEvent, converterFactory.intermediateCatchEventConverter()::convertBoundaryEvent) .<IntermediateCatchEvent>when(e -> e instanceof IntermediateCatchEvent, converterFactory.intermediateCatchEventConverter()::convert) .<IntermediateThrowEvent>when(e -> e instanceof IntermediateThrowEvent, converterFactory.intermediateThrowEventConverter()::convert) .<Task>when(e -> e instanceof Task, converterFactory.taskConverter()::convert) .<Gateway>when(e -> e instanceof Gateway, converterFactory.gatewayConverter()::convert) .<SubProcess>when(e -> e instanceof SubProcess, converterFactory.subProcessConverter()::convertSubProcess) .<CallActivity>when(e -> e instanceof CallActivity, converterFactory.callActivityConverter()::convert) .<TextAnnotation>when(e -> e instanceof TextAnnotation, converterFactory.textAnnotationConverter()::convert) .<DataObjectReference>when(e -> e instanceof DataObjectReference, converterFactory.dataObjectConverter()::convert) .ignore(e -> e instanceof DataStoreReference, DataStoreReference.class) .ignore(e -> e instanceof DataObject, DataObject.class) .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(textAnnotationConverter).convert(textAnnotation); DataObjectReference dataObjectReference = mock(DataObjectReference.class); tested.convertNode(dataObjectReference); verify(dataObjectConverter).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); @Override ProcessData createProcessData(String processVariables); @Override AdvancedData createAdvancedData(String globalVariables, String metaDataAttributes); }### Answer:
@Test public void testCreateNode() { assertTrue(tested.createNode("id").getContent().getDefinition() instanceof BPMNDiagramImpl); } |
### Question:
RootProcessConverter extends BaseRootProcessConverter<BPMNDiagramImpl, DiagramSet, ProcessData, AdvancedData> { @Override public ProcessData createProcessData(String processVariables) { return new ProcessData(new ProcessVariables(processVariables)); } RootProcessConverter(TypedFactoryManager typedFactoryManager,
PropertyReaderFactory propertyReaderFactory,
DefinitionResolver definitionResolver,
BaseConverterFactory factory); @Override ProcessData createProcessData(String processVariables); @Override AdvancedData createAdvancedData(String globalVariables, String metaDataAttributes); }### Answer:
@Test public void testCreateProcessData() { assertNotNull(tested.createProcessData("id")); } |
### Question:
RootProcessConverter extends BaseRootProcessConverter<BPMNDiagramImpl, DiagramSet, ProcessData, AdvancedData> { @Override protected DiagramSet createDiagramSet(Process process, ProcessPropertyReader e, DefinitionsPropertyReader d) { return new DiagramSet(new Name(revertIllegalCharsAttribute(process.getName())), new Documentation(e.getDocumentation()), new Id(revertIllegalCharsAttribute(process.getId())), new Package(e.getPackage()), new ProcessType(e.getProcessType()), new Version(e.getVersion()), new AdHoc(e.isAdHoc()), new ProcessInstanceDescription(e.getDescription()), new Imports(new ImportsValue(e.getDefaultImports(), d.getWSDLImports())), new Executable(process.isIsExecutable()), new SLADueDate(e.getSlaDueDate())); } RootProcessConverter(TypedFactoryManager typedFactoryManager,
PropertyReaderFactory propertyReaderFactory,
DefinitionResolver definitionResolver,
BaseConverterFactory factory); @Override ProcessData createProcessData(String processVariables); @Override AdvancedData createAdvancedData(String globalVariables, String metaDataAttributes); }### 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:
DMNDiagramsSession implements GraphsProvider { public DMNDiagramElement getDRGDiagramElement() { return Optional.ofNullable(getSessionState()).map(DMNDiagramsSessionState::getDRGDiagramElement).orElse(null); } DMNDiagramsSession(); @Inject DMNDiagramsSession(final ManagedInstance<DMNDiagramsSessionState> dmnDiagramsSessionStates,
final SessionManager sessionManager,
final DMNDiagramUtils dmnDiagramUtils); void destroyState(final Metadata metadata); DMNDiagramsSessionState setState(final Metadata metadata,
final Map<String, Diagram> diagramsByDiagramElementId,
final Map<String, DMNDiagramElement> dmnDiagramsByDiagramElementId); boolean isSessionStatePresent(); DMNDiagramsSessionState getSessionState(); String getCurrentSessionKey(); String getSessionKey(final Metadata metadata); void add(final DMNDiagramElement dmnDiagram,
final Diagram stunnerDiagram); void remove(final DMNDiagramElement dmnDiagram); @Override Diagram getDiagram(final String dmnDiagramElementId); @Override String getCurrentDiagramId(); DMNDiagramElement getDMNDiagramElement(final String dmnDiagramElementId); DMNDiagramTuple getDiagramTuple(final String dmnDiagramElementId); List<DMNDiagramTuple> getDMNDiagrams(); void onDMNDiagramSelected(final @Observes DMNDiagramSelected selected); boolean belongsToCurrentSessionState(final DMNDiagramElement diagramElement); Optional<DMNDiagramElement> getCurrentDMNDiagramElement(); Optional<Diagram> getCurrentDiagram(); Diagram getDRGDiagram(); DMNDiagramElement getDRGDiagramElement(); void clear(); List<DRGElement> getModelDRGElements(); List<Import> getModelImports(); @Override boolean isGlobalGraphSelected(); @Override List<Graph> getGraphs(); List<Node> getAllNodes(); Diagram getCurrentGraphDiagram(); }### Answer:
@Test public void testGetDRGDiagramElement() { final DMNDiagramElement expected = mock(DMNDiagramElement.class); doReturn(expected).when(dmnDiagramsSessionState).getDRGDiagramElement(); final DMNDiagramElement actual = dmnDiagramsSession.getDRGDiagramElement(); assertEquals(expected, actual); } |
### 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.composeResults(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:
ResultComposer { @SuppressWarnings("unchecked") public static <T> Result compose(T value, Result... result) { List<Result<Object>> results = Arrays.asList(result); return composeResults(value, results); } static Result composeResults(T value, Collection<Result<R>>... results); @SuppressWarnings("unchecked") 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, result1, result2, result3); assertResult(result); } |
### 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 DefaultImportsElement defaultImports; static final GlobalVariablesElement globalVariables; static final MetaDataAttributesElement metaDataAttributes; static final MetadataTypeDefinition<Boolean> isCase; static final MetadataTypeDefinition<String> customActivationCondition; static final MetadataTypeDefinition<Boolean> abortParent; }### 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 DefaultImportsElement defaultImports; static final GlobalVariablesElement globalVariables; static final MetaDataAttributesElement metaDataAttributes; static final MetadataTypeDefinition<Boolean> isCase; static final MetadataTypeDefinition<String> customActivationCondition; static final MetadataTypeDefinition<Boolean> abortParent; }### 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:
DMNDiagramsSession implements GraphsProvider { public void clear() { getSessionState().clear(); } DMNDiagramsSession(); @Inject DMNDiagramsSession(final ManagedInstance<DMNDiagramsSessionState> dmnDiagramsSessionStates,
final SessionManager sessionManager,
final DMNDiagramUtils dmnDiagramUtils); void destroyState(final Metadata metadata); DMNDiagramsSessionState setState(final Metadata metadata,
final Map<String, Diagram> diagramsByDiagramElementId,
final Map<String, DMNDiagramElement> dmnDiagramsByDiagramElementId); boolean isSessionStatePresent(); DMNDiagramsSessionState getSessionState(); String getCurrentSessionKey(); String getSessionKey(final Metadata metadata); void add(final DMNDiagramElement dmnDiagram,
final Diagram stunnerDiagram); void remove(final DMNDiagramElement dmnDiagram); @Override Diagram getDiagram(final String dmnDiagramElementId); @Override String getCurrentDiagramId(); DMNDiagramElement getDMNDiagramElement(final String dmnDiagramElementId); DMNDiagramTuple getDiagramTuple(final String dmnDiagramElementId); List<DMNDiagramTuple> getDMNDiagrams(); void onDMNDiagramSelected(final @Observes DMNDiagramSelected selected); boolean belongsToCurrentSessionState(final DMNDiagramElement diagramElement); Optional<DMNDiagramElement> getCurrentDMNDiagramElement(); Optional<Diagram> getCurrentDiagram(); Diagram getDRGDiagram(); DMNDiagramElement getDRGDiagramElement(); void clear(); List<DRGElement> getModelDRGElements(); List<Import> getModelImports(); @Override boolean isGlobalGraphSelected(); @Override List<Graph> getGraphs(); List<Node> getAllNodes(); Diagram getCurrentGraphDiagram(); }### Answer:
@Test public void testClear() { final DMNDiagramElement dmnDiagram = mock(DMNDiagramElement.class); final Diagram stunnerDiagram = mock(Diagram.class); final String diagramId = "0000"; when(dmnDiagram.getId()).thenReturn(new Id(diagramId)); dmnDiagramsSession.add(dmnDiagram, stunnerDiagram); assertEquals(dmnDiagram, dmnDiagramsSession.getDMNDiagramElement(diagramId)); assertEquals(stunnerDiagram, dmnDiagramsSession.getDiagram(diagramId)); assertEquals(dmnDiagram, dmnDiagramsSession.getDiagramTuple(diagramId).getDMNDiagram()); assertEquals(stunnerDiagram, dmnDiagramsSession.getDiagramTuple(diagramId).getStunnerDiagram()); dmnDiagramsSession.clear(); assertNull(dmnDiagramsSession.getDMNDiagramElement(diagramId)); assertNull(dmnDiagramsSession.getDiagram(diagramId)); assertNull(dmnDiagramsSession.getDiagramTuple(diagramId).getDMNDiagram()); assertNull(dmnDiagramsSession.getDiagramTuple(diagramId).getStunnerDiagram()); } |
### Question:
DMNDiagramsSession implements GraphsProvider { public List<DRGElement> getModelDRGElements() { return Optional.ofNullable(getSessionState()).map(DMNDiagramsSessionState::getModelDRGElements).orElse(emptyList()); } DMNDiagramsSession(); @Inject DMNDiagramsSession(final ManagedInstance<DMNDiagramsSessionState> dmnDiagramsSessionStates,
final SessionManager sessionManager,
final DMNDiagramUtils dmnDiagramUtils); void destroyState(final Metadata metadata); DMNDiagramsSessionState setState(final Metadata metadata,
final Map<String, Diagram> diagramsByDiagramElementId,
final Map<String, DMNDiagramElement> dmnDiagramsByDiagramElementId); boolean isSessionStatePresent(); DMNDiagramsSessionState getSessionState(); String getCurrentSessionKey(); String getSessionKey(final Metadata metadata); void add(final DMNDiagramElement dmnDiagram,
final Diagram stunnerDiagram); void remove(final DMNDiagramElement dmnDiagram); @Override Diagram getDiagram(final String dmnDiagramElementId); @Override String getCurrentDiagramId(); DMNDiagramElement getDMNDiagramElement(final String dmnDiagramElementId); DMNDiagramTuple getDiagramTuple(final String dmnDiagramElementId); List<DMNDiagramTuple> getDMNDiagrams(); void onDMNDiagramSelected(final @Observes DMNDiagramSelected selected); boolean belongsToCurrentSessionState(final DMNDiagramElement diagramElement); Optional<DMNDiagramElement> getCurrentDMNDiagramElement(); Optional<Diagram> getCurrentDiagram(); Diagram getDRGDiagram(); DMNDiagramElement getDRGDiagramElement(); void clear(); List<DRGElement> getModelDRGElements(); List<Import> getModelImports(); @Override boolean isGlobalGraphSelected(); @Override List<Graph> getGraphs(); List<Node> getAllNodes(); Diagram getCurrentGraphDiagram(); }### Answer:
@Test public void testGetModelDRGElements() { final List<DRGElement> expected = asList(mock(DRGElement.class), mock(DRGElement.class)); doReturn(expected).when(dmnDiagramsSessionState).getModelDRGElements(); final List<DRGElement> actual = dmnDiagramsSession.getModelDRGElements(); assertEquals(expected, actual); } |
### Question:
VariableDeclaration { @Override public String toString() { String tagString = ""; if (!Strings.isNullOrEmpty(tags)) { tagString = ":" + tags; } if (type == null || type.isEmpty()) { return typedIdentifier.getName() + tagString; } else { return typedIdentifier.getName() + ":" + type + tagString; } } 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:
DMNDiagramsSession implements GraphsProvider { public List<Import> getModelImports() { return Optional.ofNullable(getSessionState()).map(DMNDiagramsSessionState::getModelImports).orElse(emptyList()); } DMNDiagramsSession(); @Inject DMNDiagramsSession(final ManagedInstance<DMNDiagramsSessionState> dmnDiagramsSessionStates,
final SessionManager sessionManager,
final DMNDiagramUtils dmnDiagramUtils); void destroyState(final Metadata metadata); DMNDiagramsSessionState setState(final Metadata metadata,
final Map<String, Diagram> diagramsByDiagramElementId,
final Map<String, DMNDiagramElement> dmnDiagramsByDiagramElementId); boolean isSessionStatePresent(); DMNDiagramsSessionState getSessionState(); String getCurrentSessionKey(); String getSessionKey(final Metadata metadata); void add(final DMNDiagramElement dmnDiagram,
final Diagram stunnerDiagram); void remove(final DMNDiagramElement dmnDiagram); @Override Diagram getDiagram(final String dmnDiagramElementId); @Override String getCurrentDiagramId(); DMNDiagramElement getDMNDiagramElement(final String dmnDiagramElementId); DMNDiagramTuple getDiagramTuple(final String dmnDiagramElementId); List<DMNDiagramTuple> getDMNDiagrams(); void onDMNDiagramSelected(final @Observes DMNDiagramSelected selected); boolean belongsToCurrentSessionState(final DMNDiagramElement diagramElement); Optional<DMNDiagramElement> getCurrentDMNDiagramElement(); Optional<Diagram> getCurrentDiagram(); Diagram getDRGDiagram(); DMNDiagramElement getDRGDiagramElement(); void clear(); List<DRGElement> getModelDRGElements(); List<Import> getModelImports(); @Override boolean isGlobalGraphSelected(); @Override List<Graph> getGraphs(); List<Node> getAllNodes(); Diagram getCurrentGraphDiagram(); }### Answer:
@Test public void testGetModelImports() { final List<Import> expected = asList(mock(Import.class), mock(Import.class)); doReturn(expected).when(dmnDiagramsSessionState).getModelImports(); final List<Import> actual = dmnDiagramsSession.getModelImports(); assertEquals(expected, actual); } |
### Question:
DataObjectConverter { public PropertyWriter toElement(Node<View<DataObject>, ?> node) { final DataObject def = node.getContent().getDefinition(); if (def != null) { DataObjectReference element = bpmn2.createDataObjectReference(); element.setId(node.getUUID()); DataObjectPropertyWriter writer = propertyWriterFactory.of(element); DataObject definition = node.getContent().getDefinition(); writer.setName(StringUtils.replaceIllegalCharsAttribute(StringUtils.replaceIllegalCharsForDataObjects(definition.getName().getValue()))); writer.setType(definition.getType().getValue().getType()); writer.setAbsoluteBounds(node); return writer; } return ConverterUtils.notSupported(def); } DataObjectConverter(PropertyWriterFactory propertyWriterFactory); PropertyWriter toElement(Node<View<DataObject>, ?> node); }### Answer:
@Test(expected = NullPointerException.class) public void toElement() { PropertyWriter propertyWriter = tested.toElement(node); verify(writer).setName(NAME); verify(writer).setType(TYPE); verify(writer).setAbsoluteBounds(node); assertEquals(writer, propertyWriter); Node<View<DataObject>, ?> node2 = new NodeImpl<>(UUID.uuid()); node2.setContent(dataObjectView2); TextAnnotation textAnnotation = new TextAnnotation(); when(dataObjectView2.getDefinition()).thenReturn(null); PropertyWriter propertyWriter2 = tested.toElement(node2); } |
### Question:
TextAnnotationConverter { public PropertyWriter toElement(Node<View<TextAnnotation>, ?> node) { final TextAnnotation def = node.getContent().getDefinition(); if (def != null) { TextAnnotation definition = node.getContent().getDefinition(); org.eclipse.bpmn2.TextAnnotation element = bpmn2.createTextAnnotation(); element.setId(node.getUUID()); TextAnnotationPropertyWriter writer = propertyWriterFactory.of(element); BPMNGeneralSet general = definition.getGeneral(); writer.setName(general.getName().getValue()); writer.setDocumentation(general.getDocumentation().getValue()); writer.setAbsoluteBounds(node); return writer; } return ConverterUtils.notSupported(def); } TextAnnotationConverter(PropertyWriterFactory propertyWriterFactory); PropertyWriter toElement(Node<View<TextAnnotation>, ?> node); }### Answer:
@Test public void toElement() { PropertyWriter propertyWriter = tested.toElement(node); verify(writer).setName(NAME); verify(writer).setDocumentation(DOC); verify(writer).setAbsoluteBounds(node); assertEquals(writer, propertyWriter); }
@Test(expected = NullPointerException.class) public void toElementWithNullValue() { when(textAnnotationView.getDefinition()).thenReturn(null); PropertyWriter propertyWriter = tested.toElement(node); } |
### Question:
DMNDiagramsSession implements GraphsProvider { @Override public String getCurrentDiagramId() { if (!Objects.isNull(getSessionState())) { final Optional<DMNDiagramElement> current = getCurrentDMNDiagramElement(); if (current.isPresent()) { return current.get().getId().getValue(); } } return null; } DMNDiagramsSession(); @Inject DMNDiagramsSession(final ManagedInstance<DMNDiagramsSessionState> dmnDiagramsSessionStates,
final SessionManager sessionManager,
final DMNDiagramUtils dmnDiagramUtils); void destroyState(final Metadata metadata); DMNDiagramsSessionState setState(final Metadata metadata,
final Map<String, Diagram> diagramsByDiagramElementId,
final Map<String, DMNDiagramElement> dmnDiagramsByDiagramElementId); boolean isSessionStatePresent(); DMNDiagramsSessionState getSessionState(); String getCurrentSessionKey(); String getSessionKey(final Metadata metadata); void add(final DMNDiagramElement dmnDiagram,
final Diagram stunnerDiagram); void remove(final DMNDiagramElement dmnDiagram); @Override Diagram getDiagram(final String dmnDiagramElementId); @Override String getCurrentDiagramId(); DMNDiagramElement getDMNDiagramElement(final String dmnDiagramElementId); DMNDiagramTuple getDiagramTuple(final String dmnDiagramElementId); List<DMNDiagramTuple> getDMNDiagrams(); void onDMNDiagramSelected(final @Observes DMNDiagramSelected selected); boolean belongsToCurrentSessionState(final DMNDiagramElement diagramElement); Optional<DMNDiagramElement> getCurrentDMNDiagramElement(); Optional<Diagram> getCurrentDiagram(); Diagram getDRGDiagram(); DMNDiagramElement getDRGDiagramElement(); void clear(); List<DRGElement> getModelDRGElements(); List<Import> getModelImports(); @Override boolean isGlobalGraphSelected(); @Override List<Graph> getGraphs(); List<Node> getAllNodes(); Diagram getCurrentGraphDiagram(); }### Answer:
@Test public void testGetCurrentDiagramId() { final DMNDiagramElement diagramElement = mock(DMNDiagramElement.class); final Diagram stunnerDiagram = mock(Diagram.class); final DMNDiagramSelected selectedDiagram = new DMNDiagramSelected(diagramElement); final Id id = mock(Id.class); final String expectedId = "value"; when(id.getValue()).thenReturn(expectedId); when(diagramElement.getId()).thenReturn(id); dmnDiagramsSession.add(diagramElement, stunnerDiagram); dmnDiagramsSession.onDMNDiagramSelected(selectedDiagram); final String actualId = dmnDiagramsSession.getCurrentDiagramId(); assertEquals(expectedId, actualId); } |
### 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); Point sourcePoint = pointOf( source.getShape().getBounds().getX() + sourcePt.getX(), source.getShape().getBounds().getY() + sourcePt.getY()); 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:
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 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 { 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()); 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:
MultipleInstanceActivityPropertyWriter extends ActivityPropertyWriter { public void setCompletionCondition(String expression) { if (!isEmpty(expression)) { setUpLoopCharacteristics(); FormalExpression formalExpression = bpmn2.createFormalExpression(); FormalExpressionBodyHandler.of(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]]>", FormalExpressionBodyHandler.of((FormalExpression) ((MultiInstanceLoopCharacteristics) activity.getLoopCharacteristics()).getCompletionCondition()).getBody()); } |
### Question:
DMNDiagramsSessionState { Diagram getDiagram(final String dmnDiagramElementId) { return diagramsByDiagramId.get(dmnDiagramElementId); } @Inject DMNDiagramsSessionState(final DMNDiagramUtils dmnDiagramUtils); Diagram getDRGDiagram(); }### Answer:
@Test public void testGetDiagram() { assertEquals(stunnerDiagram1, sessionState.getDiagram(id1)); assertEquals(stunnerDiagram2, sessionState.getDiagram(id2)); assertEquals(stunnerDiagram3, sessionState.getDiagram(id3)); } |
### 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()); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.