Search in sources :

Example 1 with FreeIpaRecommendationResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.FreeIpaRecommendationResponse in project cloudbreak by hortonworks.

the class FreeIpaRecommendationServiceTest method testGetRecommendation.

@Test
public void testGetRecommendation() {
    when(credentialService.getCredentialByCredCrn(anyString())).thenReturn(new Credential("AWS", "", "", "", ""));
    when(cloudParameterService.getVmTypesV2(any(), eq("eu-central-1"), eq("AWS"), eq(CdpResourceType.DEFAULT), any())).thenReturn(initCloudVmTypes());
    when(defaultInstanceTypeProvider.getForPlatform(eq("AWS"))).thenReturn("medium");
    FreeIpaRecommendationResponse recommendation = underTest.getRecommendation("cred", "eu-central-1", null);
    assertEquals("medium", recommendation.getDefaultInstanceType());
    Set<VmTypeResponse> vmTypes = recommendation.getVmTypes();
    assertEquals(2, vmTypes.size());
    assertThat(vmTypes.stream().map(VmTypeResponse::getValue).collect(Collectors.toSet())).containsExactly("large", "medium");
}
Also used : Credential(com.sequenceiq.freeipa.dto.Credential) VmTypeResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.VmTypeResponse) FreeIpaRecommendationResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.FreeIpaRecommendationResponse) Test(org.junit.jupiter.api.Test)

Example 2 with FreeIpaRecommendationResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.FreeIpaRecommendationResponse in project cloudbreak by hortonworks.

the class FreeIpaRecommendationService method getRecommendation.

public FreeIpaRecommendationResponse getRecommendation(String credentialCrn, String region, String availabilityZone) {
    Credential credential = credentialService.getCredentialByCredCrn(credentialCrn);
    String defaultInstanceType = defaultInstanceTypeProvider.getForPlatform(credential.getCloudPlatform());
    Set<VmTypeResponse> availableVmTypes = getAvailableVmTypes(region, availabilityZone, credential, defaultInstanceType);
    return new FreeIpaRecommendationResponse(availableVmTypes, defaultInstanceType);
}
Also used : Credential(com.sequenceiq.freeipa.dto.Credential) VmTypeResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.VmTypeResponse) FreeIpaRecommendationResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.FreeIpaRecommendationResponse)

Aggregations

FreeIpaRecommendationResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.FreeIpaRecommendationResponse)2 VmTypeResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.VmTypeResponse)2 Credential (com.sequenceiq.freeipa.dto.Credential)2 Test (org.junit.jupiter.api.Test)1