@Test public void testGenerateWhenTemplateProcessThrowsIOExceptionThenCloudConnectorExceptionComesForAppCreationCommandTemplate() throws IOException, TemplateException { doThrow(new IOException()).when(template).process(any(), any(StringWriter.class)); thrown.expect(CloudConnectorException.class); thrown.expectMessage(format(GENERATE_EXCEPTION_MESSAGE_FORMAT, APP_CREATION_COMMAND_TEMPLATE_PATH)); underTest.generate(DEPLOYMENT_ADDRESS); verify(template, times(1)).process(any(), any(StringWriter.class)); verify(freemarkerConfiguration, times(1)).getTemplate(anyString(), anyString()); verify(freemarkerConfiguration, times(1)).getTemplate(APP_CREATION_COMMAND_TEMPLATE_PATH, ENCODING); }
public String generate(String deploymentAddress) { try { if (StringUtils.isEmpty(deploymentAddress)) { deploymentAddress = DEFAULT_DEPLOYMENT_ADDRESS; } Map<String, Object> model = buildModel(deploymentAddress, getAppIdentifierURI(deploymentAddress), getReplyURL(deploymentAddress)); Template template = freemarkerConfiguration.getTemplate(appCreationCommandTemplatePath, ENCODING); return processTemplateIntoString(template, model); } catch (IOException | TemplateException e) { String message = String.format(GENERATE_EXCEPTION_MESSAGE_FORMAT, appCreationCommandTemplatePath); throw new CloudConnectorException(message, e); } }
AzureCredentialAppCreationCommand { public String generate(String deploymentAddress) { try { if (StringUtils.isEmpty(deploymentAddress)) { deploymentAddress = DEFAULT_DEPLOYMENT_ADDRESS; } Map<String, Object> model = buildModel(deploymentAddress, getAppIdentifierURI(deploymentAddress), getReplyURL(deploymentAddress)); Template template = freemarkerConfiguration.getTemplate(appCreationCommandTemplatePath, ENCODING); return processTemplateIntoString(template, model); } catch (IOException | TemplateException e) { String message = String.format(GENERATE_EXCEPTION_MESSAGE_FORMAT, appCreationCommandTemplatePath); throw new CloudConnectorException(message, e); } } }
AzureCredentialAppCreationCommand { public String generate(String deploymentAddress) { try { if (StringUtils.isEmpty(deploymentAddress)) { deploymentAddress = DEFAULT_DEPLOYMENT_ADDRESS; } Map<String, Object> model = buildModel(deploymentAddress, getAppIdentifierURI(deploymentAddress), getReplyURL(deploymentAddress)); Template template = freemarkerConfiguration.getTemplate(appCreationCommandTemplatePath, ENCODING); return processTemplateIntoString(template, model); } catch (IOException | TemplateException e) { String message = String.format(GENERATE_EXCEPTION_MESSAGE_FORMAT, appCreationCommandTemplatePath); throw new CloudConnectorException(message, e); } }  }
AzureCredentialAppCreationCommand { public String generate(String deploymentAddress) { try { if (StringUtils.isEmpty(deploymentAddress)) { deploymentAddress = DEFAULT_DEPLOYMENT_ADDRESS; } Map<String, Object> model = buildModel(deploymentAddress, getAppIdentifierURI(deploymentAddress), getReplyURL(deploymentAddress)); Template template = freemarkerConfiguration.getTemplate(appCreationCommandTemplatePath, ENCODING); return processTemplateIntoString(template, model); } catch (IOException | TemplateException e) { String message = String.format(GENERATE_EXCEPTION_MESSAGE_FORMAT, appCreationCommandTemplatePath); throw new CloudConnectorException(message, e); } }  String generate(String deploymentAddress); AzureApplicationCreationView generateJSON(String deploymentAddress); }
AzureCredentialAppCreationCommand { public String generate(String deploymentAddress) { try { if (StringUtils.isEmpty(deploymentAddress)) { deploymentAddress = DEFAULT_DEPLOYMENT_ADDRESS; } Map<String, Object> model = buildModel(deploymentAddress, getAppIdentifierURI(deploymentAddress), getReplyURL(deploymentAddress)); Template template = freemarkerConfiguration.getTemplate(appCreationCommandTemplatePath, ENCODING); return processTemplateIntoString(template, model); } catch (IOException | TemplateException e) { String message = String.format(GENERATE_EXCEPTION_MESSAGE_FORMAT, appCreationCommandTemplatePath); throw new CloudConnectorException(message, e); } }  String generate(String deploymentAddress); AzureApplicationCreationView generateJSON(String deploymentAddress);  }