Search in sources :

Example 26 with Context

use of com.aws.greengrass.dependency.Context in project aws-greengrass-nucleus by aws-greengrass.

the class MergeTest method testSomeMethod.

@Test
void testSomeMethod() throws Exception {
    try (Context context = new Context()) {
        Configuration c = new Configuration(context);
        c.read(Kernel.class.getResource("config.yaml"), false);
        Configuration b = new Configuration(context).copyFrom(c);
        assertEquals(c.getRoot(), b.getRoot());
    }
}
Also used : Context(com.aws.greengrass.dependency.Context) Configuration(com.aws.greengrass.config.Configuration) Test(org.junit.jupiter.api.Test)

Example 27 with Context

use of com.aws.greengrass.dependency.Context in project aws-greengrass-nucleus by aws-greengrass.

the class ShellRunnerTest method beforeEach.

@BeforeEach
void beforeEach() throws IOException {
    context = new Context();
    Topics config = initializeMockedConfig();
    Topics servicePrivateTopics = mock(Topics.class);
    Topic mockTopic = mock(Topic.class);
    when(config.lookupTopics(GreengrassService.PRIVATE_STORE_NAMESPACE_TOPIC)).thenReturn(servicePrivateTopics);
    when(servicePrivateTopics.findLeafChild(SERVICE_UNIQUE_ID_KEY)).thenReturn(uniqueId);
    when(servicePrivateTopics.createLeafChild(anyString())).thenReturn(mockTopic);
    when(mockTopic.withParentNeedsToKnow(false)).thenReturn(mockTopic);
    when(nucleusPaths.workPath(any())).thenReturn(tempDir);
    lenient().when(nucleusPaths.workPath()).thenReturn(tempDir);
    greengrassService = new GreengrassService(config);
    context.put(NucleusPaths.class, nucleusPaths);
    context.put(DeviceConfiguration.class, mock(DeviceConfiguration.class));
}
Also used : Context(com.aws.greengrass.dependency.Context) Topics(com.aws.greengrass.config.Topics) Topic(com.aws.greengrass.config.Topic) DeviceConfiguration(com.aws.greengrass.deployment.DeviceConfiguration) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 28 with Context

use of com.aws.greengrass.dependency.Context in project aws-greengrass-nucleus by aws-greengrass.

the class KernelConfigResolverTest method setupMocks.

@BeforeEach
void setupMocks() throws IOException {
    path = Paths.get("Artifacts", TEST_INPUT_PACKAGE_A);
    lenient().when(nucleusPaths.artifactPath(any())).thenReturn(path.toAbsolutePath());
    config = new Configuration(new Context());
    lenient().when(kernel.getConfig()).thenReturn(config);
    lenient().when(deviceConfiguration.getNucleusComponentName()).thenReturn(DEFAULT_NUCLEUS_COMPONENT_NAME);
    lenient().when(deviceConfiguration.getThingName()).thenReturn(config.lookup("thingname").withValue(THE_THINGNAME));
}
Also used : Context(com.aws.greengrass.dependency.Context) DeploymentPackageConfiguration(com.aws.greengrass.deployment.model.DeploymentPackageConfiguration) Configuration(com.aws.greengrass.config.Configuration) DeviceConfiguration(com.aws.greengrass.deployment.DeviceConfiguration) ComponentConfiguration(com.amazon.aws.iot.greengrass.component.common.ComponentConfiguration) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 29 with Context

use of com.aws.greengrass.dependency.Context in project aws-greengrass-nucleus by aws-greengrass.

the class DependencyResolverTest method setupTopics.

@BeforeEach
void setupTopics() throws Exception {
    context = new Context();
    groupToTargetComponentsTopics = Topics.of(context, GROUP_TO_ROOT_COMPONENTS_TOPICS, null);
    ComponentRecipe componentRecipe = mock(ComponentRecipe.class);
    lenient().when(componentRecipe.getComponentType()).thenReturn(ComponentType.GENERIC);
    lenient().when(componentStore.getPackageRecipe(any())).thenReturn(componentRecipe);
}
Also used : Context(com.aws.greengrass.dependency.Context) ComponentRecipe(com.aws.greengrass.componentmanager.models.ComponentRecipe) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 30 with Context

use of com.aws.greengrass.dependency.Context in project aws-greengrass-nucleus by aws-greengrass.

the class AuthorizationPolicyParserTest method readConfig.

private void readConfig(String filename) throws IOException {
    realConfig = new Configuration(new Context());
    try (InputStream inputStream = getClass().getResourceAsStream(filename)) {
        assertNotNull(inputStream);
        realConfig.mergeMap(0, new YAMLMapper().readValue(inputStream, Map.class));
    }
    when(kernel.getConfig()).thenReturn(realConfig);
}
Also used : ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) Context(com.aws.greengrass.dependency.Context) Configuration(com.aws.greengrass.config.Configuration) YAMLMapper(com.fasterxml.jackson.dataformat.yaml.YAMLMapper) InputStream(java.io.InputStream) Map(java.util.Map)

Aggregations

Context (com.aws.greengrass.dependency.Context)36 Topics (com.aws.greengrass.config.Topics)24 Test (org.junit.jupiter.api.Test)21 Configuration (com.aws.greengrass.config.Configuration)19 BeforeEach (org.junit.jupiter.api.BeforeEach)15 ExtensionContext (org.junit.jupiter.api.extension.ExtensionContext)15 DeviceConfiguration (com.aws.greengrass.deployment.DeviceConfiguration)14 IOException (java.io.IOException)8 ExecutorService (java.util.concurrent.ExecutorService)8 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)8 ChildChanged (com.aws.greengrass.config.ChildChanged)7 WhatHappened (com.aws.greengrass.config.WhatHappened)7 DEVICE_MQTT_NAMESPACE (com.aws.greengrass.deployment.DeviceConfiguration.DEVICE_MQTT_NAMESPACE)7 DEVICE_PARAM_AWS_REGION (com.aws.greengrass.deployment.DeviceConfiguration.DEVICE_PARAM_AWS_REGION)7 DEVICE_PARAM_CERTIFICATE_FILE_PATH (com.aws.greengrass.deployment.DeviceConfiguration.DEVICE_PARAM_CERTIFICATE_FILE_PATH)7 DEVICE_PARAM_IOT_DATA_ENDPOINT (com.aws.greengrass.deployment.DeviceConfiguration.DEVICE_PARAM_IOT_DATA_ENDPOINT)7 DEVICE_PARAM_PRIVATE_KEY_PATH (com.aws.greengrass.deployment.DeviceConfiguration.DEVICE_PARAM_PRIVATE_KEY_PATH)7 DEVICE_PARAM_ROOT_CA_PATH (com.aws.greengrass.deployment.DeviceConfiguration.DEVICE_PARAM_ROOT_CA_PATH)7 DEVICE_PARAM_THING_NAME (com.aws.greengrass.deployment.DeviceConfiguration.DEVICE_PARAM_THING_NAME)7 DEFAULT_MQTT_MAX_OF_PUBLISH_RETRY_COUNT (com.aws.greengrass.mqttclient.MqttClient.DEFAULT_MQTT_MAX_OF_PUBLISH_RETRY_COUNT)7