Search in sources :

Example 76 with TextNode

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;
    }
}
Also used : TreeNode(com.fasterxml.jackson.core.TreeNode) TextNode(com.fasterxml.jackson.databind.node.TextNode) ActionRegistry(org.talend.dataprep.transformation.pipeline.ActionRegistry)

Example 77 with TextNode

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);
}
Also used : ArgumentCaptor(org.mockito.ArgumentCaptor) TextNode(com.fasterxml.jackson.databind.node.TextNode) IOException(java.io.IOException) Matchers.anyString(org.mockito.Matchers.anyString) JsonParseException(com.fasterxml.jackson.core.JsonParseException) ReplyCaller(io.joynr.dispatching.rpc.ReplyCaller) SynchronizedReplyCaller(io.joynr.dispatching.rpc.SynchronizedReplyCaller) InvocationOnMock(org.mockito.invocation.InvocationOnMock) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) Reply(joynr.Reply) Test(org.junit.Test)

Example 78 with TextNode

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);
}
Also used : Context(com.squarespace.template.Context) CodeMachine(com.squarespace.template.CodeMachine) TextNode(com.fasterxml.jackson.databind.node.TextNode)

Example 79 with TextNode

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));
}
Also used : IntNode(com.fasterxml.jackson.databind.node.IntNode) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) TextNode(com.fasterxml.jackson.databind.node.TextNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Test(org.junit.Test)

Example 80 with TextNode

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));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) TextNode(com.fasterxml.jackson.databind.node.TextNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) 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