Search in sources :

Example 81 with TextNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project drools by kiegroup.

the class AbstractExpressionEvaluatorTest method isObjectEmpty.

@Test
public void isObjectEmpty() {
    ObjectNode json = new ObjectNode(factory);
    assertTrue(expressionEvaluatorLocal.isObjectEmpty(json));
    ObjectNode nestedNode = new ObjectNode(factory);
    json.set("emptyField", nestedNode);
    assertTrue(expressionEvaluatorLocal.isObjectEmpty(json));
    nestedNode.set("notEmptyField", new TextNode("text"));
    assertFalse(expressionEvaluatorLocal.isObjectEmpty(json));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) TextNode(com.fasterxml.jackson.databind.node.TextNode) Test(org.junit.Test)

Example 82 with TextNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project drools by kiegroup.

the class ExpressionEvaluatorFactoryTest method getOrCreate.

@Test
public void getOrCreate() {
    FactMappingValue simpleFMV = new FactMappingValue(FactIdentifier.INDEX, ExpressionIdentifier.INDEX, "10");
    FactMappingValue objectFMV = new FactMappingValue(FactIdentifier.INDEX, ExpressionIdentifier.INDEX, "10");
    FactMappingValue mvelFMV = new FactMappingValue(FactIdentifier.INDEX, ExpressionIdentifier.INDEX, MVEL_ESCAPE_SYMBOL + " 10");
    FactMappingValue mvelWithSpacesFMV = new FactMappingValue(FactIdentifier.INDEX, ExpressionIdentifier.INDEX, "     " + MVEL_ESCAPE_SYMBOL + " 10");
    FactMappingValue mvelCollectionExpressionFMV = new FactMappingValue(FactIdentifier.INDEX, ExpressionIdentifier.INDEX, new TextNode(MVEL_ESCAPE_SYMBOL + " 10").textValue());
    FactMappingValue mvelCollectionExpressionWithSpacesFMV = new FactMappingValue(FactIdentifier.INDEX, ExpressionIdentifier.INDEX, new TextNode("     " + MVEL_ESCAPE_SYMBOL + " 10").textValue());
    FactMappingValue mvelCollectionExpressionWitoutMVELEscapeSymbolFMV = new FactMappingValue(FactIdentifier.INDEX, ExpressionIdentifier.INDEX, new TextNode(" 10").textValue());
    ExpressionEvaluatorFactory ruleEvaluatorFactory = ExpressionEvaluatorFactory.create(classLoader, ScenarioSimulationModel.Type.RULE);
    ExpressionEvaluatorFactory dmnEvaluatorFactory = ExpressionEvaluatorFactory.create(classLoader, ScenarioSimulationModel.Type.DMN);
    assertTrue(ruleEvaluatorFactory.getOrCreate(simpleFMV) instanceof BaseExpressionEvaluator);
    assertTrue(ruleEvaluatorFactory.getOrCreate(objectFMV) instanceof BaseExpressionEvaluator);
    assertTrue(ruleEvaluatorFactory.getOrCreate(mvelFMV) instanceof MVELExpressionEvaluator);
    assertTrue(ruleEvaluatorFactory.getOrCreate(mvelWithSpacesFMV) instanceof MVELExpressionEvaluator);
    assertTrue(ruleEvaluatorFactory.getOrCreate(mvelCollectionExpressionFMV) instanceof MVELExpressionEvaluator);
    assertTrue(ruleEvaluatorFactory.getOrCreate(mvelCollectionExpressionWithSpacesFMV) instanceof MVELExpressionEvaluator);
    assertTrue(ruleEvaluatorFactory.getOrCreate(mvelCollectionExpressionWitoutMVELEscapeSymbolFMV) instanceof BaseExpressionEvaluator);
    assertTrue(dmnEvaluatorFactory.getOrCreate(simpleFMV) instanceof DMNFeelExpressionEvaluator);
    assertTrue(dmnEvaluatorFactory.getOrCreate(objectFMV) instanceof DMNFeelExpressionEvaluator);
    assertTrue(dmnEvaluatorFactory.getOrCreate(mvelFMV) instanceof DMNFeelExpressionEvaluator);
    assertTrue(dmnEvaluatorFactory.getOrCreate(mvelWithSpacesFMV) instanceof DMNFeelExpressionEvaluator);
    assertTrue(dmnEvaluatorFactory.getOrCreate(mvelCollectionExpressionFMV) instanceof DMNFeelExpressionEvaluator);
    assertTrue(dmnEvaluatorFactory.getOrCreate(mvelCollectionExpressionWithSpacesFMV) instanceof DMNFeelExpressionEvaluator);
    assertTrue(dmnEvaluatorFactory.getOrCreate(mvelCollectionExpressionWitoutMVELEscapeSymbolFMV) instanceof DMNFeelExpressionEvaluator);
}
Also used : FactMappingValue(org.drools.scenariosimulation.api.model.FactMappingValue) TextNode(com.fasterxml.jackson.databind.node.TextNode) Test(org.junit.Test)

