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