public void shouldReturnLatestDeployment()

in src/integration-test/java/com/awslabs/iot/helpers/implementations/BasicGreengrassV1HelperTests.java [121:149]


    public void shouldReturnLatestDeployment() throws Exception {
        Callable<Stream<GroupInformation>> getGroupInformationStream = () -> greengrassV1Helper.getGroups();
        testNotMeaningfulWithout("Greengrass groups", getGroupInformationStream.call());

        // Must have at least two deployments in a single group so we can make sure the latest deployment is returned properly
        Option<ImmutableGreengrassGroupId> groupIdOption = getGroupIdWithXorMoreDeployments(getGroupInformationStream, 2);

        // Use the group ID we found or a fake value if we didn't find any
        ImmutableGreengrassGroupId groupId = groupIdOption.getOrElse(ImmutableGreengrassGroupId.builder().groupId("fake").build());

        Callable<Stream<Deployment>> getDeploymentsStream = () -> greengrassV1Helper.getDeployments(groupId);
        testNotMeaningfulWithoutAtLeast("Greengrass deployments in any group", getDeploymentsStream.call(), 2);

        Long latestDeploymentCreatedAt = greengrassV1Helper.getLatestDeployment(groupId)
                .map(Deployment::createdAt)
                .map(Instant::parse)
                .map(Instant::toEpochMilli)
                .get();

        Long maxCreatedAt = greengrassV1Helper.getDeployments(groupId)
                .map(Deployment::createdAt)
                .map(Instant::parse)
                .map(Instant::toEpochMilli)
                .sorted()
                .reverse()
                .get();

        assertThat(latestDeploymentCreatedAt, is(maxCreatedAt));
    }