Search in sources :

Example 1 with DMNMessageImpl

use of org.kie.dmn.core.impl.DMNMessageImpl in project drools by kiegroup.

the class DMNScenarioRunnerHelperTest method getSingleFactValueResultFailDecisionWithMessages.

@Test
public void getSingleFactValueResultFailDecisionWithMessages() {
    DMNMessage errorMessage = new DMNMessageImpl(ERROR, "DMN Internal Error", DMNMessageType.FEEL_EVALUATION_ERROR, null);
    DMNMessage warnMessage = new DMNMessageImpl(WARN, "DMN Internal Warn", DMNMessageType.FEEL_EVALUATION_ERROR, null);
    DMNDecisionResult failedDecision = createDecisionResultMock("Test", false, new ArrayList<>());
    ValueWrapper<?> failedResult = runnerHelper.getSingleFactValueResult(null, null, failedDecision, Arrays.asList(warnMessage, errorMessage), expressionEvaluator);
    assertFalse(failedResult.isValid());
    assertEquals("The decision \"" + failedDecision.getDecisionName() + "\" has not been successfully evaluated: DMN Internal Error", failedResult.getErrorMessage().get());
}
Also used : DMNMessage(org.kie.dmn.api.core.DMNMessage) DMNDecisionResult(org.kie.dmn.api.core.DMNDecisionResult) DMNMessageImpl(org.kie.dmn.core.impl.DMNMessageImpl) Test(org.junit.Test)

Example 2 with DMNMessageImpl

use of org.kie.dmn.core.impl.DMNMessageImpl in project drools by kiegroup.

the class DMNValidatorImpl method validateSchema.

private List<DMNMessage> validateSchema(String xml, String path) {
    List<DMNMessage> problems = new ArrayList<>();
    try {
        DMN_VERSION inferDMNVersion = XStreamMarshaller.inferDMNVersion(new StringReader(xml));
        Schema usingSchema = determineSchema(inferDMNVersion);
        Source s = new StreamSource(new StringReader(xml));
        validateSchema(s, usingSchema);
    } catch (Exception e) {
        problems.add(new DMNMessageImpl(DMNMessage.Severity.ERROR, MsgUtil.createMessage(Msg.FAILED_XML_VALIDATION, e.getMessage()), Msg.FAILED_XML_VALIDATION.getType(), null, e).withPath(path));
    }
    return problems;
}
Also used : DMNMessage(org.kie.dmn.api.core.DMNMessage) Schema(javax.xml.validation.Schema) StreamSource(javax.xml.transform.stream.StreamSource) ArrayList(java.util.ArrayList) StringReader(java.io.StringReader) DMN_VERSION(org.kie.dmn.backend.marshalling.v1x.XStreamMarshaller.DMN_VERSION) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) DMNMessageImpl(org.kie.dmn.core.impl.DMNMessageImpl)

Aggregations

DMNMessage (org.kie.dmn.api.core.DMNMessage)2 DMNMessageImpl (org.kie.dmn.core.impl.DMNMessageImpl)2 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 Source (javax.xml.transform.Source)1 StreamSource (javax.xml.transform.stream.StreamSource)1 Schema (javax.xml.validation.Schema)1 Test (org.junit.Test)1 DMNDecisionResult (org.kie.dmn.api.core.DMNDecisionResult)1 DMN_VERSION (org.kie.dmn.backend.marshalling.v1x.XStreamMarshaller.DMN_VERSION)1 SAXException (org.xml.sax.SAXException)1