Tell failure if originator is not a device
This commit is contained in:
parent
f5a7fe73ab
commit
094cff6174
@ -98,8 +98,11 @@ public class TbDeviceStateNode implements TbNode {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityType.DEVICE.equals(msg.getOriginator().getEntityType())) {
|
||||
ctx.tellSuccess(msg);
|
||||
EntityType originatorEntityType = msg.getOriginator().getEntityType();
|
||||
if (!EntityType.DEVICE.equals(originatorEntityType)) {
|
||||
ctx.tellFailure(msg, new IllegalArgumentException(
|
||||
"Unsupported originator entity type: [" + originatorEntityType + "]. Only DEVICE entity type is supported."
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -263,7 +263,12 @@ public class TbDeviceStateNodeTest {
|
||||
node.onMsg(ctxMock, msg);
|
||||
|
||||
// THEN
|
||||
then(ctxMock).should().tellSuccess(msg);
|
||||
var exceptionCaptor = ArgumentCaptor.forClass(Exception.class);
|
||||
then(ctxMock).should().tellFailure(eq(msg), exceptionCaptor.capture());
|
||||
assertThat(exceptionCaptor.getValue())
|
||||
.isInstanceOf(IllegalArgumentException.class)
|
||||
.hasMessage("Unsupported originator entity type: [" + unsupportedType + "]. Only DEVICE entity type is supported.");
|
||||
|
||||
then(ctxMock).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user