Search in sources :

Example 11 with InformationItemPrimary

use of org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary in project kie-wb-common by kiegroup.

the class DecisionTableEditorDefinitionEnricherTest method testModelEnrichmentWhenParentIsBKM.

@Test
public void testModelEnrichmentWhenParentIsBKM() {
    final FunctionDefinition functionDefinition = mock(FunctionDefinition.class);
    final DMNModelInstrumentedBase dmnModelInstrumentedBase = mock(DMNModelInstrumentedBase.class);
    final BusinessKnowledgeModel businessKnowledgeModel = new BusinessKnowledgeModel();
    businessKnowledgeModel.setVariable(new InformationItemPrimary(new Id(), new Name(), OUTPUT_DATA_QNAME));
    businessKnowledgeModel.setEncapsulatedLogic(functionDefinition);
    final Optional<DecisionTable> oModel = definition.getModelClass();
    oModel.get().setParent(functionDefinition);
    when(functionDefinition.asDMNModelInstrumentedBase()).thenReturn(dmnModelInstrumentedBase);
    when(dmnModelInstrumentedBase.getParent()).thenReturn(businessKnowledgeModel);
    definition.enrich(Optional.empty(), functionDefinition, oModel);
    final DecisionTable model = oModel.get();
    assertBasicEnrichment(model);
    assertStandardInputClauseEnrichment(model);
    final List<OutputClause> output = model.getOutput();
    assertThat(output.size()).isEqualTo(1);
    assertThat(output.get(0).getName()).isEqualTo(DEFAULT_OUTPUT_NAME);
    assertThat(output.get(0).getTypeRef()).isEqualTo(OUTPUT_DATA_QNAME);
    assertStandardDecisionRuleEnrichment(model);
    assertParentHierarchyEnrichment(model);
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) DMNModelInstrumentedBase(org.kie.workbench.common.dmn.api.definition.model.DMNModelInstrumentedBase) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 12 with InformationItemPrimary

use of org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary in project kie-wb-common by kiegroup.

the class DecisionTableEditorDefinitionEnricherTest method testModelEnrichmentWhenHasExpressionIsHasVariable.

@Test
public void testModelEnrichmentWhenHasExpressionIsHasVariable() {
    decision.setVariable(new InformationItemPrimary(new Id(), new Name(), OUTPUT_DATA_QNAME));
    final Optional<DecisionTable> oModel = definition.getModelClass();
    definition.enrich(Optional.empty(), decision, oModel);
    final DecisionTable model = oModel.get();
    assertBasicEnrichment(model);
    assertStandardInputClauseEnrichment(model);
    final List<OutputClause> output = model.getOutput();
    assertThat(output.size()).isEqualTo(1);
    assertThat(output.get(0).getName()).isEqualTo(DEFAULT_OUTPUT_NAME);
    assertThat(output.get(0).getTypeRef()).isEqualTo(OUTPUT_DATA_QNAME);
    assertStandardDecisionRuleEnrichment(model);
    assertParentHierarchyEnrichment(model);
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 13 with InformationItemPrimary

use of org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary in project kie-wb-common by kiegroup.

the class DecisionTableEditorDefinitionEnricherTest method testModelEnrichmentWhenDecisionTypeRefIsStructureWithMultipleFields.

@Test
public void testModelEnrichmentWhenDecisionTypeRefIsStructureWithMultipleFields() {
    final DMNGraphUtils dmnGraphUtils = mock(DMNGraphUtils.class);
    final Definitions definitions = mock(Definitions.class);
    final HasExpression hasExpression = mock(HasExpression.class);
    final Decision decision = mock(Decision.class);
    final InformationItemPrimary informationItemPrimary = mock(InformationItemPrimary.class);
    final ItemDefinition tPerson = mockTPersonStructure();
    when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
    when(definitions.getItemDefinition()).thenReturn(Collections.singletonList(tPerson));
    when(hasExpression.asDMNModelInstrumentedBase()).thenReturn(decision);
    when(decision.getVariable()).thenReturn(informationItemPrimary);
    when(informationItemPrimary.getTypeRef()).thenReturn(new QName("", TYPE_PERSON));
    final DecisionTableEditorDefinitionEnricher enricher = new DecisionTableEditorDefinitionEnricher(null, dmnGraphUtils, itemDefinitionUtils);
    final Optional<DecisionTable> oModel = definition.getModelClass();
    final DecisionTable model = oModel.get();
    enricher.buildOutputClausesByDataType(hasExpression, model, new DecisionRule());
    final List<OutputClause> outputClauses = model.getOutput();
    assertThat(outputClauses.size()).isEqualTo(2);
    final OutputClause outputClause1 = outputClauses.get(0);
    final OutputClause outputClause2 = outputClauses.get(1);
    assertEquals("age", outputClause1.getName());
    assertEquals(NUMBER.asQName(), outputClause1.getTypeRef());
    assertEquals("name", outputClause2.getName());
    assertEquals(STRING.asQName(), outputClause2.getTypeRef());
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) DMNGraphUtils(org.kie.workbench.common.dmn.client.graph.DMNGraphUtils) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) Test(org.junit.Test)

