Search in sources :

Example 21 with List

use of org.kie.dmn.model.v1_1.List in project drools by kiegroup.

the class ItemDefinitionDependenciesTest method testGeneric2.

@Test
public void testGeneric2() {
    ItemDefinition z = build("z");
    ItemDefinition b = build("b");
    ItemDefinition a = build("a", z);
    List<ItemDefinition> originalList = Arrays.asList(new ItemDefinition[] { z, b, a });
    List<ItemDefinition> orderedList = orderingStrategy(originalList);
    assertTrue("Index of z < a", orderedList.indexOf(z) < orderedList.indexOf(a));
}
Also used : ItemDefinition(org.kie.dmn.model.v1_1.ItemDefinition) Test(org.junit.Test)

Example 22 with List

use of org.kie.dmn.model.v1_1.List in project drools by kiegroup.

the class ItemDefinitionDependenciesTest method testOrdering4.

@Test
public void testOrdering4() {
    ItemDefinition _TypeDecisionA1 = build("TypeDecisionA1");
    ItemDefinition _TypeDecisionA2_x = build("TypeDecisionA2.x", _TypeDecisionA1);
    ItemDefinition _TypeDecisionA3 = build("TypeDecisionA3", _TypeDecisionA2_x);
    ItemDefinition _TypeDecisionB1 = build("TypeDecisionB1");
    ItemDefinition _TypeDecisionB2_x = build("TypeDecisionB2.x", _TypeDecisionB1);
    ItemDefinition _TypeDecisionB3 = build("TypeDecisionB3", _TypeDecisionB2_x, _TypeDecisionA3);
    ItemDefinition _TypeDecisionC1 = build("TypeDecisionC1", _TypeDecisionA3, _TypeDecisionB3);
    ItemDefinition _TypeDecisionC4 = build("TypeDecisionC4");
    List<ItemDefinition> originalList = Arrays.asList(new ItemDefinition[] { _TypeDecisionA1, _TypeDecisionA2_x, _TypeDecisionA3, _TypeDecisionB1, _TypeDecisionB2_x, _TypeDecisionB3, _TypeDecisionC1, _TypeDecisionC4 });
    List<ItemDefinition> orderedList = orderingStrategy(originalList);
    assertTrue("Index of _TypeDecisionA1 < _TypeDecisionA2_x", orderedList.indexOf(_TypeDecisionA1) < orderedList.indexOf(_TypeDecisionA2_x));
    assertTrue("Index of _TypeDecisionA2_x < _TypeDecisionA3", orderedList.indexOf(_TypeDecisionA2_x) < orderedList.indexOf(_TypeDecisionA3));
    assertTrue("Index of _TypeDecisionA3 < _TypeDecisionB3", orderedList.indexOf(_TypeDecisionA3) < orderedList.indexOf(_TypeDecisionB3));
    assertTrue("Index of _TypeDecisionA3 < _TypeDecisionC1", orderedList.indexOf(_TypeDecisionA3) < orderedList.indexOf(_TypeDecisionC1));
    assertTrue("Index of _TypeDecisionB1 < _TypeDecisionB2_x", orderedList.indexOf(_TypeDecisionB1) < orderedList.indexOf(_TypeDecisionB2_x));
    assertTrue("Index of _TypeDecisionB2_x < _TypeDecisionB3", orderedList.indexOf(_TypeDecisionB2_x) < orderedList.indexOf(_TypeDecisionB3));
    assertTrue("Index of _TypeDecisionB3 < _TypeDecisionC1", orderedList.indexOf(_TypeDecisionB3) < orderedList.indexOf(_TypeDecisionC1));
}
Also used : ItemDefinition(org.kie.dmn.model.v1_1.ItemDefinition) Test(org.junit.Test)

Example 23 with List

use of org.kie.dmn.model.v1_1.List in project drools by kiegroup.

the class ItemDefinitionDependenciesTest method testGeneric.

