Search in sources :

Example 21 with TestContext

use of com.sequenceiq.it.cloudbreak.context.TestContext 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 22 with TestContext

use of com.sequenceiq.it.cloudbreak.context.TestContext 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 23 with TestContext

use of com.sequenceiq.it.cloudbreak.context.TestContext 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 24 with TestContext

use of com.sequenceiq.it.cloudbreak.context.TestContext 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 25 with TestContext

use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.

the class RedbeamsDatabaseServerTestDto method valid.

@Override
public RedbeamsDatabaseServerTestDto valid() {
    TestContext testContext = getTestContext();
    if (testContext == null) {
        throw new IllegalStateException("Cannot create valid instance, test context is not available");
    }
    String environmentCrn = testContext.get(EnvironmentTestDto.class).getResponse().getCrn();
    return withName(getResourcePropertyProvider().getName()).withPlatform().withDatabaseServer().withEnvironmentCrn(environmentCrn);
}
Also used : TestContext(com.sequenceiq.it.cloudbreak.context.TestContext)

Aggregations

TestContext (com.sequenceiq.it.cloudbreak.context.TestContext)45 Test (org.testng.annotations.Test)38 Description (com.sequenceiq.it.cloudbreak.context.Description)32 Inject (javax.inject.Inject)32 RunningParameter.key (com.sequenceiq.it.cloudbreak.context.RunningParameter.key)20 DistroXTestDto (com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto)20 SdxTestClient (com.sequenceiq.it.cloudbreak.client.SdxTestClient)18 MockedTestContext (com.sequenceiq.it.cloudbreak.context.MockedTestContext)18 UseSpotInstances (com.sequenceiq.it.cloudbreak.util.spot.UseSpotInstances)17 SdxClusterStatusResponse (com.sequenceiq.sdx.api.model.SdxClusterStatusResponse)17 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)15 List (java.util.List)15 AbstractE2ETest (com.sequenceiq.it.cloudbreak.testcase.e2e.AbstractE2ETest)14 DistroXTestClient (com.sequenceiq.it.cloudbreak.client.DistroXTestClient)13 Logger (org.slf4j.Logger)13 LoggerFactory (org.slf4j.LoggerFactory)13 EnvironmentTestDto (com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto)12 SdxTestDto (com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto)12 SdxDatabaseRequest (com.sequenceiq.sdx.api.model.SdxDatabaseRequest)11 EnvironmentTestClient (com.sequenceiq.it.cloudbreak.client.EnvironmentTestClient)10