Example 83 with TextNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project drools by kiegroup.

the class DMNFeelExpressionEvaluatorTest method expressionMapTest_Wrong.

@Test(expected = IllegalArgumentException.class)
public void expressionMapTest_Wrong() {
    String expressionCollectionJsonString = new TextNode(": 5 y : 3 }").toString();
    expressionEvaluator.convertResult(expressionCollectionJsonString, Map.class.getCanonicalName(), Collections.EMPTY_LIST);
}
Also used : TextNode(com.fasterxml.jackson.databind.node.TextNode) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Test(org.junit.Test)

Example 84 with TextNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project drools by kiegroup.

the class MVELExpressionEvaluatorTest method cleanExpression.

@Test
public void cleanExpression() {
    assertEquals("test", evaluator.cleanExpression(MVEL_ESCAPE_SYMBOL + "test"));
    assertEquals(" test", evaluator.cleanExpression(MVEL_ESCAPE_SYMBOL + " test"));
    assertEquals(" " + MVEL_ESCAPE_SYMBOL + " test", evaluator.cleanExpression(MVEL_ESCAPE_SYMBOL + " " + MVEL_ESCAPE_SYMBOL + " test"));
    assertEquals("test", evaluator.cleanExpression(new TextNode(MVEL_ESCAPE_SYMBOL + "test").toString()));
    assertEquals(" test", evaluator.cleanExpression(new TextNode(MVEL_ESCAPE_SYMBOL + " test").toString()));
    assertEquals(" " + MVEL_ESCAPE_SYMBOL + " test", evaluator.cleanExpression(new TextNode(MVEL_ESCAPE_SYMBOL + " " + MVEL_ESCAPE_SYMBOL + " test").toString()));
    assertThatThrownBy(() -> evaluator.cleanExpression("test")).isInstanceOf(IllegalArgumentException.class).hasMessageStartingWith("Malformed MVEL expression");
    assertThatThrownBy(() -> evaluator.cleanExpression(new TextNode("test").toString())).isInstanceOf(IllegalArgumentException.class).hasMessageStartingWith("Malformed MVEL expression");
}
Also used : TextNode(com.fasterxml.jackson.databind.node.TextNode) Test(org.junit.Test)

Example 85 with TextNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project drools by kiegroup.

the class BaseExpressionEvaluatorTest method expressionListVerifyResultTest.

@Test(expected = IllegalArgumentException.class)
public void expressionListVerifyResultTest() {
    String expressionCollectionJsonString = new TextNode("10").toString();
    List<BigDecimal> contextValue = Collections.singletonList(BigDecimal.valueOf(10));
    assertTrue(expressionEvaluator.verifyResult(expressionCollectionJsonString, contextValue, List.class).isSuccessful());
}
Also used : TextNode(com.fasterxml.jackson.databind.node.TextNode) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

TextNode (com.fasterxml.jackson.databind.node.TextNode)140 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)48 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)37 Test (org.junit.Test)37 JsonNode (com.fasterxml.jackson.databind.JsonNode)34 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)16 IntNode (com.fasterxml.jackson.databind.node.IntNode)16 ArrayList (java.util.ArrayList)16 Test (org.junit.jupiter.api.Test)15 MockScheduler (org.apache.kafka.common.utils.MockScheduler)14 MockTime (org.apache.kafka.common.utils.MockTime)14 ExpectedTaskBuilder (org.apache.kafka.trogdor.common.ExpectedTasks.ExpectedTaskBuilder)14 ExpectedTasks (org.apache.kafka.trogdor.common.ExpectedTasks)13 DoubleNode (com.fasterxml.jackson.databind.node.DoubleNode)12 WorkerRunning (org.apache.kafka.trogdor.rest.WorkerRunning)12 TreeNode (com.fasterxml.jackson.core.TreeNode)11 HashMap (java.util.HashMap)11 List (java.util.List)11 NoOpTaskSpec (org.apache.kafka.trogdor.task.NoOpTaskSpec)11 Map (java.util.Map)10