ValidateTemplateOperation implements TemplatesValidator { @Override public void validate(final TemplatesValidationContext validationContext) throws RestErrorException { logger.info("Validating template operation: " + validationContext.getOperationName()); if (validationContext.getCloud() == null) { throw new RestErrorException(CloudifyErrorMessages.ILLEGAL_TEMPLATE_OPERATION_ON_LOCAL_CLOUD.getName(), validationContext.getOperationName()); } }  @Override void validate(final TemplatesValidationContext validationContext);  }
@Test public void testAddTemplatesOnLocalcloud() { AddTemplatesValidationContext validationContext = new AddTemplatesValidationContext(); validationContext.setCloud(null); validationContext.setOperationName("add-templates"); AddTemplatesRequest request = new AddTemplatesRequest(); request.setUploadKey("key"); validationContext.setRequest(request); ValidateTemplateOperation validator = new ValidateTemplateOperation(); try { validator.validate(validationContext); Assert.fail("RestErrorException expected"); } catch (RestErrorException e) { Assert.assertEquals(CloudifyErrorMessages.ILLEGAL_TEMPLATE_OPERATION_ON_LOCAL_CLOUD.getName(), e.getMessage()); } }