Search in sources :

Example 46 with InformationItem

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

the class AddRelationColumnCommandTest method testGraphCommandExecuteWithExistingColumn_InsertBefore.

@Test
public void testGraphCommandExecuteWithExistingColumn_InsertBefore() {
    final InformationItem existingInformationItem = new InformationItem();
    relation.getColumn().add(existingInformationItem);
    final List row = new List();
    relation.getRow().add(row);
    final LiteralExpression existingLiteralExpression = new LiteralExpression();
    row.getExpression().add(0, HasExpression.wrap(row, existingLiteralExpression));
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(2, relation.getColumn().size());
    assertEquals(informationItem, relation.getColumn().get(0));
    assertEquals(RelationDefaultValueUtilities.PREFIX + "1", informationItem.getName().getValue());
    assertEquals(existingInformationItem, relation.getColumn().get(1));
    assertEquals(1, relation.getRow().size());
    assertEquals(2, relation.getRow().get(0).getExpression().size());
    assertTrue(relation.getRow().get(0).getExpression().get(0).getExpression() instanceof LiteralExpression);
    assertEquals(existingLiteralExpression, relation.getRow().get(0).getExpression().get(1).getExpression());
    assertEquals(relation, informationItem.getParent());
    assertEquals(relation.getRow().get(0), relation.getRow().get(0).getExpression().get(0).getExpression().getParent());
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) List(org.kie.workbench.common.dmn.api.definition.model.List) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Example 47 with InformationItem

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

the class AddRelationColumnCommandTest method setup.

@Before
public void setup() {
    this.relation = new Relation();
    this.informationItem = new InformationItem();
    this.uiModel = new BaseGridData();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModelMapper = new RelationUIModelMapper(() -> uiModel, () -> Optional.of(relation), listSelector, DEFAULT_HEIGHT);
    makeCommand(1);
    doReturn(ruleManager).when(handler).getRuleManager();
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiModelColumn).getIndex();
}
Also used : RelationUIModelMapper(org.kie.workbench.common.dmn.client.editors.expressions.types.relation.RelationUIModelMapper) Relation(org.kie.workbench.common.dmn.api.definition.model.Relation) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 48 with InformationItem

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

the class DeleteRelationRowCommandTest method testGraphCommandUndoWithColumns.

@Test
public void testGraphCommandUndoWithColumns() {
    relation.getColumn().add(new InformationItem());
    final LiteralExpression literalExpression = new LiteralExpression();
    literalExpression.getText().setValue(VALUE);
    relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, literalExpression));
    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));
    assertEquals(1, relation.getColumn().size());
    assertEquals(1, relation.getRow().size());
    assertEquals(1, relation.getRow().get(0).getExpression().size());
    assertEquals(VALUE, ((LiteralExpression) relation.getRow().get(0).getExpression().get(0).getExpression()).getText().getValue());
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) 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) Test(org.junit.Test)

Example 49 with InformationItem

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

the class DeleteRelationRowCommandTest method testGraphCommandExecuteWithColumns.

@Test
public void testGraphCommandExecuteWithColumns() {
    relation.getColumn().add(new InformationItem());
    relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, new LiteralExpression()));
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(0, relation.getRow().size());
    assertEquals(1, relation.getColumn().size());
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) 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) Test(org.junit.Test)

Example 50 with InformationItem

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

the class AddRelationRowCommandTest method testCanvasCommandUndoWithColumns.

@Test
public void testCanvasCommandUndoWithColumns() {
    relation.getColumn().add(new InformationItem());
    relation.getRow().add(new org.kie.workbench.common.dmn.api.definition.model.List());
    uiModel.appendColumn(uiModelColumn);
    uiModel.appendRow(new BaseGridRow());
    uiModelMapper.fromDMNModel(0, 0);
    // Add Graph column first as RelationUIModelMapper relies on the model being first updated
    command.newGraphCommand(handler).execute(gce);
    // Add column and then undo
    final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
    reset(command, canvasOperation);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.undo(handler));
    assertEquals(2, uiModel.getColumnCount());
    assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
    assertEquals(uiModelColumn, uiModel.getColumns().get(1));
    assertEquals(1, uiModel.getRowCount());
    verify(command).updateRowNumbers();
    verify(command).updateParentInformation();
    verify(canvasOperation).execute();
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) List(org.kie.workbench.common.dmn.api.definition.model.List) Test(org.junit.Test)

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