use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class ListUIModelMapperTest method testFromDMNModelCellTypes.
@Test
public void testFromDMNModelCellTypes() {
setup(new LiteralExpression(), false);
IntStream.range(0, 1).forEach(rowIndex -> {
mapper.fromDMNModel(rowIndex, ROW_COLUMN_INDEX);
mapper.fromDMNModel(rowIndex, EXPRESSION_COLUMN_INDEX);
});
assertThat(uiModel.getCell(0, ROW_COLUMN_INDEX)).isInstanceOf(ContextGridCell.class);
assertThat(uiModel.getCell(0, EXPRESSION_COLUMN_INDEX)).isInstanceOf(ContextGridCell.class);
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class RelationUIModelMapperTest method setup.
@Before
public void setup() {
this.uiModel = new BaseGridData();
this.uiModel.appendRow(new BaseGridRow());
this.uiModel.appendRow(new BaseGridRow());
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiRelationColumn1);
this.uiModel.appendColumn(uiRelationColumn2);
when(uiRowNumberColumn.getIndex()).thenReturn(0);
when(uiRelationColumn1.getIndex()).thenReturn(1);
when(uiRelationColumn2.getIndex()).thenReturn(2);
this.relation = new Relation();
this.relation.getColumn().add(new InformationItem());
this.relation.getColumn().add(new InformationItem());
final List rowList1 = new List();
rowList1.getExpression().add(HasExpression.wrap(rowList1, new LiteralExpression() {
{
getText().setValue("le(1,0)");
}
}));
rowList1.getExpression().add(HasExpression.wrap(rowList1, new LiteralExpression() {
{
getText().setValue("le(2,0)");
}
}));
final List rowList2 = new List();
rowList2.getExpression().add(HasExpression.wrap(rowList2, new LiteralExpression() {
{
getText().setValue("le(1,1)");
}
}));
rowList2.getExpression().add(HasExpression.wrap(rowList2, new LiteralExpression() {
{
getText().setValue("le(2,1)");
}
}));
this.relation.getRow().add(rowList1);
this.relation.getRow().add(rowList2);
this.mapper = new RelationUIModelMapper(() -> uiModel, () -> Optional.of(relation), listSelector, DEFAULT_HEIGHT);
this.cellValueSupplier = Optional::empty;
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class RelationUIModelMapperTest method testToDMNModelLiteralExpressionsNullValue.
@Test
public void testToDMNModelLiteralExpressionsNullValue() {
cellValueSupplier = () -> Optional.of(new BaseGridCellValue<>(null));
for (int uiRowIndex = 0; uiRowIndex < uiModel.getRowCount(); uiRowIndex++) {
for (int uiColumnIndex = 1; uiColumnIndex < uiModel.getColumnCount(); uiColumnIndex++) {
mapper.toDMNModel(uiRowIndex, uiColumnIndex, cellValueSupplier);
final LiteralExpression le = (LiteralExpression) relation.getRow().get(uiRowIndex).getExpression().get(uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT).getExpression();
assertNull(le.getText().getValue());
}
}
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class RelationUIModelMapperTest method testToDMNModelLiteralExpressionsNonEmptyValue.
@Test
public void testToDMNModelLiteralExpressionsNonEmptyValue() {
for (int uiRowIndex = 0; uiRowIndex < uiModel.getRowCount(); uiRowIndex++) {
for (int uiColumnIndex = 1; uiColumnIndex < uiModel.getColumnCount(); uiColumnIndex++) {
final String value = "(" + uiColumnIndex + "," + uiRowIndex + ")";
cellValueSupplier = () -> Optional.of(new BaseGridCellValue<>(value));
mapper.toDMNModel(uiRowIndex, uiColumnIndex, cellValueSupplier);
final LiteralExpression le = (LiteralExpression) relation.getRow().get(uiRowIndex).getExpression().get(uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT).getExpression();
assertEquals(value, le.getText().getValue());
}
}
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class FunctionDefinitionPropertyConverter method convertContextEntryExpression.
private static void convertContextEntryExpression(final ContextEntry contextEntry, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
final Expression expression = contextEntry.getExpression();
if (expression instanceof LiteralExpression) {
final LiteralExpression le = (LiteralExpression) expression;
final String variableName = contextEntry.getVariable().getName().getValue();
if (Objects.equals(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT, variableName)) {
final LiteralExpressionPMMLDocument e = convertLiteralExpressionToPMMLDocument(le);
// Ensure ComponentWidths are updated for the converted LiteralExpression
hasComponentWidthsConsumer.accept(e.getId().getValue(), e);
contextEntry.setExpression(e);
} else if (Objects.equals(LiteralExpressionPMMLDocumentModel.VARIABLE_MODEL, variableName)) {
final LiteralExpressionPMMLDocumentModel e = convertLiteralExpressionToPMMLDocumentModel(le);
// Ensure ComponentWidths are updated for the converted LiteralExpression
hasComponentWidthsConsumer.accept(e.getId().getValue(), e);
contextEntry.setExpression(e);
}
}
}
Aggregations