Search in sources :

Example 26 with ContextEntry

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

the class AddContextEntryCommandTest method testGraphCommandExecuteMultipleEntriesPresent.

@Test
public void testGraphCommandExecuteMultipleEntriesPresent() {
    final String EXISTING_ENTRY_NAME = "old one";
    final ContextEntry firstEntry = new ContextEntry() {

        {
            setVariable(new InformationItem() {

                {
                    setName(new Name(EXISTING_ENTRY_NAME));
                }
            });
        }
    };
    context.getContextEntry().add(0, firstEntry);
    makeCommand();
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(3, context.getContextEntry().size());
    assertEquals(firstEntry, context.getContextEntry().get(0));
    assertEquals(EXISTING_ENTRY_NAME, firstEntry.getVariable().getName().getValue());
    assertEquals(contextEntry, context.getContextEntry().get(1));
    assertEquals(ContextEntryDefaultValueUtilities.PREFIX + "1", contextEntry.getVariable().getName().getValue());
    assertEquals(defaultResultContextEntry, context.getContextEntry().get(2));
    assertEquals(context, contextEntry.getParent());
    assertEquals(contextEntry, contextEntry.getVariable().getParent());
}
Also used : GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 27 with ContextEntry

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

the class AddContextEntryCommandTest method testGraphCommandUndoMultipleEntriesPresent.

@Test
public void testGraphCommandUndoMultipleEntriesPresent() {
    final ContextEntry firstEntry = new ContextEntry() {

        {
            setVariable(new InformationItem() {

                {
                    setName(new Name("old one"));
                }
            });
        }
    };
    context.getContextEntry().add(0, firstEntry);
    makeCommand();
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    // Add column and then undo
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
    assertEquals(2, context.getContextEntry().size());
    assertEquals(firstEntry, context.getContextEntry().get(0));
    assertEquals(defaultResultContextEntry, context.getContextEntry().get(1));
}
Also used : GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 28 with ContextEntry

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

the class DeleteContextEntryCommandTest method testGraphCommandExecuteMultipleRows.

@Test
public void testGraphCommandExecuteMultipleRows() {
    addContextEntries(3);
    final ContextEntry firstEntry = context.getContextEntry().get(0);
    final ContextEntry lastEntry = context.getContextEntry().get(2);
    makeCommand(1);
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    Assertions.assertThat(context.getContextEntry()).containsExactly(firstEntry, lastEntry);
}
Also used : GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry) Test(org.junit.Test)

Example 29 with ContextEntry

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

the class DeleteContextEntryCommandTest method testGraphCommandUndoMultipleRows.

@Test
public void testGraphCommandUndoMultipleRows() {
    addContextEntries(3);
    final ContextEntry firstEntry = context.getContextEntry().get(0);
    final ContextEntry originalEntry = context.getContextEntry().get(1);
    final ContextEntry lastEntry = context.getContextEntry().get(2);
    makeCommand(1);
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    // Delete row and then undo
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
    Assertions.assertThat(context.getContextEntry()).containsExactly(firstEntry, originalEntry, lastEntry);
}
Also used : GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry) Test(org.junit.Test)

Example 30 with ContextEntry

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

the class DeleteContextEntryCommandTest method addContextEntries.

private void addContextEntries(final int entriesCount) {
    final int originalRowCount = uiModel.getRowCount();
    for (int i = 0; i < originalRowCount; i++) {
        uiModel.deleteRow(0);
    }
    context.getContextEntry().clear();
    for (int i = 0; i < entriesCount; i++) {
        context.getContextEntry().add(new ContextEntry());
        uiModel.appendRow(new BaseGridRow());
    }
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry)

Aggregations

ContextEntry (org.kie.workbench.common.dmn.api.definition.model.ContextEntry)40 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)22 Context (org.kie.workbench.common.dmn.api.definition.model.Context)19 Test (org.junit.Test)16 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)8 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)7 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)6 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)5 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)5 TContextEntry (org.kie.dmn.model.v1_2.TContextEntry)4 TInformationItem (org.kie.dmn.model.v1_2.TInformationItem)4 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)4 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)4 OutputClause (org.kie.workbench.common.dmn.api.definition.model.OutputClause)4 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)4 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)4 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)4 TLiteralExpression (org.kie.dmn.model.v1_2.TLiteralExpression)3 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)3 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)3