Search in sources :

Example 1 with InstanceGroupV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request in project cloudbreak by hortonworks.

the class DistroXV1RequestTest method getAllRecipesIfRecipeNamesAreNullTest.

@Test
public void getAllRecipesIfRecipeNamesAreNullTest() {
    DistroXV1Request distroXV1Request = new DistroXV1Request();
    InstanceGroupV1Request instanceGroupV1Request = new InstanceGroupV1Request();
    instanceGroupV1Request.setRecipeNames(null);
    distroXV1Request.setInstanceGroups(Collections.singleton(instanceGroupV1Request));
    Set<String> allRecipes = distroXV1Request.getAllRecipes();
    assertEquals(0, allRecipes.size());
}
Also used : InstanceGroupV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request) Test(org.junit.jupiter.api.Test)

Example 2 with InstanceGroupV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request in project cloudbreak by hortonworks.

the class RootVolumeSizeValidatorTest method tesIsValidWhenTemplateIsNull.

@Test
public void tesIsValidWhenTemplateIsNull() {
    InstanceGroupV1Request value = new InstanceGroupV1Request();
    boolean actual = underTest.isValid(value, null);
    Assertions.assertTrue(actual);
    verify(rootVolumeSizeProvider, never()).getForPlatform(any());
}
Also used : InstanceGroupV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with InstanceGroupV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request in project cloudbreak by hortonworks.

the class RootVolumeSizeValidatorTest method tesIsValidWhenSizeIsNull.

@Test
public void tesIsValidWhenSizeIsNull() {
    InstanceTemplateV1Request templateV1Request = new InstanceTemplateV1Request();
    templateV1Request.setRootVolume(new RootVolumeV1Request());
    InstanceGroupV1Request value = new InstanceGroupV1Request();
    value.setTemplate(templateV1Request);
    boolean actual = underTest.isValid(value, null);
    Assertions.assertTrue(actual);
    verify(rootVolumeSizeProvider, never()).getForPlatform(any());
}
Also used : InstanceGroupV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request) InstanceTemplateV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.InstanceTemplateV1Request) RootVolumeV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.volume.RootVolumeV1Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with InstanceGroupV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request in project cloudbreak by hortonworks.

the class RootVolumeSizeValidatorTest method testIsValid.

@ParameterizedTest
@MethodSource("isValidSource")
public void testIsValid(boolean valid, int size) {
    InstanceTemplateV1Request templateV1Request = new InstanceTemplateV1Request();
    templateV1Request.setAws(new AwsInstanceTemplateV1Parameters());
    RootVolumeV1Request rootVolume = new RootVolumeV1Request();
    rootVolume.setSize(size);
    templateV1Request.setRootVolume(rootVolume);
    ConstraintValidatorContext context = mock(ConstraintValidatorContext.class);
    ConstraintValidatorContext.ConstraintViolationBuilder builder = mock(ConstraintValidatorContext.ConstraintViolationBuilder.class);
    when(rootVolumeSizeProvider.getForPlatform("AWS")).thenReturn(10);
    if (!valid) {
        when(context.buildConstraintViolationWithTemplate("Group root volume (" + size + "GB) couldn't be less than 10GB")).thenReturn(builder);
    }
    InstanceGroupV1Request value = new InstanceGroupV1Request();
    value.setName("group");
    value.setTemplate(templateV1Request);
    boolean actual = underTest.isValid(value, context);
    Assertions.assertEquals(actual, valid);
    int times = valid ? 0 : 1;
    verify(context, times(times)).buildConstraintViolationWithTemplate("Group root volume (" + size + "GB) couldn't be less than 10GB");
}
Also used : InstanceGroupV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request) InstanceTemplateV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.InstanceTemplateV1Request) ConstraintValidatorContext(javax.validation.ConstraintValidatorContext) AwsInstanceTemplateV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.AwsInstanceTemplateV1Parameters) RootVolumeV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.volume.RootVolumeV1Request) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 5 with InstanceGroupV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request in project cloudbreak by hortonworks.

the class DistroXTestDto method withRecipe.

public DistroXTestDto withRecipe(String recipeName) {
    InstanceGroupV1Request instanceGroupV1Request = getRequest().getInstanceGroups().iterator().next();
    instanceGroupV1Request.setRecipeNames(Sets.newHashSet());
    instanceGroupV1Request.getRecipeNames().add(recipeName);
    return this;
}
Also used : InstanceGroupV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request)

Aggregations

InstanceGroupV1Request (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request)23 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 Test (org.junit.jupiter.api.Test)14 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)10 NetworkV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request)9 InstanceTemplateV1Request (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.InstanceTemplateV1Request)8 InstanceGroupAwsNetworkV1Parameters (com.sequenceiq.distrox.api.v1.distrox.model.network.aws.InstanceGroupAwsNetworkV1Parameters)8 NetworkV1Request (com.sequenceiq.distrox.api.v1.distrox.model.network.NetworkV1Request)7 AwsNetworkV1Parameters (com.sequenceiq.distrox.api.v1.distrox.model.network.aws.AwsNetworkV1Parameters)7 HashSet (java.util.HashSet)7 InstanceGroupNetworkV1Request (com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Request)6 Pair (org.apache.commons.lang3.tuple.Pair)6 InstanceGroupV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request)5 RootVolumeV1Request (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.volume.RootVolumeV1Request)3 MethodSource (org.junit.jupiter.params.provider.MethodSource)3 DefaultClusterTemplateV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.requests.DefaultClusterTemplateV4Request)2 InstanceGroupNetworkV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.network.InstanceGroupNetworkV4Request)2 DistroXV1Request (com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request)2 AwsInstanceTemplateV1Parameters (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.AwsInstanceTemplateV1Parameters)2 Map (java.util.Map)2