Added test to verify that regular messages are processed by edge service after sync complete
This commit is contained in:
parent
4890976b9f
commit
e6ec672e50
@ -201,12 +201,36 @@ abstract public class BaseEdgeTest extends AbstractControllerTest {
|
|||||||
installation();
|
installation();
|
||||||
|
|
||||||
edgeImitator = new EdgeImitator("localhost", 7070, edge.getRoutingKey(), edge.getSecret());
|
edgeImitator = new EdgeImitator("localhost", 7070, edge.getRoutingKey(), edge.getSecret());
|
||||||
edgeImitator.expectMessageAmount(14);
|
edgeImitator.expectMessageAmount(15);
|
||||||
edgeImitator.connect();
|
edgeImitator.connect();
|
||||||
|
|
||||||
|
requestEdgeRuleChainMetadata();
|
||||||
|
|
||||||
verifyEdgeConnectionAndInitialData();
|
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
|
@After
|
||||||
public void afterTest() throws Exception {
|
public void afterTest() throws Exception {
|
||||||
try {
|
try {
|
||||||
@ -281,7 +305,7 @@ abstract public class BaseEdgeTest extends AbstractControllerTest {
|
|||||||
DeviceUpdateMsg deviceUpdateMsg = deviceUpdateMsgOpt.get();
|
DeviceUpdateMsg deviceUpdateMsg = deviceUpdateMsgOpt.get();
|
||||||
Assert.assertEquals(UpdateMsgType.ENTITY_CREATED_RPC_MESSAGE, deviceUpdateMsg.getMsgType());
|
Assert.assertEquals(UpdateMsgType.ENTITY_CREATED_RPC_MESSAGE, deviceUpdateMsg.getMsgType());
|
||||||
UUID deviceUUID = new UUID(deviceUpdateMsg.getIdMSB(), deviceUpdateMsg.getIdLSB());
|
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);
|
Assert.assertNotNull(device);
|
||||||
List<Device> edgeDevices = doGetTypedWithPageLink("/api/edge/" + edge.getUuidId() + "/devices?",
|
List<Device> edgeDevices = doGetTypedWithPageLink("/api/edge/" + edge.getUuidId() + "/devices?",
|
||||||
new TypeReference<PageData<Device>>() {}, new PageLink(100)).getData();
|
new TypeReference<PageData<Device>>() {}, new PageLink(100)).getData();
|
||||||
@ -295,7 +319,7 @@ abstract public class BaseEdgeTest extends AbstractControllerTest {
|
|||||||
DeviceProfileUpdateMsg deviceProfileUpdateMsg = deviceProfileUpdateMsgOpt.get();
|
DeviceProfileUpdateMsg deviceProfileUpdateMsg = deviceProfileUpdateMsgOpt.get();
|
||||||
Assert.assertEquals(UpdateMsgType.ENTITY_CREATED_RPC_MESSAGE, deviceProfileUpdateMsg.getMsgType());
|
Assert.assertEquals(UpdateMsgType.ENTITY_CREATED_RPC_MESSAGE, deviceProfileUpdateMsg.getMsgType());
|
||||||
UUID deviceProfileUUID = new UUID(deviceProfileUpdateMsg.getIdMSB(), deviceProfileUpdateMsg.getIdLSB());
|
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);
|
||||||
Assert.assertNotNull(deviceProfile.getProfileData());
|
Assert.assertNotNull(deviceProfile.getProfileData());
|
||||||
Assert.assertNotNull(deviceProfile.getProfileData().getAlarms());
|
Assert.assertNotNull(deviceProfile.getProfileData().getAlarms());
|
||||||
@ -321,7 +345,7 @@ abstract public class BaseEdgeTest extends AbstractControllerTest {
|
|||||||
RuleChainUpdateMsg ruleChainUpdateMsg = ruleChainUpdateMsgOpt.get();
|
RuleChainUpdateMsg ruleChainUpdateMsg = ruleChainUpdateMsgOpt.get();
|
||||||
Assert.assertEquals(UpdateMsgType.ENTITY_CREATED_RPC_MESSAGE, ruleChainUpdateMsg.getMsgType());
|
Assert.assertEquals(UpdateMsgType.ENTITY_CREATED_RPC_MESSAGE, ruleChainUpdateMsg.getMsgType());
|
||||||
UUID ruleChainUUID = new UUID(ruleChainUpdateMsg.getIdMSB(), ruleChainUpdateMsg.getIdLSB());
|
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);
|
Assert.assertNotNull(ruleChain);
|
||||||
List<RuleChain> edgeRuleChains = doGetTypedWithPageLink("/api/edge/" + edge.getUuidId() + "/ruleChains?",
|
List<RuleChain> edgeRuleChains = doGetTypedWithPageLink("/api/edge/" + edge.getUuidId() + "/ruleChains?",
|
||||||
new TypeReference<PageData<RuleChain>>() {}, new PageLink(100)).getData();
|
new TypeReference<PageData<RuleChain>>() {}, new PageLink(100)).getData();
|
||||||
@ -329,6 +353,13 @@ abstract public class BaseEdgeTest extends AbstractControllerTest {
|
|||||||
|
|
||||||
testAutoGeneratedCodeByProtobuf(ruleChainUpdateMsg);
|
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();
|
validateAdminSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user