Search in sources :

Example 81 with InformationItem

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

the class ParametersPopoverViewImplTest method testSetParameters.

@Test
public void testSetParameters() {
    final InformationItem parameter1 = new InformationItem();
    final InformationItem parameter2 = new InformationItem();
    parameter1.getName().setValue(PARAMETER1_NAME);
    parameter2.getName().setValue(PARAMETER2_NAME);
    final List<InformationItem> parameters = Arrays.asList(parameter1, parameter2);
    view.setParameters(parameters);
    verify(parameterView1).setName(eq(PARAMETER1_NAME));
    verifyRemoveClickHandler(parameter1, parameterView1);
    verifyParameterNameChangeHandler(parameter1, parameterView1);
    verifyParameterTypeRefChangeHandler(parameter1, parameterView1);
    verify(parameterView2).setName(eq(PARAMETER2_NAME));
    verifyRemoveClickHandler(parameter2, parameterView2);
    verifyParameterNameChangeHandler(parameter2, parameterView2);
    verifyParameterTypeRefChangeHandler(parameter2, parameterView2);
    verify(parametersContainer, times(2)).appendChild(element);
}
Also used : InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) Test(org.junit.Test)

Example 82 with InformationItem

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

the class RelationDefaultValueUtilitiesTest method testGetNewColumnNameWithDeletion.

@Test
public void testGetNewColumnNameWithDeletion() {
    final InformationItem informationItem1 = new InformationItem();
    relation.getColumn().add(informationItem1);
    informationItem1.getName().setValue(RelationDefaultValueUtilities.getNewColumnName(relation));
    assertThat(informationItem1.getName().getValue()).isEqualTo(RelationDefaultValueUtilities.PREFIX + "1");
    final InformationItem informationItem2 = new InformationItem();
    relation.getColumn().add(informationItem2);
    informationItem2.getName().setValue(RelationDefaultValueUtilities.getNewColumnName(relation));
    assertThat(informationItem2.getName().getValue()).isEqualTo(RelationDefaultValueUtilities.PREFIX + "2");
    relation.getColumn().remove(informationItem1);
    final InformationItem informationItem3 = new InformationItem();
    relation.getColumn().add(informationItem3);
    informationItem3.getName().setValue(RelationDefaultValueUtilities.getNewColumnName(relation));
    assertThat(informationItem3.getName().getValue()).isEqualTo(RelationDefaultValueUtilities.PREFIX + "3");
}
Also used : InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) Test(org.junit.Test)

Example 83 with InformationItem

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

the class InvocationDefaultValueUtilitiesTest method testGetNewParameterName.

@Test
public void testGetNewParameterName() {
    final Binding binding1 = new Binding() {

        {
            setParameter(new InformationItem());
        }
    };
    invocation.getBinding().add(binding1);
    binding1.getParameter().getName().setValue(InvocationDefaultValueUtilities.getNewParameterName(invocation));
    assertThat(binding1.getParameter().getName().getValue()).isEqualTo(InvocationDefaultValueUtilities.PREFIX + "1");
    final Binding binding2 = new Binding() {

        {
            setParameter(new InformationItem());
        }
    };
    invocation.getBinding().add(binding2);
    binding2.getParameter().getName().setValue(InvocationDefaultValueUtilities.getNewParameterName(invocation));
    assertThat(binding2.getParameter().getName().getValue()).isEqualTo(InvocationDefaultValueUtilities.PREFIX + "2");
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) Test(org.junit.Test)

Example 84 with InformationItem

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

the class InvocationDefaultValueUtilitiesTest method testGetNewParameterNameWithExistingParameters.

@Test
public void testGetNewParameterNameWithExistingParameters() {
    final Binding binding1 = new Binding() {

        {
            setParameter(new InformationItem());
        }
    };
    invocation.getBinding().add(binding1);
    binding1.getParameter().getName().setValue("binding");
    final Binding binding2 = new Binding() {

        {
            setParameter(new InformationItem());
        }
    };
    invocation.getBinding().add(binding2);
    binding2.getParameter().getName().setValue(InvocationDefaultValueUtilities.getNewParameterName(invocation));
    assertThat(binding2.getParameter().getName().getValue()).isEqualTo(InvocationDefaultValueUtilities.PREFIX + "1");
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) Test(org.junit.Test)

Example 85 with InformationItem

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

the class BaseContextUIModelMapperTest method setup.

@SuppressWarnings("unchecked")
public void setup(final boolean isOnlyVisualChangeAllowedSupplier) {
    this.uiModel = new BaseGridData();
    this.uiModel.appendRow(new BaseGridRow());
    this.uiModel.appendRow(new BaseGridRow());
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiNameColumn);
    this.uiModel.appendColumn(uiExpressionEditorColumn);
    when(uiRowNumberColumn.getIndex()).thenReturn(0);
    when(uiNameColumn.getIndex()).thenReturn(1);
    when(uiExpressionEditorColumn.getIndex()).thenReturn(2);
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
    when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
    when(literalExpressionEditorDefinition.getModelClass()).thenReturn(Optional.of(literalExpression));
    when(literalExpressionEditor.getExpression()).thenReturn(() -> Optional.of(literalExpression));
    when(literalExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(literalExpressionEditor));
    when(undefinedExpressionEditorDefinition.getModelClass()).thenReturn(Optional.empty());
    when(undefinedExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(undefinedExpressionEditor));
    this.context = new Context();
    this.context.getContextEntry().add(new ContextEntry() {

        {
            setVariable(new InformationItem() {

                {
                    setName(new Name("ii1"));
                }
            });
        }
    });
    this.context.getContextEntry().add(new ContextEntry() {

        {
            setExpression(new LiteralExpression());
        }
    });
    this.mapper = getMapper(isOnlyVisualChangeAllowedSupplier);
    this.cellValueSupplier = Optional::empty;
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.model.Context) ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) Optional(java.util.Optional) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry) Name(org.kie.workbench.common.dmn.api.property.dmn.Name)

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