use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.
the class MoveRowsCommandTest method setup.
@Before
public void setup() {
this.context = new Context();
this.uiModel = new DMNGridData();
doReturn(ruleManager).when(handler).getRuleManager();
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiNameColumn).getIndex();
doReturn(2).when(uiExpressionEditorColumn).getIndex();
addContextEntry(II1);
addContextEntry(II2);
addUiModelColumn(uiRowNumberColumn);
addUiModelColumn(uiNameColumn);
addUiModelColumn(uiExpressionEditorColumn);
addUiModelRow(0);
addUiModelRow(1);
}
use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.
the class HasExpressionTest method testWrapNonNull.
@Test
public void testWrapNonNull() {
final LiteralExpression le = new LiteralExpression();
final HasExpression hasExpression = HasExpression.wrap(parent, le);
assertNotNull(hasExpression.getExpression());
assertEquals(le, hasExpression.getExpression());
assertEquals(parent, hasExpression.asDMNModelInstrumentedBase());
final Context context = new Context();
hasExpression.setExpression(context);
assertNotNull(hasExpression.getExpression());
assertEquals(context, hasExpression.getExpression());
assertEquals(parent, hasExpression.asDMNModelInstrumentedBase());
}
use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.
the class ContextGrid method doAfterSelectionChange.
@Override
public void doAfterSelectionChange(final int uiRowIndex, final int uiColumnIndex) {
if (hasAnyHeaderCellSelected() || hasMultipleRowsSelected()) {
super.doAfterSelectionChange(uiRowIndex, uiColumnIndex);
return;
}
if (uiRowIndex < model.getRowCount() - 1) {
if (getExpression().get().isPresent()) {
final Context context = getExpression().get().get();
fireDomainObjectSelectionEvent(context.getContextEntry().get(uiRowIndex).getVariable());
return;
}
}
super.doAfterSelectionChange(uiRowIndex, uiColumnIndex);
}
use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.
the class DMNMarshallerStandaloneTest method checkDecisionWithContextWithoutDefaultResult.
private void checkDecisionWithContextWithoutDefaultResult(Graph<?, Node<?, ?>> g) {
Node<?, ?> decisionNode = g.getNode("_30810b88-8416-4c02-8ed1-8c19b7606243");
assertNodeContentDefinitionIs(decisionNode, Decision.class);
Context context = (Context) ((Decision) ((View<?>) decisionNode.getContent()).getDefinition()).getExpression();
InformationItem defaultResultVariable = context.getContextEntry().get(1).getVariable();
assertNull("Default result variable", defaultResultVariable);
Expression defaultResultExpression = context.getContextEntry().get(1).getExpression();
assertNull("Default result expression", defaultResultExpression);
}
use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.
the class DMNMarshallerStandaloneTest method testContextEntryDataType.
@Test
@SuppressWarnings("unchecked")
public void testContextEntryDataType() throws Exception {
final DMNMarshallerStandalone marshaller = getDMNMarshaller();
final Context context = new Context();
context.setTypeRef(BuiltInType.DATE_TIME.asQName());
final ContextEntry contextEntry = new ContextEntry();
final LiteralExpression literalExpression = new LiteralExpression();
literalExpression.setTypeRef(BuiltInType.BOOLEAN.asQName());
literalExpression.getText().setValue("feel");
contextEntry.setExpression(literalExpression);
context.getContextEntry().add(contextEntry);
final Diagram<Graph, Metadata> mockedDiagram = newDiagramDecisionWithExpression(context);
final String marshalledSource = marshaller.marshall(mockedDiagram);
final Graph<?, Node<View, ?>> unmarshalledGraph = marshaller.unmarshall(createMetadata(), new StringInputStream(marshalledSource));
assertThat(unmarshalledGraph.nodes()).hasSize(2);
checkDecisionExpression(unmarshalledGraph, context);
}
Aggregations