Search in sources :

Example 6 with InformationItem

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

the class ContextEntryDefaultValueUtilitiesTest method testGetNewContextEntryNameWithDeletion.

@Test
public void testGetNewContextEntryNameWithDeletion() {
    final ContextEntry contextEntry1 = new ContextEntry() {

        {
            setVariable(new InformationItem());
        }
    };
    context.getContextEntry().add(contextEntry1);
    contextEntry1.getVariable().getName().setValue(ContextEntryDefaultValueUtilities.getNewContextEntryName(context));
    assertThat(contextEntry1.getVariable().getName().getValue()).isEqualTo(ContextEntryDefaultValueUtilities.PREFIX + "1");
    final ContextEntry contextEntry2 = new ContextEntry() {

        {
            setVariable(new InformationItem());
        }
    };
    context.getContextEntry().add(contextEntry2);
    contextEntry2.getVariable().getName().setValue(ContextEntryDefaultValueUtilities.getNewContextEntryName(context));
    assertThat(contextEntry2.getVariable().getName().getValue()).isEqualTo(ContextEntryDefaultValueUtilities.PREFIX + "2");
    context.getContextEntry().remove(contextEntry1);
    final ContextEntry contextEntry3 = new ContextEntry() {

        {
            setVariable(new InformationItem());
        }
    };
    context.getContextEntry().add(contextEntry3);
    contextEntry3.getVariable().getName().setValue(ContextEntryDefaultValueUtilities.getNewContextEntryName(context));
    assertThat(contextEntry3.getVariable().getName().getValue()).isEqualTo(ContextEntryDefaultValueUtilities.PREFIX + "3");
}
Also used : InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry) Test(org.junit.Test)

Example 7 with InformationItem

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

the class ContextEntryDefaultValueUtilitiesTest method testGetNewContextEntryName.

@Test
public void testGetNewContextEntryName() {
    final ContextEntry contextEntry1 = new ContextEntry() {

        {
            setVariable(new InformationItem());
        }
    };
    context.getContextEntry().add(contextEntry1);
    contextEntry1.getVariable().getName().setValue(ContextEntryDefaultValueUtilities.getNewContextEntryName(context));
    assertThat(contextEntry1.getVariable().getName().getValue()).isEqualTo(ContextEntryDefaultValueUtilities.PREFIX + "1");
    final ContextEntry contextEntry2 = new ContextEntry() {

        {
            setVariable(new InformationItem());
        }
    };
    context.getContextEntry().add(contextEntry2);
    contextEntry2.getVariable().getName().setValue(ContextEntryDefaultValueUtilities.getNewContextEntryName(context));
    assertThat(contextEntry2.getVariable().getName().getValue()).isEqualTo(ContextEntryDefaultValueUtilities.PREFIX + "2");
}
Also used : InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry) Test(org.junit.Test)

Example 8 with InformationItem

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

the class ContextEntryDefaultValueUtilitiesTest method testGetNewContextEntryNameWithExistingContextEntries.

@Test
public void testGetNewContextEntryNameWithExistingContextEntries() {
    final ContextEntry contextEntry1 = new ContextEntry() {

        {
            setVariable(new InformationItem());
        }
    };
    context.getContextEntry().add(contextEntry1);
    contextEntry1.getVariable().getName().setValue("entry");
    final ContextEntry contextEntry2 = new ContextEntry() {

        {
            setVariable(new InformationItem());
        }
    };
    context.getContextEntry().add(contextEntry2);
    contextEntry2.getVariable().getName().setValue(ContextEntryDefaultValueUtilities.getNewContextEntryName(context));
    assertThat(contextEntry2.getVariable().getName().getValue()).isEqualTo(ContextEntryDefaultValueUtilities.PREFIX + "1");
}
Also used : InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry) Test(org.junit.Test)

Example 9 with InformationItem

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

the class DMNMarshallerStandaloneTest method checkDecisionWithContextWithDefaultResult.

private void checkDecisionWithContextWithDefaultResult(Graph<?, Node<?, ?>> g) {
    Node<?, ?> decisionNode = g.getNode("_30810b88-8416-4c02-8ed1-8c19b7606243");
    assertNodeContentDefinitionIs(decisionNode, Decision.class);
    Context context = (Context) ((Decision) ((View<?>) decisionNode.getContent()).getDefinition()).getExpression();
    InformationItem defaultResultVariable = context.getContextEntry().get(1).getVariable();
    assertNull("Default result variable", defaultResultVariable);
    Expression defaultResultExpression = context.getContextEntry().get(1).getExpression();
    assertNotNull("Default result expression", defaultResultExpression);
    assertEquals("defaultResultExpression's parent-parent is contextNode", "_0f38d114-5d6e-40dd-aa9c-9f031f9b0571", ((DMNElement) (defaultResultExpression).getParent().getParent()).getId().getValue());
}
Also used : NamespaceContext(javax.xml.namespace.NamespaceContext) DMNContext(org.kie.dmn.api.core.DMNContext) Context(org.kie.workbench.common.dmn.api.definition.model.Context) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) DMNElement(org.kie.workbench.common.dmn.api.definition.model.DMNElement) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) View(org.kie.workbench.common.stunner.core.graph.content.view.View)

Example 10 with InformationItem

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

the class RelationPropertyConverter method dmnFromWB.

public static org.kie.dmn.model.api.Relation dmnFromWB(final Relation wb, final Consumer<ComponentWidths> componentWidthsConsumer) {
    final org.kie.dmn.model.api.Relation result = new org.kie.dmn.model.v1_2.TRelation();
    result.setId(wb.getId().getValue());
    result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
    QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
    for (InformationItem iitem : wb.getColumn()) {
        final org.kie.dmn.model.api.InformationItem iitemConverted = InformationItemPropertyConverter.dmnFromWB(iitem);
        if (iitemConverted != null) {
            iitemConverted.setParent(result);
        }
        result.getColumn().add(iitemConverted);
    }
    for (org.kie.workbench.common.dmn.api.definition.model.List list : wb.getRow()) {
        final org.kie.dmn.model.api.List listConverted = ListPropertyConverter.dmnFromWB(list, componentWidthsConsumer);
        if (listConverted != null) {
            listConverted.setParent(result);
        }
        result.getRow().add(listConverted);
    }
    return result;
}
Also used : InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem)

Aggregations

InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)110 Test (org.junit.Test)61 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)24 ContextEntry (org.kie.workbench.common.dmn.api.definition.model.ContextEntry)22 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)22 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)20 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)19 Binding (org.kie.workbench.common.dmn.api.definition.model.Binding)13 Context (org.kie.workbench.common.dmn.api.definition.model.Context)11 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)11 Before (org.junit.Before)10 List (org.kie.workbench.common.dmn.api.definition.model.List)10 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)10 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)10 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)9 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)9 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)9 HasName (org.kie.workbench.common.dmn.api.definition.HasName)7 Relation (org.kie.workbench.common.dmn.api.definition.model.Relation)7 JSITInformationItem (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInformationItem)7