Search in sources :

Example 1 with DataTypeConversionErrorParserMessage

use of org.drools.workbench.models.guided.dtree.shared.model.parser.messages.DataTypeConversionErrorParserMessage in project drools by kiegroup.

the class GuidedDecisionTreeDRLPersistenceUnmarshallingMessagesTest method testValue_BigInteger.

@Test
public void testValue_BigInteger() throws Exception {
    final String drl = "rule \"test_0\"\n" + "when \n" + "  Person( bigIntegerField == \"abc\" )\n" + "then \n" + "end";
    final GuidedDecisionTree expected = new GuidedDecisionTree();
    expected.setTreeName("test");
    final TypeNode type = new TypeNodeImpl("Person");
    expected.setRoot(type);
    addModelField("Person", "this", "Person", DataType.TYPE_THIS);
    addModelField("Person", "bigIntegerField", BigInteger.class.getName(), DataType.TYPE_NUMERIC_BIGINTEGER);
    final GuidedDecisionTree model = getAndTestUnmarshalledModel(drl, "test", 1);
    assertEquals(expected.getTreeName(), model.getTreeName());
    assertNull(model.getRoot());
    assertEquals("test_0", model.getParserErrors().get(0).getOriginalRuleName());
    assertEqualsIgnoreWhitespace(drl, model.getParserErrors().get(0).getOriginalDrl());
    assertNotNull(model.getParserErrors().get(0).getMessages());
    assertEquals(1, model.getParserErrors().get(0).getMessages().size());
    assertTrue(model.getParserErrors().get(0).getMessages().get(0) instanceof DataTypeConversionErrorParserMessage);
    final String drl2 = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
    assertEqualsIgnoreWhitespace(drl, drl2);
}
Also used : TypeNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.TypeNodeImpl) BigInteger(java.math.BigInteger) DataTypeConversionErrorParserMessage(org.drools.workbench.models.guided.dtree.shared.model.parser.messages.DataTypeConversionErrorParserMessage) GuidedDecisionTree(org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) Test(org.junit.Test)

Example 2 with DataTypeConversionErrorParserMessage

use of org.drools.workbench.models.guided.dtree.shared.model.parser.messages.DataTypeConversionErrorParserMessage in project drools by kiegroup.

the class GuidedDecisionTreeDRLPersistenceUnmarshallingMessagesTest method testValue_BigDecimal.

@Test
public void testValue_BigDecimal() throws Exception {
    final String drl = "rule \"test_0\"\n" + "when \n" + "  Person( bigDecimalField == \"abc\" )\n" + "then \n" + "end";
    final GuidedDecisionTree expected = new GuidedDecisionTree();
    expected.setTreeName("test");
    final TypeNode type = new TypeNodeImpl("Person");
    expected.setRoot(type);
    addModelField("Person", "this", "Person", DataType.TYPE_THIS);
    addModelField("Person", "bigDecimalField", BigDecimal.class.getName(), DataType.TYPE_NUMERIC_BIGDECIMAL);
    final GuidedDecisionTree model = getAndTestUnmarshalledModel(drl, "test", 1);
    assertEquals(expected.getTreeName(), model.getTreeName());
    assertNull(model.getRoot());
    assertEquals("test_0", model.getParserErrors().get(0).getOriginalRuleName());
    assertEqualsIgnoreWhitespace(drl, model.getParserErrors().get(0).getOriginalDrl());
    assertNotNull(model.getParserErrors().get(0).getMessages());
    assertEquals(1, model.getParserErrors().get(0).getMessages().size());
    assertTrue(model.getParserErrors().get(0).getMessages().get(0) instanceof DataTypeConversionErrorParserMessage);
    final String drl2 = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
    assertEqualsIgnoreWhitespace(drl, drl2);
}
Also used : TypeNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.TypeNodeImpl) DataTypeConversionErrorParserMessage(org.drools.workbench.models.guided.dtree.shared.model.parser.messages.DataTypeConversionErrorParserMessage) GuidedDecisionTree(org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 3 with DataTypeConversionErrorParserMessage

use of org.drools.workbench.models.guided.dtree.shared.model.parser.messages.DataTypeConversionErrorParserMessage in project drools by kiegroup.

the class GuidedDecisionTreeDRLPersistenceUnmarshallingMessagesTest method testValue_Integer.

@Test
public void testValue_Integer() throws Exception {
    final String drl = "rule \"test_0\"\n" + "when \n" + "  Person( integerField == \"abc\" )\n" + "then \n" + "end";
    final GuidedDecisionTree expected = new GuidedDecisionTree();
    expected.setTreeName("test");
    final TypeNode type = new TypeNodeImpl("Person");
    expected.setRoot(type);
    addModelField("Person", "this", "Person", DataType.TYPE_THIS);
    addModelField("Person", "integerField", Integer.class.getName(), DataType.TYPE_NUMERIC_INTEGER);
    final GuidedDecisionTree model = getAndTestUnmarshalledModel(drl, "test", 1);
    assertEquals(expected.getTreeName(), model.getTreeName());
    assertNull(model.getRoot());
    assertEquals("test_0", model.getParserErrors().get(0).getOriginalRuleName());
    assertEqualsIgnoreWhitespace(drl, model.getParserErrors().get(0).getOriginalDrl());
    assertNotNull(model.getParserErrors().get(0).getMessages());
    assertEquals(1, model.getParserErrors().get(0).getMessages().size());
    assertTrue(model.getParserErrors().get(0).getMessages().get(0) instanceof DataTypeConversionErrorParserMessage);
    final String drl2 = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
    assertEqualsIgnoreWhitespace(drl, drl2);
}
Also used : BigInteger(java.math.BigInteger) TypeNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.TypeNodeImpl) DataTypeConversionErrorParserMessage(org.drools.workbench.models.guided.dtree.shared.model.parser.messages.DataTypeConversionErrorParserMessage) GuidedDecisionTree(org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) Test(org.junit.Test)

