use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project drools by kiegroup.
the class BaseExpressionEvaluatorTest method expressionMapVerifyResultTest.
@Test(expected = IllegalArgumentException.class)
public void expressionMapVerifyResultTest() {
String expressionCollectionJsonString = new TextNode("{key_a : 1}").toString();
Map<String, BigDecimal> contextValue = Collections.singletonMap("key_a", BigDecimal.valueOf(1));
assertTrue(expressionEvaluator.verifyResult(expressionCollectionJsonString, contextValue, Map.class).isSuccessful());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project drools by kiegroup.
the class DMNFeelExpressionEvaluatorTest method expressionObjectListTest.
@Test
public void expressionObjectListTest() {
String expressionCollectionJsonString = new TextNode("[{age:10},{name:\"John\"}]").toString();
List<Map<String, Object>> result = (List<Map<String, Object>>) expressionEvaluator.convertResult(expressionCollectionJsonString, List.class.getCanonicalName(), Collections.EMPTY_LIST);
assertEquals(2, result.size());
assertThat(result.get(0)).containsOnly(entry("age", BigDecimal.TEN));
assertThat(result.get(1)).containsOnly(entry("name", "John"));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project drools by kiegroup.
the class DMNFeelExpressionEvaluatorTest method expressionListVerifyResultTest.
@Test
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());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project drools by kiegroup.
the class DMNFeelExpressionEvaluatorTest method expressionMapVerifyResultTest.
@Test
public void expressionMapVerifyResultTest() {
String expressionCollectionJsonString = new TextNode("{key_a : 1}").toString();
Map<String, BigDecimal> contextValue = Collections.singletonMap("key_a", BigDecimal.valueOf(1));
assertTrue(expressionEvaluator.verifyResult(expressionCollectionJsonString, contextValue, Map.class).isSuccessful());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project XRTB by benmfaul.
the class Node method iterateObject.
/**
* Iterate over a Jackson object and create a Java Map.
*
* @param node.
* ObjectNode. The Jackson node to set up as a Map.
* @return Map. Returns the Map implementation of the Jackson node.
*/
Map iterateObject(ObjectNode node) {
Map m = new HashMap();
Iterator it = node.iterator();
it = node.fieldNames();
while (it.hasNext()) {
String key = (String) it.next();
Object s = node.get(key);
if (s instanceof TextNode) {
TextNode t = (TextNode) s;
m.put(key, t.textValue());
} else if (s instanceof DoubleNode) {
DoubleNode t = (DoubleNode) s;
m.put(key, t.numberValue());
} else if (s instanceof IntNode) {
IntNode t = (IntNode) s;
m.put(key, t.numberValue());
} else
// indeterminate, need to traverse
m.put(key, s);
}
return m;
}
Aggregations