add node details
This commit is contained in:
parent
84c91a17cb
commit
57a913aa00
@ -39,9 +39,9 @@ import java.util.concurrent.ExecutionException;
|
|||||||
name = "split array msg",
|
name = "split array msg",
|
||||||
configClazz = EmptyNodeConfiguration.class,
|
configClazz = EmptyNodeConfiguration.class,
|
||||||
nodeDescription = "Split array message into several msgs",
|
nodeDescription = "Split array message into several msgs",
|
||||||
nodeDetails = "Split the array fetched from the msg body. Returns inner objects of the extracted array as "
|
nodeDetails = "Split the array fetched from the msg body. If the msg data is not a JSON object returns the "
|
||||||
+ "separate messages via <code>Success</code> chain. If msg data is not a JSON array, "
|
+ "incoming message as outbound message with <code>Failure</code> chain, otherwise returns "
|
||||||
+ "the incoming message is returned",
|
+ "inner objects of the extracted array as separate messages via <code>Success</code> chain.",
|
||||||
icon = "content_copy",
|
icon = "content_copy",
|
||||||
configDirective = "tbNodeEmptyConfig"
|
configDirective = "tbNodeEmptyConfig"
|
||||||
)
|
)
|
||||||
@ -72,7 +72,7 @@ public class TbSplitArrayMsgNode implements TbNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx.tellSuccess(msg);
|
ctx.tellFailure(msg, new RuntimeException("Msg data is not a JSON Array!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -94,15 +94,18 @@ public class TbSplitArrayMsgNodeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenNoArrayMsg_whenOnMsg_thenVerifyOutput() throws Exception {
|
void givenNoArrayMsg_whenOnMsg_thenFailure() throws Exception {
|
||||||
String data = "{\"Attribute_1\":22.5,\"Attribute_2\":10.3}";
|
String data = "{\"Attribute_1\":22.5,\"Attribute_2\":10.3}";
|
||||||
JsonNode dataNode = JacksonUtil.toJsonNode(data);
|
JsonNode dataNode = JacksonUtil.toJsonNode(data);
|
||||||
TbMsg msg = getTbMsg(deviceId, dataNode.toString());
|
TbMsg msg = getTbMsg(deviceId, dataNode.toString());
|
||||||
node.onMsg(ctx, msg);
|
node.onMsg(ctx, msg);
|
||||||
|
|
||||||
ArgumentCaptor<TbMsg> newMsgCaptor = ArgumentCaptor.forClass(TbMsg.class);
|
ArgumentCaptor<TbMsg> newMsgCaptor = ArgumentCaptor.forClass(TbMsg.class);
|
||||||
verify(ctx, times(1)).tellSuccess(newMsgCaptor.capture());
|
ArgumentCaptor<Exception> exceptionCaptor = ArgumentCaptor.forClass(Exception.class);
|
||||||
verify(ctx, never()).tellFailure(any(), any());
|
verify(ctx, never()).tellSuccess(any());
|
||||||
|
verify(ctx, times(1)).tellFailure(newMsgCaptor.capture(), exceptionCaptor.capture());
|
||||||
|
|
||||||
|
assertThat(exceptionCaptor.getValue()).isInstanceOf(RuntimeException.class);
|
||||||
|
|
||||||
TbMsg newMsg = newMsgCaptor.getValue();
|
TbMsg newMsg = newMsgCaptor.getValue();
|
||||||
assertThat(newMsg).isNotNull();
|
assertThat(newMsg).isNotNull();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user