Search in sources :

Example 1 with NucleusConfiguration

use of com.aws.greengrass.provisioning.ProvisionConfiguration.NucleusConfiguration in project aws-greengrass-nucleus by aws-greengrass.

the class KernelLifecycleTest method createMockProvisioningConforguration.

private ProvisionConfiguration createMockProvisioningConforguration() {
    ProvisionConfiguration provisionConfiguration = new ProvisionConfiguration();
    NucleusConfiguration nucleusConfiguration = new NucleusConfiguration();
    nucleusConfiguration.setIotRoleAlias(MOCK_IOT_ROLE_ALIAS);
    nucleusConfiguration.setAwsRegion(MOCK_AWS_REGION);
    nucleusConfiguration.setIotDataEndpoint(MOCK_IOT_DATA_ENDPOINT);
    nucleusConfiguration.setIotCredentialsEndpoint(MOCK_IOT_CREDENTIAL_ENDPOINT);
    provisionConfiguration.setNucleusConfiguration(nucleusConfiguration);
    SystemConfiguration systemConfiguration = new SystemConfiguration();
    systemConfiguration.setThingName(MOCK_THING_NAME);
    systemConfiguration.setRootCAPath(MOCK_ROOT_CA_PATH);
    systemConfiguration.setPrivateKeyPath(MOCK_PRIVATE_KEY_PATH);
    systemConfiguration.setCertificateFilePath(MOCK_CERTIFICATE_KEY_PATH);
    provisionConfiguration.setSystemConfiguration(systemConfiguration);
    return provisionConfiguration;
}
Also used : ProvisionConfiguration(com.aws.greengrass.provisioning.ProvisionConfiguration) NucleusConfiguration(com.aws.greengrass.provisioning.ProvisionConfiguration.NucleusConfiguration) SystemConfiguration(com.aws.greengrass.provisioning.ProvisionConfiguration.SystemConfiguration)

Example 2 with NucleusConfiguration

use of com.aws.greengrass.provisioning.ProvisionConfiguration.NucleusConfiguration in project aws-greengrass-nucleus by aws-greengrass.

the class KernelLifecycleTest method GIVEN_kernel_WHEN_launch_with_provisioning_plugin_THEN_configuration_is_updated.

@SuppressWarnings("PMD.CloseResource")
@Test
void GIVEN_kernel_WHEN_launch_with_provisioning_plugin_THEN_configuration_is_updated() throws Exception {
    mockProvisioning();
    ProvisionConfiguration mockProvisionConfiguration = createMockProvisioningConforguration();
    when(mockProvisioningPlugin.updateIdentityConfiguration(any())).thenReturn(mockProvisionConfiguration);
    EZPlugins pluginMock = mock(EZPlugins.class);
    when(mockContext.get(EZPlugins.class)).thenReturn(pluginMock);
    doAnswer((i) -> {
        ImplementingClassMatchProcessor func = i.getArgument(1);
        func.processMatch(mockPluginClass);
        return null;
    }).when(pluginMock).implementing(eq(DeviceIdentityInterface.class), any());
    kernelLifecycle.launch();
    ArgumentCaptor<NucleusConfiguration> nucleusConfigCaptor = ArgumentCaptor.forClass(NucleusConfiguration.class);
    verify(mockProvisioningConfigUpdateHelper, timeout(500).times(1)).updateNucleusConfiguration(nucleusConfigCaptor.capture(), eq(UpdateBehaviorTree.UpdateBehavior.MERGE));
    ArgumentCaptor<SystemConfiguration> systemConfigCaptor = ArgumentCaptor.forClass(SystemConfiguration.class);
    verify(mockProvisioningConfigUpdateHelper, timeout(500).times(1)).updateSystemConfiguration(systemConfigCaptor.capture(), eq(UpdateBehaviorTree.UpdateBehavior.MERGE));
    assertEquals(mockProvisionConfiguration.getNucleusConfiguration(), nucleusConfigCaptor.getValue());
    assertEquals(mockProvisionConfiguration.getSystemConfiguration(), systemConfigCaptor.getValue());
}
Also used : EZPlugins(com.aws.greengrass.dependency.EZPlugins) DeviceIdentityInterface(com.aws.greengrass.provisioning.DeviceIdentityInterface) ProvisionConfiguration(com.aws.greengrass.provisioning.ProvisionConfiguration) NucleusConfiguration(com.aws.greengrass.provisioning.ProvisionConfiguration.NucleusConfiguration) ImplementingClassMatchProcessor(io.github.lukehutch.fastclasspathscanner.matchprocessor.ImplementingClassMatchProcessor) SystemConfiguration(com.aws.greengrass.provisioning.ProvisionConfiguration.SystemConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

ProvisionConfiguration (com.aws.greengrass.provisioning.ProvisionConfiguration)2 NucleusConfiguration (com.aws.greengrass.provisioning.ProvisionConfiguration.NucleusConfiguration)2 SystemConfiguration (com.aws.greengrass.provisioning.ProvisionConfiguration.SystemConfiguration)2 EZPlugins (com.aws.greengrass.dependency.EZPlugins)1 DeviceIdentityInterface (com.aws.greengrass.provisioning.DeviceIdentityInterface)1 ImplementingClassMatchProcessor (io.github.lukehutch.fastclasspathscanner.matchprocessor.ImplementingClassMatchProcessor)1 Test (org.junit.jupiter.api.Test)1