Search in sources :

Example 1 with MapToTaggedResponseAdapter

use of com.sequenceiq.common.api.tag.response.MapToTaggedResponseAdapter in project cloudbreak by hortonworks.

the class CloudProviderSideTagAssertion method verifyTags.

private void verifyTags(List<String> instanceIds, Map<String, String> customTags, TestContext testContext, String resourceName) {
    if ((instanceIds != null && !instanceIds.isEmpty()) || !instanceIds.contains(null)) {
        CloudFunctionality cloudFunctionality = cloudProviderProxy.getCloudFunctionality();
        Map<String, Map<String, String>> tagsByInstanceId = cloudFunctionality.listTagsByInstanceId(resourceName, instanceIds);
        tagsByInstanceId.forEach((id, tags) -> {
            LOGGER.info(" Verifying resource: {} instance ID: {} with tags: {}", resourceName, id, tags);
            tagsUtil.verifyTags(new MapToTaggedResponseAdapter(tags), testContext);
            customTags.forEach((key, value) -> assertThat(tags.get(cloudFunctionality.transformTagKeyOrValue(key))).isEqualTo(cloudFunctionality.transformTagKeyOrValue(value)));
        });
    } else {
        LOGGER.error("Tag validation is not possible, because of {} instance ids: {} null or contains null!", resourceName, instanceIds);
        throw new TestFailException(String.format(" Tag validation is not possible, because of %s instance ids: %s null or contains null ", resourceName, instanceIds));
    }
}
Also used : CloudFunctionality(com.sequenceiq.it.cloudbreak.util.CloudFunctionality) MapToTaggedResponseAdapter(com.sequenceiq.common.api.tag.response.MapToTaggedResponseAdapter) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) Map(java.util.Map)

Aggregations

MapToTaggedResponseAdapter (com.sequenceiq.common.api.tag.response.MapToTaggedResponseAdapter)1 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)1 CloudFunctionality (com.sequenceiq.it.cloudbreak.util.CloudFunctionality)1 Map (java.util.Map)1