use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project data-prep by Talend.
the class ActionDefinitionDeserializer method deserialize.
@Override
public ActionDefinition deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
final TreeNode treeNode = jp.readValueAsTree();
final TreeNode nodeName = treeNode.get("name");
if (nodeName instanceof TextNode) {
final String name = ((TextNode) nodeName).asText();
return Providers.get(ActionRegistry.class).get(name);
} else {
LOGGER.error("No action available for: {}.", treeNode);
return null;
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project joynr by bmwcarit.
the class ProxyTest method createProxyAndCallAsyncMethodSuccess.
@Test
public void createProxyAndCallAsyncMethodSuccess() throws Exception {
TestInterface proxy = getTestInterfaceProxy();
// when joynrMessageSender1.sendRequest is called, get the replyCaller from the mock dispatcher and call
// messageCallback on it.
Mockito.doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws JsonParseException, JsonMappingException, IOException {
// capture the replyCaller passed into the dispatcher for calling later
ArgumentCaptor<ReplyCaller> replyCallerCaptor = ArgumentCaptor.forClass(ReplyCaller.class);
verify(replyCallerDirectory).addReplyCaller(anyString(), replyCallerCaptor.capture(), Mockito.any(ExpiryDate.class));
String requestReplyId = "createProxyAndCallAsyncMethodSuccess_requestReplyId";
// pass the response to the replyCaller
replyCallerCaptor.getValue().messageCallBack(new Reply(requestReplyId, new TextNode(asyncReplyText)));
return null;
}
}).when(requestReplyManager).sendRequest(Mockito.<String>any(), Mockito.<DiscoveryEntryWithMetaInfo>any(), Mockito.<Request>any(), Mockito.<MessagingQos>any());
final Future<String> future = proxy.asyncMethod(callback);
// the test usually takes only 200 ms, so if we wait 1 sec, something has gone wrong
String reply = future.get(1000);
verify(callback).resolve(asyncReplyText);
Assert.assertEquals(RequestStatusCode.OK, future.getStatus().getCode());
Assert.assertEquals(asyncReplyText, reply);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project template-compiler by Squarespace.
the class UnitsMetricPredicateTest method run.
private void run(CLDR.Locale locale, String template, String expected) throws CodeException {
Context ctx = new Context(new TextNode(""));
ctx.cldrLocale(locale);
CodeMachine sink = machine();
tokenizer(template, sink).consume();
ctx.execute(sink.getCode());
Assert.assertEquals(ctx.buffer().toString(), expected);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project drools by kiegroup.
the class AbstractExpressionEvaluatorTest method getSimpleTypeNodeTextValue.
@Test
public void getSimpleTypeNodeTextValue() {
Assertions.assertThatThrownBy(() -> expressionEvaluatorLocal.getSimpleTypeNodeTextValue(new ArrayNode(factory))).isInstanceOf(IllegalArgumentException.class).hasMessage("Parameter does not contains a simple type");
ObjectNode jsonNode = new ObjectNode(factory);
jsonNode.set(VALUE, new TextNode("testValue"));
assertEquals("testValue", expressionEvaluatorLocal.getSimpleTypeNodeTextValue(jsonNode));
jsonNode.set(VALUE, new IntNode(10));
assertNull(expressionEvaluatorLocal.getSimpleTypeNodeTextValue(jsonNode));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project drools by kiegroup.
the class AbstractExpressionEvaluatorTest method isSimpleTypeNode.
@Test
public void isSimpleTypeNode() {
assertFalse(expressionEvaluatorLocal.isSimpleTypeNode(new ArrayNode(factory)));
ObjectNode jsonNode = new ObjectNode(factory);
jsonNode.set(VALUE, new TextNode("test"));
assertTrue(expressionEvaluatorLocal.isSimpleTypeNode(jsonNode));
jsonNode.set("otherField", new TextNode("testValue"));
assertFalse(expressionEvaluatorLocal.isSimpleTypeNode(jsonNode));
}
Aggregations