Package com.sequenceiq.cloudbreak.controller.json

Examples of com.sequenceiq.cloudbreak.controller.json.TemplateJson


        assertEquals(underTest.isValid(templateJson, constraintValidatorContext), true);
    }

    @Test
    public void validAwsTemplateWithInvalidSshLocationWithSpecificNumberJsonWillReturnTrue() {
        TemplateJson templateJson = new TemplateJson();
        templateJson.setCloudPlatform(CloudPlatform.AWS);
        templateJson.setDescription("description");
        templateJson.setName("name");
        Map<String, Object> parameters = new HashMap<>();
        parameters.put(AwsTemplateParam.AMI_ID.getName(), "ami");
        parameters.put(AwsTemplateParam.INSTANCE_TYPE.getName(), InstanceType.C1Medium.name());
        parameters.put(AwsTemplateParam.REGION.getName(), Regions.AP_NORTHEAST_1);
        parameters.put(AwsTemplateParam.SSH_LOCATION.getName(), "192.0.0.0/256");
        templateJson.setVolumeCount(3);
        templateJson.setVolumeSize(30);
        parameters.put(AwsTemplateParam.VOLUME_TYPE.getName(), "Gp2");
        templateJson.setParameters(parameters);
        assertEquals(underTest.isValid(templateJson, constraintValidatorContext), false);
    }
View Full Code Here


        assertEquals(underTest.isValid(templateJson, constraintValidatorContext), false);
    }

    @Test
    public void awsTemplateJsonWithInvalidVolumeTypeFails() {
        TemplateJson templateJson = new TemplateJson();
        templateJson.setCloudPlatform(CloudPlatform.AWS);
        templateJson.setDescription("description");
        templateJson.setName("name");
        Map<String, Object> parameters = new HashMap<>();
        parameters.put(AwsTemplateParam.AMI_ID.getName(), "ami");
        parameters.put(AwsTemplateParam.INSTANCE_TYPE.getName(), InstanceType.C1Medium.name());
        parameters.put(AwsTemplateParam.REGION.getName(), Regions.AP_NORTHEAST_1);
        parameters.put(AwsTemplateParam.SSH_LOCATION.getName(), "0.0.0.0/0");
        templateJson.setVolumeCount(3);
        templateJson.setVolumeSize(30);
        parameters.put(AwsTemplateParam.VOLUME_TYPE.getName(), "invalid");
        templateJson.setParameters(parameters);
        assertEquals(underTest.isValid(templateJson, constraintValidatorContext), false);
    }
View Full Code Here

    @Test
    public void testConvertAzureTemplateEntityToJson() {
        // GIVEN
        // WHEN
        TemplateJson result = underTest.convert(azureTemplate);
        // THEN
        assertEquals(result.getCloudPlatform(), azureTemplate.cloudPlatform());
        assertEquals(result.getParameters().get(AzureTemplateParam.LOCATION.getName()),
                azureTemplate.getLocation().name());

    }
View Full Code Here

        azureTemplate.setPublicInAccount(true);
        return azureTemplate;
    }

    private TemplateJson createTemplateJson() {
        TemplateJson templateJson = new TemplateJson();
        templateJson.setCloudPlatform(CloudPlatform.AZURE);
        templateJson.setId(1L);
        templateJson.setDescription(DUMMY_DESCRIPTION);
        templateJson.setName(DUMMY_NAME);
        Map<String, Object> props = new HashMap<>();
        props.put(AzureTemplateParam.LOCATION.getName(), DUMMY_LOCATION.name());
        props.put(AzureTemplateParam.IMAGENAME.getName(), DUMMY_IMAGE_NAME);
        props.put(AzureTemplateParam.VMTYPE.getName(), DUMMY_VM_TYPE);
        templateJson.setParameters(props);
        return templateJson;
    }
View Full Code Here

    @Test
    public void testConvertAwsTemplateConverterEntityToJson() {
        // GIVEN
        // WHEN
        TemplateJson result = underTest.convert(awsTemplate);
        assertEquals(result.getCloudPlatform(), awsTemplate.cloudPlatform());
        assertEquals(result.getDescription(), awsTemplate.getDescription());
        assertEquals(result.getParameters().get(AwsTemplateParam.INSTANCE_TYPE.getName()), awsTemplate.getInstanceType().name());
    }
View Full Code Here

        AwsTemplate result = underTest.convert(templateJson);
        assertEquals(result.cloudPlatform(), templateJson.getCloudPlatform());
    }

    private TemplateJson createTemplateJson() {
        TemplateJson templateJson = new TemplateJson();
        templateJson.setCloudPlatform(CloudPlatform.AWS);
        templateJson.setDescription(DUMMY_DESCRIPTION);
        templateJson.setName(DUMMY_NAME);
        Map<String, Object> props = new HashMap<>();
        props.put(AwsTemplateParam.REGION.getName(), Regions.DEFAULT_REGION.toString());
        props.put(AwsTemplateParam.AMI_ID.getName(), DUMMY_AMI_ID);
        props.put(AwsTemplateParam.INSTANCE_TYPE.getName(), InstanceType.C1Medium.name());
        props.put(AwsTemplateParam.SSH_LOCATION.getName(), DUMMY_SSH_LOCATION);
        templateJson.setVolumeCount(2);
        templateJson.setVolumeSize(60);
        props.put(AwsTemplateParam.VOLUME_TYPE.getName(), "Gp2");
        templateJson.setParameters(props);
        return templateJson;
    }
View Full Code Here

@Component
public class AzureTemplateConverter extends AbstractConverter<TemplateJson, AzureTemplate> {

    @Override
    public TemplateJson convert(AzureTemplate entity) {
        TemplateJson azureTemplateJson = new TemplateJson();
        azureTemplateJson.setName(entity.getName());
        azureTemplateJson.setCloudPlatform(CloudPlatform.AZURE);
        azureTemplateJson.setId(entity.getId());
        azureTemplateJson.setDescription(entity.getDescription());
        Map<String, Object> props = new HashMap<>();
        putProperty(props, AzureTemplateParam.LOCATION.getName(), entity.getLocation());
        putProperty(props, AzureTemplateParam.IMAGENAME.getName(), entity.getImageName());
        putProperty(props, AzureTemplateParam.VMTYPE.getName(), entity.getVmType());
        azureTemplateJson.setCloudPlatform(CloudPlatform.AZURE);
        azureTemplateJson.setParameters(props);
        azureTemplateJson.setDescription(entity.getDescription() == null ? "" : entity.getDescription());
        azureTemplateJson.setVolumeCount(entity.getVolumeCount());
        azureTemplateJson.setVolumeSize(entity.getVolumeSize());
        return azureTemplateJson;
    }
View Full Code Here

TOP

Related Classes of com.sequenceiq.cloudbreak.controller.json.TemplateJson

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.