Example 4 with DataTypeConversionErrorParserMessage

use of org.drools.workbench.models.guided.dtree.shared.model.parser.messages.DataTypeConversionErrorParserMessage in project drools-wb by kiegroup.

the class ParserMessagesPopup method getMessage.

private String getMessage(final ParserMessage msg) {
    if (msg instanceof AmbiguousRootParserMessage) {
        final TypeNode tn = model.getRoot();
        final AmbiguousRootParserMessage m = (AmbiguousRootParserMessage) msg;
        return GuidedDecisionTreeConstants.INSTANCE.parserMessageAmbiguousRootParserMessage(tn.getClassName(), m.getClassName());
    } else if (msg instanceof BindingNotFoundParserMessage) {
        final BindingNotFoundParserMessage m = (BindingNotFoundParserMessage) msg;
        return GuidedDecisionTreeConstants.INSTANCE.parserMessageBindingNotFoundParserMessage(m.getBinding());
    } else if (msg instanceof DataTypeConversionErrorParserMessage) {
        final DataTypeConversionErrorParserMessage m = (DataTypeConversionErrorParserMessage) msg;
        return GuidedDecisionTreeConstants.INSTANCE.parserMessageDataTypeConversionErrorParserMessage(m.getValue(), m.getDataTypeClassName());
    } else if (msg instanceof DataTypeNotFoundParserMessage) {
        final DataTypeNotFoundParserMessage m = (DataTypeNotFoundParserMessage) msg;
        return GuidedDecisionTreeConstants.INSTANCE.parserMessageDataTypeNotFoundParserMessage(m.getClassName(), m.getFieldName());
    } else if (msg instanceof DefaultParserMessage) {
        final DefaultParserMessage m = (DefaultParserMessage) msg;
        return GuidedDecisionTreeConstants.INSTANCE.parserMessageDefaultParserMessage(m.getMessage());
    } else if (msg instanceof InvalidRootParserMessage) {
        return GuidedDecisionTreeConstants.INSTANCE.parserMessageInvalidRootParserMessage();
    } else if (msg instanceof UnsupportedFieldConstraintParserMessage) {
        return GuidedDecisionTreeConstants.INSTANCE.parserMessageUnsupportedFieldConstraintParserMessage();
    } else if (msg instanceof UnsupportedFieldConstraintTypeParserMessage) {
        return GuidedDecisionTreeConstants.INSTANCE.parserMessageUnsupportedFieldConstraintTypeParserMessage();
    } else if (msg instanceof UnsupportedFieldNatureTypeParserMessage) {
        return GuidedDecisionTreeConstants.INSTANCE.parserMessageUnsupportedFieldNatureTypeParserMessage();
    } else if (msg instanceof UnsupportedIActionParserMessage) {
        return GuidedDecisionTreeConstants.INSTANCE.parserMessageUnsupportedIActionParserMessage();
    } else if (msg instanceof UnsupportedIPatternParserMessage) {
        return GuidedDecisionTreeConstants.INSTANCE.parserMessageUnsupportedIPatternParserMessage();
    } else {
        return GuidedDecisionTreeConstants.INSTANCE.parserMessageUnknownMessage();
    }
}
Also used : UnsupportedIPatternParserMessage(org.drools.workbench.models.guided.dtree.shared.model.parser.messages.UnsupportedIPatternParserMessage) DataTypeNotFoundParserMessage(org.drools.workbench.models.guided.dtree.shared.model.parser.messages.DataTypeNotFoundParserMessage) BindingNotFoundParserMessage(org.drools.workbench.models.guided.dtree.shared.model.parser.messages.BindingNotFoundParserMessage) InvalidRootParserMessage(org.drools.workbench.models.guided.dtree.shared.model.parser.messages.InvalidRootParserMessage) UnsupportedFieldConstraintParserMessage(org.drools.workbench.models.guided.dtree.shared.model.parser.messages.UnsupportedFieldConstraintParserMessage) UnsupportedFieldNatureTypeParserMessage(org.drools.workbench.models.guided.dtree.shared.model.parser.messages.UnsupportedFieldNatureTypeParserMessage) DataTypeConversionErrorParserMessage(org.drools.workbench.models.guided.dtree.shared.model.parser.messages.DataTypeConversionErrorParserMessage) DefaultParserMessage(org.drools.workbench.models.guided.dtree.shared.model.parser.messages.DefaultParserMessage) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) UnsupportedIActionParserMessage(org.drools.workbench.models.guided.dtree.shared.model.parser.messages.UnsupportedIActionParserMessage) AmbiguousRootParserMessage(org.drools.workbench.models.guided.dtree.shared.model.parser.messages.AmbiguousRootParserMessage) UnsupportedFieldConstraintTypeParserMessage(org.drools.workbench.models.guided.dtree.shared.model.parser.messages.UnsupportedFieldConstraintTypeParserMessage)

