Merge pull request #9712 from volodymyr-babak/edge/relation-request-fix-recusrive
Edge Requests Service - fetch only first level of relation from cloud…
This commit is contained in:
commit
848191efb5
@ -294,7 +294,7 @@ public class DefaultEdgeRequestsService implements EdgeRequestsService {
|
|||||||
private ListenableFuture<List<EntityRelation>> findRelationByQuery(TenantId tenantId, Edge edge,
|
private ListenableFuture<List<EntityRelation>> findRelationByQuery(TenantId tenantId, Edge edge,
|
||||||
EntityId entityId, EntitySearchDirection direction) {
|
EntityId entityId, EntitySearchDirection direction) {
|
||||||
EntityRelationsQuery query = new EntityRelationsQuery();
|
EntityRelationsQuery query = new EntityRelationsQuery();
|
||||||
query.setParameters(new RelationsSearchParameters(entityId, direction, -1, false));
|
query.setParameters(new RelationsSearchParameters(entityId, direction, 1, false));
|
||||||
return relationService.findByQuery(tenantId, query);
|
return relationService.findByQuery(tenantId, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -129,14 +129,24 @@ public class RelationEdgeTest extends AbstractEdgeTest {
|
|||||||
Device device = findDeviceByName("Edge Device 1");
|
Device device = findDeviceByName("Edge Device 1");
|
||||||
Asset asset = findAssetByName("Edge Asset 1");
|
Asset asset = findAssetByName("Edge Asset 1");
|
||||||
|
|
||||||
EntityRelation relation = new EntityRelation();
|
EntityRelation deviceToAssetRelation = new EntityRelation();
|
||||||
relation.setType("test");
|
deviceToAssetRelation.setType("test");
|
||||||
relation.setFrom(device.getId());
|
deviceToAssetRelation.setFrom(device.getId());
|
||||||
relation.setTo(asset.getId());
|
deviceToAssetRelation.setTo(asset.getId());
|
||||||
relation.setTypeGroup(RelationTypeGroup.COMMON);
|
deviceToAssetRelation.setTypeGroup(RelationTypeGroup.COMMON);
|
||||||
|
|
||||||
edgeImitator.expectMessageAmount(1);
|
edgeImitator.expectMessageAmount(1);
|
||||||
doPost("/api/relation", relation);
|
doPost("/api/relation", deviceToAssetRelation);
|
||||||
|
Assert.assertTrue(edgeImitator.waitForMessages());
|
||||||
|
|
||||||
|
EntityRelation assetToTenantRelation = new EntityRelation();
|
||||||
|
assetToTenantRelation.setType("test");
|
||||||
|
assetToTenantRelation.setFrom(asset.getId());
|
||||||
|
assetToTenantRelation.setTo(tenantId);
|
||||||
|
assetToTenantRelation.setTypeGroup(RelationTypeGroup.COMMON);
|
||||||
|
|
||||||
|
edgeImitator.expectMessageAmount(1);
|
||||||
|
doPost("/api/relation", assetToTenantRelation);
|
||||||
Assert.assertTrue(edgeImitator.waitForMessages());
|
Assert.assertTrue(edgeImitator.waitForMessages());
|
||||||
|
|
||||||
UplinkMsg.Builder uplinkMsgBuilder = UplinkMsg.newBuilder();
|
UplinkMsg.Builder uplinkMsgBuilder = UplinkMsg.newBuilder();
|
||||||
@ -159,16 +169,16 @@ public class RelationEdgeTest extends AbstractEdgeTest {
|
|||||||
Assert.assertTrue(latestMessage instanceof RelationUpdateMsg);
|
Assert.assertTrue(latestMessage instanceof RelationUpdateMsg);
|
||||||
RelationUpdateMsg relationUpdateMsg = (RelationUpdateMsg) latestMessage;
|
RelationUpdateMsg relationUpdateMsg = (RelationUpdateMsg) latestMessage;
|
||||||
Assert.assertEquals(UpdateMsgType.ENTITY_CREATED_RPC_MESSAGE, relationUpdateMsg.getMsgType());
|
Assert.assertEquals(UpdateMsgType.ENTITY_CREATED_RPC_MESSAGE, relationUpdateMsg.getMsgType());
|
||||||
Assert.assertEquals(relation.getType(), relationUpdateMsg.getType());
|
Assert.assertEquals(deviceToAssetRelation.getType(), relationUpdateMsg.getType());
|
||||||
|
|
||||||
UUID fromUUID = new UUID(relationUpdateMsg.getFromIdMSB(), relationUpdateMsg.getFromIdLSB());
|
UUID fromUUID = new UUID(relationUpdateMsg.getFromIdMSB(), relationUpdateMsg.getFromIdLSB());
|
||||||
EntityId fromEntityId = EntityIdFactory.getByTypeAndUuid(relationUpdateMsg.getFromEntityType(), fromUUID);
|
EntityId fromEntityId = EntityIdFactory.getByTypeAndUuid(relationUpdateMsg.getFromEntityType(), fromUUID);
|
||||||
Assert.assertEquals(relation.getFrom(), fromEntityId);
|
Assert.assertEquals(deviceToAssetRelation.getFrom(), fromEntityId);
|
||||||
|
|
||||||
UUID toUUID = new UUID(relationUpdateMsg.getToIdMSB(), relationUpdateMsg.getToIdLSB());
|
UUID toUUID = new UUID(relationUpdateMsg.getToIdMSB(), relationUpdateMsg.getToIdLSB());
|
||||||
EntityId toEntityId = EntityIdFactory.getByTypeAndUuid(relationUpdateMsg.getToEntityType(), toUUID);
|
EntityId toEntityId = EntityIdFactory.getByTypeAndUuid(relationUpdateMsg.getToEntityType(), toUUID);
|
||||||
Assert.assertEquals(relation.getTo(), toEntityId);
|
Assert.assertEquals(deviceToAssetRelation.getTo(), toEntityId);
|
||||||
|
|
||||||
Assert.assertEquals(relation.getTypeGroup().name(), relationUpdateMsg.getTypeGroup());
|
Assert.assertEquals(deviceToAssetRelation.getTypeGroup().name(), relationUpdateMsg.getTypeGroup());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user