Search in sources :

Example 1 with MissingRequiredComponentsException

use of com.aws.greengrass.componentmanager.exceptions.MissingRequiredComponentsException in project aws-greengrass-nucleus by aws-greengrass.

the class ComponentManagerTest method GIVEN_deployment_WHEN_dependency_closure_is_missing_download_prereq_component_THEN_fail.

@Test
void GIVEN_deployment_WHEN_dependency_closure_is_missing_download_prereq_component_THEN_fail() throws Exception {
    ComponentIdentifier testComponent = new ComponentIdentifier("test.component", new Semver("1.0.0"));
    ComponentRecipe mockRecipe = mock(ComponentRecipe.class);
    Optional<ComponentRecipe> recipeResult = Optional.of(mockRecipe);
    // Private ECR image
    List<ComponentArtifact> artifacts = Collections.singletonList(ComponentArtifact.builder().artifactUri(new URI("s3://some/artifact")).build());
    when(mockRecipe.getArtifacts()).thenReturn(artifacts);
    when(componentStore.findPackageRecipe(any())).thenReturn(recipeResult);
    doThrow(new MissingRequiredComponentsException("Missing required component for download")).when(artifactDownloaderFactory).checkDownloadPrerequisites(any(), any(), any());
    List<ComponentIdentifier> dependencyClosure = Arrays.asList(testComponent);
    assertThrows(MissingRequiredComponentsException.class, () -> componentManager.checkPreparePackagesPrerequisites(dependencyClosure));
}
Also used : MissingRequiredComponentsException(com.aws.greengrass.componentmanager.exceptions.MissingRequiredComponentsException) ComponentIdentifier(com.aws.greengrass.componentmanager.models.ComponentIdentifier) ComponentArtifact(com.aws.greengrass.componentmanager.models.ComponentArtifact) ComponentRecipe(com.aws.greengrass.componentmanager.models.ComponentRecipe) Semver(com.vdurmont.semver4j.Semver) URI(java.net.URI) Test(org.junit.jupiter.api.Test)

Aggregations

MissingRequiredComponentsException (com.aws.greengrass.componentmanager.exceptions.MissingRequiredComponentsException)1 ComponentArtifact (com.aws.greengrass.componentmanager.models.ComponentArtifact)1 ComponentIdentifier (com.aws.greengrass.componentmanager.models.ComponentIdentifier)1 ComponentRecipe (com.aws.greengrass.componentmanager.models.ComponentRecipe)1 Semver (com.vdurmont.semver4j.Semver)1 URI (java.net.URI)1 Test (org.junit.jupiter.api.Test)1