Search in sources :

Example 31 with StackV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response 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 32 with StackV4Response

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

the class TagsUtilTest method verifyTagsShouldFailAbstractTestDtoDoesNotHaveAnyNeededTags.

@Test
void verifyTagsShouldFailAbstractTestDtoDoesNotHaveAnyNeededTags() {
    DistroXTestDto testDto = new DistroXTestDto(mock(TestContext.class));
    testDto.setResponse(new StackV4Response());
    String expectedMessage = String.format(TagsUtil.TAG_VALUE_IS_NULL_FAILURE_PATTERN, TagsUtil.TEST_NAME_TAG);
    assertThatThrownBy(() -> underTest.verifyTags(testDto, testContext)).hasMessageContaining(expectedMessage);
}
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) Test(org.testng.annotations.Test)

Example 33 with StackV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response 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 34 with StackV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response 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 35 with StackV4Response

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

the class StackOperations method get.

public StackV4Response get(NameOrCrn nameOrCrn, Long workspaceId, Set<String> entries, StackType stackType) {
    LOGGER.info("Validate stack in workspace {}.", workspaceId);
    StackV4Response stackResponse = stackCommonService.findStackByNameOrCrnAndWorkspaceId(nameOrCrn, workspaceId, entries, stackType);
    LOGGER.info("Adding environment name and credential to the response.");
    environmentServiceDecorator.prepareEnvironmentAndCredentialName(stackResponse);
    LOGGER.info("Adding SDX CRN and name to the response.");
    sdxServiceDecorator.prepareSdxAttributes(stackResponse);
    LOGGER.info("Query Stack successfully decorated.");
    return stackResponse;
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)

Aggregations

StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)101 Test (org.junit.jupiter.api.Test)26 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)22 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)19 ClusterV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response)14 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)13 Test (org.junit.Test)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)11 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)8 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)8 MockedTestContext (com.sequenceiq.it.cloudbreak.context.MockedTestContext)7 TestContext (com.sequenceiq.it.cloudbreak.context.TestContext)7 DistroXTestDto (com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto)7 ArrayList (java.util.ArrayList)7 Test (org.testng.annotations.Test)7 InstanceGroupV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.InstanceGroupV4Response)6 TagsV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response)6 TransactionExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException)6 TransactionRuntimeExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)6 BaseDiagnosticsCollectionRequest (com.sequenceiq.common.api.diagnostics.BaseDiagnosticsCollectionRequest)6