use of com.aws.greengrass.deployment.DeviceConfiguration.DEVICE_PARAM_THING_NAME in project aws-greengrass-nucleus by aws-greengrass.
the class ProvisionFromTestPlugin method GIVEN_nucleus_started_with_testProvisioningPlugin_AND_without_config_params_THEN_device_runs_offline_mode.
@Order(1)
@Test
@SuppressWarnings("PMD.AvoidDeeplyNestedIfStmts")
void GIVEN_nucleus_started_with_testProvisioningPlugin_AND_without_config_params_THEN_device_runs_offline_mode() throws Throwable {
URL filepath = getClass().getResource("config_without_test_provisioning_plugin.yaml");
ConfigPlatformResolver.initKernelWithMultiPlatformConfig(kernel, filepath);
CountDownLatch logLatch = new CountDownLatch(2);
CountDownLatch reverseLatch = new CountDownLatch(1);
DeviceConfiguration deviceConfiguration = kernel.getContext().get(DeviceConfiguration.class);
try (AutoCloseable listener = TestUtils.createCloseableLogListener((message) -> {
String messageString = message.getMessage();
if (messageString.contains(IotJobsHelper.DEVICE_OFFLINE_MESSAGE) || messageString.contains(ShadowDeploymentListener.DEVICE_OFFLINE_MESSAGE)) {
logLatch.countDown();
} else if (KernelLifecycle.UPDATED_PROVISIONING_MESSAGE.equals(messageString)) {
deviceConfiguration.onAnyChange((what, node) -> {
if (node != null && WhatHappened.childChanged.equals(what)) {
if (node.childOf(DEVICE_PARAM_THING_NAME) || node.childOf(DEVICE_PARAM_IOT_DATA_ENDPOINT) || node.childOf(DEVICE_PARAM_PRIVATE_KEY_PATH) || node.childOf(DEVICE_PARAM_CERTIFICATE_FILE_PATH) || node.childOf(DEVICE_PARAM_ROOT_CA_PATH) || node.childOf(DEVICE_PARAM_AWS_REGION)) {
reverseLatch.countDown();
}
}
});
logLatch.countDown();
}
})) {
kernel.launch();
assertTrue(logLatch.await(2, TimeUnit.SECONDS));
assertFalse(reverseLatch.await(5, TimeUnit.SECONDS));
}
}
Aggregations