@Test public void testGenerateWhenFreemarkerConfigGetTemplateThrowsTemplateNotFoundExceptionThenCloudConnectorExceptionComesForAppCreationJsonTemplate() throws IOException, TemplateException { doThrow(new TemplateNotFoundException(TEMPLATE_NAME, new Object(), TEMPLATE_NOT_FOUND_EXCEPTION_MESSAGE)).when(freemarkerConfiguration) .getTemplate(APP_CREATION_JSON_TEMPLATE_PATH, ENCODING); thrown.expect(CloudConnectorException.class); thrown.expectMessage(format(GENERATE_EXCEPTION_MESSAGE_FORMAT, APP_CREATION_JSON_TEMPLATE_PATH)); underTest.generateJSON(DEPLOYMENT_ADDRESS); verify(template, times(0)).process(any(), any(StringWriter.class)); verify(freemarkerConfiguration, times(1)).getTemplate(anyString(), anyString()); verify(freemarkerConfiguration, times(1)).getTemplate(APP_CREATION_JSON_TEMPLATE_PATH, ENCODING); }
public AzureApplicationCreationView generateJSON(String deploymentAddress) { try { String appIdentifierURI = getAppIdentifierURI(deploymentAddress); String appSecret = UUID.randomUUID().toString(); String replyURL = getReplyURL(deploymentAddress); Template template = freemarkerConfiguration.getTemplate(appCreationJSONTemplatePath, ENCODING); Map<String, Object> model = buildModel(deploymentAddress, appIdentifierURI, replyURL); model.put("appSecret", appSecret); model.put("keyId", UUID.randomUUID().toString()); String creationRequestPayload = processTemplateIntoString(template, model); return new AzureApplicationCreationView(appIdentifierURI, appSecret, replyURL, creationRequestPayload); } catch (IOException | TemplateException e) { String message = String.format(GENERATE_EXCEPTION_MESSAGE_FORMAT, appCreationJSONTemplatePath); throw new CloudConnectorException(message, e); } }
AzureCredentialAppCreationCommand { public AzureApplicationCreationView generateJSON(String deploymentAddress) { try { String appIdentifierURI = getAppIdentifierURI(deploymentAddress); String appSecret = UUID.randomUUID().toString(); String replyURL = getReplyURL(deploymentAddress); Template template = freemarkerConfiguration.getTemplate(appCreationJSONTemplatePath, ENCODING); Map<String, Object> model = buildModel(deploymentAddress, appIdentifierURI, replyURL); model.put("appSecret", appSecret); model.put("keyId", UUID.randomUUID().toString()); String creationRequestPayload = processTemplateIntoString(template, model); return new AzureApplicationCreationView(appIdentifierURI, appSecret, replyURL, creationRequestPayload); } catch (IOException | TemplateException e) { String message = String.format(GENERATE_EXCEPTION_MESSAGE_FORMAT, appCreationJSONTemplatePath); throw new CloudConnectorException(message, e); } } }
AzureCredentialAppCreationCommand { public AzureApplicationCreationView generateJSON(String deploymentAddress) { try { String appIdentifierURI = getAppIdentifierURI(deploymentAddress); String appSecret = UUID.randomUUID().toString(); String replyURL = getReplyURL(deploymentAddress); Template template = freemarkerConfiguration.getTemplate(appCreationJSONTemplatePath, ENCODING); Map<String, Object> model = buildModel(deploymentAddress, appIdentifierURI, replyURL); model.put("appSecret", appSecret); model.put("keyId", UUID.randomUUID().toString()); String creationRequestPayload = processTemplateIntoString(template, model); return new AzureApplicationCreationView(appIdentifierURI, appSecret, replyURL, creationRequestPayload); } catch (IOException | TemplateException e) { String message = String.format(GENERATE_EXCEPTION_MESSAGE_FORMAT, appCreationJSONTemplatePath); throw new CloudConnectorException(message, e); } }  }
AzureCredentialAppCreationCommand { public AzureApplicationCreationView generateJSON(String deploymentAddress) { try { String appIdentifierURI = getAppIdentifierURI(deploymentAddress); String appSecret = UUID.randomUUID().toString(); String replyURL = getReplyURL(deploymentAddress); Template template = freemarkerConfiguration.getTemplate(appCreationJSONTemplatePath, ENCODING); Map<String, Object> model = buildModel(deploymentAddress, appIdentifierURI, replyURL); model.put("appSecret", appSecret); model.put("keyId", UUID.randomUUID().toString()); String creationRequestPayload = processTemplateIntoString(template, model); return new AzureApplicationCreationView(appIdentifierURI, appSecret, replyURL, creationRequestPayload); } catch (IOException | TemplateException e) { String message = String.format(GENERATE_EXCEPTION_MESSAGE_FORMAT, appCreationJSONTemplatePath); throw new CloudConnectorException(message, e); } }  String generate(String deploymentAddress); AzureApplicationCreationView generateJSON(String deploymentAddress); }
AzureCredentialAppCreationCommand { public AzureApplicationCreationView generateJSON(String deploymentAddress) { try { String appIdentifierURI = getAppIdentifierURI(deploymentAddress); String appSecret = UUID.randomUUID().toString(); String replyURL = getReplyURL(deploymentAddress); Template template = freemarkerConfiguration.getTemplate(appCreationJSONTemplatePath, ENCODING); Map<String, Object> model = buildModel(deploymentAddress, appIdentifierURI, replyURL); model.put("appSecret", appSecret); model.put("keyId", UUID.randomUUID().toString()); String creationRequestPayload = processTemplateIntoString(template, model); return new AzureApplicationCreationView(appIdentifierURI, appSecret, replyURL, creationRequestPayload); } catch (IOException | TemplateException e) { String message = String.format(GENERATE_EXCEPTION_MESSAGE_FORMAT, appCreationJSONTemplatePath); throw new CloudConnectorException(message, e); } }  String generate(String deploymentAddress); AzureApplicationCreationView generateJSON(String deploymentAddress);  }