@Test
public void testGeneric() {
    ItemDefinition a = build("a");
    ItemDefinition b = build("b");
    ItemDefinition c = build("c", a, b);
    ItemDefinition d = build("d", c);
    List<ItemDefinition> originalList = Arrays.asList(new ItemDefinition[] { d, c, b, a });
    List<ItemDefinition> orderedList = orderingStrategy(originalList);
    assertThat(orderedList.subList(0, 2), containsInAnyOrder(a, b));
    assertThat(orderedList.subList(2, 4), contains(c, d));
}
Also used : ItemDefinition(org.kie.dmn.model.v1_1.ItemDefinition) Test(org.junit.Test)

Example 24 with List

use of org.kie.dmn.model.v1_1.List in project drools by kiegroup.

the class DMNValidatorImpl method validate.

@Override
public List<DMNMessage> validate(Reader reader, Validation... options) {
    DMNMessageManager results = new DefaultDMNMessagesManager();
    EnumSet<Validation> flags = EnumSet.copyOf(Arrays.asList(options));
    try {
        String content = readContent(reader);
        if (flags.contains(VALIDATE_SCHEMA)) {
            results.addAll(validateSchema(new StringReader(content)));
        }
        if (flags.contains(VALIDATE_MODEL) || flags.contains(VALIDATE_COMPILATION)) {
            Definitions dmndefs = DMNMarshallerFactory.newDefaultMarshaller().unmarshal(new StringReader(content));
            Definitions.normalize(dmndefs);
            validateModelCompilation(dmndefs, results, flags);
        }
    } catch (Throwable t) {
        MsgUtil.reportMessage(LOG, DMNMessage.Severity.ERROR, null, results, t, null, Msg.FAILED_VALIDATOR);
    }
    return results.getMessages();
}
Also used : DMNMessageManager(org.kie.dmn.core.api.DMNMessageManager) Definitions(org.kie.dmn.model.v1_1.Definitions) StringReader(java.io.StringReader) DefaultDMNMessagesManager(org.kie.dmn.core.util.DefaultDMNMessagesManager)

Example 25 with List

use of org.kie.dmn.model.v1_1.List in project kie-wb-common by kiegroup.

the class RelationUIModelMapperTest method setup.

@Before
public void setup() {
    this.uiModel = new BaseGridData();
    this.uiModel.appendRow(new DMNGridRow());
    this.uiModel.appendRow(new DMNGridRow());
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiRelationColumn1);
    this.uiModel.appendColumn(uiRelationColumn2);
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiRelationColumn1).getIndex();
    doReturn(2).when(uiRelationColumn2).getIndex();
    this.relation = new Relation();
    this.relation.getColumn().add(new InformationItem());
    this.relation.getColumn().add(new InformationItem());
    this.relation.getRow().add(new List() {

        {
            getExpression().add(new LiteralExpression() {

                {
                    setText("le(1,0)");
                }
            });
            getExpression().add(new LiteralExpression() {

                {
                    setText("le(2,0)");
                }
            });
        }
    });
    this.relation.getRow().add(new List() {

        {
            getExpression().add(new LiteralExpression() {

                {
                    setText("le(1,1)");
                }
            });
            getExpression().add(new LiteralExpression() {

                {
                    setText("le(2,1)");
                }
            });
        }
    });
    this.mapper = new RelationUIModelMapper(() -> uiModel, () -> Optional.of(relation), listSelector);
    this.cellValueSupplier = Optional::empty;
}
Also used : Relation(org.kie.workbench.common.dmn.api.definition.v1_1.Relation) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Optional(java.util.Optional) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) List(org.kie.workbench.common.dmn.api.definition.v1_1.List) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Aggregations

Test (org.junit.Test)54 List (org.kie.workbench.common.dmn.api.definition.v1_1.List)26 ItemDefinition (org.kie.dmn.model.v1_1.ItemDefinition)21 QName (javax.xml.namespace.QName)17 ArrayList (java.util.ArrayList)15 List (java.util.List)14 DMNMessage (org.kie.dmn.api.core.DMNMessage)14 Import (org.kie.dmn.model.v1_1.Import)13 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)13 CoreMatchers.is (org.hamcrest.CoreMatchers.is)11 DMNMessageType (org.kie.dmn.api.core.DMNMessageType)11 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)11 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)10 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)10 Definitions (org.kie.dmn.model.v1_1.Definitions)9 IOException (java.io.IOException)8 Collectors (java.util.stream.Collectors)8 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)8 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)8 Reader (java.io.Reader)7