use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response in project cloudbreak by hortonworks.
the class StackToStackV4ResponseConverter method getTags.
private TagsV4Response getTags(Json tag) {
try {
if (tag != null && tag.getValue() != null) {
StackTags stackTag = tag.get(StackTags.class);
return stackTagsToTagsV4ResponseConverter.convert(stackTag);
}
} catch (Exception e) {
LOGGER.info("Failed to convert dynamic tags.", e);
}
TagsV4Response response = new TagsV4Response();
response.setApplication(new HashMap<>());
response.setDefaults(new HashMap<>());
response.setUserDefined(new HashMap<>());
return response;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response in project cloudbreak by hortonworks.
the class TagsUtilTest method verifyCreatorWithCdpCrnButTestContextHasAltusCrn.
@Test
void verifyCreatorWithCdpCrnButTestContextHasAltusCrn() {
DistroXTestDto testDto = new DistroXTestDto(mock(TestContext.class));
StackV4Response response = new StackV4Response();
TagsV4Response tags = new TagsV4Response();
tags.setUserDefined(Map.of(TagsUtil.TEST_NAME_TAG, TEST_NAME));
tags.setDefaults(DEFAULT_TAGS);
response.setTags(tags);
testDto.setResponse(response);
when(testContext.getActingUserCrn()).thenReturn(Crn.fromString("crn:altus:iam:us-west-1:qe-gcp:user:cloudbreak-qe@hortonworks.com"));
when(gcpLabelUtil.transformLabelKeyOrValue(anyString())).thenReturn(CLOUDERA_CREATOR_RESOURCE_NAME_TAG_KEY);
assertThatCode(() -> underTest.verifyTags(testDto, testContext)).doesNotThrowAnyException();
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response in project cloudbreak by hortonworks.
the class TagsUtilTest method verifyTagsShouldFailAbstractTestDtoDoesNotHaveAllNeededTags.
@Test
void verifyTagsShouldFailAbstractTestDtoDoesNotHaveAllNeededTags() {
DistroXTestDto testDto = new DistroXTestDto(mock(TestContext.class));
StackV4Response response = new StackV4Response();
TagsV4Response tags = new TagsV4Response();
tags.setUserDefined(Map.of(TagsUtil.TEST_NAME_TAG, TEST_NAME));
Map<String, String> defaultTags = new HashMap<>(DEFAULT_TAGS);
defaultTags.remove("owner");
tags.setDefaults(defaultTags);
response.setTags(tags);
testDto.setResponse(response);
String expectedMsg = String.format(TagsUtil.TAG_VALUE_IS_NULL_FAILURE_PATTERN, OWNER_TAG_KEY);
assertThatThrownBy(() -> underTest.verifyTags(testDto, testContext)).hasMessageContaining(expectedMsg).matches(e -> !e.getMessage().contains(TagsUtil.MISSING_TEST_NAME_TAG_MESSAGE)).matches(e -> defaultTags.keySet().stream().noneMatch(tag -> e.getMessage().contains(tag)));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response in project cloudbreak by hortonworks.
the class TagsUtilTest method verifyCreatorAsGcpLabelTransformedValue.
@Test
void verifyCreatorAsGcpLabelTransformedValue() {
DistroXTestDto testDto = new DistroXTestDto(mock(TestContext.class));
StackV4Response response = new StackV4Response();
TagsV4Response tags = new TagsV4Response();
tags.setUserDefined(Map.of(TagsUtil.TEST_NAME_TAG, TEST_NAME));
Map<String, String> defaultTags = new HashMap<>(DEFAULT_TAGS);
defaultTags.put(CLOUDERA_CREATOR_RESOURCE_NAME_TAG_KEY, ACTING_USER_CRN);
tags.setDefaults(defaultTags);
response.setTags(tags);
testDto.setResponse(response);
when(gcpLabelUtil.transformLabelKeyOrValue(anyString())).thenReturn(CLOUDERA_CREATOR_RESOURCE_NAME_TAG_KEY);
assertThatCode(() -> underTest.verifyTags(testDto, testContext)).doesNotThrowAnyException();
}
Aggregations