Remove unnecessary originator locality check
This commit is contained in:
parent
5e846116a8
commit
c65a9c2e0d
@ -81,14 +81,7 @@ public class TbDeviceStateNode implements TbNode {
|
||||
|
||||
@Override
|
||||
public void onMsg(TbContext ctx, TbMsg msg) {
|
||||
var originator = msg.getOriginator();
|
||||
if (!ctx.isLocalEntity(originator)) {
|
||||
log.warn("[{}][{}] Received message from non-local entity [{}]!",
|
||||
ctx.getTenantId().getId(), ctx.getSelfId().getId(), originator.getId());
|
||||
ctx.ack(msg);
|
||||
return;
|
||||
}
|
||||
if (!EntityType.DEVICE.equals(originator.getEntityType())) {
|
||||
if (!EntityType.DEVICE.equals(msg.getOriginator().getEntityType())) {
|
||||
ctx.tellSuccess(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -132,32 +132,15 @@ public class TbDeviceStateNodeTest {
|
||||
// GIVEN
|
||||
var asset = new AssetId(UUID.randomUUID());
|
||||
var msg = TbMsg.newMsg(TbMsgType.ENTITY_CREATED, asset, TbMsgMetaData.EMPTY, TbMsg.EMPTY_JSON_OBJECT);
|
||||
given(ctxMock.isLocalEntity(asset)).willReturn(true);
|
||||
|
||||
// WHEN
|
||||
node.onMsg(ctxMock, msg);
|
||||
|
||||
// THEN
|
||||
then(ctxMock).should().isLocalEntity(asset);
|
||||
then(ctxMock).should().tellSuccess(msg);
|
||||
then(ctxMock).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenNonLocalOriginator_whenOnMsg_thenTellsSuccessAndNoActivityActionsTriggered() {
|
||||
// GIVEN
|
||||
given(ctxMock.isLocalEntity(msg.getOriginator())).willReturn(false);
|
||||
given(ctxMock.getSelfId()).willReturn(new RuleNodeId(UUID.randomUUID()));
|
||||
given(ctxMock.getTenantId()).willReturn(TENANT_ID);
|
||||
|
||||
// WHEN
|
||||
node.onMsg(ctxMock, msg);
|
||||
|
||||
// THEN
|
||||
then(ctxMock).should().ack(msg);
|
||||
then(ctxMock).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideSupportedEventsAndExpectedMessages")
|
||||
public void givenSupportedEvent_whenOnMsg_thenCorrectMsgIsSent(TbMsgType event, TransportProtos.ToCoreMsg expectedToCoreMsg) {
|
||||
@ -171,7 +154,6 @@ public class TbDeviceStateNodeTest {
|
||||
}
|
||||
given(ctxMock.getTenantId()).willReturn(TENANT_ID);
|
||||
given(ctxMock.getClusterService()).willReturn(tbClusterServiceMock);
|
||||
given(ctxMock.isLocalEntity(msg.getOriginator())).willReturn(true);
|
||||
|
||||
// WHEN
|
||||
node.onMsg(ctxMock, msg);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user