Search in sources :

Example 1 with TagsV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response in project cloudbreak by hortonworks.

the class TagsUtilTest method verifyTagsShouldFailTestContextHasNullAsActingCrn.

@Test
void verifyTagsShouldFailTestContextHasNullAsActingCrn() {
    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(null);
    String expectedMsg = String.format("[%s] tag validation is not possible, because of either the tag value [%s] or acting user Crn [%s]" + " is empty or null!", CLOUDERA_CREATOR_RESOURCE_NAME_TAG_KEY, ACTING_USER_CRN, "null");
    assertThatThrownBy(() -> underTest.verifyTags(testDto, testContext)).hasMessageContaining(expectedMsg).matches(e -> !e.getMessage().contains(TagsUtil.MISSING_TEST_NAME_TAG_MESSAGE));
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) MockedTestContext(com.sequenceiq.it.cloudbreak.context.MockedTestContext) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) TagsV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response) Test(org.testng.annotations.Test)

Example 2 with TagsV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response in project cloudbreak by hortonworks.

the class TagsUtilTest method verifyTagsShouldVerifyTagToAbstractTestDtoWithTaggedResponse.

@Test
void verifyTagsShouldVerifyTagToAbstractTestDtoWithTaggedResponse() {
    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(gcpLabelUtil.transformLabelKeyOrValue(anyString())).thenReturn(CLOUDERA_CREATOR_RESOURCE_NAME_TAG_KEY);
    assertThatCode(() -> underTest.verifyTags(testDto, testContext)).doesNotThrowAnyException();
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) MockedTestContext(com.sequenceiq.it.cloudbreak.context.MockedTestContext) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) TagsV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response) Test(org.testng.annotations.Test)

Example 3 with TagsV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response in project cloudbreak by hortonworks.

the class TagsUtilTest method verifyCreatorWithAltusCrnButTestContextHasCdpCrn.

@Test
void verifyCreatorWithAltusCrnButTestContextHasCdpCrn() {
    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, "crn:altus:iam:us-west-1:qe-gcp:user:cloudbreak-qe@hortonworks.com");
    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();
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) HashMap(java.util.HashMap) MockedTestContext(com.sequenceiq.it.cloudbreak.context.MockedTestContext) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) TagsV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response) Test(org.testng.annotations.Test)

Example 4 with TagsV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response in project cloudbreak by hortonworks.

the class StackTagsToTagsV4ResponseConverter method convert.

public TagsV4Response convert(StackTags source) {
    TagsV4Response response = new TagsV4Response();
    response.setApplication(source.getApplicationTags());
    response.setDefaults(source.getDefaultTags());
    response.setUserDefined(source.getUserDefinedTags());
    return response;
}
Also used : TagsV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response)

Example 5 with TagsV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response in project cloudbreak by hortonworks.

the class StackTagsToTagsV4ResponseConverterTest method testConvert.

@Test
public void testConvert() {
    Map<String, String> applicationTags = Map.of("aTagK1", "aTagV1", "aTagK2", "aTagV2");
    Map<String, String> defaultTags = Map.of("dTagK1", "dTagV1", "dTagK2", "dTagV2");
    Map<String, String> userDefinedTags = Map.of("uTagK1", "uTagV1", "uTagK2", "uTagV2");
    StackTags source = new StackTags(userDefinedTags, applicationTags, defaultTags);
    TagsV4Response result = underTest.convert(source);
    assertNotNull(result);
    assertEquals(applicationTags, result.getApplication());
    assertEquals(defaultTags, result.getDefaults());
    assertEquals(userDefinedTags, result.getUserDefined());
}
Also used : StackTags(com.sequenceiq.cloudbreak.cloud.model.StackTags) TagsV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response) Test(org.junit.Test)

Aggregations

TagsV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response)9 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)6 MockedTestContext (com.sequenceiq.it.cloudbreak.context.MockedTestContext)6 TestContext (com.sequenceiq.it.cloudbreak.context.TestContext)6 DistroXTestDto (com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto)6 Test (org.testng.annotations.Test)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 HashMap (java.util.HashMap)3 StackTags (com.sequenceiq.cloudbreak.cloud.model.StackTags)2 Crn (com.sequenceiq.cloudbreak.auth.crn.Crn)1 GcpLabelUtil (com.sequenceiq.cloudbreak.cloud.gcp.util.GcpLabelUtil)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)1 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)1 AbstractTestDto (com.sequenceiq.it.cloudbreak.dto.AbstractTestDto)1 CloudbreakTestDto (com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto)1 SdxTestDto (com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto)1 SdxClusterRequest (com.sequenceiq.sdx.api.model.SdxClusterRequest)1 Map (java.util.Map)1 Optional (java.util.Optional)1