method2testcases
stringlengths 118
6.63k
|
---|
### Question:
DMNGridPanel extends GridLienzoPanel { @Override public void onResize() { doResize(() -> { updatePanelSize(); refreshScrollPosition(); final TransformMediator restriction = mousePanMediator.getTransformMediator(); final Transform transform = restriction.adjust(getDefaultGridLayer().getViewport().getTransform(), getDefaultGridLayer().getVisibleBounds()); getDefaultGridLayer().getViewport().setTransform(transform); getDefaultGridLayer().batch(); }); } DMNGridPanel(final DMNGridLayer gridLayer,
final RestrictedMousePanMediator mousePanMediator,
final ContextMenuHandler contextMenuHandler); @Override void onResize(); static final int LIENZO_PANEL_WIDTH; static final int LIENZO_PANEL_HEIGHT; }### Answer:
@Test public void testOnResize() { gridPanel.onResize(); verify(gridPanel).updatePanelSize(); verify(gridPanel).refreshScrollPosition(); verify(viewport).setTransform(eq(newTransform)); verify(gridLayer, times(2)).batch(); } |
### Question:
QNamePropertyType implements PropertyType { @Override public String getName() { return NAME; } @Override String getName(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); static final String NAME; }### Answer:
@Test public void testName() { assertEquals(QNamePropertyType.NAME, new QNamePropertyType().getName()); } |
### Question:
AllowedAnswers implements DMNProperty { public AllowedAnswers copy() { return new AllowedAnswers(value); } AllowedAnswers(); AllowedAnswers(final String value); AllowedAnswers copy(); String getValue(); void setValue(final String value); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testCopy() { final AllowedAnswers source = new AllowedAnswers(ALLOWED_ANSWER_VALUE); final AllowedAnswers target = source.copy(); assertNotNull(target); assertEquals(ALLOWED_ANSWER_VALUE, target.getValue()); } |
### Question:
DMNDefinitionSetResourceType extends AbstractDefinitionSetResourceType { @Override public Category getCategory() { return this.category; } DMNDefinitionSetResourceType(); @Inject DMNDefinitionSetResourceType(final Decision category); @Override Category getCategory(); @Override String getShortName(); @Override String getDescription(); @Override String getSuffix(); @Override int getPriority(); @Override Class<?> getDefinitionSetType(); }### Answer:
@Test public void testCategory() { assertTrue(resourceType.getCategory() instanceof Decision); } |
### Question:
DMNDefinitionSetResourceType extends AbstractDefinitionSetResourceType { @Override public String getShortName() { return NAME; } DMNDefinitionSetResourceType(); @Inject DMNDefinitionSetResourceType(final Decision category); @Override Category getCategory(); @Override String getShortName(); @Override String getDescription(); @Override String getSuffix(); @Override int getPriority(); @Override Class<?> getDefinitionSetType(); }### Answer:
@Test public void testShortName() { assertEquals(DMNDefinitionSetResourceType.NAME, resourceType.getShortName()); } |
### Question:
DMNDefinitionSetResourceType extends AbstractDefinitionSetResourceType { @Override public String getDescription() { return DESCRIPTION; } DMNDefinitionSetResourceType(); @Inject DMNDefinitionSetResourceType(final Decision category); @Override Category getCategory(); @Override String getShortName(); @Override String getDescription(); @Override String getSuffix(); @Override int getPriority(); @Override Class<?> getDefinitionSetType(); }### Answer:
@Test public void testDescription() { assertEquals(DMNDefinitionSetResourceType.DESCRIPTION, resourceType.getDescription()); } |
### Question:
DMNDefinitionSetResourceType extends AbstractDefinitionSetResourceType { @Override public String getSuffix() { return DMN_EXTENSION; } DMNDefinitionSetResourceType(); @Inject DMNDefinitionSetResourceType(final Decision category); @Override Category getCategory(); @Override String getShortName(); @Override String getDescription(); @Override String getSuffix(); @Override int getPriority(); @Override Class<?> getDefinitionSetType(); }### Answer:
@Test public void testSuffix() { assertEquals(DMNDefinitionSetResourceType.DMN_EXTENSION, resourceType.getSuffix()); } |
### Question:
DMNDefinitionSetResourceType extends AbstractDefinitionSetResourceType { @Override public int getPriority() { return 0; } DMNDefinitionSetResourceType(); @Inject DMNDefinitionSetResourceType(final Decision category); @Override Category getCategory(); @Override String getShortName(); @Override String getDescription(); @Override String getSuffix(); @Override int getPriority(); @Override Class<?> getDefinitionSetType(); }### Answer:
@Test public void testPriority() { assertEquals(0, resourceType.getPriority()); } |
### Question:
DMNDefinitionSetResourceType extends AbstractDefinitionSetResourceType { @Override public Class<?> getDefinitionSetType() { return DMNDefinitionSet.class; } DMNDefinitionSetResourceType(); @Inject DMNDefinitionSetResourceType(final Decision category); @Override Category getCategory(); @Override String getShortName(); @Override String getDescription(); @Override String getSuffix(); @Override int getPriority(); @Override Class<?> getDefinitionSetType(); }### Answer:
@Test public void testDefinitionSetType() { assertEquals(DMNDefinitionSet.class, resourceType.getDefinitionSetType()); } |
### Question:
DMNImportTypes { public static DMNImportTypes determineImportType(final String namespace) { return importTypes .stream() .filter(importType -> importType.matchesNamespace(namespace)) .findFirst() .orElse(null); } private DMNImportTypes(final String fileExtension,
final String... namespaces); static DMNImportTypes determineImportType(final String namespace); String getFileExtension(); String getDefaultNamespace(); List<String> getNamespaces(); static final DMNImportTypes DMN; static final DMNImportTypes PMML; }### Answer:
@Test public void testUnknown() { assertNull(DMNImportTypes.determineImportType("cheese")); } |
### Question:
DMNImportTypes { public List<String> getNamespaces() { return namespaces; } private DMNImportTypes(final String fileExtension,
final String... namespaces); static DMNImportTypes determineImportType(final String namespace); String getFileExtension(); String getDefaultNamespace(); List<String> getNamespaces(); static final DMNImportTypes DMN; static final DMNImportTypes PMML; }### Answer:
@Test public void testGetNamespacesDMN() { final List<String> namespaces = DMNImportTypes.DMN.getNamespaces(); assertEquals(1, namespaces.size()); assertEquals("http: }
@Test public void testGetNamespacesPMML() { final List<String> namespaces = DMNImportTypes.PMML.getNamespaces(); assertEquals(7, namespaces.size()); assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: } |
### Question:
NameAndDataTypeColumnRenderer extends BaseGridColumnRenderer<InformationItemCell.HasNameCell> { @Override public Group renderCell(final GridCell<InformationItemCell.HasNameCell> cell, final GridBodyCellRenderContext context) { if (cell == null || cell.getValue() == null) { return null; } final InformationItemCell.HasNameCell hasNameCell = cell.getValue().getValue(); return hasNameCell.render(context); } NameAndDataTypeColumnRenderer(); @Override Group renderHeaderContent(final List<GridColumn.HeaderMetaData> headerMetaData,
final GridHeaderColumnRenderContext context,
final int headerRowIndex,
final double blockWidth,
final double rowHeight); @Override Group renderCell(final GridCell<InformationItemCell.HasNameCell> cell,
final GridBodyCellRenderContext context); }### Answer:
@Test @SuppressWarnings("unchecked") public void testRenderCellWithValue() { this.cell = new BaseGridCell<>(new BaseGridCellValue<>(InformationItemCell.HasNameCell.wrap(TITLE))); assertThat(renderer.renderCell(cell, bodyContext)).isNotNull(); verify(text1).setText(eq(TITLE)); verify(text1).setX(BLOCK_WIDTH / 2); verify(text1).setY(ROW_HEIGHT / 2); } |
### Question:
DMNImportTypes { public String getDefaultNamespace() { return namespaces.get(namespaces.size() - 1); } private DMNImportTypes(final String fileExtension,
final String... namespaces); static DMNImportTypes determineImportType(final String namespace); String getFileExtension(); String getDefaultNamespace(); List<String> getNamespaces(); static final DMNImportTypes DMN; static final DMNImportTypes PMML; }### Answer:
@Test public void testGetDefaultNameSpaceDMN() { assertEquals("http: }
@Test public void testGetDefaultNameSpacePMML() { assertEquals("http: } |
### Question:
PMMLParameterMetadata { public String getName() { return name; } PMMLParameterMetadata(final @MapsTo("name") String name); String getName(); }### Answer:
@Test public void testGetters() { final PMMLParameterMetadata metadata = new PMMLParameterMetadata(PARAMETER_NAME); assertEquals(PARAMETER_NAME, metadata.getName()); } |
### Question:
PMMLIncludedModel extends BaseIncludedModel { public Integer getModelCount() { return modelCount; } PMMLIncludedModel(final @MapsTo("modelName") String modelName,
final @MapsTo("modelPackage") String modelPackage,
final @MapsTo("path") String path,
final @MapsTo("importType") String importType,
final @MapsTo("modelCount") Integer modelCount); Integer getModelCount(); }### Answer:
@Test public void testGetters() { final PMMLIncludedModel model = new PMMLIncludedModel(MODEL_NAME, MODEL_PACKAGE, PATH, IMPORT_TYPE, MODELS_COUNT); assertEquals(MODEL_NAME, model.getModelName()); assertEquals(MODEL_PACKAGE, model.getModelPackage()); assertEquals(PATH, model.getPath()); assertEquals(IMPORT_TYPE, model.getImportType()); assertEquals(MODELS_COUNT, model.getModelCount()); } |
### Question:
DataObject { public String getClassNameWithoutPackage() { int lastIndex = 0; if (classType.contains(".")) { lastIndex = classType.lastIndexOf('.') + 1; } return classType.substring(lastIndex); } DataObject(); DataObject(final String classType); String getClassType(); void setClassType(final String classType); List<DataObjectProperty> getProperties(); void setProperties(final List<DataObjectProperty> properties); String getClassNameWithoutPackage(); }### Answer:
@Test public void testExtractName() { final String name1 = "org.java.SomeClass"; final DataObject dataObject = new DataObject(name1); final String expected1 = "SomeClass"; final String actual1 = dataObject.getClassNameWithoutPackage(); assertEquals(expected1, actual1); final String name2 = "SomeOtherClass"; final String expected2 = "SomeOtherClass"; final DataObject dataObject2 = new DataObject(name2); final String actual2 = dataObject2.getClassNameWithoutPackage(); assertEquals(expected2, actual2); } |
### Question:
BuiltInTypeUtils { public static boolean isBuiltInType(final String type) { return builtInTypeNames() .anyMatch(builtInTypeName -> Objects.equals(builtInTypeName, type)); } static boolean isBuiltInType(final String type); static Optional<BuiltInType> findBuiltInTypeByName(final String name); }### Answer:
@Test public void testIsDefaultWhenTypeIsDefault() { assertTrue(BuiltInTypeUtils.isBuiltInType("string")); }
@Test public void testIsDefaultWhenTypeIsDefaultWithAlternativeAlias() { assertTrue(BuiltInTypeUtils.isBuiltInType("dayTimeDuration")); }
@Test public void testIsNotDefaultWhenTypeIsDefaultWithAnUpperCaseCharacter() { assertFalse(BuiltInTypeUtils.isBuiltInType("String")); }
@Test public void testIsDefaultWhenTypeIsNull() { assertFalse(BuiltInTypeUtils.isBuiltInType(null)); }
@Test public void testIsDefaultWhenTypeIsNotDefault() { assertFalse(BuiltInTypeUtils.isBuiltInType("tAddress")); } |
### Question:
ListBoxDOMElement extends BaseDOMElement<String, ListBox> implements TakesValue<String>,
Focusable { @Override public void setValue(final String value) { this.originalValue = value; for (int i = 0; i < widget.getItemCount(); i++) { if (Objects.equals(widget.getItemText(i), value)) { widget.setSelectedIndex(i); break; } } } ListBoxDOMElement(final ListBox widget,
final GridLayer gridLayer,
final GridWidget gridWidget,
final SessionManager sessionManager,
final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
final Function<GridCellTuple, Command> hasNoValueCommand,
final Function<GridCellValueTuple, Command> hasValueCommand); @Override void setValue(final String value); @Override String getValue(); @Override int getTabIndex(); @Override void setAccessKey(final char key); @Override void setFocus(final boolean focused); @Override void setTabIndex(final int index); @Override void initialise(final GridBodyCellRenderContext context); @Override @SuppressWarnings("unchecked") void flush(final String value); }### Answer:
@Test public void testSetValue() { final List<String> values = new Lists.Builder<String>().add("value1").add("value2").add(VALUE).build(); final String[] varArgs = new String[values.size() - 1]; values.subList(1, values.size()).toArray(varArgs); when(widget.getItemCount()).thenReturn(values.size()); when(widget.getItemText(anyInt())).thenReturn(values.get(0), varArgs); domElement.setValue(VALUE); verify(widget).setSelectedIndex(values.indexOf(VALUE)); } |
### Question:
BuiltInTypeUtils { public static Optional<BuiltInType> findBuiltInTypeByName(final String name) { return getBuiltInTypeValuesStream() .filter(builtInType -> Arrays.asList(builtInType.getNames()).contains(name)) .findAny(); } static boolean isBuiltInType(final String type); static Optional<BuiltInType> findBuiltInTypeByName(final String name); }### Answer:
@Test public void testFindBuiltInTypeByNameWhenItFinds() { assertTrue(BuiltInTypeUtils.findBuiltInTypeByName("boolean").isPresent()); assertEquals(BOOLEAN, BuiltInTypeUtils.findBuiltInTypeByName("boolean").get()); }
@Test public void testFindBuiltInTypeByNameWhenItDoesNotFind() { assertFalse(BuiltInTypeUtils.findBuiltInTypeByName("something").isPresent()); } |
### Question:
DMNDiagramUtils { public List<DRGElement> getDRGElements(final Diagram diagram) { return getDefinitionStream(diagram) .filter(d -> d instanceof DRGElement) .map(d -> (DRGElement) d) .collect(Collectors.toList()); } DMNDiagramUtils(); List<DRGElement> getDRGElements(final Diagram diagram); String getNamespace(final Diagram diagram); Definitions getDefinitions(final Diagram diagram); Stream<Object> getDefinitionStream(final Diagram diagram); @SuppressWarnings("unchecked") Stream<Node> getNodeStream(final Diagram diagram); }### Answer:
@Test public void testGetNodes() { final DRGElement drgElement = mock(DRGElement.class); when(definition.getDefinition()).thenReturn(drgElement); final List<DRGElement> actualNodes = utils.getDRGElements(diagram); final List<DRGElement> expectedNodes = singletonList(drgElement); assertEquals(expectedNodes, actualNodes); } |
### Question:
DMNDiagramUtils { public Definitions getDefinitions(final Diagram diagram) { return getDefinitionStream(diagram) .filter(d -> d instanceof DMNDiagram) .map(d -> (DMNDiagram) d) .findFirst() .map(DMNDiagram::getDefinitions) .orElse(NONE); } DMNDiagramUtils(); List<DRGElement> getDRGElements(final Diagram diagram); String getNamespace(final Diagram diagram); Definitions getDefinitions(final Diagram diagram); Stream<Object> getDefinitionStream(final Diagram diagram); @SuppressWarnings("unchecked") Stream<Node> getNodeStream(final Diagram diagram); }### Answer:
@Test public void testGetDefinitionsWithRootNode() { final DMNDiagram definition = new DMNDiagram(); graph.addNode(newNode(definition)); final Definitions definitions = utils.getDefinitions(diagram); assertNotNull(definitions); assertEquals(definition.getDefinitions(), definitions); }
@Test public void testGetDefinitionsWithMultipleRootNodes() { final Decision definition1 = new Decision(); final DMNDiagram definition2 = new DMNDiagram(); graph.addNode(newNode(definition1)); graph.addNode(newNode(definition2)); final Definitions definitions = utils.getDefinitions(diagram); assertNotNull(definitions); assertEquals(definition2.getDefinitions(), definitions); }
@Test public void testGetDefinitionsWithConnectedNodes() { final Decision definition1 = new Decision(); final DMNDiagram definition2 = new DMNDiagram(); final Node<View, Edge> node1 = newNode(definition1); final Node<View, Edge> node2 = newNode(definition2); final Edge<View, Node> edge = new EdgeImpl<>(UUID.uuid()); node1.getInEdges().add(edge); node2.getOutEdges().add(edge); edge.setSourceNode(node2); edge.setTargetNode(node1); graph.addNode(node1); graph.addNode(node2); final Definitions definitions = utils.getDefinitions(diagram); assertNotNull(definitions); assertEquals(definition2.getDefinitions(), definitions); }
@Test public void testGetDefinitionsWithNoNodes() { assertNull(utils.getDefinitions(diagram)); } |
### Question:
AcyclicDirectedGraphRule extends RuleExtensionHandler<AcyclicDirectedGraphRule, GraphConnectionContext> { @Override @SuppressWarnings("unchecked") public RuleViolations evaluate(final RuleExtension rule, final GraphConnectionContext context) { final GraphEvaluationState state = context.getState(); final Graph<?, Node> graph = (Graph<?, Node>) state.getGraph(); final Optional<Node<? extends View<?>, ? extends Edge>> oSource = context.getSource(); final Optional<Node<? extends View<?>, ? extends Edge>> oTarget = context.getTarget(); final Edge<? extends View<?>, ? extends Node> oConnector = context.getConnector(); final DefaultRuleViolations result = new DefaultRuleViolations(); if (!(oSource.isPresent() && oTarget.isPresent())) { return result; } final Node<?, Edge> source = (Node<?, Edge>) oSource.get(); final Node<?, Edge> target = (Node<?, Edge>) oTarget.get(); final Edge<?, Node> connector = (Edge<?, Node>) oConnector; try { final TreeWalkTraverseProcessor walker = getTreeWalker(source, target, connector); walker.traverse(graph, new TreeTraverseCallback<Graph, Node, Edge>() { final Set<Node> inProgress = new HashSet<>(); @Override public void startGraphTraversal(final Graph graph) { } @Override public boolean startNodeTraversal(final Node node) { if (inProgress.contains(node)) { throw new DirectedAcrylicGraphViolationException(); } inProgress.add(node); return true; } @Override public boolean startEdgeTraversal(final Edge edge) { return true; } @Override public void endNodeTraversal(final Node node) { inProgress.remove(node); } @Override public void endEdgeTraversal(final Edge edge) { } @Override public void endGraphTraversal() { } }); } catch (DirectedAcrylicGraphViolationException e) { result.addViolation(new RuleViolationImpl(ERROR_MESSAGE)); } return result; } @Override Class<AcyclicDirectedGraphRule> getExtensionType(); @Override Class<GraphConnectionContext> getContextType(); @Override boolean accepts(final RuleExtension rule,
final GraphConnectionContext context); @Override @SuppressWarnings("unchecked") RuleViolations evaluate(final RuleExtension rule,
final GraphConnectionContext context); }### Answer:
@Test @SuppressWarnings("unchecked") public void checkCyclicalConnection() { final Node node1 = new NodeImpl<>("node1"); final Node node2 = new NodeImpl<>("node2"); final Edge c1 = new EdgeImpl<>("edge1"); node1.getOutEdges().add(c1); node2.getInEdges().add(c1); c1.setSourceNode(node1); c1.setTargetNode(node2); graph.addNode(node1); graph.addNode(node2); when(context.getSource()).thenReturn(Optional.of(node2)); when(context.getTarget()).thenReturn(Optional.of(node1)); when(context.getConnector()).thenReturn(connector); final RuleViolations result = check.evaluate(rule, context); assertNotNull(result); assertTrue(result.violations().iterator().hasNext()); final RuleViolation violation = result.violations().iterator().next(); assertNotNull(violation); assertTrue(violation.getArguments().isPresent()); assertEquals(1, violation.getArguments().get().length); assertEquals(AcyclicDirectedGraphRule.ERROR_MESSAGE, violation.getArguments().get()[0]); } |
### Question:
SingleConnectorPerTypeGraphRule extends RuleExtensionHandler<SingleConnectorPerTypeGraphRule, GraphConnectionContext> { @Override @SuppressWarnings("unchecked") public RuleViolations evaluate(final RuleExtension rule, final GraphConnectionContext context) { final Optional<Node<? extends View<?>, ? extends Edge>> oSource = context.getSource(); final Optional<Node<? extends View<?>, ? extends Edge>> oTarget = context.getTarget(); final DefaultRuleViolations result = new DefaultRuleViolations(); if (!(oSource.isPresent() && oTarget.isPresent())) { return result; } final Node<? extends View<?>, ? extends Edge> source = oSource.get(); final Node<? extends View<?>, ? extends Edge> target = oTarget.get(); final Edge<? extends View<?>, ? extends Node> connector = context.getConnector(); if (isConnectionAlreadyFormed(source, target, connector)) { result.addViolation(new RuleViolationImpl(ERROR_MESSAGE)); } return result; } @Override Class<SingleConnectorPerTypeGraphRule> getExtensionType(); @Override Class<GraphConnectionContext> getContextType(); @Override boolean accepts(final RuleExtension rule,
final GraphConnectionContext context); @Override @SuppressWarnings("unchecked") RuleViolations evaluate(final RuleExtension rule,
final GraphConnectionContext context); }### Answer:
@Test @SuppressWarnings("unchecked") public void checkHasExistingConnection() { final Node node1 = new NodeImpl<>("node1"); final Node node2 = new NodeImpl<>("node2"); final Edge existingConnector = new EdgeImpl<>("edge1"); final ViewConnector existingConnectorView = mock(ViewConnector.class); existingConnector.setContent(existingConnectorView); when(existingConnectorView.getDefinition()).thenReturn(new Definition()); node1.getOutEdges().add(existingConnector); node2.getInEdges().add(existingConnector); existingConnector.setSourceNode(node1); existingConnector.setTargetNode(node2); graph.addNode(node1); graph.addNode(node2); when(context.getSource()).thenReturn(Optional.of(node1)); when(context.getTarget()).thenReturn(Optional.of(node2)); when(context.getConnector()).thenReturn(connector); final RuleViolations result = check.evaluate(rule, context); assertNotNull(result); assertTrue(result.violations().iterator().hasNext()); final RuleViolation violation = result.violations().iterator().next(); assertNotNull(violation); assertTrue(violation.getArguments().isPresent()); assertEquals(1, violation.getArguments().get().length); assertEquals(SingleConnectorPerTypeGraphRule.ERROR_MESSAGE, violation.getArguments().get()[0]); } |
### Question:
ListBoxDOMElement extends BaseDOMElement<String, ListBox> implements TakesValue<String>,
Focusable { @Override public String getValue() { return widget.getSelectedValue(); } ListBoxDOMElement(final ListBox widget,
final GridLayer gridLayer,
final GridWidget gridWidget,
final SessionManager sessionManager,
final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
final Function<GridCellTuple, Command> hasNoValueCommand,
final Function<GridCellValueTuple, Command> hasValueCommand); @Override void setValue(final String value); @Override String getValue(); @Override int getTabIndex(); @Override void setAccessKey(final char key); @Override void setFocus(final boolean focused); @Override void setTabIndex(final int index); @Override void initialise(final GridBodyCellRenderContext context); @Override @SuppressWarnings("unchecked") void flush(final String value); }### Answer:
@Test public void testGetValue() { domElement.getValue(); verify(widget).getSelectedValue(); } |
### Question:
NoInputNodesInImportedDecisionRule extends RuleExtensionHandler<NoInputNodesInImportedDecisionRule, GraphConnectionContext> { @Override public RuleViolations evaluate(final RuleExtension rule, final GraphConnectionContext context) { final Optional<Node<? extends View<?>, ? extends Edge>> oSource = context.getSource(); final Optional<Node<? extends View<?>, ? extends Edge>> oTarget = context.getTarget(); final DefaultRuleViolations result = new DefaultRuleViolations(); if (!(oSource.isPresent() && oTarget.isPresent())) { return result; } if (isReadOnly(oTarget)) { result.addViolation(new RuleViolationImpl(ERROR_MESSAGE)); } return result; } @Override Class<NoInputNodesInImportedDecisionRule> getExtensionType(); @Override Class<GraphConnectionContext> getContextType(); @Override boolean accepts(final RuleExtension rule,
final GraphConnectionContext context); @Override RuleViolations evaluate(final RuleExtension rule,
final GraphConnectionContext context); }### Answer:
@Test @SuppressWarnings("unchecked") public void testEvaluate() { final Node source = mock(Node.class); final Node target = mock(Node.class); final View content = mock(View.class); final DynamicReadOnly dynamicReadonly = mock(DynamicReadOnly.class); when(dynamicReadonly.isAllowOnlyVisualChange()).thenReturn(true); when(content.getDefinition()).thenReturn(dynamicReadonly); when(target.getContent()).thenReturn(content); when(context.getSource()).thenReturn(Optional.of(source)); when(context.getTarget()).thenReturn(Optional.of(target)); final RuleViolations result = check.evaluate(rule, context); assertNotNull(result); final RuleViolation violation = result.violations().iterator().next(); assertNotNull(violation); assertTrue(violation.getArguments().isPresent()); assertEquals(1, violation.getArguments().get().length); assertEquals(NoInputNodesInImportedDecisionRule.ERROR_MESSAGE, violation.getArguments().get()[0]); } |
### Question:
NoInputNodesInImportedDecisionRule extends RuleExtensionHandler<NoInputNodesInImportedDecisionRule, GraphConnectionContext> { boolean isReadOnly(final Optional<Node<? extends View<?>, ? extends Edge>> oTarget) { final Node<? extends View<?>, ? extends Edge> target = oTarget.get(); final View<?> content = target.getContent(); if (Objects.isNull(content)) { return false; } final Object definition = content.getDefinition(); if (definition instanceof DynamicReadOnly) { if (((DynamicReadOnly) definition).isAllowOnlyVisualChange()) { return true; } } return false; } @Override Class<NoInputNodesInImportedDecisionRule> getExtensionType(); @Override Class<GraphConnectionContext> getContextType(); @Override boolean accepts(final RuleExtension rule,
final GraphConnectionContext context); @Override RuleViolations evaluate(final RuleExtension rule,
final GraphConnectionContext context); }### Answer:
@Test @SuppressWarnings("unchecked") public void testIsReadOnly() { final Node target = mock(Node.class); final View content = mock(View.class); final DynamicReadOnly dynamicReadonly = mock(DynamicReadOnly.class); when(dynamicReadonly.isAllowOnlyVisualChange()).thenReturn(true); when(content.getDefinition()).thenReturn(dynamicReadonly); when(target.getContent()).thenReturn(content); when(context.getTarget()).thenReturn(Optional.of(target)); final boolean actual = check.isReadOnly(Optional.of(target)); assertTrue(actual); verify(check).isReadOnly(any(Optional.class)); } |
### Question:
NoInputNodesInImportedDecisionRule extends RuleExtensionHandler<NoInputNodesInImportedDecisionRule, GraphConnectionContext> { @Override public boolean accepts(final RuleExtension rule, final GraphConnectionContext context) { if (context.getTarget().isPresent()) { final Node<? extends View<?>, ? extends Edge> target = context.getTarget().get(); final View<?> content = target.getContent(); if (Objects.isNull(content)) { return false; } final Object definition = content.getDefinition(); return Objects.equals(definition.getClass().getName(), rule.getId()); } return false; } @Override Class<NoInputNodesInImportedDecisionRule> getExtensionType(); @Override Class<GraphConnectionContext> getContextType(); @Override boolean accepts(final RuleExtension rule,
final GraphConnectionContext context); @Override RuleViolations evaluate(final RuleExtension rule,
final GraphConnectionContext context); }### Answer:
@Test public void testAcceptWhenIsExpectedClass() { when(rule.getId()).thenReturn(definition.getClass().getName()); final boolean actual = check.accepts(rule, context); assertTrue(actual); }
@Test public void testAcceptWhenIsNotExpectedClass() { when(rule.getId()).thenReturn("SomeOtherClass"); final boolean actual = check.accepts(rule, context); assertFalse(actual); } |
### Question:
OutputClause extends DMNElement implements HasTypeRef,
DomainObject { @Override public List<HasTypeRef> getHasTypeRefs() { final List<HasTypeRef> hasTypeRefs = new ArrayList<>(singletonList(this)); hasTypeRefs.addAll(getNotNullHasTypeRefs(getDefaultOutputEntry())); return hasTypeRefs; } OutputClause(); OutputClause(final Id id,
final Description description,
final OutputClauseUnaryTests outputValues,
final OutputClauseLiteralExpression defaultOutputEntry,
final String name,
final QName typeRef); OutputClause copy(); @Override List<HasTypeRef> getHasTypeRefs(); String getStunnerCategory(); Set<String> getStunnerLabels(); OutputClauseUnaryTests getOutputValues(); void setOutputValues(final OutputClauseUnaryTests value); OutputClauseLiteralExpression getDefaultOutputEntry(); void setDefaultOutputEntry(final OutputClauseLiteralExpression value); String getName(); void setName(final String value); @Override QName getTypeRef(); @Override void setTypeRef(final QName value); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); @Override String getDomainObjectUUID(); @Override String getDomainObjectNameTranslationKey(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testGetHasTypeRefs() { final OutputClauseLiteralExpression outputClauseLiteralExpression = mock(OutputClauseLiteralExpression.class); final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class); doReturn(outputClauseLiteralExpression).when(outputClause).getDefaultOutputEntry(); when(outputClauseLiteralExpression.getHasTypeRefs()).thenReturn(asList(hasTypeRef1, hasTypeRef2)); final List<HasTypeRef> actualHasTypeRefs = outputClause.getHasTypeRefs(); final List<HasTypeRef> expectedHasTypeRefs = asList(outputClause, hasTypeRef1, hasTypeRef2); assertEquals(expectedHasTypeRefs, actualHasTypeRefs); } |
### Question:
OutputClause extends DMNElement implements HasTypeRef,
DomainObject { public OutputClause copy() { return new OutputClause( new Id(), Optional.ofNullable(description).map(Description::copy).orElse(null), Optional.ofNullable(outputValues).map(OutputClauseUnaryTests::copy).orElse(null), Optional.ofNullable(defaultOutputEntry).map(OutputClauseLiteralExpression::copy).orElse(null), name, Optional.ofNullable(typeRef).map(QName::copy).orElse(null) ); } OutputClause(); OutputClause(final Id id,
final Description description,
final OutputClauseUnaryTests outputValues,
final OutputClauseLiteralExpression defaultOutputEntry,
final String name,
final QName typeRef); OutputClause copy(); @Override List<HasTypeRef> getHasTypeRefs(); String getStunnerCategory(); Set<String> getStunnerLabels(); OutputClauseUnaryTests getOutputValues(); void setOutputValues(final OutputClauseUnaryTests value); OutputClauseLiteralExpression getDefaultOutputEntry(); void setDefaultOutputEntry(final OutputClauseLiteralExpression value); String getName(); void setName(final String value); @Override QName getTypeRef(); @Override void setTypeRef(final QName value); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); @Override String getDomainObjectUUID(); @Override String getDomainObjectNameTranslationKey(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testCopy() { final OutputClause source = new OutputClause( new Id(OUTPUT_ID), new Description(DESCRIPTION), buildOutputClauseUnaryTests(), buildOutputClauseLiteralExpression(), NAME, BuiltInType.BOOLEAN.asQName() ); final OutputClause target = source.copy(); assertNotNull(target); assertNotEquals(OUTPUT_ID, target.getId().getValue()); assertEquals(DESCRIPTION, target.getDescription().getValue()); assertNotNull(target.getOutputValues()); assertNotEquals(CLAUSE_ID, target.getOutputValues().getId()); assertEquals(TEXT, target.getOutputValues().getText().getValue()); assertNotNull(target.getOutputValues()); assertNotEquals(UNARY_ID, target.getOutputValues().getId()); assertEquals(TEXT, target.getOutputValues().getText().getValue()); assertEquals(ConstraintType.ENUMERATION, target.getOutputValues().getConstraintType()); } |
### Question:
DecisionTable extends Expression { public HitPolicy getHitPolicy() { if (hitPolicy == null) { return HitPolicy.UNIQUE; } else { return hitPolicy; } } DecisionTable(); DecisionTable(final Id id,
final Description description,
final QName typeRef,
final List<InputClause> input,
final List<OutputClause> output,
final List<DecisionRule> rule,
final HitPolicy hitPolicy,
final BuiltinAggregator aggregation,
final DecisionTableOrientation preferredOrientation,
final String outputLabel); @Override DecisionTable copy(); List<RuleAnnotationClause> getAnnotations(); List<InputClause> getInput(); List<OutputClause> getOutput(); List<DecisionRule> getRule(); HitPolicy getHitPolicy(); void setHitPolicy(final HitPolicy value); BuiltinAggregator getAggregation(); void setAggregation(final BuiltinAggregator value); DecisionTableOrientation getPreferredOrientation(); void setPreferredOrientation(final DecisionTableOrientation value); String getOutputLabel(); void setOutputLabel(final String value); @Override List<HasTypeRef> getHasTypeRefs(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testDefaultHitPolicy() { assertEquals(HitPolicy.UNIQUE, decisionTable.getHitPolicy()); } |
### Question:
DecisionTable extends Expression { @Override public List<HasTypeRef> getHasTypeRefs() { final List<HasTypeRef> hasTypeRefs = super.getHasTypeRefs(); hasTypeRefs.addAll(getFlatHasTypeRefs(getInput())); hasTypeRefs.addAll(getFlatHasTypeRefs(getOutput())); hasTypeRefs.addAll(getFlatHasTypeRefs(getRule())); return hasTypeRefs; } DecisionTable(); DecisionTable(final Id id,
final Description description,
final QName typeRef,
final List<InputClause> input,
final List<OutputClause> output,
final List<DecisionRule> rule,
final HitPolicy hitPolicy,
final BuiltinAggregator aggregation,
final DecisionTableOrientation preferredOrientation,
final String outputLabel); @Override DecisionTable copy(); List<RuleAnnotationClause> getAnnotations(); List<InputClause> getInput(); List<OutputClause> getOutput(); List<DecisionRule> getRule(); HitPolicy getHitPolicy(); void setHitPolicy(final HitPolicy value); BuiltinAggregator getAggregation(); void setAggregation(final BuiltinAggregator value); DecisionTableOrientation getPreferredOrientation(); void setPreferredOrientation(final DecisionTableOrientation value); String getOutputLabel(); void setOutputLabel(final String value); @Override List<HasTypeRef> getHasTypeRefs(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testGetHasTypeRefs() { final InputClause inputClauses1 = mock(InputClause.class); final InputClause inputClauses2 = mock(InputClause.class); final List<InputClause> inputClauses = asList(inputClauses1, inputClauses2); final OutputClause outputClauses1 = mock(OutputClause.class); final OutputClause outputClauses2 = mock(OutputClause.class); final List<OutputClause> outputClauses = asList(outputClauses1, outputClauses2); final DecisionRule decisionRules1 = mock(DecisionRule.class); final DecisionRule decisionRules2 = mock(DecisionRule.class); final List<DecisionRule> decisionRules = asList(decisionRules1, decisionRules2); final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef3 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef4 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef5 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef6 = mock(HasTypeRef.class); doReturn(inputClauses).when(decisionTable).getInput(); doReturn(outputClauses).when(decisionTable).getOutput(); doReturn(decisionRules).when(decisionTable).getRule(); when(inputClauses1.getHasTypeRefs()).thenReturn(asList(hasTypeRef1)); when(inputClauses2.getHasTypeRefs()).thenReturn(asList(hasTypeRef2)); when(outputClauses1.getHasTypeRefs()).thenReturn(asList(hasTypeRef3)); when(outputClauses2.getHasTypeRefs()).thenReturn(asList(hasTypeRef4)); when(decisionRules1.getHasTypeRefs()).thenReturn(asList(hasTypeRef5)); when(decisionRules2.getHasTypeRefs()).thenReturn(asList(hasTypeRef6)); final List<HasTypeRef> actualHasTypeRefs = decisionTable.getHasTypeRefs(); final List<HasTypeRef> expectedHasTypeRefs = asList(decisionTable, hasTypeRef1, hasTypeRef2, hasTypeRef3, hasTypeRef4, hasTypeRef5, hasTypeRef6); assertEquals(expectedHasTypeRefs, actualHasTypeRefs); } |
### Question:
DecisionTable extends Expression { @Override public int getRequiredComponentWidthCount() { return getInput().size() + getOutput().size() + getAnnotations().size() + STATIC_COLUMNS; } DecisionTable(); DecisionTable(final Id id,
final Description description,
final QName typeRef,
final List<InputClause> input,
final List<OutputClause> output,
final List<DecisionRule> rule,
final HitPolicy hitPolicy,
final BuiltinAggregator aggregation,
final DecisionTableOrientation preferredOrientation,
final String outputLabel); @Override DecisionTable copy(); List<RuleAnnotationClause> getAnnotations(); List<InputClause> getInput(); List<OutputClause> getOutput(); List<DecisionRule> getRule(); HitPolicy getHitPolicy(); void setHitPolicy(final HitPolicy value); BuiltinAggregator getAggregation(); void setAggregation(final BuiltinAggregator value); DecisionTableOrientation getPreferredOrientation(); void setPreferredOrientation(final DecisionTableOrientation value); String getOutputLabel(); void setOutputLabel(final String value); @Override List<HasTypeRef> getHasTypeRefs(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testComponentWidths() { assertEquals(decisionTable.getRequiredComponentWidthCount(), decisionTable.getComponentWidths().size()); decisionTable.getComponentWidths().forEach(Assert::assertNull); } |
### Question:
DecisionTable extends Expression { @Override public DecisionTable copy() { final DecisionTable clonedDecisionTable = new DecisionTable(); clonedDecisionTable.description = Optional.ofNullable(description).map(Description::copy).orElse(null); clonedDecisionTable.typeRef = Optional.ofNullable(typeRef).map(QName::copy).orElse(null); clonedDecisionTable.componentWidths = new ArrayList<>(componentWidths); clonedDecisionTable.input = input.stream().map(InputClause::copy).collect(Collectors.toList()); clonedDecisionTable.output = output.stream().map(OutputClause::copy).collect(Collectors.toList()); clonedDecisionTable.rule = rule.stream().map(DecisionRule::copy).collect(Collectors.toList()); clonedDecisionTable.annotations = Optional.ofNullable(annotations) .map(annotationEntryList -> annotationEntryList.stream().map(RuleAnnotationClause::copy).collect(Collectors.toList())) .orElse(null); clonedDecisionTable.hitPolicy = hitPolicy; clonedDecisionTable.aggregation = aggregation; clonedDecisionTable.preferredOrientation = preferredOrientation; clonedDecisionTable.outputLabel = outputLabel; return clonedDecisionTable; } DecisionTable(); DecisionTable(final Id id,
final Description description,
final QName typeRef,
final List<InputClause> input,
final List<OutputClause> output,
final List<DecisionRule> rule,
final HitPolicy hitPolicy,
final BuiltinAggregator aggregation,
final DecisionTableOrientation preferredOrientation,
final String outputLabel); @Override DecisionTable copy(); List<RuleAnnotationClause> getAnnotations(); List<InputClause> getInput(); List<OutputClause> getOutput(); List<DecisionRule> getRule(); HitPolicy getHitPolicy(); void setHitPolicy(final HitPolicy value); BuiltinAggregator getAggregation(); void setAggregation(final BuiltinAggregator value); DecisionTableOrientation getPreferredOrientation(); void setPreferredOrientation(final DecisionTableOrientation value); String getOutputLabel(); void setOutputLabel(final String value); @Override List<HasTypeRef> getHasTypeRefs(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testCopy() { final DecisionTable source = new DecisionTable(new Id(TABLE_ID), new Description(DESCRIPTION), BuiltInType.BOOLEAN.asQName(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), HitPolicy.UNIQUE, SUM, DecisionTableOrientation.RULE_AS_ROW, OUTPUT_LABEL); final DecisionTable target = source.copy(); assertNotNull(target); assertNotEquals(TABLE_ID, target.getId().getValue()); assertEquals(DESCRIPTION, target.getDescription().getValue()); assertEquals(BuiltInType.BOOLEAN.asQName(), target.getTypeRef()); assertTrue(target.getInput().isEmpty()); assertTrue(target.getOutput().isEmpty()); assertTrue(target.getRule().isEmpty()); assertEquals(HitPolicy.UNIQUE, target.getHitPolicy()); assertEquals(SUM, target.getAggregation()); assertEquals(DecisionTableOrientation.RULE_AS_ROW, target.getPreferredOrientation()); assertEquals(OUTPUT_LABEL, target.getOutputLabel()); } |
### Question:
TextBoxDOMElement extends BaseDOMElement<String, TextBox> implements TakesValue<String>,
Focusable { @Override public void setValue(final String value) { getWidget().setValue(value); this.originalValue = value; } TextBoxDOMElement(final TextBox widget,
final GridLayer gridLayer,
final GridWidget gridWidget,
final SessionManager sessionManager,
final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
final Function<GridCellTuple, Command> hasNoValueCommand,
final Function<GridCellValueTuple, Command> hasValueCommand); @Override void setValue(final String value); @Override String getValue(); @Override int getTabIndex(); @Override void setAccessKey(final char key); @Override void setFocus(final boolean focused); @Override void setTabIndex(final int index); @Override void initialise(final GridBodyCellRenderContext context); @Override @SuppressWarnings("unchecked") void flush(final String value); }### Answer:
@Test public void testSetValue() { domElement.setValue(VALUE); verify(widget).setValue(VALUE); } |
### Question:
InputClauseLiteralExpression extends DMNModelInstrumentedBase implements IsLiteralExpression,
HasText,
HasTypeRef,
DMNPropertySet,
DomainObject { @Override public List<HasTypeRef> getHasTypeRefs() { return new ArrayList<>(singletonList(this)); } InputClauseLiteralExpression(); InputClauseLiteralExpression(final Id id,
final Description description,
final QName typeRef,
final Text text,
final ImportedValues importedValues); InputClauseLiteralExpression copy(); @Override List<HasTypeRef> getHasTypeRefs(); String getStunnerCategory(); Set<String> getStunnerLabels(); @Override Id getId(); @Override Description getDescription(); void setDescription(final Description description); @Override QName getTypeRef(); @Override void setTypeRef(final QName typeRef); @Override Text getText(); @Override void setText(final Text text); @Override ImportedValues getImportedValues(); void setImportedValues(final ImportedValues importedValues); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); QNameHolder getTypeRefHolder(); void setTypeRefHolder(final QNameHolder typeRefHolder); @Override String getDomainObjectUUID(); @Override String getDomainObjectNameTranslationKey(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testGetHasTypeRefs() { final List<HasTypeRef> actualHasTypeRefs = inputClauseLiteralExpression.getHasTypeRefs(); final List<HasTypeRef> expectedHasTypeRefs = singletonList(inputClauseLiteralExpression); assertEquals(expectedHasTypeRefs, actualHasTypeRefs); } |
### Question:
InputClauseLiteralExpression extends DMNModelInstrumentedBase implements IsLiteralExpression,
HasText,
HasTypeRef,
DMNPropertySet,
DomainObject { public InputClauseLiteralExpression copy() { final InputClauseLiteralExpression clonedInputClauseLiteralExpression = new InputClauseLiteralExpression(); clonedInputClauseLiteralExpression.description = Optional.ofNullable(description).map(Description::copy).orElse(null); clonedInputClauseLiteralExpression.typeRef = Optional.ofNullable(typeRef).map(QName::copy).orElse(null); clonedInputClauseLiteralExpression.typeRefHolder = Optional.ofNullable(typeRefHolder).map(QNameHolder::copy).orElse(null); clonedInputClauseLiteralExpression.text = Optional.ofNullable(text).map(Text::copy).orElse(null); clonedInputClauseLiteralExpression.importedValues = Optional.ofNullable(importedValues).map(ImportedValues::copy).orElse(null); return clonedInputClauseLiteralExpression; } InputClauseLiteralExpression(); InputClauseLiteralExpression(final Id id,
final Description description,
final QName typeRef,
final Text text,
final ImportedValues importedValues); InputClauseLiteralExpression copy(); @Override List<HasTypeRef> getHasTypeRefs(); String getStunnerCategory(); Set<String> getStunnerLabels(); @Override Id getId(); @Override Description getDescription(); void setDescription(final Description description); @Override QName getTypeRef(); @Override void setTypeRef(final QName typeRef); @Override Text getText(); @Override void setText(final Text text); @Override ImportedValues getImportedValues(); void setImportedValues(final ImportedValues importedValues); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); QNameHolder getTypeRefHolder(); void setTypeRefHolder(final QNameHolder typeRefHolder); @Override String getDomainObjectUUID(); @Override String getDomainObjectNameTranslationKey(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testCopy() { final InputClauseLiteralExpression source = new InputClauseLiteralExpression( new Id(CLAUSE_ID), new Description(DESCRIPTION), BuiltInType.BOOLEAN.asQName(), new Text(TEXT), new ImportedValues() ); final InputClauseLiteralExpression target = source.copy(); assertNotNull(target); assertNotEquals(CLAUSE_ID, target.getId()); assertEquals(TEXT, target.getText().getValue()); assertEquals(DESCRIPTION, target.getDescription().getValue()); assertEquals(BuiltInType.BOOLEAN.asQName(), target.getTypeRef()); } |
### Question:
RuleAnnotationClause extends DMNElement implements HasName { public RuleAnnotationClause copy() { final RuleAnnotationClause clonedRuleAnnotationClause = new RuleAnnotationClause(); clonedRuleAnnotationClause.name = Optional.ofNullable(name).map(Name::copy).orElse(null); return clonedRuleAnnotationClause; } RuleAnnotationClause(); RuleAnnotationClause copy(); @Override Name getName(); @Override void setName(final Name name); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testCopy() { final RuleAnnotationClause source = new RuleAnnotationClause(); source.setName(new Name(RULE_NAME)); final RuleAnnotationClause target = source.copy(); assertNotNull(target); assertEquals(RULE_NAME, target.getName().getValue()); } |
### Question:
TextAnnotation extends Artifact implements DMNViewDefinition<GeneralRectangleDimensionsSet>,
HasText,
HasContentDefinitionId,
DynamicReadOnly { @Override public void setAllowOnlyVisualChange(final boolean allowOnlyVisualChange) { this.allowOnlyVisualChange = allowOnlyVisualChange; } TextAnnotation(); TextAnnotation(final Id id,
final org.kie.workbench.common.dmn.api.property.dmn.Description description,
final Text text,
final TextFormat textFormat,
final BackgroundSet backgroundSet,
final FontSet fontSet,
final GeneralRectangleDimensionsSet dimensionsSet); String getStunnerCategory(); Set<String> getStunnerLabels(); @Override BackgroundSet getBackgroundSet(); void setBackgroundSet(final BackgroundSet backgroundSet); @Override FontSet getFontSet(); void setFontSet(final FontSet fontSet); @Override GeneralRectangleDimensionsSet getDimensionsSet(); void setDimensionsSet(final GeneralRectangleDimensionsSet dimensionsSet); @Override Text getText(); @Override void setText(final Text text); TextFormat getTextFormat(); void setTextFormat(final TextFormat textFormat); @Override String getContentDefinitionId(); @Override String getDiagramId(); @Override void setContentDefinitionId(final String contentDefinitionId); @Override void setDiagramId(final String dmnDiagramId); @Override boolean equals(final Object o); @Override int hashCode(); @Override void setAllowOnlyVisualChange(final boolean allowOnlyVisualChange); @Override boolean isAllowOnlyVisualChange(); @Override ReadOnly getReadOnly(final String fieldName); }### Answer:
@Test public void testGetReadOnlyNotSet() { textAnnotation.setAllowOnlyVisualChange(false); checkIfItIsNotSet("something"); }
@Test public void testGetReadOnlyWithReadOnlyValuesAndAllowOnlyVisualChangesNotSet() { textAnnotation.setAllowOnlyVisualChange(false); for (final String readonlyField : READONLY_FIELDS) { checkIfItIsNotSet(readonlyField); } }
@Test public void testGetReadOnlyWithReadOnlyValues() { textAnnotation.setAllowOnlyVisualChange(true); for (final String readonlyField : READONLY_FIELDS) { checkIfIsReadOnly(readonlyField); } }
@Test public void testGetReadOnlyWithNotReadOnlyValues() { textAnnotation.setAllowOnlyVisualChange(true); checkIfItIsNotReadOnly("Font"); checkIfItIsNotReadOnly("Something"); } |
### Question:
TextAnnotation extends Artifact implements DMNViewDefinition<GeneralRectangleDimensionsSet>,
HasText,
HasContentDefinitionId,
DynamicReadOnly { @Override public String getContentDefinitionId() { return getId().getValue(); } TextAnnotation(); TextAnnotation(final Id id,
final org.kie.workbench.common.dmn.api.property.dmn.Description description,
final Text text,
final TextFormat textFormat,
final BackgroundSet backgroundSet,
final FontSet fontSet,
final GeneralRectangleDimensionsSet dimensionsSet); String getStunnerCategory(); Set<String> getStunnerLabels(); @Override BackgroundSet getBackgroundSet(); void setBackgroundSet(final BackgroundSet backgroundSet); @Override FontSet getFontSet(); void setFontSet(final FontSet fontSet); @Override GeneralRectangleDimensionsSet getDimensionsSet(); void setDimensionsSet(final GeneralRectangleDimensionsSet dimensionsSet); @Override Text getText(); @Override void setText(final Text text); TextFormat getTextFormat(); void setTextFormat(final TextFormat textFormat); @Override String getContentDefinitionId(); @Override String getDiagramId(); @Override void setContentDefinitionId(final String contentDefinitionId); @Override void setDiagramId(final String dmnDiagramId); @Override boolean equals(final Object o); @Override int hashCode(); @Override void setAllowOnlyVisualChange(final boolean allowOnlyVisualChange); @Override boolean isAllowOnlyVisualChange(); @Override ReadOnly getReadOnly(final String fieldName); }### Answer:
@Test public void testGetContentDefinitionId() { final String contentDefinitionId = "the id"; final Id id = mock(Id.class); doReturn(id).when(textAnnotation).getId(); when(id.getValue()).thenReturn(contentDefinitionId); final String currentId = textAnnotation.getContentDefinitionId(); assertEquals(contentDefinitionId, currentId); } |
### Question:
LiteralExpression extends Expression implements IsLiteralExpression,
HasText,
DomainObject { @Override public int getRequiredComponentWidthCount() { return STATIC_COLUMNS; } LiteralExpression(); LiteralExpression(final Id id,
final org.kie.workbench.common.dmn.api.property.dmn.Description description,
final QName typeRef,
final Text text,
final ImportedValues importedValues,
final ExpressionLanguage expressionLanguage); @Override LiteralExpression copy(); String getStunnerCategory(); Set<String> getStunnerLabels(); @Override Text getText(); @Override void setText(final Text text); @Override ImportedValues getImportedValues(); void setImportedValues(final ImportedValues importedValues); ExpressionLanguage getExpressionLanguage(); void setExpressionLanguage(final ExpressionLanguage expressionLanguage); @Override String getDomainObjectUUID(); @Override String getDomainObjectNameTranslationKey(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testComponentWidths() { assertEquals(literalExpression.getRequiredComponentWidthCount(), literalExpression.getComponentWidths().size()); literalExpression.getComponentWidths().forEach(Assert::assertNull); } |
### Question:
LiteralExpression extends Expression implements IsLiteralExpression,
HasText,
DomainObject { @Override public LiteralExpression copy() { final LiteralExpression clonedLiteralExpression = new LiteralExpression(); clonedLiteralExpression.description = Optional.ofNullable(description).map(Description::copy).orElse(null); clonedLiteralExpression.typeRef = Optional.ofNullable(typeRef).map(QName::copy).orElse(null); clonedLiteralExpression.componentWidths = new ArrayList<>(componentWidths); clonedLiteralExpression.text = Optional.ofNullable(text).map(Text::copy).orElse(null); clonedLiteralExpression.importedValues = Optional.ofNullable(importedValues).map(ImportedValues::copy).orElse(null); clonedLiteralExpression.expressionLanguage = Optional.ofNullable(expressionLanguage).map(ExpressionLanguage::copy).orElse(null); return clonedLiteralExpression; } LiteralExpression(); LiteralExpression(final Id id,
final org.kie.workbench.common.dmn.api.property.dmn.Description description,
final QName typeRef,
final Text text,
final ImportedValues importedValues,
final ExpressionLanguage expressionLanguage); @Override LiteralExpression copy(); String getStunnerCategory(); Set<String> getStunnerLabels(); @Override Text getText(); @Override void setText(final Text text); @Override ImportedValues getImportedValues(); void setImportedValues(final ImportedValues importedValues); ExpressionLanguage getExpressionLanguage(); void setExpressionLanguage(final ExpressionLanguage expressionLanguage); @Override String getDomainObjectUUID(); @Override String getDomainObjectNameTranslationKey(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testCopy() { final LiteralExpression source = new LiteralExpression( new Id(LITERAL_ID), new Description(DESCRIPTION), BuiltInType.BOOLEAN.asQName(), new Text(TEXT), null, new ExpressionLanguage(EXPRESSION_LANGUAGE) ); final LiteralExpression target = source.copy(); assertNotNull(target); assertNotEquals(LITERAL_ID, target.getId()); assertEquals(DESCRIPTION, target.getDescription().getValue()); assertEquals(BuiltInType.BOOLEAN.asQName(), target.getTypeRef()); assertEquals(TEXT, target.getText().getValue()); assertNull(target.getImportedValues()); assertEquals(EXPRESSION_LANGUAGE, target.getExpressionLanguage().getValue()); } |
### Question:
TextBoxDOMElement extends BaseDOMElement<String, TextBox> implements TakesValue<String>,
Focusable { @Override public String getValue() { return getWidget().getValue(); } TextBoxDOMElement(final TextBox widget,
final GridLayer gridLayer,
final GridWidget gridWidget,
final SessionManager sessionManager,
final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
final Function<GridCellTuple, Command> hasNoValueCommand,
final Function<GridCellValueTuple, Command> hasValueCommand); @Override void setValue(final String value); @Override String getValue(); @Override int getTabIndex(); @Override void setAccessKey(final char key); @Override void setFocus(final boolean focused); @Override void setTabIndex(final int index); @Override void initialise(final GridBodyCellRenderContext context); @Override @SuppressWarnings("unchecked") void flush(final String value); }### Answer:
@Test public void testGetValue() { domElement.getValue(); verify(widget).getValue(); } |
### Question:
Context extends Expression { @Override public List<HasTypeRef> getHasTypeRefs() { final List<HasTypeRef> hasTypeRefs = super.getHasTypeRefs(); hasTypeRefs.addAll(getFlatHasTypeRefs(getContextEntry())); return hasTypeRefs; } Context(); Context(final Id id,
final Description description,
final QName typeRef); @Override Context copy(); List<ContextEntry> getContextEntry(); @Override List<HasTypeRef> getHasTypeRefs(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testGetHasTypeRefs() { final ContextEntry contextEntry1 = mock(ContextEntry.class); final ContextEntry contextEntry2 = mock(ContextEntry.class); final List<ContextEntry> contextEntry = asList(contextEntry1, contextEntry2); final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class); doReturn(contextEntry).when(context).getContextEntry(); when(contextEntry1.getHasTypeRefs()).thenReturn(asList(hasTypeRef1)); when(contextEntry2.getHasTypeRefs()).thenReturn(asList(hasTypeRef2)); final List<HasTypeRef> actualHasTypeRefs = context.getHasTypeRefs(); final List<HasTypeRef> expectedHasTypeRefs = asList(context, hasTypeRef1, hasTypeRef2); assertEquals(expectedHasTypeRefs, actualHasTypeRefs); } |
### Question:
Context extends Expression { @Override public int getRequiredComponentWidthCount() { return STATIC_COLUMNS; } Context(); Context(final Id id,
final Description description,
final QName typeRef); @Override Context copy(); List<ContextEntry> getContextEntry(); @Override List<HasTypeRef> getHasTypeRefs(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testComponentWidths() { assertEquals(context.getRequiredComponentWidthCount(), context.getComponentWidths().size()); context.getComponentWidths().forEach(Assert::assertNull); } |
### Question:
Context extends Expression { @Override public Context copy() { final Context clonedContext = new Context(); clonedContext.description = Optional.ofNullable(description).map(Description::copy).orElse(null); clonedContext.typeRef = Optional.ofNullable(typeRef).map(QName::copy).orElse(null); clonedContext.componentWidths = new ArrayList<>(componentWidths); clonedContext.contextEntry = Optional.ofNullable(contextEntry) .map(contextEntryList -> contextEntryList.stream().map(ContextEntry::copy).collect(Collectors.toList())) .orElse(null); return clonedContext; } Context(); Context(final Id id,
final Description description,
final QName typeRef); @Override Context copy(); List<ContextEntry> getContextEntry(); @Override List<HasTypeRef> getHasTypeRefs(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testCopy() { final Context source = new Context(new Id(CONTEXT_ID), new Description(DESCRIPTION), BuiltInType.BOOLEAN.asQName()); final Context target = source.copy(); assertNotNull(target); assertNotEquals(CONTEXT_ID, target.getId().getValue()); assertEquals(DESCRIPTION, target.getDescription().getValue()); assertEquals(BuiltInType.BOOLEAN.asQName(), target.getTypeRef()); } |
### Question:
Invocation extends Expression implements HasExpression { @Override public List<HasTypeRef> getHasTypeRefs() { final List<HasTypeRef> hasTypeRefs = super.getHasTypeRefs(); hasTypeRefs.addAll(getNotNullHasTypeRefs(getExpression())); hasTypeRefs.addAll(getFlatHasTypeRefs(getBinding())); return hasTypeRefs; } Invocation(); Invocation(final Id id,
final Description description,
final QName typeRef,
final Expression expression,
final List<Binding> binding); @Override Invocation copy(); @Override Expression getExpression(); @Override void setExpression(final Expression value); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); List<Binding> getBinding(); @Override List<HasTypeRef> getHasTypeRefs(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testGetHasTypeRefs() { final Expression expression = mock(Expression.class); final Binding binding1 = mock(Binding.class); final Binding binding2 = mock(Binding.class); final List<Binding> binding = asList(binding1, binding2); final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef3 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef4 = mock(HasTypeRef.class); doReturn(expression).when(invocation).getExpression(); doReturn(binding).when(invocation).getBinding(); when(expression.getHasTypeRefs()).thenReturn(asList(hasTypeRef1, hasTypeRef2)); when(binding1.getHasTypeRefs()).thenReturn(asList(hasTypeRef3)); when(binding2.getHasTypeRefs()).thenReturn(asList(hasTypeRef4)); final List<HasTypeRef> actualHasTypeRefs = invocation.getHasTypeRefs(); final List<HasTypeRef> expectedHasTypeRefs = asList(invocation, hasTypeRef1, hasTypeRef2, hasTypeRef3, hasTypeRef4); assertEquals(expectedHasTypeRefs, actualHasTypeRefs); } |
### Question:
Invocation extends Expression implements HasExpression { @Override public int getRequiredComponentWidthCount() { return STATIC_COLUMNS; } Invocation(); Invocation(final Id id,
final Description description,
final QName typeRef,
final Expression expression,
final List<Binding> binding); @Override Invocation copy(); @Override Expression getExpression(); @Override void setExpression(final Expression value); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); List<Binding> getBinding(); @Override List<HasTypeRef> getHasTypeRefs(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testComponentWidths() { assertEquals(invocation.getRequiredComponentWidthCount(), invocation.getComponentWidths().size()); invocation.getComponentWidths().forEach(Assert::assertNull); } |
### Question:
Invocation extends Expression implements HasExpression { @Override public Invocation copy() { final Invocation clonedInvocation = new Invocation(); clonedInvocation.description = Optional.ofNullable(description).map(Description::copy).orElse(null); clonedInvocation.typeRef = Optional.ofNullable(typeRef).map(QName::copy).orElse(null); clonedInvocation.componentWidths = new ArrayList<>(componentWidths); clonedInvocation.expression = Optional.ofNullable(expression).map(Expression::copy).orElse(null); clonedInvocation.binding = binding.stream().map(Binding::copy).collect(Collectors.toList()); return clonedInvocation; } Invocation(); Invocation(final Id id,
final Description description,
final QName typeRef,
final Expression expression,
final List<Binding> binding); @Override Invocation copy(); @Override Expression getExpression(); @Override void setExpression(final Expression value); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); List<Binding> getBinding(); @Override List<HasTypeRef> getHasTypeRefs(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testCopy() { final Invocation source = new Invocation( new Id(INVOCATION_ID), new Description(DESCRIPTION), BuiltInType.BOOLEAN.asQName(), null, new ArrayList<>() ); final Invocation target = source.copy(); assertNotNull(target); assertNotEquals(INVOCATION_ID, target.getId()); assertEquals(DESCRIPTION, target.getDescription().getValue()); assertEquals(BuiltInType.BOOLEAN.asQName(), target.getTypeRef()); assertNull(target.getExpression()); assertTrue(target.getBinding().isEmpty()); } |
### Question:
NamedElement extends DMNElement implements HasName { @Override public void setName(final Name name) { this.name = name; this.nameHolder.setValue(name); } NamedElement(); NamedElement(final Id id,
final Description description,
final Name name); @Override Name getName(); @Override void setName(final Name name); NameHolder getNameHolder(); void setNameHolder(final NameHolder nameHolder); }### Answer:
@Test public void testSetName() { namedElement.setName(new Name(NAME)); assertEquals(NAME, namedElement.getName().getValue()); assertEquals(NAME, namedElement.getNameHolder().getValue().getValue()); } |
### Question:
NamedElement extends DMNElement implements HasName { public void setNameHolder(final NameHolder nameHolder) { this.name.setValue(nameHolder.getValue().getValue()); this.nameHolder = nameHolder; } NamedElement(); NamedElement(final Id id,
final Description description,
final Name name); @Override Name getName(); @Override void setName(final Name name); NameHolder getNameHolder(); void setNameHolder(final NameHolder nameHolder); }### Answer:
@Test public void testSetNameHolder() { namedElement.setNameHolder(new NameHolder(new Name(NAME))); assertEquals(NAME, namedElement.getName().getValue()); assertEquals(NAME, namedElement.getNameHolder().getValue().getValue()); } |
### Question:
FunctionDefinition extends Expression implements HasExpression { @Override public List<HasTypeRef> getHasTypeRefs() { final List<HasTypeRef> hasTypeRefs = super.getHasTypeRefs(); hasTypeRefs.addAll(getNotNullHasTypeRefs(getExpression())); hasTypeRefs.addAll(getFlatHasTypeRefs(getFormalParameter())); return hasTypeRefs; } FunctionDefinition(); FunctionDefinition(final Id id,
final Description description,
final QName typeRef,
final Expression expression); @Override FunctionDefinition copy(); @Override Expression getExpression(); @Override void setExpression(final Expression expression); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); List<InformationItem> getFormalParameter(); Kind getKind(); void setKind(Kind kind); @Override List<HasTypeRef> getHasTypeRefs(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testGetHasTypeRefs() { final Expression expression = mock(Expression.class); final InformationItem informationItem1 = mock(InformationItem.class); final InformationItem informationItem2 = mock(InformationItem.class); final List<InformationItem> formalParameter = asList(informationItem1, informationItem2); final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef3 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef4 = mock(HasTypeRef.class); doReturn(expression).when(functionDefinition).getExpression(); doReturn(formalParameter).when(functionDefinition).getFormalParameter(); when(expression.getHasTypeRefs()).thenReturn(asList(hasTypeRef1, hasTypeRef2)); when(informationItem1.getHasTypeRefs()).thenReturn(asList(hasTypeRef3)); when(informationItem2.getHasTypeRefs()).thenReturn(asList(hasTypeRef4)); final List<HasTypeRef> actualHasTypeRefs = functionDefinition.getHasTypeRefs(); final List<HasTypeRef> expectedHasTypeRefs = asList(functionDefinition, hasTypeRef1, hasTypeRef2, hasTypeRef3, hasTypeRef4); assertEquals(expectedHasTypeRefs, actualHasTypeRefs); } |
### Question:
FunctionDefinition extends Expression implements HasExpression { @Override public int getRequiredComponentWidthCount() { return STATIC_COLUMNS; } FunctionDefinition(); FunctionDefinition(final Id id,
final Description description,
final QName typeRef,
final Expression expression); @Override FunctionDefinition copy(); @Override Expression getExpression(); @Override void setExpression(final Expression expression); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); List<InformationItem> getFormalParameter(); Kind getKind(); void setKind(Kind kind); @Override List<HasTypeRef> getHasTypeRefs(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testComponentWidths() { assertEquals(functionDefinition.getRequiredComponentWidthCount(), functionDefinition.getComponentWidths().size()); functionDefinition.getComponentWidths().forEach(Assert::assertNull); } |
### Question:
MonacoEditorWidget extends TextBoxBase { public void setValue(final String value) { getCodeEditor().ifPresent(c -> c.setValue(value)); } MonacoEditorWidget(); void setCodeEditor(final MonacoStandaloneCodeEditor codeEditor); void setValue(final String value); @Override String getValue(); @Override void setFocus(final boolean focused); Optional<MonacoStandaloneCodeEditor> getCodeEditor(); @Override void setTabIndex(final int index); }### Answer:
@Test public void testSetValueWhenCodeEditorIsPresent() { final String value = "value"; widget.setValue(value); verify(codeEditor).setValue(value); } |
### Question:
FunctionDefinition extends Expression implements HasExpression { @Override public FunctionDefinition copy() { final FunctionDefinition clonedFunctionDefinition = new FunctionDefinition(); clonedFunctionDefinition.description = Optional.ofNullable(description).map(Description::copy).orElse(null); clonedFunctionDefinition.typeRef = Optional.ofNullable(typeRef).map(QName::copy).orElse(null); clonedFunctionDefinition.componentWidths = new ArrayList<>(componentWidths); clonedFunctionDefinition.expression = Optional.ofNullable(expression).map(Expression::copy).orElse(null); clonedFunctionDefinition.formalParameter = cloneFormalParameterList(); clonedFunctionDefinition.kind = kind; clonedFunctionDefinition.getAdditionalAttributes().putAll(cloneAdditionalAttributes()); return clonedFunctionDefinition; } FunctionDefinition(); FunctionDefinition(final Id id,
final Description description,
final QName typeRef,
final Expression expression); @Override FunctionDefinition copy(); @Override Expression getExpression(); @Override void setExpression(final Expression expression); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); List<InformationItem> getFormalParameter(); Kind getKind(); void setKind(Kind kind); @Override List<HasTypeRef> getHasTypeRefs(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testCopy() { final FunctionDefinition source = new FunctionDefinition(); source.setId(new Id(FUNCTION_ID)); source.setDescription(new Description(DESCRIPTION)); source.setTypeRef(BuiltInType.BOOLEAN.asQName()); source.setKind(FunctionDefinition.Kind.JAVA); final FunctionDefinition target = source.copy(); assertNotNull(target); assertNotEquals(FUNCTION_ID, target.getId().getValue()); assertEquals(DESCRIPTION, target.getDescription().getValue()); assertEquals(BuiltInType.BOOLEAN.asQName(), target.getTypeRef()); assertEquals(FunctionDefinition.Kind.JAVA, target.getKind()); } |
### Question:
Import extends NamedElement { @Override public int hashCode() { return HashUtil.combineHashCodes(id != null ? id.hashCode() : 0, description != null ? description.hashCode() : 0, name != null ? name.hashCode() : 0, namespace != null ? namespace.hashCode() : 0, locationURI != null ? locationURI.hashCode() : 0, importType != null ? importType.hashCode() : 0); } Import(); Import(final String namespace,
final LocationURI locationURI,
final String importType); String getNamespace(); void setNamespace(final String namespace); LocationURI getLocationURI(); void setLocationURI(final LocationURI locationURI); String getImportType(); void setImportType(final String importType); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testHashCodeWithTheSameId() { import1.setId(new Id("123")); import2.setId(new Id("123")); assertEquals(import1.hashCode(), import2.hashCode()); }
@Test public void testHashCodeWithTheADifferentId() { import1.setId(new Id("123")); import2.setId(new Id("456")); assertNotEquals(import1.hashCode(), import2.hashCode()); }
@Test public void testHashCodeWithTheSameName() { import1.setName(new Name("123")); import2.setName(new Name("123")); assertEquals(import1.hashCode(), import2.hashCode()); }
@Test public void testHashCodeWithTheADifferentName() { import1.setName(new Name("123")); import2.setName(new Name("456")); assertNotEquals(import1.hashCode(), import2.hashCode()); }
@Test public void testHashCodeWithTheSameDescription() { import1.setDescription(new Description("desc")); import2.setDescription(new Description("desc")); assertEquals(import1.hashCode(), import2.hashCode()); }
@Test public void testHashCodeWithTheADifferentDescription() { import1.setDescription(new Description("desc1")); import2.setDescription(new Description("desc2")); assertNotEquals(import1.hashCode(), import2.hashCode()); } |
### Question:
ContextEntry extends DMNModelInstrumentedBase implements HasExpression,
HasTypeRefs,
HasVariable<InformationItem> { @Override public List<HasTypeRef> getHasTypeRefs() { final List<HasTypeRef> hasTypeRefs = new ArrayList<>(); hasTypeRefs.addAll(getNotNullHasTypeRefs(getExpression())); hasTypeRefs.addAll(getNotNullHasTypeRefs(getVariable())); return hasTypeRefs; } ContextEntry copy(); @Override InformationItem getVariable(); @Override void setVariable(final InformationItem value); @Override Expression getExpression(); @Override void setExpression(final Expression value); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); @Override boolean equals(final Object o); @Override int hashCode(); @Override List<HasTypeRef> getHasTypeRefs(); static final String DEFAULT_EXPRESSION_VALUE; }### Answer:
@Test public void testGetHasTypeRefs() { final Expression expression = mock(Expression.class); final InformationItem variable = mock(InformationItem.class); final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef3 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef4 = mock(HasTypeRef.class); doReturn(expression).when(contextEntry).getExpression(); doReturn(variable).when(contextEntry).getVariable(); when(expression.getHasTypeRefs()).thenReturn(asList(hasTypeRef1, hasTypeRef2)); when(variable.getHasTypeRefs()).thenReturn(asList(hasTypeRef3, hasTypeRef4)); final List<HasTypeRef> actualHasTypeRefs = contextEntry.getHasTypeRefs(); final List<HasTypeRef> expectedHasTypeRefs = asList(hasTypeRef1, hasTypeRef2, hasTypeRef3, hasTypeRef4); assertEquals(expectedHasTypeRefs, actualHasTypeRefs); } |
### Question:
ContextEntry extends DMNModelInstrumentedBase implements HasExpression,
HasTypeRefs,
HasVariable<InformationItem> { public ContextEntry copy() { final ContextEntry clonedContextEntry = new ContextEntry(); clonedContextEntry.variable = Optional.ofNullable(variable).map(InformationItem::copy).orElse(null); clonedContextEntry.expression = Optional.ofNullable(expression).map(Expression::copy).orElse(null); return clonedContextEntry; } ContextEntry copy(); @Override InformationItem getVariable(); @Override void setVariable(final InformationItem value); @Override Expression getExpression(); @Override void setExpression(final Expression value); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); @Override boolean equals(final Object o); @Override int hashCode(); @Override List<HasTypeRef> getHasTypeRefs(); static final String DEFAULT_EXPRESSION_VALUE; }### Answer:
@Test public void testCopy() { final ContextEntry source = new ContextEntry(); final InformationItem informationItem = new InformationItem(new Id(ITEM_ID), new Description(DESCRIPTION), new Name(INFORMATION_ITEM_NAME), BuiltInType.BOOLEAN.asQName()); source.setVariable(informationItem); final ContextEntry target = source.copy(); assertNotNull(target); assertNull(target.getExpression()); assertNotNull(target.getVariable()); assertNotEquals(ITEM_ID, target.getVariable().getId().getValue()); assertEquals(DESCRIPTION, target.getVariable().getDescription().getValue()); assertEquals(INFORMATION_ITEM_NAME, target.getVariable().getName().getValue()); assertEquals(BuiltInType.BOOLEAN.asQName(), target.getVariable().getTypeRef()); } |
### Question:
List extends Expression { @Override public java.util.List<HasTypeRef> getHasTypeRefs() { final java.util.List<HasTypeRef> hasTypeRefs = super.getHasTypeRefs(); hasTypeRefs.addAll(getFlatHasTypeRefsFromExpressions(getExpression())); return hasTypeRefs; } List(); List(final Id id,
final Description description,
final QName typeRef,
final java.util.List<HasExpression> expression); @Override List copy(); java.util.List<HasExpression> getExpression(); @Override java.util.List<HasTypeRef> getHasTypeRefs(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testGetHasTypeRefs() { final Expression expression1 = mock(Expression.class); final Expression expression2 = mock(Expression.class); final List<HasExpression> hasExpressions = asList(HasExpression.wrap(list, expression1), HasExpression.wrap(list, expression2)); final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class); doReturn(hasExpressions).when(list).getExpression(); when(expression1.getHasTypeRefs()).thenReturn(asList(hasTypeRef1)); when(expression2.getHasTypeRefs()).thenReturn(asList(hasTypeRef2)); final List<HasTypeRef> actualHasTypeRefs = list.getHasTypeRefs(); final List<HasTypeRef> expectedHasTypeRefs = asList(list, hasTypeRef1, hasTypeRef2); assertEquals(expectedHasTypeRefs, actualHasTypeRefs); } |
### Question:
MonacoEditorWidget extends TextBoxBase { @Override public String getValue() { return getCodeEditor() .map(editor -> editor.getValue()) .orElse(""); } MonacoEditorWidget(); void setCodeEditor(final MonacoStandaloneCodeEditor codeEditor); void setValue(final String value); @Override String getValue(); @Override void setFocus(final boolean focused); Optional<MonacoStandaloneCodeEditor> getCodeEditor(); @Override void setTabIndex(final int index); }### Answer:
@Test public void testGetValueWhenCodeEditorIsPresent() { final String expectedValue = "value"; when(codeEditor.getValue()).thenReturn(expectedValue); final String actualValue = widget.getValue(); assertEquals(expectedValue, actualValue); } |
### Question:
List extends Expression { @Override public int getRequiredComponentWidthCount() { return STATIC_COLUMNS; } List(); List(final Id id,
final Description description,
final QName typeRef,
final java.util.List<HasExpression> expression); @Override List copy(); java.util.List<HasExpression> getExpression(); @Override java.util.List<HasTypeRef> getHasTypeRefs(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testComponentWidths() { assertEquals(list.getRequiredComponentWidthCount(), list.getComponentWidths().size()); list.getComponentWidths().forEach(Assert::assertNull); } |
### Question:
List extends Expression { @Override public List copy() { final List clonedList = new List(); clonedList.description = Optional.ofNullable(description).map(Description::copy).orElse(null); clonedList.typeRef = Optional.ofNullable(typeRef).map(QName::copy).orElse(null); clonedList.componentWidths = new ArrayList<>(componentWidths); clonedList.expression = expression.stream().map(expressionWrapperMappingFn(clonedList)).collect(Collectors.toList()); return clonedList; } List(); List(final Id id,
final Description description,
final QName typeRef,
final java.util.List<HasExpression> expression); @Override List copy(); java.util.List<HasExpression> getExpression(); @Override java.util.List<HasTypeRef> getHasTypeRefs(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testCopy() { final org.kie.workbench.common.dmn.api.definition.model.List source = new org.kie.workbench.common.dmn.api.definition.model.List( new Id(LIST_ID), new Description(DESCRIPTION), BuiltInType.BOOLEAN.asQName(), new ArrayList<>() ); final org.kie.workbench.common.dmn.api.definition.model.List target = source.copy(); assertNotNull(target); assertNotEquals(LIST_ID, target.getId()); assertEquals(DESCRIPTION, target.getDescription().getValue()); assertEquals(BuiltInType.BOOLEAN.asQName(), target.getTypeRef()); assertTrue(target.getExpression().isEmpty()); } |
### Question:
ImportPMML extends Import { @Override public Name getName() { return wrapped; } ImportPMML(); ImportPMML(final String namespace,
final LocationURI locationURI,
final String importType); int getModelCount(); void setModelCount(final int modelCount); @Override String getNamespace(); @Override void setNamespace(final String namespace); @Override Name getName(); @Override void setName(final Name name); }### Answer:
@Test public void testNameObjectParameterConstructor() { final ImportPMML anImport = new ImportPMML("namespace", new LocationURI(), DMNImportTypes.PMML.getDefaultNamespace()); assertEquals("namespace", anImport.getName().getValue()); doNameObjectTest(anImport); }
@Test public void testNameValueParameterConstructor() { final ImportPMML anImport = new ImportPMML("namespace", new LocationURI(), DMNImportTypes.PMML.getDefaultNamespace()); assertEquals("namespace", anImport.getName().getValue()); doNameValueTest(anImport); }
@Test public void testNamespaceParameterConstructor() { final ImportPMML anImport = new ImportPMML("original", new LocationURI(), DMNImportTypes.PMML.getDefaultNamespace()); assertEquals("original", anImport.getName().getValue()); doNamespaceTest(anImport); } |
### Question:
RuleAnnotationClauseText extends DMNElement implements HasText { public RuleAnnotationClauseText copy() { final RuleAnnotationClauseText clonedRuleAnnotationClauseText = new RuleAnnotationClauseText(); clonedRuleAnnotationClauseText.text = Optional.ofNullable(text).map(Text::copy).orElse(null); return clonedRuleAnnotationClauseText; } RuleAnnotationClauseText(); RuleAnnotationClauseText copy(); @Override Text getText(); @Override void setText(final Text text); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testCopy() { final RuleAnnotationClauseText source = new RuleAnnotationClauseText(); source.setText(new Text(TEXT_VALUE)); final RuleAnnotationClauseText target = source.copy(); assertNotNull(target); assertEquals(TEXT_VALUE, target.getText().getValue()); } |
### Question:
DecisionRule extends DMNElement implements HasTypeRefs { @Override public List<HasTypeRef> getHasTypeRefs() { return new ArrayList<>(getFlatHasTypeRefs(getOutputEntry())); } DecisionRule(); DecisionRule(final Id id,
final Description description,
final List<UnaryTests> inputEntry,
final List<LiteralExpression> outputEntry); DecisionRule copy(); List<RuleAnnotationClauseText> getAnnotationEntry(); List<UnaryTests> getInputEntry(); List<LiteralExpression> getOutputEntry(); @Override List<HasTypeRef> getHasTypeRefs(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testGetHasTypeRefs() { final LiteralExpression literalExpression1 = mock(LiteralExpression.class); final LiteralExpression literalExpression2 = mock(LiteralExpression.class); final List<LiteralExpression> outputEntry = asList(literalExpression1, literalExpression2); doReturn(outputEntry).when(decisionRule).getOutputEntry(); when(literalExpression1.getHasTypeRefs()).thenReturn(asList(literalExpression1)); when(literalExpression2.getHasTypeRefs()).thenReturn(asList(literalExpression2)); final List<HasTypeRef> actualHasTypeRefs = decisionRule.getHasTypeRefs(); final List<HasTypeRef> expectedHasTypeRefs = asList(literalExpression1, literalExpression2); assertEquals(expectedHasTypeRefs, actualHasTypeRefs); } |
### Question:
DecisionRule extends DMNElement implements HasTypeRefs { public DecisionRule copy() { DecisionRule clonedDecisionRule = new DecisionRule(); clonedDecisionRule.description = Optional.ofNullable(description).map(Description::copy).orElse(null); clonedDecisionRule.inputEntry = inputEntry.stream().map(UnaryTests::copy).collect(Collectors.toList()); clonedDecisionRule.outputEntry = outputEntry.stream().map(LiteralExpression::copy).collect(Collectors.toList()); clonedDecisionRule.annotationEntry = Optional.ofNullable(annotationEntry) .map(annotationEntryList -> annotationEntryList.stream().map(RuleAnnotationClauseText::copy).collect(Collectors.toList())) .orElse(null); return clonedDecisionRule; } DecisionRule(); DecisionRule(final Id id,
final Description description,
final List<UnaryTests> inputEntry,
final List<LiteralExpression> outputEntry); DecisionRule copy(); List<RuleAnnotationClauseText> getAnnotationEntry(); List<UnaryTests> getInputEntry(); List<LiteralExpression> getOutputEntry(); @Override List<HasTypeRef> getHasTypeRefs(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testCopy() { final DecisionRule source = new DecisionRule(new Id(DECISION_RULE_ID), new Description(DESCRIPTION), new ArrayList<>(), new ArrayList<>()); final DecisionRule target = source.copy(); assertNotNull(target); assertNotEquals(DECISION_RULE_ID, target.getId().getValue()); assertEquals(DESCRIPTION, target.getDescription().getValue()); assertTrue(target.getInputEntry().isEmpty()); assertTrue(target.getOutputEntry().isEmpty()); } |
### Question:
HasTypeRefHelper { public static List<HasTypeRef> getNotNullHasTypeRefs(final HasTypeRef hasTypeRef) { final Optional<HasTypeRef> optional = Optional.ofNullable(hasTypeRef); return optional .map(HasTypeRef::getHasTypeRefs) .orElse(emptyList()); } static List<HasTypeRef> getNotNullHasTypeRefs(final HasTypeRef hasTypeRef); static List<HasTypeRef> getFlatHasTypeRefs(final List<? extends HasTypeRefs> hasTypeRefList); static List<HasTypeRef> getFlatHasTypeRefsFromExpressions(final List<? extends HasExpression> hasTypeRefListExpressions); }### Answer:
@Test public void testGetNotNullHasTypeRefs() { final HasTypeRef hasTypeRef = mock(HasTypeRef.class); final List<HasTypeRef> expectedHasTypeRefs = asList(mock(HasTypeRef.class), mock(HasTypeRef.class)); when(hasTypeRef.getHasTypeRefs()).thenReturn(expectedHasTypeRefs); final List<HasTypeRef> actualHasTypeRefs = HasTypeRefHelper.getNotNullHasTypeRefs(hasTypeRef); assertEquals(expectedHasTypeRefs, actualHasTypeRefs); }
@Test public void testGetNotNullHasTypeRefsWhenHasTypeRefIsNull() { final List<HasTypeRef> expectedHasTypeRefs = emptyList(); final List<HasTypeRef> actualHasTypeRefs = HasTypeRefHelper.getNotNullHasTypeRefs(null); assertEquals(expectedHasTypeRefs, actualHasTypeRefs); } |
### Question:
MonacoEditorWidget extends TextBoxBase { @Override public void setFocus(final boolean focused) { getCodeEditor().ifPresent(c -> { if (focused) { c.focus(); } }); } MonacoEditorWidget(); void setCodeEditor(final MonacoStandaloneCodeEditor codeEditor); void setValue(final String value); @Override String getValue(); @Override void setFocus(final boolean focused); Optional<MonacoStandaloneCodeEditor> getCodeEditor(); @Override void setTabIndex(final int index); }### Answer:
@Test public void testSetFocusWhenFocusIsEnabled() { widget.setFocus(true); verify(codeEditor).focus(); }
@Test public void testSetFocusWhenFocusIsNotEnabled() { widget.setFocus(false); verify(codeEditor, never()).focus(); } |
### Question:
HasTypeRefHelper { public static List<HasTypeRef> getFlatHasTypeRefs(final List<? extends HasTypeRefs> hasTypeRefList) { return hasTypeRefList .stream() .flatMap(typeRefs -> typeRefs.getHasTypeRefs().stream()) .collect(Collectors.toList()); } static List<HasTypeRef> getNotNullHasTypeRefs(final HasTypeRef hasTypeRef); static List<HasTypeRef> getFlatHasTypeRefs(final List<? extends HasTypeRefs> hasTypeRefList); static List<HasTypeRef> getFlatHasTypeRefsFromExpressions(final List<? extends HasExpression> hasTypeRefListExpressions); }### Answer:
@Test public void testGetFlatHasTypeRefs() { final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef3 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef4 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef5 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef6 = mock(HasTypeRef.class); final List<HasTypeRef> typeRefList1 = asList(hasTypeRef3, hasTypeRef4); final List<HasTypeRef> typeRefList2 = asList(hasTypeRef5, hasTypeRef6); final List<HasTypeRefs> hasTypeRefs = asList(hasTypeRef1, hasTypeRef2); when(hasTypeRef1.getHasTypeRefs()).thenReturn(typeRefList1); when(hasTypeRef2.getHasTypeRefs()).thenReturn(typeRefList2); final List<HasTypeRef> actual = HasTypeRefHelper.getFlatHasTypeRefs(hasTypeRefs); final List<HasTypeRef> expected = asList(hasTypeRef3, hasTypeRef4, hasTypeRef5, hasTypeRef6); assertEquals(expected, actual); } |
### Question:
HasTypeRefHelper { public static List<HasTypeRef> getFlatHasTypeRefsFromExpressions(final List<? extends HasExpression> hasTypeRefListExpressions) { return hasTypeRefListExpressions .stream() .map(HasExpression::getExpression) .flatMap(typeRefs -> typeRefs.getHasTypeRefs().stream()) .collect(Collectors.toList()); } static List<HasTypeRef> getNotNullHasTypeRefs(final HasTypeRef hasTypeRef); static List<HasTypeRef> getFlatHasTypeRefs(final List<? extends HasTypeRefs> hasTypeRefList); static List<HasTypeRef> getFlatHasTypeRefsFromExpressions(final List<? extends HasExpression> hasTypeRefListExpressions); }### Answer:
@Test public void testGetFlatHasTypeRefsFromExpressions() { final Expression expression1 = mock(Expression.class); final Expression expression2 = mock(Expression.class); final DMNModelInstrumentedBase parent = mock(DMNModelInstrumentedBase.class); final HasExpression hasExpression1 = HasExpression.wrap(parent, expression1); final HasExpression hasExpression2 = HasExpression.wrap(parent, expression2); final List<HasExpression> hasExpressions = asList(hasExpression1, hasExpression2); final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef3 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef4 = mock(HasTypeRef.class); final List<HasTypeRef> typeRefList1 = asList(hasTypeRef1, hasTypeRef2); final List<HasTypeRef> typeRefList2 = asList(hasTypeRef3, hasTypeRef4); when(expression1.getHasTypeRefs()).thenReturn(typeRefList1); when(expression2.getHasTypeRefs()).thenReturn(typeRefList2); final List<HasTypeRef> actual = HasTypeRefHelper.getFlatHasTypeRefsFromExpressions(hasExpressions); final List<HasTypeRef> expected = asList(hasTypeRef1, hasTypeRef2, hasTypeRef3, hasTypeRef4); assertEquals(expected, actual); } |
### Question:
InformationItemPrimary extends DMNModelInstrumentedBase implements DMNPropertySet,
IsInformationItem { @Override public List<HasTypeRef> getHasTypeRefs() { return new ArrayList<>(singletonList(this)); } InformationItemPrimary(); InformationItemPrimary(final Id id,
final Name name,
final QName typeRef); String getStunnerCategory(); Set<String> getStunnerLabels(); @Override Name getName(); @Override void setName(final Name name); @Override QName getTypeRef(); @Override void setTypeRef(final QName typeRef); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); @Override List<HasTypeRef> getHasTypeRefs(); QNameHolder getTypeRefHolder(); void setTypeRefHolder(final QNameHolder typeRefHolder); @Override String getDomainObjectUUID(); Id getId(); @Override String getDomainObjectNameTranslationKey(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testGetHasTypeRefs() { final List<HasTypeRef> actualHasTypeRefs = informationItemPrimary.getHasTypeRefs(); final List<HasTypeRef> expectedHasTypeRefs = singletonList(informationItemPrimary); assertEquals(expectedHasTypeRefs, actualHasTypeRefs); } |
### Question:
Relation extends Expression { @Override public java.util.List<HasTypeRef> getHasTypeRefs() { final java.util.List<HasTypeRef> hasTypeRefs = super.getHasTypeRefs(); hasTypeRefs.addAll(getFlatHasTypeRefs(getColumn())); hasTypeRefs.addAll(getFlatHasTypeRefs(getRow())); return hasTypeRefs; } Relation(); Relation(final Id id,
final Description description,
final QName typeRef,
final java.util.List<InformationItem> column,
final java.util.List<List> row); @Override Relation copy(); java.util.List<InformationItem> getColumn(); java.util.List<List> getRow(); @Override java.util.List<HasTypeRef> getHasTypeRefs(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); static final int STATIC_COLUMNS; }### Answer:
@Test public void testGetHasTypeRefs() { final InformationItem column1 = mock(InformationItem.class); final InformationItem column2 = mock(InformationItem.class); final List<InformationItem> column = asList(column1, column2); final org.kie.workbench.common.dmn.api.definition.model.List row1 = mock(org.kie.workbench.common.dmn.api.definition.model.List.class); final org.kie.workbench.common.dmn.api.definition.model.List row2 = mock(org.kie.workbench.common.dmn.api.definition.model.List.class); final List<org.kie.workbench.common.dmn.api.definition.model.List> row = asList(row1, row2); final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef3 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef4 = mock(HasTypeRef.class); doReturn(column).when(relation).getColumn(); doReturn(row).when(relation).getRow(); when(column1.getHasTypeRefs()).thenReturn(asList(hasTypeRef1)); when(column2.getHasTypeRefs()).thenReturn(asList(hasTypeRef2)); when(row1.getHasTypeRefs()).thenReturn(asList(hasTypeRef3)); when(row2.getHasTypeRefs()).thenReturn(asList(hasTypeRef4)); final List<HasTypeRef> actualHasTypeRefs = relation.getHasTypeRefs(); final List<HasTypeRef> expectedHasTypeRefs = asList(relation, hasTypeRef1, hasTypeRef2, hasTypeRef3, hasTypeRef4); assertEquals(expectedHasTypeRefs, actualHasTypeRefs); } |
### Question:
Relation extends Expression { @Override public int getRequiredComponentWidthCount() { return getColumn().size() + STATIC_COLUMNS; } Relation(); Relation(final Id id,
final Description description,
final QName typeRef,
final java.util.List<InformationItem> column,
final java.util.List<List> row); @Override Relation copy(); java.util.List<InformationItem> getColumn(); java.util.List<List> getRow(); @Override java.util.List<HasTypeRef> getHasTypeRefs(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); static final int STATIC_COLUMNS; }### Answer:
@Test public void testComponentWidths() { assertEquals(relation.getRequiredComponentWidthCount(), relation.getComponentWidths().size()); relation.getComponentWidths().forEach(Assert::assertNull); } |
### Question:
Relation extends Expression { @Override public Relation copy() { final Relation clonedRelation = new Relation(); clonedRelation.description = Optional.ofNullable(description).map(Description::copy).orElse(null); clonedRelation.typeRef = Optional.ofNullable(typeRef).map(QName::copy).orElse(null); clonedRelation.componentWidths = new ArrayList<>(componentWidths); clonedRelation.column = column.stream().map(InformationItem::copy).collect(Collectors.toList()); clonedRelation.row = row.stream().map(List::copy).collect(Collectors.toList()); return clonedRelation; } Relation(); Relation(final Id id,
final Description description,
final QName typeRef,
final java.util.List<InformationItem> column,
final java.util.List<List> row); @Override Relation copy(); java.util.List<InformationItem> getColumn(); java.util.List<List> getRow(); @Override java.util.List<HasTypeRef> getHasTypeRefs(); @Override int getRequiredComponentWidthCount(); @Override boolean equals(final Object o); @Override int hashCode(); static final int STATIC_COLUMNS; }### Answer:
@Test public void testCopy() { final Relation source = new Relation( new Id(RELATION_ID), new Description(DESCRIPTION), BuiltInType.BOOLEAN.asQName(), new ArrayList<>(), new ArrayList<>() ); final Relation target = source.copy(); assertNotNull(target); assertNotEquals(RELATION_ID, target.getId()); assertEquals(DESCRIPTION, target.getDescription().getValue()); assertEquals(BuiltInType.BOOLEAN.asQName(), target.getTypeRef()); assertTrue(target.getColumn().isEmpty()); assertTrue(target.getRow().isEmpty()); } |
### Question:
InputClause extends DMNElement implements HasTypeRefs,
DomainObject { @Override public List<HasTypeRef> getHasTypeRefs() { return new ArrayList<>(getNotNullHasTypeRefs(getInputExpression())); } InputClause(); InputClause(final Id id,
final Description description,
final InputClauseLiteralExpression inputExpression,
final InputClauseUnaryTests inputValues); InputClause copy(); @Override List<HasTypeRef> getHasTypeRefs(); String getStunnerCategory(); Set<String> getStunnerLabels(); InputClauseLiteralExpression getInputExpression(); void setInputExpression(final InputClauseLiteralExpression value); InputClauseUnaryTests getInputValues(); void setInputValues(final InputClauseUnaryTests value); @Override String getDomainObjectUUID(); @Override String getDomainObjectNameTranslationKey(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testGetHasTypeRefs() { final InputClauseLiteralExpression literalExpression = mock(InputClauseLiteralExpression.class); final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class); doReturn(literalExpression).when(inputClause).getInputExpression(); when(literalExpression.getHasTypeRefs()).thenReturn(asList(hasTypeRef1, hasTypeRef2)); final List<HasTypeRef> actualHasTypeRefs = inputClause.getHasTypeRefs(); final List<HasTypeRef> expectedHasTypeRefs = asList(hasTypeRef1, hasTypeRef2); assertEquals(expectedHasTypeRefs, actualHasTypeRefs); } |
### Question:
InputClause extends DMNElement implements HasTypeRefs,
DomainObject { public InputClause copy() { return new InputClause( new Id(), Optional.ofNullable(description).map(Description::copy).orElse(null), Optional.ofNullable(inputExpression).map(InputClauseLiteralExpression::copy).orElse(null), Optional.ofNullable(inputValues).map(InputClauseUnaryTests::copy).orElse(null) ); } InputClause(); InputClause(final Id id,
final Description description,
final InputClauseLiteralExpression inputExpression,
final InputClauseUnaryTests inputValues); InputClause copy(); @Override List<HasTypeRef> getHasTypeRefs(); String getStunnerCategory(); Set<String> getStunnerLabels(); InputClauseLiteralExpression getInputExpression(); void setInputExpression(final InputClauseLiteralExpression value); InputClauseUnaryTests getInputValues(); void setInputValues(final InputClauseUnaryTests value); @Override String getDomainObjectUUID(); @Override String getDomainObjectNameTranslationKey(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testCopy() { final InputClause source = new InputClause( new Id(INPUT_ID), new Description(DESCRIPTION), buildInputClauseLiteralExpression(), buildInputClauseUnaryTests() ); final InputClause target = source.copy(); assertNotNull(target); assertNotEquals(INPUT_ID, target.getId().getValue()); assertEquals(DESCRIPTION, target.getDescription().getValue()); assertNotNull(target.getInputExpression()); assertNotEquals(CLAUSE_ID, target.getInputExpression().getId()); assertEquals(TEXT, target.getInputExpression().getText().getValue()); assertEquals(DESCRIPTION, target.getInputExpression().getDescription().getValue()); assertEquals(BuiltInType.BOOLEAN.asQName(), target.getInputExpression().getTypeRef()); assertNotNull(target.getInputValues()); assertNotEquals(UNARY_ID, target.getInputValues().getId()); assertEquals(TEXT, target.getInputValues().getText().getValue()); assertEquals(ConstraintType.ENUMERATION, target.getInputValues().getConstraintType()); } |
### Question:
Binding extends DMNModelInstrumentedBase implements HasExpression,
HasTypeRefs,
HasVariable<InformationItem> { @Override public List<HasTypeRef> getHasTypeRefs() { final List<HasTypeRef> hasTypeRefs = new ArrayList<>(); hasTypeRefs.addAll(getNotNullHasTypeRefs(getExpression())); hasTypeRefs.addAll(getNotNullHasTypeRefs(getParameter())); return hasTypeRefs; } Binding copy(); InformationItem getParameter(); void setParameter(final InformationItem value); @Override //Proxy for getParameter() to allow use as HasVariable InformationItem getVariable(); @Override //Proxy for setParameter(..) to allow use as HasVariable void setVariable(final InformationItem informationItem); @Override Expression getExpression(); @Override void setExpression(final Expression value); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); @Override boolean equals(final Object o); @Override int hashCode(); @Override List<HasTypeRef> getHasTypeRefs(); }### Answer:
@Test public void testGetHasTypeRefs() { final Expression expression = mock(Expression.class); final InformationItem parameter = mock(InformationItem.class); final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef3 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef4 = mock(HasTypeRef.class); doReturn(expression).when(binding).getExpression(); doReturn(parameter).when(binding).getParameter(); when(expression.getHasTypeRefs()).thenReturn(asList(hasTypeRef1, hasTypeRef2)); when(parameter.getHasTypeRefs()).thenReturn(asList(hasTypeRef3, hasTypeRef4)); final List<HasTypeRef> actualHasTypeRefs = binding.getHasTypeRefs(); final List<HasTypeRef> expectedHasTypeRefs = asList(hasTypeRef1, hasTypeRef2, hasTypeRef3, hasTypeRef4); assertEquals(expectedHasTypeRefs, actualHasTypeRefs); } |
### Question:
Binding extends DMNModelInstrumentedBase implements HasExpression,
HasTypeRefs,
HasVariable<InformationItem> { public Binding copy() { final Binding bindingCloned = new Binding(); bindingCloned.parameter = Optional.ofNullable(parameter).map(InformationItem::copy).orElse(null); bindingCloned.expression = Optional.ofNullable(expression).map(Expression::copy).orElse(null); return bindingCloned; } Binding copy(); InformationItem getParameter(); void setParameter(final InformationItem value); @Override //Proxy for getParameter() to allow use as HasVariable InformationItem getVariable(); @Override //Proxy for setParameter(..) to allow use as HasVariable void setVariable(final InformationItem informationItem); @Override Expression getExpression(); @Override void setExpression(final Expression value); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); @Override boolean equals(final Object o); @Override int hashCode(); @Override List<HasTypeRef> getHasTypeRefs(); }### Answer:
@Test public void testCopy() { final Binding source = new Binding(); final InformationItem informationItem = new InformationItem(new Id(ITEM_ID), new Description(DESCRIPTION), new Name(INFORMATION_ITEM_NAME), BuiltInType.BOOLEAN.asQName()); source.setParameter(informationItem); final Binding target = source.copy(); assertNotNull(target); assertNull(target.getExpression()); assertNotNull(target.getParameter()); assertNotEquals(ITEM_ID, target.getParameter().getId().getValue()); assertEquals(DESCRIPTION, target.getParameter().getDescription().getValue()); assertEquals(INFORMATION_ITEM_NAME, target.getParameter().getName().getValue()); assertEquals(BuiltInType.BOOLEAN.asQName(), target.getParameter().getTypeRef()); } |
### Question:
DMNPathsHelperImpl implements DMNPathsHelper { @Override public String getRelativeURI(final Path dmnModelPath, final Path includedModelPath) { if (Objects.isNull(dmnModelPath)) { return includedModelPath.getFileName(); } final org.uberfire.java.nio.file.Path nioDMN = convertPath(normalizePath(dmnModelPath)); final org.uberfire.java.nio.file.Path nioIncluded = convertPath(normalizePath(includedModelPath)); final org.uberfire.java.nio.file.Path nioRelative = nioDMN.relativize(nioIncluded); final String strRelative = FilenameUtils.separatorsToUnix(nioRelative.toString()); if (strRelative.startsWith("../")) { return strRelative.substring(3); } else { return strRelative; } } DMNPathsHelperImpl(); @Inject DMNPathsHelperImpl(final RefactoringQueryService refactoringQueryService,
final DMNImportTypesHelper importTypesHelper,
final @Named("ioStrategy") IOService ioService); @Override List<Path> getModelsPaths(final WorkspaceProject workspaceProject); @Override List<Path> getDMNModelsPaths(final WorkspaceProject workspaceProject); @Override List<Path> getPMMLModelsPaths(final WorkspaceProject workspaceProject); @Override String getRelativeURI(final Path dmnModelPath,
final Path includedModelPath); }### Answer:
@Test public void testGetRelativeURIWhenStandalone() { final Path includedModelPath = mock(Path.class); when(includedModelPath.getFileName()).thenReturn("file1"); assertEquals("file1", pathsHelper.getRelativeURI(null, includedModelPath)); } |
### Question:
ItemDefinition extends NamedElement implements HasTypeRef,
DynamicReadOnly { @Override public List<HasTypeRef> getHasTypeRefs() { return new ArrayList<>(singletonList(this)); } ItemDefinition(); ItemDefinition(final Id id,
final Description description,
final Name name,
final QName typeRef,
final UnaryTests allowedValues,
final List<ItemDefinition> itemComponent,
final String typeLanguage,
final Boolean isCollection,
final Boolean allowOnlyVisualChange); @Override QName getTypeRef(); @Override void setTypeRef(final QName value); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); @Override List<HasTypeRef> getHasTypeRefs(); UnaryTests getAllowedValues(); void setAllowedValues(final UnaryTests value); List<ItemDefinition> getItemComponent(); String getTypeLanguage(); void setTypeLanguage(final String value); boolean isIsCollection(); void setIsCollection(final Boolean value); boolean isImported(); @Override boolean equals(final Object o); @Override int hashCode(); @Override void setAllowOnlyVisualChange(final boolean allowOnlyVisualChange); @Override boolean isAllowOnlyVisualChange(); }### Answer:
@Test public void testGetHasTypeRefs() { final List<HasTypeRef> actualHasTypeRefs = itemDefinition.getHasTypeRefs(); final List<HasTypeRef> expectedHasTypeRefs = singletonList(itemDefinition); assertEquals(expectedHasTypeRefs, actualHasTypeRefs); } |
### Question:
DRGElement extends NamedElement implements DynamicReadOnly,
HasContentDefinitionId { @Override public void setAllowOnlyVisualChange(final boolean allowOnlyVisualChange) { this.allowOnlyVisualChange = allowOnlyVisualChange; } DRGElement(); DRGElement(final Id id,
final Description description,
final Name name); @Override void setAllowOnlyVisualChange(final boolean allowOnlyVisualChange); @Override boolean isAllowOnlyVisualChange(); @Override ReadOnly getReadOnly(final String fieldName); @Override String getContentDefinitionId(); @Override String getDiagramId(); @Override void setDiagramId(final String dmnDiagramId); @Override void setContentDefinitionId(final String contentDefinitionId); DocumentationLinksHolder getLinksHolder(); void setLinksHolder(final DocumentationLinksHolder linksHolder); }### Answer:
@Test public void testGetReadOnlyNotSet() { drgElement.setAllowOnlyVisualChange(false); checkIfItIsNotSet("something"); }
@Test public void testGetReadOnlyWithReadOnlyValuesAndAllowOnlyVisualChangesNotSet() { drgElement.setAllowOnlyVisualChange(false); for (final String readonlyField : READONLY_FIELDS) { checkIfItIsNotSet(readonlyField); } }
@Test public void testGetReadOnlyWithReadOnlyValues() { drgElement.setAllowOnlyVisualChange(true); for (final String readonlyField : READONLY_FIELDS) { checkIfIsReadOnly(readonlyField); } }
@Test public void testGetReadOnlyWithNotReadOnlyValues() { drgElement.setAllowOnlyVisualChange(true); checkIfItIsNotReadOnly("Font"); checkIfItIsNotReadOnly("Something"); } |
### Question:
DRGElement extends NamedElement implements DynamicReadOnly,
HasContentDefinitionId { @Override public String getContentDefinitionId() { return getId().getValue(); } DRGElement(); DRGElement(final Id id,
final Description description,
final Name name); @Override void setAllowOnlyVisualChange(final boolean allowOnlyVisualChange); @Override boolean isAllowOnlyVisualChange(); @Override ReadOnly getReadOnly(final String fieldName); @Override String getContentDefinitionId(); @Override String getDiagramId(); @Override void setDiagramId(final String dmnDiagramId); @Override void setContentDefinitionId(final String contentDefinitionId); DocumentationLinksHolder getLinksHolder(); void setLinksHolder(final DocumentationLinksHolder linksHolder); }### Answer:
@Test public void testGetContentDefinitionId() { final String contentDefinitionId = "the id"; final Id id = mock(Id.class); when(drgElement.getId()).thenReturn(id); when(id.getValue()).thenReturn(contentDefinitionId); final String currentId = drgElement.getContentDefinitionId(); assertEquals(contentDefinitionId, currentId); } |
### Question:
ImportedValues extends Import implements DMNPropertySet,
DomainObject { public ImportedValues copy() { ImportedValues clonedImportedValues = new ImportedValues(); clonedImportedValues.id = new Id(); clonedImportedValues.namespace = namespace; clonedImportedValues.locationURI = Optional.ofNullable(locationURI).map(LocationURI::copy).orElse(null); clonedImportedValues.importType = importType; clonedImportedValues.importedElement = importedElement; clonedImportedValues.expressionLanguage = Optional.ofNullable(expressionLanguage).map(ExpressionLanguage::copy).orElse(null); return clonedImportedValues; } ImportedValues(); ImportedValues(final String namespace,
final LocationURI locationURI,
final String importType,
final String importedElement,
final ExpressionLanguage expressionLanguage); ImportedValues copy(); String getStunnerCategory(); Set<String> getStunnerLabels(); String getImportedElement(); void setImportedElement(final String importedElement); ExpressionLanguage getExpressionLanguage(); void setExpressionLanguage(final ExpressionLanguage expressionLanguage); @Override String getDomainObjectUUID(); @Override String getDomainObjectNameTranslationKey(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testCopy() { final ImportedValues source = new ImportedValues( NAMESPACE, new LocationURI(LOCATION_URI), IMPORT_TYPE, IMPORTED_ELEMENT, new ExpressionLanguage(EXPRESSION_LANGUAGE) ); final ImportedValues target = source.copy(); assertNotNull(target); assertEquals(NAMESPACE, target.getNamespace()); assertEquals(LOCATION_URI, target.getLocationURI().getValue()); assertEquals(IMPORT_TYPE, target.getImportType()); assertEquals(IMPORTED_ELEMENT, target.getImportedElement()); assertEquals(EXPRESSION_LANGUAGE, target.getExpressionLanguage().getValue()); } |
### Question:
Expression extends DMNElement implements HasTypeRef,
HasComponentWidths { @Override public List<HasTypeRef> getHasTypeRefs() { return new ArrayList<>(singletonList(this)); } Expression(); Expression(final Id id,
final Description description,
final QName typeRef); abstract Expression copy(); @Override QName getTypeRef(); @Override void setTypeRef(final QName typeRef); @Override java.util.List<Double> getComponentWidths(); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); @Override List<HasTypeRef> getHasTypeRefs(); }### Answer:
@Test public void testGetHasTypeRefs() { final List<HasTypeRef> actualHasTypeRefs = expression.getHasTypeRefs(); final List<HasTypeRef> expectedHasTypeRefs = singletonList(expression); assertEquals(expectedHasTypeRefs, actualHasTypeRefs); } |
### Question:
Expression extends DMNElement implements HasTypeRef,
HasComponentWidths { @Override public java.util.List<Double> getComponentWidths() { final int requiredComponentWidthCount = getRequiredComponentWidthCount(); if (componentWidths.size() != requiredComponentWidthCount) { componentWidths = new ArrayList<>(requiredComponentWidthCount); IntStream.range(0, requiredComponentWidthCount).forEach(i -> componentWidths.add(null)); } return componentWidths; } Expression(); Expression(final Id id,
final Description description,
final QName typeRef); abstract Expression copy(); @Override QName getTypeRef(); @Override void setTypeRef(final QName typeRef); @Override java.util.List<Double> getComponentWidths(); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); @Override List<HasTypeRef> getHasTypeRefs(); }### Answer:
@Test public void testComponentWidths() { assertEquals(expression.getRequiredComponentWidthCount(), expression.getComponentWidths().size()); expression.getComponentWidths().forEach(Assert::assertNull); } |
### Question:
InformationItem extends NamedElement implements DMNPropertySet,
IsInformationItem { @Override public List<HasTypeRef> getHasTypeRefs() { return new ArrayList<>(singletonList(this)); } InformationItem(); InformationItem(final Id id,
final Description description,
final Name name,
final QName typeRef); String getStunnerCategory(); Set<String> getStunnerLabels(); InformationItem copy(); @Override QName getTypeRef(); @Override void setTypeRef(final QName typeRef); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); @Override List<HasTypeRef> getHasTypeRefs(); QNameHolder getTypeRefHolder(); void setTypeRefHolder(final QNameHolder typeRefHolder); @Override String getDomainObjectUUID(); @Override String getDomainObjectNameTranslationKey(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testGetHasTypeRefs() { final List<HasTypeRef> actualHasTypeRefs = informationItem.getHasTypeRefs(); final List<HasTypeRef> expectedHasTypeRefs = singletonList(informationItem); assertEquals(expectedHasTypeRefs, actualHasTypeRefs); } |
### Question:
TextAreaDOMElement extends BaseDOMElement<String, TextArea> implements TakesValue<String>,
Focusable { @Override public void setValue(final String value) { getWidget().setValue(value); this.originalValue = value; } TextAreaDOMElement(final TextArea widget,
final GridLayer gridLayer,
final GridWidget gridWidget,
final SessionManager sessionManager,
final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
final Function<GridCellTuple, Command> hasNoValueCommand,
final Function<GridCellValueTuple, Command> hasValueCommand); @Override void initialise(final GridBodyCellRenderContext context); @Override void setValue(final String value); @Override String getValue(); @Override int getTabIndex(); @Override void setAccessKey(final char key); @Override void setFocus(final boolean focused); @Override void setTabIndex(final int index); @Override @SuppressWarnings("unchecked") void flush(final String value); }### Answer:
@Test public void testSetValue() { domElement.setValue(VALUE); verify(widget).setValue(VALUE); } |
### Question:
InformationItem extends NamedElement implements DMNPropertySet,
IsInformationItem { public InformationItem copy() { final InformationItem clonedInformationItem = new InformationItem(); clonedInformationItem.description = Optional.ofNullable(description).map(Description::copy).orElse(null); clonedInformationItem.name = Optional.ofNullable(name).map(Name::copy).orElse(null); clonedInformationItem.nameHolder = Optional.ofNullable(nameHolder).map(NameHolder::copy).orElse(null); clonedInformationItem.typeRef = Optional.ofNullable(typeRef).map(QName::copy).orElse(null); clonedInformationItem.typeRefHolder = Optional.ofNullable(typeRefHolder).map(QNameHolder::copy).orElse(null); return clonedInformationItem; } InformationItem(); InformationItem(final Id id,
final Description description,
final Name name,
final QName typeRef); String getStunnerCategory(); Set<String> getStunnerLabels(); InformationItem copy(); @Override QName getTypeRef(); @Override void setTypeRef(final QName typeRef); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); @Override List<HasTypeRef> getHasTypeRefs(); QNameHolder getTypeRefHolder(); void setTypeRefHolder(final QNameHolder typeRefHolder); @Override String getDomainObjectUUID(); @Override String getDomainObjectNameTranslationKey(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testCopy() { final InformationItem source = new InformationItem(new Id(ITEM_ID), new Description(DESCRIPTION), new Name(INFORMATION_ITEM_NAME), BuiltInType.BOOLEAN.asQName()); final InformationItem target = source.copy(); assertNotNull(target); assertNotEquals(ITEM_ID, target.getId().getValue()); assertEquals(DESCRIPTION, target.getDescription().getValue()); assertEquals(INFORMATION_ITEM_NAME, target.getName().getValue()); assertEquals(BuiltInType.BOOLEAN.asQName(), target.getTypeRef()); } |
### Question:
OutputClauseLiteralExpression extends DMNModelInstrumentedBase implements IsLiteralExpression,
HasText,
HasTypeRef,
DMNPropertySet,
DomainObject { @Override public List<HasTypeRef> getHasTypeRefs() { return new ArrayList<>(singletonList(this)); } OutputClauseLiteralExpression(); OutputClauseLiteralExpression(final Id id,
final Description description,
final QName typeRef,
final Text text,
final ImportedValues importedValues); OutputClauseLiteralExpression copy(); @Override List<HasTypeRef> getHasTypeRefs(); String getStunnerCategory(); Set<String> getStunnerLabels(); @Override Id getId(); @Override Description getDescription(); void setDescription(final Description description); @Override QName getTypeRef(); @Override void setTypeRef(final QName typeRef); @Override Text getText(); @Override void setText(final Text text); @Override ImportedValues getImportedValues(); void setImportedValues(final ImportedValues importedValues); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); @Override String getDomainObjectUUID(); @Override String getDomainObjectNameTranslationKey(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testGetHasTypeRefs() { final List<HasTypeRef> actualHasTypeRefs = outputClauseLiteralExpression.getHasTypeRefs(); final List<HasTypeRef> expectedHasTypeRefs = singletonList(outputClauseLiteralExpression); assertEquals(expectedHasTypeRefs, actualHasTypeRefs); } |
### Question:
OutputClauseLiteralExpression extends DMNModelInstrumentedBase implements IsLiteralExpression,
HasText,
HasTypeRef,
DMNPropertySet,
DomainObject { public OutputClauseLiteralExpression copy() { return new OutputClauseLiteralExpression( new Id(), Optional.ofNullable(description).map(Description::copy).orElse(null), Optional.ofNullable(typeRef).map(QName::copy).orElse(null), Optional.ofNullable(text).map(Text::copy).orElse(null), Optional.ofNullable(importedValues).map(ImportedValues::copy).orElse(null) ); } OutputClauseLiteralExpression(); OutputClauseLiteralExpression(final Id id,
final Description description,
final QName typeRef,
final Text text,
final ImportedValues importedValues); OutputClauseLiteralExpression copy(); @Override List<HasTypeRef> getHasTypeRefs(); String getStunnerCategory(); Set<String> getStunnerLabels(); @Override Id getId(); @Override Description getDescription(); void setDescription(final Description description); @Override QName getTypeRef(); @Override void setTypeRef(final QName typeRef); @Override Text getText(); @Override void setText(final Text text); @Override ImportedValues getImportedValues(); void setImportedValues(final ImportedValues importedValues); @Override DMNModelInstrumentedBase asDMNModelInstrumentedBase(); @Override String getDomainObjectUUID(); @Override String getDomainObjectNameTranslationKey(); @Override boolean equals(final Object o); @Override int hashCode(); }### Answer:
@Test public void testCopy() { final OutputClauseLiteralExpression source = new OutputClauseLiteralExpression( new Id(CLAUSE_ID), new Description(DESCRIPTION), BuiltInType.BOOLEAN.asQName(), new Text(TEXT), null ); final OutputClauseLiteralExpression target = source.copy(); assertNotNull(target); assertNotEquals(CLAUSE_ID, target.getId()); assertEquals(DESCRIPTION, target.getDescription().getValue()); assertEquals(BuiltInType.BOOLEAN.asQName(), target.getTypeRef()); assertEquals(TEXT, target.getText().getValue()); assertNull(target.getImportedValues()); } |
### Question:
MockDataObjectsServiceImpl extends DataObjectsServiceImpl { @Override public List<DataObject> loadDataObjects(final WorkspaceProject workspaceProject) { return Collections.emptyList(); } @Override List<DataObject> loadDataObjects(final WorkspaceProject workspaceProject); }### Answer:
@Test public void testLoadDataObjectsWithNullWorkspaceProject() { assertThat(dataObjectsService.loadDataObjects(null)).isEmpty(); }
@Test public void testLoadDataObjectsWithNonNullWorkspaceProject() { assertThat(dataObjectsService.loadDataObjects(workspaceProject)).isEmpty(); } |
### Question:
DMNDiagramEditor implements KieEditorWrapperView.KieEditorWrapperPresenter { Supplier<Integer> getHashcodeSupplier() { return () -> getDiagram().hashCode(); } @Inject DMNDiagramEditor(final SessionManager sessionManager,
final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
final SessionEditorPresenter<EditorSession> presenter,
final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent,
final Event<ChangeTitleWidgetEvent> changeTitleNotificationEvent,
final Event<SessionFocusedEvent> sessionFocusedEvent,
final DecisionNavigatorDock decisionNavigatorDock,
final DiagramEditorPropertiesDock diagramPropertiesDock,
final PreviewDiagramDock diagramPreviewAndExplorerDock,
final @DMNEditor DMNLayoutHelper layoutHelper,
final OpenDiagramLayoutExecutor layoutExecutor,
final DataTypesPage dataTypesPage,
final IncludedModelsPage includedModelsPage,
final @DMNEditor DocumentationView<Diagram> documentationView,
final DMNEditorSearchIndex editorSearchIndex,
final SearchBarComponent<DMNSearchableElement> searchBarComponent,
final DefinitionManager definitionManager,
final ClientFactoryService clientFactoryServices,
final DMNShowcaseDiagramService diagramService,
final MenuDevCommandsBuilder menuDevCommandsBuilder,
final ScreenPanelView screenPanelView,
final ScreenErrorView screenErrorView,
final KieEditorWrapperView kieView,
final MonacoFEELInitializer feelInitializer,
final DMNDiagramsSession dmnDiagramsSession,
final DMNMarshallerService marshallerService,
final DRDNameChanger drdNameChanger,
final LazyCanvasFocusUtils lazyCanvasFocusUtils); @PostConstruct void init(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); @OnStartup void onStartup(final PlaceRequest placeRequest); void onDataTypeEditModeToggle(final @Observes DataTypeEditModeToggleEvent editModeToggleEvent); void onMultiPageEditorSelectedPageEvent(final @Observes MultiPageEditorSelectedPageEvent event); void onRefreshFormPropertiesEvent(final @Observes RefreshFormPropertiesEvent event); @OnFocus void onFocus(); @OnClose void onClose(); @WorkbenchMenu void getMenu(final Consumer<Menus> menusConsumer); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getWidget(); @WorkbenchContextId String getMyContextRef(); @Override void onSourceTabSelected(); @Override void onEditTabSelected(); @Override void onEditTabUnselected(); @Override void onOverviewSelected(); static final String EDITOR_ID; }### Answer:
@Test public void testGetHashcodeSupplier() { final Diagram diagram = new DiagramImpl("something", null); final Integer expectedHashcode = diagram.hashCode(); doReturn(diagram).when(editor).getDiagram(); final Integer actualHashcode = editor.getHashcodeSupplier().get(); assertEquals(expectedHashcode, actualHashcode); } |
### Question:
DMNDiagramEditor implements KieEditorWrapperView.KieEditorWrapperPresenter { Supplier<Boolean> getIsDataTypesTabActiveSupplier() { return () -> { final int selectedPageIndex = kieView.getMultiPage().selectedPage(); return selectedPageIndex == DATA_TYPES_PAGE_INDEX; }; } @Inject DMNDiagramEditor(final SessionManager sessionManager,
final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
final SessionEditorPresenter<EditorSession> presenter,
final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent,
final Event<ChangeTitleWidgetEvent> changeTitleNotificationEvent,
final Event<SessionFocusedEvent> sessionFocusedEvent,
final DecisionNavigatorDock decisionNavigatorDock,
final DiagramEditorPropertiesDock diagramPropertiesDock,
final PreviewDiagramDock diagramPreviewAndExplorerDock,
final @DMNEditor DMNLayoutHelper layoutHelper,
final OpenDiagramLayoutExecutor layoutExecutor,
final DataTypesPage dataTypesPage,
final IncludedModelsPage includedModelsPage,
final @DMNEditor DocumentationView<Diagram> documentationView,
final DMNEditorSearchIndex editorSearchIndex,
final SearchBarComponent<DMNSearchableElement> searchBarComponent,
final DefinitionManager definitionManager,
final ClientFactoryService clientFactoryServices,
final DMNShowcaseDiagramService diagramService,
final MenuDevCommandsBuilder menuDevCommandsBuilder,
final ScreenPanelView screenPanelView,
final ScreenErrorView screenErrorView,
final KieEditorWrapperView kieView,
final MonacoFEELInitializer feelInitializer,
final DMNDiagramsSession dmnDiagramsSession,
final DMNMarshallerService marshallerService,
final DRDNameChanger drdNameChanger,
final LazyCanvasFocusUtils lazyCanvasFocusUtils); @PostConstruct void init(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); @OnStartup void onStartup(final PlaceRequest placeRequest); void onDataTypeEditModeToggle(final @Observes DataTypeEditModeToggleEvent editModeToggleEvent); void onMultiPageEditorSelectedPageEvent(final @Observes MultiPageEditorSelectedPageEvent event); void onRefreshFormPropertiesEvent(final @Observes RefreshFormPropertiesEvent event); @OnFocus void onFocus(); @OnClose void onClose(); @WorkbenchMenu void getMenu(final Consumer<Menus> menusConsumer); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getWidget(); @WorkbenchContextId String getMyContextRef(); @Override void onSourceTabSelected(); @Override void onEditTabSelected(); @Override void onEditTabUnselected(); @Override void onOverviewSelected(); static final String EDITOR_ID; }### Answer:
@Test public void testGetIsDataTypesTabActiveSupplierWhenDataTypesTabIsActive() { final MultiPageEditor multiPageEditor = mock(MultiPageEditor.class); when(kieView.getMultiPage()).thenReturn(multiPageEditor); when(multiPageEditor.selectedPage()).thenReturn(DATA_TYPES_PAGE_INDEX); assertTrue(editor.getIsDataTypesTabActiveSupplier().get()); }
@Test public void testGetIsDataTypesTabActiveSupplierWhenDataTypesTabIsNotActive() { final MultiPageEditor multiPageEditor = mock(MultiPageEditor.class); when(kieView.getMultiPage()).thenReturn(multiPageEditor); when(multiPageEditor.selectedPage()).thenReturn(DATA_TYPES_PAGE_INDEX + 1); assertFalse(editor.getIsDataTypesTabActiveSupplier().get()); } |
### Question:
DMNDiagramEditor implements KieEditorWrapperView.KieEditorWrapperPresenter { void setupSearchComponent() { final HTMLElement element = searchBarComponent.getView().getElement(); searchBarComponent.init(editorSearchIndex); kieView.getMultiPage().addTabBarWidget(getWidget(element)); } @Inject DMNDiagramEditor(final SessionManager sessionManager,
final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
final SessionEditorPresenter<EditorSession> presenter,
final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent,
final Event<ChangeTitleWidgetEvent> changeTitleNotificationEvent,
final Event<SessionFocusedEvent> sessionFocusedEvent,
final DecisionNavigatorDock decisionNavigatorDock,
final DiagramEditorPropertiesDock diagramPropertiesDock,
final PreviewDiagramDock diagramPreviewAndExplorerDock,
final @DMNEditor DMNLayoutHelper layoutHelper,
final OpenDiagramLayoutExecutor layoutExecutor,
final DataTypesPage dataTypesPage,
final IncludedModelsPage includedModelsPage,
final @DMNEditor DocumentationView<Diagram> documentationView,
final DMNEditorSearchIndex editorSearchIndex,
final SearchBarComponent<DMNSearchableElement> searchBarComponent,
final DefinitionManager definitionManager,
final ClientFactoryService clientFactoryServices,
final DMNShowcaseDiagramService diagramService,
final MenuDevCommandsBuilder menuDevCommandsBuilder,
final ScreenPanelView screenPanelView,
final ScreenErrorView screenErrorView,
final KieEditorWrapperView kieView,
final MonacoFEELInitializer feelInitializer,
final DMNDiagramsSession dmnDiagramsSession,
final DMNMarshallerService marshallerService,
final DRDNameChanger drdNameChanger,
final LazyCanvasFocusUtils lazyCanvasFocusUtils); @PostConstruct void init(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); @OnStartup void onStartup(final PlaceRequest placeRequest); void onDataTypeEditModeToggle(final @Observes DataTypeEditModeToggleEvent editModeToggleEvent); void onMultiPageEditorSelectedPageEvent(final @Observes MultiPageEditorSelectedPageEvent event); void onRefreshFormPropertiesEvent(final @Observes RefreshFormPropertiesEvent event); @OnFocus void onFocus(); @OnClose void onClose(); @WorkbenchMenu void getMenu(final Consumer<Menus> menusConsumer); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getWidget(); @WorkbenchContextId String getMyContextRef(); @Override void onSourceTabSelected(); @Override void onEditTabSelected(); @Override void onEditTabUnselected(); @Override void onOverviewSelected(); static final String EDITOR_ID; }### Answer:
@Test public void testSetupSearchComponent() { final MultiPageEditor multiPageEditor = mock(MultiPageEditor.class); when(kieView.getMultiPage()).thenReturn(multiPageEditor); editor.setupSearchComponent(); verify(searchBarComponent).init(editorSearchIndex); verify(multiPageEditor).addTabBarWidget(searchBarComponentWidget); } |
### Question:
TextAreaDOMElement extends BaseDOMElement<String, TextArea> implements TakesValue<String>,
Focusable { @Override public String getValue() { return getWidget().getValue(); } TextAreaDOMElement(final TextArea widget,
final GridLayer gridLayer,
final GridWidget gridWidget,
final SessionManager sessionManager,
final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
final Function<GridCellTuple, Command> hasNoValueCommand,
final Function<GridCellValueTuple, Command> hasValueCommand); @Override void initialise(final GridBodyCellRenderContext context); @Override void setValue(final String value); @Override String getValue(); @Override int getTabIndex(); @Override void setAccessKey(final char key); @Override void setFocus(final boolean focused); @Override void setTabIndex(final int index); @Override @SuppressWarnings("unchecked") void flush(final String value); }### Answer:
@Test public void testGetValue() { domElement.getValue(); verify(widget).getValue(); } |
### Question:
DMNDiagramEditor implements KieEditorWrapperView.KieEditorWrapperPresenter { @OnClose public void onClose() { destroyDock(); destroySession(); dataTypesPage.disableShortcuts(); dmnDiagramsSession.destroyState(getMetadata()); } @Inject DMNDiagramEditor(final SessionManager sessionManager,
final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
final SessionEditorPresenter<EditorSession> presenter,
final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent,
final Event<ChangeTitleWidgetEvent> changeTitleNotificationEvent,
final Event<SessionFocusedEvent> sessionFocusedEvent,
final DecisionNavigatorDock decisionNavigatorDock,
final DiagramEditorPropertiesDock diagramPropertiesDock,
final PreviewDiagramDock diagramPreviewAndExplorerDock,
final @DMNEditor DMNLayoutHelper layoutHelper,
final OpenDiagramLayoutExecutor layoutExecutor,
final DataTypesPage dataTypesPage,
final IncludedModelsPage includedModelsPage,
final @DMNEditor DocumentationView<Diagram> documentationView,
final DMNEditorSearchIndex editorSearchIndex,
final SearchBarComponent<DMNSearchableElement> searchBarComponent,
final DefinitionManager definitionManager,
final ClientFactoryService clientFactoryServices,
final DMNShowcaseDiagramService diagramService,
final MenuDevCommandsBuilder menuDevCommandsBuilder,
final ScreenPanelView screenPanelView,
final ScreenErrorView screenErrorView,
final KieEditorWrapperView kieView,
final MonacoFEELInitializer feelInitializer,
final DMNDiagramsSession dmnDiagramsSession,
final DMNMarshallerService marshallerService,
final DRDNameChanger drdNameChanger,
final LazyCanvasFocusUtils lazyCanvasFocusUtils); @PostConstruct void init(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); @OnStartup void onStartup(final PlaceRequest placeRequest); void onDataTypeEditModeToggle(final @Observes DataTypeEditModeToggleEvent editModeToggleEvent); void onMultiPageEditorSelectedPageEvent(final @Observes MultiPageEditorSelectedPageEvent event); void onRefreshFormPropertiesEvent(final @Observes RefreshFormPropertiesEvent event); @OnFocus void onFocus(); @OnClose void onClose(); @WorkbenchMenu void getMenu(final Consumer<Menus> menusConsumer); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getWidget(); @WorkbenchContextId String getMyContextRef(); @Override void onSourceTabSelected(); @Override void onEditTabSelected(); @Override void onEditTabUnselected(); @Override void onOverviewSelected(); static final String EDITOR_ID; }### Answer:
@Test public void testOnClose() { final Metadata metadata = mock(Metadata.class); doNothing().when(editor).destroyDock(); doNothing().when(editor).destroySession(); doReturn(metadata).when(editor).getMetadata(); editor.onClose(); verify(editor).destroyDock(); verify(editor).destroySession(); verify(dataTypesPage).disableShortcuts(); verify(dataTypesPage).disableShortcuts(); verify(dmnDiagramsSession).destroyState(metadata); } |
### Question:
DMNDiagramEditor implements KieEditorWrapperView.KieEditorWrapperPresenter { Metadata buildMetadata(final String defSetId, final String shapeSetId, final String title) { final Path root = PathFactory.newPath(".", ROOT); return new MetadataImpl.MetadataImplBuilder(defSetId, definitionManager) .setTitle(title) .setRoot(root) .setPath(PathFactory.newPath(title, root.toURI() + "/" + uuid() + ".dmn")) .setShapeSetId(shapeSetId) .build(); } @Inject DMNDiagramEditor(final SessionManager sessionManager,
final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
final SessionEditorPresenter<EditorSession> presenter,
final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent,
final Event<ChangeTitleWidgetEvent> changeTitleNotificationEvent,
final Event<SessionFocusedEvent> sessionFocusedEvent,
final DecisionNavigatorDock decisionNavigatorDock,
final DiagramEditorPropertiesDock diagramPropertiesDock,
final PreviewDiagramDock diagramPreviewAndExplorerDock,
final @DMNEditor DMNLayoutHelper layoutHelper,
final OpenDiagramLayoutExecutor layoutExecutor,
final DataTypesPage dataTypesPage,
final IncludedModelsPage includedModelsPage,
final @DMNEditor DocumentationView<Diagram> documentationView,
final DMNEditorSearchIndex editorSearchIndex,
final SearchBarComponent<DMNSearchableElement> searchBarComponent,
final DefinitionManager definitionManager,
final ClientFactoryService clientFactoryServices,
final DMNShowcaseDiagramService diagramService,
final MenuDevCommandsBuilder menuDevCommandsBuilder,
final ScreenPanelView screenPanelView,
final ScreenErrorView screenErrorView,
final KieEditorWrapperView kieView,
final MonacoFEELInitializer feelInitializer,
final DMNDiagramsSession dmnDiagramsSession,
final DMNMarshallerService marshallerService,
final DRDNameChanger drdNameChanger,
final LazyCanvasFocusUtils lazyCanvasFocusUtils); @PostConstruct void init(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); @OnStartup void onStartup(final PlaceRequest placeRequest); void onDataTypeEditModeToggle(final @Observes DataTypeEditModeToggleEvent editModeToggleEvent); void onMultiPageEditorSelectedPageEvent(final @Observes MultiPageEditorSelectedPageEvent event); void onRefreshFormPropertiesEvent(final @Observes RefreshFormPropertiesEvent event); @OnFocus void onFocus(); @OnClose void onClose(); @WorkbenchMenu void getMenu(final Consumer<Menus> menusConsumer); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getWidget(); @WorkbenchContextId String getMyContextRef(); @Override void onSourceTabSelected(); @Override void onEditTabSelected(); @Override void onEditTabUnselected(); @Override void onOverviewSelected(); static final String EDITOR_ID; }### Answer:
@Test public void testBuildMetadata() { final String defSetId = "defSetId"; final String shapeSetId = "shapeSetId"; final String title = "title"; final String uuid = "00001111"; doReturn(uuid).when(editor).uuid(); final MetadataImpl metadata = (MetadataImpl) editor.buildMetadata(defSetId, shapeSetId, title); assertEquals(title, metadata.getTitle()); assertEquals("default: assertEquals("default: assertEquals(shapeSetId, metadata.getShapeSetId()); assertEquals(defSetId, metadata.getDefinitionSetId()); } |
### Question:
DMNDiagramEditor implements KieEditorWrapperView.KieEditorWrapperPresenter { void openDock() { decisionNavigatorDock.open(); diagramPropertiesDock.open(); diagramPreviewAndExplorerDock.open(); } @Inject DMNDiagramEditor(final SessionManager sessionManager,
final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
final SessionEditorPresenter<EditorSession> presenter,
final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent,
final Event<ChangeTitleWidgetEvent> changeTitleNotificationEvent,
final Event<SessionFocusedEvent> sessionFocusedEvent,
final DecisionNavigatorDock decisionNavigatorDock,
final DiagramEditorPropertiesDock diagramPropertiesDock,
final PreviewDiagramDock diagramPreviewAndExplorerDock,
final @DMNEditor DMNLayoutHelper layoutHelper,
final OpenDiagramLayoutExecutor layoutExecutor,
final DataTypesPage dataTypesPage,
final IncludedModelsPage includedModelsPage,
final @DMNEditor DocumentationView<Diagram> documentationView,
final DMNEditorSearchIndex editorSearchIndex,
final SearchBarComponent<DMNSearchableElement> searchBarComponent,
final DefinitionManager definitionManager,
final ClientFactoryService clientFactoryServices,
final DMNShowcaseDiagramService diagramService,
final MenuDevCommandsBuilder menuDevCommandsBuilder,
final ScreenPanelView screenPanelView,
final ScreenErrorView screenErrorView,
final KieEditorWrapperView kieView,
final MonacoFEELInitializer feelInitializer,
final DMNDiagramsSession dmnDiagramsSession,
final DMNMarshallerService marshallerService,
final DRDNameChanger drdNameChanger,
final LazyCanvasFocusUtils lazyCanvasFocusUtils); @PostConstruct void init(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); @OnStartup void onStartup(final PlaceRequest placeRequest); void onDataTypeEditModeToggle(final @Observes DataTypeEditModeToggleEvent editModeToggleEvent); void onMultiPageEditorSelectedPageEvent(final @Observes MultiPageEditorSelectedPageEvent event); void onRefreshFormPropertiesEvent(final @Observes RefreshFormPropertiesEvent event); @OnFocus void onFocus(); @OnClose void onClose(); @WorkbenchMenu void getMenu(final Consumer<Menus> menusConsumer); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getWidget(); @WorkbenchContextId String getMyContextRef(); @Override void onSourceTabSelected(); @Override void onEditTabSelected(); @Override void onEditTabUnselected(); @Override void onOverviewSelected(); static final String EDITOR_ID; }### Answer:
@Test public void testOpenDock() { final EditorSession session = mock(EditorSession.class); final AbstractCanvasHandler canvasHandler = mock(AbstractCanvasHandler.class); when(session.getCanvasHandler()).thenReturn(canvasHandler); editor.openDock(); verify(decisionNavigatorDock).open(); } |
### Question:
DMNDiagramEditor implements KieEditorWrapperView.KieEditorWrapperPresenter { void destroyDock() { decisionNavigatorDock.close(); decisionNavigatorDock.resetContent(); diagramPropertiesDock.close(); diagramPreviewAndExplorerDock.close(); } @Inject DMNDiagramEditor(final SessionManager sessionManager,
final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
final SessionEditorPresenter<EditorSession> presenter,
final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent,
final Event<ChangeTitleWidgetEvent> changeTitleNotificationEvent,
final Event<SessionFocusedEvent> sessionFocusedEvent,
final DecisionNavigatorDock decisionNavigatorDock,
final DiagramEditorPropertiesDock diagramPropertiesDock,
final PreviewDiagramDock diagramPreviewAndExplorerDock,
final @DMNEditor DMNLayoutHelper layoutHelper,
final OpenDiagramLayoutExecutor layoutExecutor,
final DataTypesPage dataTypesPage,
final IncludedModelsPage includedModelsPage,
final @DMNEditor DocumentationView<Diagram> documentationView,
final DMNEditorSearchIndex editorSearchIndex,
final SearchBarComponent<DMNSearchableElement> searchBarComponent,
final DefinitionManager definitionManager,
final ClientFactoryService clientFactoryServices,
final DMNShowcaseDiagramService diagramService,
final MenuDevCommandsBuilder menuDevCommandsBuilder,
final ScreenPanelView screenPanelView,
final ScreenErrorView screenErrorView,
final KieEditorWrapperView kieView,
final MonacoFEELInitializer feelInitializer,
final DMNDiagramsSession dmnDiagramsSession,
final DMNMarshallerService marshallerService,
final DRDNameChanger drdNameChanger,
final LazyCanvasFocusUtils lazyCanvasFocusUtils); @PostConstruct void init(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); @OnStartup void onStartup(final PlaceRequest placeRequest); void onDataTypeEditModeToggle(final @Observes DataTypeEditModeToggleEvent editModeToggleEvent); void onMultiPageEditorSelectedPageEvent(final @Observes MultiPageEditorSelectedPageEvent event); void onRefreshFormPropertiesEvent(final @Observes RefreshFormPropertiesEvent event); @OnFocus void onFocus(); @OnClose void onClose(); @WorkbenchMenu void getMenu(final Consumer<Menus> menusConsumer); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getWidget(); @WorkbenchContextId String getMyContextRef(); @Override void onSourceTabSelected(); @Override void onEditTabSelected(); @Override void onEditTabUnselected(); @Override void onOverviewSelected(); static final String EDITOR_ID; }### Answer:
@Test public void testDestroyDock() { editor.destroyDock(); verify(decisionNavigatorDock).close(); verify(decisionNavigatorDock).resetContent(); } |
### Question:
DMNDiagramEditor implements KieEditorWrapperView.KieEditorWrapperPresenter { public void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event) { kieView.getMultiPage().selectPage(DATA_TYPES_PAGE_INDEX); } @Inject DMNDiagramEditor(final SessionManager sessionManager,
final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
final SessionEditorPresenter<EditorSession> presenter,
final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent,
final Event<ChangeTitleWidgetEvent> changeTitleNotificationEvent,
final Event<SessionFocusedEvent> sessionFocusedEvent,
final DecisionNavigatorDock decisionNavigatorDock,
final DiagramEditorPropertiesDock diagramPropertiesDock,
final PreviewDiagramDock diagramPreviewAndExplorerDock,
final @DMNEditor DMNLayoutHelper layoutHelper,
final OpenDiagramLayoutExecutor layoutExecutor,
final DataTypesPage dataTypesPage,
final IncludedModelsPage includedModelsPage,
final @DMNEditor DocumentationView<Diagram> documentationView,
final DMNEditorSearchIndex editorSearchIndex,
final SearchBarComponent<DMNSearchableElement> searchBarComponent,
final DefinitionManager definitionManager,
final ClientFactoryService clientFactoryServices,
final DMNShowcaseDiagramService diagramService,
final MenuDevCommandsBuilder menuDevCommandsBuilder,
final ScreenPanelView screenPanelView,
final ScreenErrorView screenErrorView,
final KieEditorWrapperView kieView,
final MonacoFEELInitializer feelInitializer,
final DMNDiagramsSession dmnDiagramsSession,
final DMNMarshallerService marshallerService,
final DRDNameChanger drdNameChanger,
final LazyCanvasFocusUtils lazyCanvasFocusUtils); @PostConstruct void init(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); @OnStartup void onStartup(final PlaceRequest placeRequest); void onDataTypeEditModeToggle(final @Observes DataTypeEditModeToggleEvent editModeToggleEvent); void onMultiPageEditorSelectedPageEvent(final @Observes MultiPageEditorSelectedPageEvent event); void onRefreshFormPropertiesEvent(final @Observes RefreshFormPropertiesEvent event); @OnFocus void onFocus(); @OnClose void onClose(); @WorkbenchMenu void getMenu(final Consumer<Menus> menusConsumer); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getWidget(); @WorkbenchContextId String getMyContextRef(); @Override void onSourceTabSelected(); @Override void onEditTabSelected(); @Override void onEditTabUnselected(); @Override void onOverviewSelected(); static final String EDITOR_ID; }### Answer:
@Test public void testOnDataTypePageNavTabActiveEvent() { final MultiPageEditor multiPageEditor = mock(MultiPageEditor.class); when(kieView.getMultiPage()).thenReturn(multiPageEditor); editor.onDataTypePageNavTabActiveEvent(mock(DataTypePageTabActiveEvent.class)); verify(multiPageEditor).selectPage(DMNDiagramEditor.DATA_TYPES_PAGE_INDEX); } |
### Question:
DMNDiagramEditor implements KieEditorWrapperView.KieEditorWrapperPresenter { Command getOnStartupDiagramEditorCallback() { return () -> { final Diagram diagram = getDiagram(); if (null != diagram) { updateTitle(diagram.getMetadata().getTitle()); documentationView.initialize(diagram); } }; } @Inject DMNDiagramEditor(final SessionManager sessionManager,
final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
final SessionEditorPresenter<EditorSession> presenter,
final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent,
final Event<ChangeTitleWidgetEvent> changeTitleNotificationEvent,
final Event<SessionFocusedEvent> sessionFocusedEvent,
final DecisionNavigatorDock decisionNavigatorDock,
final DiagramEditorPropertiesDock diagramPropertiesDock,
final PreviewDiagramDock diagramPreviewAndExplorerDock,
final @DMNEditor DMNLayoutHelper layoutHelper,
final OpenDiagramLayoutExecutor layoutExecutor,
final DataTypesPage dataTypesPage,
final IncludedModelsPage includedModelsPage,
final @DMNEditor DocumentationView<Diagram> documentationView,
final DMNEditorSearchIndex editorSearchIndex,
final SearchBarComponent<DMNSearchableElement> searchBarComponent,
final DefinitionManager definitionManager,
final ClientFactoryService clientFactoryServices,
final DMNShowcaseDiagramService diagramService,
final MenuDevCommandsBuilder menuDevCommandsBuilder,
final ScreenPanelView screenPanelView,
final ScreenErrorView screenErrorView,
final KieEditorWrapperView kieView,
final MonacoFEELInitializer feelInitializer,
final DMNDiagramsSession dmnDiagramsSession,
final DMNMarshallerService marshallerService,
final DRDNameChanger drdNameChanger,
final LazyCanvasFocusUtils lazyCanvasFocusUtils); @PostConstruct void init(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); @OnStartup void onStartup(final PlaceRequest placeRequest); void onDataTypeEditModeToggle(final @Observes DataTypeEditModeToggleEvent editModeToggleEvent); void onMultiPageEditorSelectedPageEvent(final @Observes MultiPageEditorSelectedPageEvent event); void onRefreshFormPropertiesEvent(final @Observes RefreshFormPropertiesEvent event); @OnFocus void onFocus(); @OnClose void onClose(); @WorkbenchMenu void getMenu(final Consumer<Menus> menusConsumer); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getWidget(); @WorkbenchContextId String getMyContextRef(); @Override void onSourceTabSelected(); @Override void onEditTabSelected(); @Override void onEditTabUnselected(); @Override void onOverviewSelected(); static final String EDITOR_ID; }### Answer:
@Test public void testGetOnStartupDiagramEditorCallback() { final Diagram diagram = mock(Diagram.class); final Metadata metadata = mock(Metadata.class); final String title = "title"; doNothing().when(editor).updateTitle(anyString()); doReturn(diagram).when(editor).getDiagram(); when(diagram.getMetadata()).thenReturn(metadata); when(metadata.getTitle()).thenReturn(title); editor.getOnStartupDiagramEditorCallback().execute(); verify(editor).updateTitle(title); verify(documentationView).initialize(diagram); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.