ValidateTemplate implements InstallServiceValidator { @Override public void validate(final InstallServiceValidationContext validationContext) throws RestErrorException { logger.info("Validating tempalte"); Cloud cloud = validationContext.getCloud(); Service service = validationContext.getService(); String templateName = null; if (service != null) { ComputeDetails compute = service.getCompute(); if (compute != null) { templateName = compute.getTemplate(); } } validateTemplate(templateName, cloud); }  @Override void validate(final InstallServiceValidationContext validationContext);  }
@Test public void testMissingTemplateOnInstallService() throws DSLException, PackagingException { Service service = ServiceReader.readService(new File(NOT_EXIST_TEMPLATE_SERVICE_GROOVY)); InstallServiceValidationContext validationContext = new InstallServiceValidationContext(); validationContext.setCloud(cloud); validationContext.setService(service); ValidatorsTestsUtils.validate(validateTempalte, validationContext, ERR_MSG); }
@Test public void testNullComputeOnInstallService() throws DSLException, PackagingException { Service service = ServiceReader.readService(new File(NO_COMPUTE_SERVICE)); InstallServiceValidationContext validationContext = new InstallServiceValidationContext(); validationContext.setCloud(cloud); validationContext.setService(service); ValidatorsTestsUtils.validate(validateTempalte, validationContext, null); }
@Test public void testMissingTemplateOnInstallApplication() throws DSLException, PackagingException { Service service = ServiceReader.readService(new File(NOT_EXIST_TEMPLATE_SERVICE_GROOVY)); InstallApplicationValidationContext validationContext = new InstallApplicationValidationContext(); validationContext.setCloud(cloud); Application application = new Application(); application.setService(service); validationContext.setApplication(application); ValidatorsTestsUtils.validate(validateApplicationServices, validationContext, ERR_MSG); }
@Test public void testNullComputeOnInstallApplication() throws DSLException, PackagingException { Service service = ServiceReader.readService(new File(NO_COMPUTE_SERVICE)); InstallApplicationValidationContext validationContext = new InstallApplicationValidationContext(); validationContext.setCloud(cloud); Application application = new Application(); application.setService(service); validationContext.setApplication(application); ValidatorsTestsUtils.validate(validateApplicationServices, validationContext, null); }