|
|
|
@ -201,12 +201,36 @@ abstract public class BaseEdgeTest extends AbstractControllerTest { |
|
|
|
installation(); |
|
|
|
|
|
|
|
edgeImitator = new EdgeImitator("localhost", 7070, edge.getRoutingKey(), edge.getSecret()); |
|
|
|
edgeImitator.expectMessageAmount(14); |
|
|
|
edgeImitator.expectMessageAmount(15); |
|
|
|
edgeImitator.connect(); |
|
|
|
|
|
|
|
requestEdgeRuleChainMetadata(); |
|
|
|
|
|
|
|
verifyEdgeConnectionAndInitialData(); |
|
|
|
} |
|
|
|
|
|
|
|
private void requestEdgeRuleChainMetadata() throws Exception { |
|
|
|
RuleChainId rootRuleChainId = getEdgeRootRuleChainId(); |
|
|
|
RuleChainMetadataRequestMsg.Builder builder = RuleChainMetadataRequestMsg.newBuilder() |
|
|
|
.setRuleChainIdMSB(rootRuleChainId.getId().getMostSignificantBits()) |
|
|
|
.setRuleChainIdLSB(rootRuleChainId.getId().getLeastSignificantBits()); |
|
|
|
testAutoGeneratedCodeByProtobuf(builder); |
|
|
|
UplinkMsg.Builder uplinkMsgBuilder = UplinkMsg.newBuilder() |
|
|
|
.addRuleChainMetadataRequestMsg(builder.build()); |
|
|
|
edgeImitator.sendUplinkMsg(uplinkMsgBuilder.build()); |
|
|
|
} |
|
|
|
|
|
|
|
private RuleChainId getEdgeRootRuleChainId() throws Exception { |
|
|
|
List<RuleChain> edgeRuleChains = doGetTypedWithPageLink("/api/edge/" + edge.getUuidId() + "/ruleChains?", |
|
|
|
new TypeReference<PageData<RuleChain>>() {}, new PageLink(100)).getData(); |
|
|
|
for (RuleChain edgeRuleChain : edgeRuleChains) { |
|
|
|
if (edgeRuleChain.isRoot()) { |
|
|
|
return edgeRuleChain.getId(); |
|
|
|
} |
|
|
|
} |
|
|
|
throw new RuntimeException("Root rule chain not found"); |
|
|
|
} |
|
|
|
|
|
|
|
@After |
|
|
|
public void afterTest() throws Exception { |
|
|
|
try { |
|
|
|
@ -281,7 +305,7 @@ abstract public class BaseEdgeTest extends AbstractControllerTest { |
|
|
|
DeviceUpdateMsg deviceUpdateMsg = deviceUpdateMsgOpt.get(); |
|
|
|
Assert.assertEquals(UpdateMsgType.ENTITY_CREATED_RPC_MESSAGE, deviceUpdateMsg.getMsgType()); |
|
|
|
UUID deviceUUID = new UUID(deviceUpdateMsg.getIdMSB(), deviceUpdateMsg.getIdLSB()); |
|
|
|
Device device = doGet("/api/device/" + deviceUUID.toString(), Device.class); |
|
|
|
Device device = doGet("/api/device/" + deviceUUID, Device.class); |
|
|
|
Assert.assertNotNull(device); |
|
|
|
List<Device> edgeDevices = doGetTypedWithPageLink("/api/edge/" + edge.getUuidId() + "/devices?", |
|
|
|
new TypeReference<PageData<Device>>() {}, new PageLink(100)).getData(); |
|
|
|
@ -295,7 +319,7 @@ abstract public class BaseEdgeTest extends AbstractControllerTest { |
|
|
|
DeviceProfileUpdateMsg deviceProfileUpdateMsg = deviceProfileUpdateMsgOpt.get(); |
|
|
|
Assert.assertEquals(UpdateMsgType.ENTITY_CREATED_RPC_MESSAGE, deviceProfileUpdateMsg.getMsgType()); |
|
|
|
UUID deviceProfileUUID = new UUID(deviceProfileUpdateMsg.getIdMSB(), deviceProfileUpdateMsg.getIdLSB()); |
|
|
|
DeviceProfile deviceProfile = doGet("/api/deviceProfile/" + deviceProfileUUID.toString(), DeviceProfile.class); |
|
|
|
DeviceProfile deviceProfile = doGet("/api/deviceProfile/" + deviceProfileUUID, DeviceProfile.class); |
|
|
|
Assert.assertNotNull(deviceProfile); |
|
|
|
Assert.assertNotNull(deviceProfile.getProfileData()); |
|
|
|
Assert.assertNotNull(deviceProfile.getProfileData().getAlarms()); |
|
|
|
@ -321,7 +345,7 @@ abstract public class BaseEdgeTest extends AbstractControllerTest { |
|
|
|
RuleChainUpdateMsg ruleChainUpdateMsg = ruleChainUpdateMsgOpt.get(); |
|
|
|
Assert.assertEquals(UpdateMsgType.ENTITY_CREATED_RPC_MESSAGE, ruleChainUpdateMsg.getMsgType()); |
|
|
|
UUID ruleChainUUID = new UUID(ruleChainUpdateMsg.getIdMSB(), ruleChainUpdateMsg.getIdLSB()); |
|
|
|
RuleChain ruleChain = doGet("/api/ruleChain/" + ruleChainUUID.toString(), RuleChain.class); |
|
|
|
RuleChain ruleChain = doGet("/api/ruleChain/" + ruleChainUUID, RuleChain.class); |
|
|
|
Assert.assertNotNull(ruleChain); |
|
|
|
List<RuleChain> edgeRuleChains = doGetTypedWithPageLink("/api/edge/" + edge.getUuidId() + "/ruleChains?", |
|
|
|
new TypeReference<PageData<RuleChain>>() {}, new PageLink(100)).getData(); |
|
|
|
@ -329,6 +353,13 @@ abstract public class BaseEdgeTest extends AbstractControllerTest { |
|
|
|
|
|
|
|
testAutoGeneratedCodeByProtobuf(ruleChainUpdateMsg); |
|
|
|
|
|
|
|
Optional<RuleChainMetadataUpdateMsg> ruleChainMetadataUpdateOpt = edgeImitator.findMessageByType(RuleChainMetadataUpdateMsg.class); |
|
|
|
Assert.assertTrue(ruleChainMetadataUpdateOpt.isPresent()); |
|
|
|
RuleChainMetadataUpdateMsg ruleChainMetadataUpdateMsg = ruleChainMetadataUpdateOpt.get(); |
|
|
|
Assert.assertEquals(UpdateMsgType.ENTITY_CREATED_RPC_MESSAGE, ruleChainMetadataUpdateMsg.getMsgType()); |
|
|
|
Assert.assertEquals(ruleChainUpdateMsg.getIdMSB(), ruleChainMetadataUpdateMsg.getRuleChainIdMSB()); |
|
|
|
Assert.assertEquals(ruleChainUpdateMsg.getIdLSB(), ruleChainMetadataUpdateMsg.getRuleChainIdLSB()); |
|
|
|
|
|
|
|
validateAdminSettings(); |
|
|
|
} |
|
|
|
|
|
|
|
|