use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context in project kie-wb-common by kiegroup.
the class DMNMarshallerTest method test_wrong_context.
@Test
public void test_wrong_context() throws IOException {
// DROOLS-2217
// SPECIAL CASE: to represent a partially edited DMN file.
// consider a LiteralExpression with null text as missing expression altogether.
final DMNRuntime runtime = roundTripUnmarshalMarshalThenUnmarshalDMN(this.getClass().getResourceAsStream("/wrong_context.dmn"));
DMNModel dmnModel = runtime.getModels().get(0);
// the DMN file is schema valid but is not a valid-DMN (a context-entry value is a literal expression missing text, which is null)
assertTrue(dmnModel.hasErrors());
// identify the error message for context-entry "ciao":
DMNMessage m0 = dmnModel.getMessages(DMNMessage.Severity.ERROR).get(0);
assertTrue("expected a message identifying the problem on a context entry for 'ciao'", m0.getMessage().startsWith("No expression defined for name 'ciao'"));
DecisionNode d0 = dmnModel.getDecisionById("_653b3426-933a-4050-9568-ab2a66b43c36");
// the identified DMN Decision is composed of a DMN Context where the first context-entry value is a literal expression missing text (text is null).
org.kie.dmn.model.v1_1.Context d0c = (org.kie.dmn.model.v1_1.Context) d0.getDecision().getExpression();
org.kie.dmn.model.v1_1.Expression contextEntryValue = d0c.getContextEntry().get(0).getExpression();
assertTrue(contextEntryValue instanceof org.kie.dmn.model.v1_1.LiteralExpression);
assertEquals(null, ((org.kie.dmn.model.v1_1.LiteralExpression) contextEntryValue).getText());
// -- Stunner side.
DMNMarshaller m = new DMNMarshaller(new XMLEncoderDiagramMetadataMarshaller(), applicationFactoryManager);
Graph<?, ?> g = m.unmarshall(null, this.getClass().getResourceAsStream("/wrong_context.dmn"));
DiagramImpl diagram = new DiagramImpl("", null);
Node<?, ?> decisionNode = g.getNode("_653b3426-933a-4050-9568-ab2a66b43c36");
assertNodeContentDefinitionIs(decisionNode, Decision.class);
View<Decision> view = ((View<Decision>) decisionNode.getContent());
// the identified DMN Decision is composed of a DMN Context where the first context-entry has missing Expression.
Context expression = (Context) view.getDefinition().getExpression();
assertEquals("a literalexpression with null text is threated as a missing expression altogether.", null, expression.getContextEntry().get(0).getExpression());
}
use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context in project kie-wb-common by kiegroup.
the class BaseContextUIModelMapperTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
this.uiModel = new BaseGridData();
this.uiModel.appendRow(new DMNGridRow());
this.uiModel.appendRow(new DMNGridRow());
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiNameColumn);
this.uiModel.appendColumn(uiExpressionEditorColumn);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiNameColumn).getIndex();
doReturn(2).when(uiExpressionEditorColumn).getIndex();
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add(literalExpressionEditorDefinition);
expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
doReturn(Optional.of(literalExpression)).when(literalExpressionEditor).getExpression();
doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
doReturn(Optional.empty()).when(undefinedExpressionEditorDefinition).getModelClass();
doReturn(Optional.of(undefinedExpressionEditor)).when(undefinedExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
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();
this.cellValueSupplier = Optional::empty;
}
use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context in project kie-wb-common by kiegroup.
the class ContextEditorDefinitionTest method testModelDefinition.
@Test
public void testModelDefinition() {
final Optional<Context> oModel = definition.getModelClass();
assertTrue(oModel.isPresent());
final Context model = oModel.get();
assertEquals(2, model.getContextEntry().size());
assertNotNull(model.getContextEntry().get(0).getVariable());
assertNull(model.getContextEntry().get(1).getVariable());
assertTrue(model.getContextEntry().get(1).getExpression() instanceof LiteralExpression);
}
use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context in project kie-wb-common by kiegroup.
the class JavaFunctionEditorDefinitionTest method testEditor.
@Test
public void testEditor() {
final Optional<Context> expression = definition.getModelClass();
final Optional<BaseExpressionGrid> oEditor = definition.getEditor(parent, Optional.empty(), hasExpression, expression, hasName, 0);
assertTrue(oEditor.isPresent());
final GridWidget editor = oEditor.get();
assertTrue(editor instanceof FunctionSupplementaryGrid);
}
use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context in project kie-wb-common by kiegroup.
the class PMMLFunctionEditorDefinitionTest method testModelDefinition.
@Test
public void testModelDefinition() {
final Optional<Context> oModel = definition.getModelClass();
assertTrue(oModel.isPresent());
final Context model = oModel.get();
assertEquals(2, model.getContextEntry().size());
assertEquals(PMMLFunctionEditorDefinition.VARIABLE_DOCUMENT, model.getContextEntry().get(0).getVariable().getName().getValue());
assertTrue(model.getContextEntry().get(0).getExpression() instanceof LiteralExpression);
assertEquals(PMMLFunctionEditorDefinition.VARIABLE_MODEL, model.getContextEntry().get(1).getVariable().getName().getValue());
assertTrue(model.getContextEntry().get(1).getExpression() instanceof LiteralExpression);
}
Aggregations