Node nodeDetails
This commit is contained in:
parent
ef28b19f80
commit
0e9dc6a19e
@ -36,7 +36,8 @@ import java.util.stream.Collectors;
|
||||
name = "delete attributes",
|
||||
configClazz = TbMsgDeleteAttributesConfiguration.class,
|
||||
nodeDescription = "Delete attributes for Message Originator.",
|
||||
nodeDetails = "Allowed scope parameter values: <b>SERVER/CLIENT/SHARED</b>. Will try to remove attributes by keys from the list",
|
||||
nodeDetails = "Attempt to remove attributes by selected keys. If msg originator doesn't have an attribute with " +
|
||||
" a key selected in the configuration, it will be ignored.",
|
||||
uiResources = {"static/rulenode/rulenode-core-config.js"},
|
||||
configDirective = "tbActionNodeDeleteAttributesConfig",
|
||||
icon = "remove_circle"
|
||||
@ -58,7 +59,7 @@ public class TbMsgDeleteAttributes implements TbNode {
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.collect(Collectors.toList());
|
||||
if (keysToDelete.isEmpty()) {
|
||||
ctx.tellFailure(msg, new RuntimeException("Selected keys patterns have invalid values!"));
|
||||
ctx.tellSuccess(msg);
|
||||
} else {
|
||||
ctx.getTelemetryService().deleteAndNotify(ctx.getTenantId(), msg.getOriginator(), config.getScope(), keysToDelete, new TelemetryNodeCallback(ctx, msg));
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ public class TbMsgDeleteAttributesTest {
|
||||
callback = mock(TbMsgCallback.class);
|
||||
ctx = mock(TbContext.class);
|
||||
config = new TbMsgDeleteAttributesConfiguration().defaultConfiguration();
|
||||
config.setKeys(List.of("${TestAttribute_1}", "$[TestAttribute_2]", "$[TestAttribute_3]"));
|
||||
config.setKeys(List.of("${TestAttribute_1}", "$[TestAttribute_2]", "$[TestAttribute_3]", "TestAttribute_4"));
|
||||
nodeConfiguration = new TbNodeConfiguration(mapper.valueToTree(config));
|
||||
node = spy(new TbMsgDeleteAttributes());
|
||||
node.init(ctx, nodeConfiguration);
|
||||
@ -116,25 +116,4 @@ public class TbMsgDeleteAttributesTest {
|
||||
verify(ctx, never()).tellFailure(any(), any());
|
||||
verify(telemetryService, times(1)).deleteAndNotify(any(), any(), anyString(), anyList(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void giveInvalidScope_whenOnMsg_thenTellFailure() throws Exception {
|
||||
final TbMsgMetaData metaData = new TbMsgMetaData();
|
||||
final String data = "{\"TestAttribute_1\": \"\", \"TestAttribute_2\": \"\"}";
|
||||
|
||||
config.setKeys(List.of("$[TestAttribute_1]", "$[TestAttribute_2]"));
|
||||
nodeConfiguration = new TbNodeConfiguration(mapper.valueToTree(config));
|
||||
node.init(ctx, nodeConfiguration);
|
||||
|
||||
TbMsg msg = TbMsg.newMsg("POST_ATTRIBUTES_REQUEST", deviceId, metaData, data, callback);
|
||||
node.onMsg(ctx, msg);
|
||||
|
||||
ArgumentCaptor<TbMsg> newMsgCaptor = ArgumentCaptor.forClass(TbMsg.class);
|
||||
ArgumentCaptor<Exception> exceptionCaptor = ArgumentCaptor.forClass(Exception.class);
|
||||
verify(ctx, never()).tellSuccess(any());
|
||||
verify(ctx, times(1)).tellFailure(newMsgCaptor.capture(), exceptionCaptor.capture());
|
||||
|
||||
assertThat(newMsgCaptor.getValue()).isSameAs(msg);
|
||||
assertThat(exceptionCaptor.getValue()).isInstanceOf(RuntimeException.class);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user