Example 14 with InformationItemPrimary

use of org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary in project kie-wb-common by kiegroup.

the class MonacoFEELSuggestionsTest method makeDecisionNode.

private NodeImpl<Definition<Decision>> makeDecisionNode(final String name, final BuiltInType builtInType) {
    final NodeImpl<Definition<Decision>> node = makeNodeImpl();
    final Definition<Decision> definition = makeDefinition();
    final Decision decision = spy(new Decision());
    final InformationItemPrimary informationItemPrimary = mock(InformationItemPrimary.class);
    final QName qName = builtInType == null ? null : new QName(builtInType);
    when(informationItemPrimary.getTypeRef()).thenReturn(qName);
    when(node.getContent()).thenReturn(definition);
    when(definition.getDefinition()).thenReturn(decision);
    decision.setName(new Name(name));
    decision.setVariable(informationItemPrimary);
    return node;
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) QName(org.kie.workbench.common.dmn.api.property.dmn.QName)

Example 15 with InformationItemPrimary

use of org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary in project kie-wb-common by kiegroup.

the class BaseNameAndDataTypeHeaderMetaDataTest method testRender.

@Test
public void testRender() {
    final QName typeRef = BuiltInType.DATE.asQName();
    final GridRenderer renderer = mock(GridRenderer.class);
    final GridRendererTheme theme = mock(GridRendererTheme.class);
    final Text tName = mock(Text.class);
    final InformationItemPrimary hasExpressionVariable = new InformationItemPrimary();
    hasExpressionVariable.setTypeRef(typeRef);
    hasExpression.setVariable(hasExpressionVariable);
    final Decision decision = new Decision();
    decision.setName(NAME);
    setup(Optional.of(decision));
    when(theme.getHeaderText()).thenReturn(tName);
    when(context.getRenderer()).thenReturn(renderer);
    when(renderer.getTheme()).thenReturn(theme);
    when(hasTypeRef.getTypeRef()).thenReturn(typeRef);
    metaData.render(context, BLOCK_WIDTH, BLOCK_HEIGHT);
    verify(tName).setText(NAME.getValue());
    verify(tName, times(2)).setListening(false);
    verify(tName, times(2)).setX(BLOCK_WIDTH / 2);
    verify(tName).setY(BLOCK_HEIGHT / 2 - SPACING);
    verify(tName).setFontStyle(FONT_STYLE_TYPE_REF);
    verify(tName).setFontSize(BaseExpressionGridTheme.FONT_SIZE - 2.0);
    verify(tName).setText("(" + typeRef.toString() + ")");
    verify(tName).setY(BLOCK_HEIGHT / 2 + SPACING);
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) GridRendererTheme(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.themes.GridRendererTheme) Text(com.ait.lienzo.client.core.shape.Text) GridRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Aggregations

InformationItemPrimary (org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary)39 Test (org.junit.Test)21 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)18 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)17 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)14 View (org.kie.workbench.common.stunner.core.graph.content.view.View)13 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)12 Node (org.kie.workbench.common.stunner.core.graph.Node)10 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)9 StylingSet (org.kie.workbench.common.dmn.api.property.styling.StylingSet)8 BindableAdapterUtils.getDefinitionId (org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId)8 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)7 GeneralRectangleDimensionsSet (org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet)6 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)5 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)5 OutputClause (org.kie.workbench.common.dmn.api.definition.model.OutputClause)5 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)5 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)4 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)4 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)4