use of com.sequenceiq.sdx.api.model.SdxCustomClusterRequest in project cloudbreak by hortonworks.
the class SdxServiceTest method createSdxCustomClusterRequest.
private SdxCustomClusterRequest createSdxCustomClusterRequest(SdxClusterShape shape, String catalog, String imageId) {
ImageSettingsV4Request imageSettingsV4Request = new ImageSettingsV4Request();
imageSettingsV4Request.setCatalog(catalog);
imageSettingsV4Request.setId(imageId);
SdxCustomClusterRequest sdxClusterRequest = new SdxCustomClusterRequest();
sdxClusterRequest.setClusterShape(shape);
sdxClusterRequest.addTags(TAGS);
sdxClusterRequest.setEnvironment("envir");
sdxClusterRequest.setImageSettingsV4Request(imageSettingsV4Request);
return sdxClusterRequest;
}
use of com.sequenceiq.sdx.api.model.SdxCustomClusterRequest in project cloudbreak by hortonworks.
the class SdxServiceTest method testCreateSdxClusterWithCustomRequestContainsImageInfo.
@Test
void testCreateSdxClusterWithCustomRequestContainsImageInfo() throws Exception {
ImageV4Response imageResponse = getImageResponse();
when(transactionService.required(isA(Supplier.class))).thenAnswer(invocation -> invocation.getArgument(0, Supplier.class).get());
String lightDutyJson = FileReaderUtils.readFileFromClasspath("/duties/7.2.7/aws/light_duty.json");
when(cdpConfigService.getConfigForKey(any())).thenReturn(JsonUtil.readValue(lightDutyJson, StackV4Request.class));
SdxCustomClusterRequest sdxClusterRequest = createSdxCustomClusterRequest(LIGHT_DUTY, "cdp-default", "imageId_1");
setSpot(sdxClusterRequest);
withCloudStorage(sdxClusterRequest);
when(imageCatalogService.getImageResponseFromImageRequest(eq(sdxClusterRequest.getImageSettingsV4Request()), any())).thenReturn(imageResponse);
long id = 10L;
when(sdxClusterRepository.save(any(SdxCluster.class))).thenAnswer(invocation -> {
SdxCluster sdxWithId = invocation.getArgument(0, SdxCluster.class);
sdxWithId.setId(id);
return sdxWithId;
});
mockEnvironmentCall(sdxClusterRequest, CloudPlatform.AWS, null);
Pair<SdxCluster, FlowIdentifier> result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.createSdx(USER_CRN, CLUSTER_NAME, sdxClusterRequest));
SdxCluster createdSdxCluster = result.getLeft();
StackV4Request stackV4Request = JsonUtil.readValue(createdSdxCluster.getStackRequest(), StackV4Request.class);
assertNotNull(stackV4Request.getImage());
assertEquals("cdp-default", stackV4Request.getImage().getCatalog());
assertEquals("imageId_1", stackV4Request.getImage().getId());
}
Aggregations