use of com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto in project cloudbreak by hortonworks.
the class TestContext method awaitForInstance.
public <T extends CloudbreakTestDto, E extends Enum<E>> T awaitForInstance(T entity, Map<List<String>, E> desiredStatuses, RunningParameter runningParameter) {
checkShutdown();
if (!getExceptionMap().isEmpty() && runningParameter.isSkipOnFail()) {
Log.await(LOGGER, String.format("Cloudbreak await for instance should be skipped because of previous error. awaitforinstance [%s]", desiredStatuses));
return entity;
}
String key = getKeyForAwait(entity, entity.getClass(), runningParameter);
CloudbreakTestDto awaitEntity = get(key);
instanceAwait.await(awaitEntity, desiredStatuses, getTestContext(), runningParameter, flowUtilSingleStatus.getPollingDurationOrTheDefault(runningParameter), maxRetry);
return entity;
}
use of com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto in project cloudbreak by hortonworks.
the class TagsUtilTest method addTestNameTagShouldNotFailWhenTestDtoIsNotAbstractTestDto.
@Test
void addTestNameTagShouldNotFailWhenTestDtoIsNotAbstractTestDto() {
CloudbreakTestDto testDto = mock(CloudbreakTestDto.class);
when(testDto.getCloudPlatform()).thenReturn(CloudPlatform.MOCK);
assertThatCode(() -> underTest.addTestNameTag(testDto.getCloudPlatform(), testDto, TEST_NAME)).doesNotThrowAnyException();
}
use of com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto in project cloudbreak by hortonworks.
the class TagsUtilTest method verifyTagsShouldNotFailWhenTestDtoIsNotAbstractTestDto.
@Test
void verifyTagsShouldNotFailWhenTestDtoIsNotAbstractTestDto() {
CloudbreakTestDto testDto = mock(CloudbreakTestDto.class);
assertThatCode(() -> underTest.verifyTags(testDto, testContext)).doesNotThrowAnyException();
}
use of com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto in project cloudbreak by hortonworks.
the class TestContext method thenException.
public <E extends Exception, T extends CloudbreakTestDto> T thenException(T entity, Class<? extends MicroserviceClient> clientClass, Assertion<T, ? extends MicroserviceClient> assertion, Class<E> expectedException, RunningParameter runningParameter) {
checkShutdown();
String key = getKey(assertion.getClass(), runningParameter);
if (!getExceptionMap().isEmpty() && runningParameter.isSkipOnFail()) {
LOGGER.info("Should be skipped because of previous error. when [{}]", key);
return entity;
}
CloudbreakUser who = setActingUser(runningParameter);
LOGGER.info("then exception {} action on {} by {}, name: {}", key, entity, who, entity.getName());
Log.thenException(LOGGER, assertion.getClass().getSimpleName() + " exception assertion on " + entity + " by " + who);
try {
String message = String.format("Expected exception with message (%s) has not been thrown!", runningParameter.getExpectedMessage());
CloudbreakTestDto cloudbreakTestDto = resourceNames.get(key);
if (cloudbreakTestDto != null) {
assertion.doAssertion(this, (T) cloudbreakTestDto, getMicroserviceClient(entity.getClass(), who.getAccessKey()));
} else {
assertion.doAssertion(this, entity, getMicroserviceClient(entity.getClass(), who.getAccessKey()));
}
getExceptionMap().put("thenException", new TestFailException(message));
LOGGER.error(message);
htmlLoggerForExceptionValidation(message, "thenException");
} catch (Exception e) {
exceptionValidation(expectedException, e, key, runningParameter, "thenException");
}
return entity;
}
use of com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto in project cloudbreak by hortonworks.
the class TestContext method then.
public <T extends CloudbreakTestDto> T then(T entity, Class<? extends MicroserviceClient> clientClass, Assertion<T, ? extends MicroserviceClient> assertion, RunningParameter runningParameter) {
checkShutdown();
String key = getKey(assertion.getClass(), runningParameter);
if (!getExceptionMap().isEmpty() && runningParameter.isSkipOnFail()) {
LOGGER.info("Should be skipped because of previous error. when [{}]", key);
return entity;
}
CloudbreakUser who = setActingUser(runningParameter);
Log.then(LOGGER, assertion.getClass().getSimpleName() + " assertion on " + entity + " by " + who);
try {
CloudbreakTestDto cloudbreakTestDto = resourceNames.get(key);
if (cloudbreakTestDto != null) {
return assertion.doAssertion(this, (T) cloudbreakTestDto, getMicroserviceClient(entity.getClass(), who.getAccessKey()));
} else {
assertion.doAssertion(this, entity, getMicroserviceClient(entity.getClass(), who.getAccessKey()));
}
} catch (Exception e) {
if (runningParameter.isLogError()) {
LOGGER.error("then [{}] assertion is failed: {}, name: {}", key, ResponseUtil.getErrorMessage(e), entity.getName(), e);
Log.then(null, assertion.getClass().getSimpleName() + " assertion is failed: " + ResponseUtil.getErrorMessage(e));
}
getExceptionMap().put(key, e);
} catch (Error e) {
getExceptionMap().put(key, new TestFailException(e.getMessage(), e));
}
return entity;
}
Aggregations