Example 5 with DataTypeConversionErrorParserMessage

use of org.drools.workbench.models.guided.dtree.shared.model.parser.messages.DataTypeConversionErrorParserMessage in project drools by kiegroup.

the class GuidedDecisionTreeDRLPersistenceUnmarshallingMessagesTest method testValue_Float.

@Test
public void testValue_Float() throws Exception {
    final String drl = "rule \"test_0\"\n" + "when \n" + "  Person( floatField == \"abc\" )\n" + "then \n" + "end";
    final GuidedDecisionTree expected = new GuidedDecisionTree();
    expected.setTreeName("test");
    final TypeNode type = new TypeNodeImpl("Person");
    expected.setRoot(type);
    addModelField("Person", "this", "Person", DataType.TYPE_THIS);
    addModelField("Person", "floatField", Float.class.getName(), DataType.TYPE_NUMERIC_FLOAT);
    final GuidedDecisionTree model = getAndTestUnmarshalledModel(drl, "test", 1);
    assertEquals(expected.getTreeName(), model.getTreeName());
    assertNull(model.getRoot());
    assertEquals("test_0", model.getParserErrors().get(0).getOriginalRuleName());
    assertEqualsIgnoreWhitespace(drl, model.getParserErrors().get(0).getOriginalDrl());
    assertNotNull(model.getParserErrors().get(0).getMessages());
    assertEquals(1, model.getParserErrors().get(0).getMessages().size());
    assertTrue(model.getParserErrors().get(0).getMessages().get(0) instanceof DataTypeConversionErrorParserMessage);
    final String drl2 = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
    assertEqualsIgnoreWhitespace(drl, drl2);
}
Also used : TypeNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.TypeNodeImpl) DataTypeConversionErrorParserMessage(org.drools.workbench.models.guided.dtree.shared.model.parser.messages.DataTypeConversionErrorParserMessage) GuidedDecisionTree(org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) Test(org.junit.Test)

Aggregations

TypeNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode)11 DataTypeConversionErrorParserMessage (org.drools.workbench.models.guided.dtree.shared.model.parser.messages.DataTypeConversionErrorParserMessage)11 GuidedDecisionTree (org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree)10 TypeNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.TypeNodeImpl)10 Test (org.junit.Test)10 BigInteger (java.math.BigInteger)2 BigDecimal (java.math.BigDecimal)1 Date (java.util.Date)1 AmbiguousRootParserMessage (org.drools.workbench.models.guided.dtree.shared.model.parser.messages.AmbiguousRootParserMessage)1 BindingNotFoundParserMessage (org.drools.workbench.models.guided.dtree.shared.model.parser.messages.BindingNotFoundParserMessage)1 DataTypeNotFoundParserMessage (org.drools.workbench.models.guided.dtree.shared.model.parser.messages.DataTypeNotFoundParserMessage)1 DefaultParserMessage (org.drools.workbench.models.guided.dtree.shared.model.parser.messages.DefaultParserMessage)1 InvalidRootParserMessage (org.drools.workbench.models.guided.dtree.shared.model.parser.messages.InvalidRootParserMessage)1 UnsupportedFieldConstraintParserMessage (org.drools.workbench.models.guided.dtree.shared.model.parser.messages.UnsupportedFieldConstraintParserMessage)1 UnsupportedFieldConstraintTypeParserMessage (org.drools.workbench.models.guided.dtree.shared.model.parser.messages.UnsupportedFieldConstraintTypeParserMessage)1 UnsupportedFieldNatureTypeParserMessage (org.drools.workbench.models.guided.dtree.shared.model.parser.messages.UnsupportedFieldNatureTypeParserMessage)1 UnsupportedIActionParserMessage (org.drools.workbench.models.guided.dtree.shared.model.parser.messages.UnsupportedIActionParserMessage)1 UnsupportedIPatternParserMessage (org.drools.workbench.models.guided.dtree.shared.model.parser.messages.UnsupportedIPatternParserMessage)1