use of com.sequenceiq.it.cloudbreak.context.MockedTestContext in project cloudbreak by hortonworks.
the class AbstractMinimalTest method testContextWithMock.
@DataProvider(name = TEST_CONTEXT_WITH_MOCK)
public Object[][] testContextWithMock() {
MockedTestContext testContext = getBean(MockedTestContext.class);
MeasuredTestContext tc = createMeasuredTestContext(testContext);
return new Object[][] { { tc } };
}
use of com.sequenceiq.it.cloudbreak.context.MockedTestContext in project cloudbreak by hortonworks.
the class MultiThreadTenantTest method collectTestCaseDescription.
private TestCaseDescription collectTestCaseDescription(MockedTestContext testContext, Method method, Object[] params) {
Description declaredAnnotation = method.getDeclaredAnnotation(Description.class);
TestCaseDescription testCaseDescription = null;
if (declaredAnnotation != null) {
testCaseDescription = new TestCaseDescriptionBuilder().given(declaredAnnotation.given()).when(declaredAnnotation.when()).then(declaredAnnotation.then());
testContext.addDescription(testCaseDescription);
} else if (method.getParameters().length == params.length) {
Parameter[] parameters = method.getParameters();
for (int i = 1; i < parameters.length; i++) {
if (parameters[i].getAnnotation(Description.class) != null) {
Object param = params[i];
if (!(param instanceof TestCaseDescription)) {
throw new IllegalArgumentException("The param annotated with @Description but the type is should be " + TestCaseDescription.class.getSimpleName());
}
testCaseDescription = (TestCaseDescription) param;
testContext.addDescription(testCaseDescription);
break;
}
}
}
return Optional.ofNullable(testCaseDescription).filter(d -> !Strings.isNullOrEmpty(d.getValue())).orElseThrow(() -> new TestCaseDescriptionMissingException(method.getName()));
}
use of com.sequenceiq.it.cloudbreak.context.MockedTestContext in project cloudbreak by hortonworks.
the class MultiThreadTenantTest method beforeTest.
@BeforeMethod
public void beforeTest(Method method, Object[] params) {
MDC.put("testlabel", method.getDeclaringClass().getSimpleName() + '.' + method.getName());
MockedTestContext testContext = (MockedTestContext) params[0];
testContext.setTestMethodName(method.getName());
collectTestCaseDescription(testContext, method, params);
}
use of com.sequenceiq.it.cloudbreak.context.MockedTestContext in project cloudbreak by hortonworks.
the class ImageCatalogChangeTest method testFreeipaImageCatalogChange.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "a running Freeipa/Datalake/Datahub", when = "calling change image catalog", then = "it should have new image catalog")
public void testFreeipaImageCatalogChange(MockedTestContext testContext) {
// Freeipa
final String newImageCatalog = testContext.given(FreeIpaTestDto.class).getResponse().getImage().getCatalog() + "&changed=true";
testContext.given(FreeipaChangeImageCatalogTestDto.class).withImageCatalog(newImageCatalog).when(freeIpaTestClient.changeImageCatalog()).given(FreeIpaTestDto.class).when(freeIpaTestClient.describe()).then((testContext1, testDto, client) -> {
final String actualCatalog = testDto.getResponse().getImage().getCatalog();
if (!newImageCatalog.equals(actualCatalog)) {
throw new TestFailException(String.format("Image catalog of Freeipa was not changed. Catalog : %s", actualCatalog));
}
return testDto;
});
// Datalake
testContext.given(SdxInternalTestDto.class).when(sdxTestClient.createInternal()).await(SdxClusterStatusResponse.RUNNING);
final StackImageV4Response sdxImage = testContext.given(SdxInternalTestDto.class).getResponse().getStackV4Response().getImage();
final String sdxNewImageCatalogName = createNewImageCatalog(testContext, sdxImage);
testContext.given(SdxChangeImageCatalogTestDto.class).withImageCatalog(sdxNewImageCatalogName).when(sdxTestClient.changeImageCatalog()).given(SdxInternalTestDto.class).when(sdxTestClient.describeInternal()).then((testContext1, testDto, client) -> {
final String actualCatalog = testDto.getResponse().getStackV4Response().getImage().getCatalogName();
if (!sdxNewImageCatalogName.equals(actualCatalog)) {
throw new TestFailException(String.format("Image catalog of Datalake was not changed. Catalog : %s", actualCatalog));
}
return testDto;
});
// Datahub
testContext.given(DistroXTestDto.class).when(distroXClient.create()).await(STACK_AVAILABLE);
final StackImageV4Response distroXImage = testContext.given(DistroXTestDto.class).getResponse().getImage();
final String distroXNewImageCatalogName = createNewImageCatalog(testContext, distroXImage);
testContext.given(DistroXChangeImageCatalogTestDto.class).withImageCatalog(distroXNewImageCatalogName).when(distroXClient.changeImageCatalog()).given(DistroXTestDto.class).when(distroXClient.get()).then((testContext1, testDto, client) -> {
final String actualCatalog = testDto.getResponse().getImage().getCatalogName();
if (!distroXNewImageCatalogName.equals(actualCatalog)) {
throw new TestFailException(String.format("Image catalog of Datahub was not changed. Catalog : %s", actualCatalog));
}
return testDto;
}).validate();
}
use of com.sequenceiq.it.cloudbreak.context.MockedTestContext in project cloudbreak by hortonworks.
the class ImageCatalogTest method testGetImageCatalogWhenCatalogDoesNotContainTheRequestedProvider.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "image catalog get the default catalog with AWS provider but catalog does not contain AWS entry", when = "calling get on the default", then = "the response does not contains AWS images")
public void testGetImageCatalogWhenCatalogDoesNotContainTheRequestedProvider(MockedTestContext testContext) {
String imgCatalogName = resourcePropertyProvider().getName();
testContext.given(imgCatalogName, ImageCatalogTestDto.class).withName(imgCatalogName).withUrl(getImageCatalogMockServerSetup().getImageCatalogUrl()).when(imageCatalogTestClient.createV4(), key(imgCatalogName)).when(new ImageCatalogGetImagesByNameAction(CloudPlatform.AWS), key(imgCatalogName)).then((testContext1, entity, cloudbreakClient) -> {
ImagesV4Response catalog = entity.getResponseByProvider();
if (!catalog.getBaseImages().isEmpty()) {
throw new IllegalArgumentException("The Images response should NOT contain results for AWS provider.");
}
return entity;
}).validate();
}
Aggregations