@Test public void testBuildShouldReturnTheRenderedTemplate() throws IOException, TemplateException { NetworkCreationRequest networkCreationRequest = createRequest(); ResourceGroup resourceGroup = mock(ResourceGroup.class); ObjectMapper objectMapper = new ObjectMapper(); JsonNode expectedJson = objectMapper.readTree(new File("src/test/resources/json/arm-network.json")); when(freeMarkerTemplateUtils.processTemplateIntoString(any(), any())).thenCallRealMethod(); when(resourceGroup.name()).thenReturn("testRg"); String actual = underTest.build(networkCreationRequest, Lists.newArrayList( publicSubnetRequest("10.0.1.0/24", 0), publicSubnetRequest("10.0.1.0/24", 1), publicSubnetRequest("10.0.1.0/24", 2)), resourceGroup.name()); JsonNode json = objectMapper.readTree(actual); assertEquals(expectedJson, json); verify(freeMarkerTemplateUtils).processTemplateIntoString(any(Template.class), anyMap()); }
public String build(NetworkCreationRequest networkRequest, List<SubnetRequest> subnets, String resourceGroupName) { try { Map<String, Object> model = createModel(networkRequest, subnets, resourceGroupName); String generatedTemplate = freeMarkerTemplateUtils.processTemplateIntoString(getTemplate(), model); LOGGER.debug("Generated Arm template: {}", generatedTemplate); return generatedTemplate; } catch (IOException | TemplateException e) { throw new CloudConnectorException("Failed to process the ARM TemplateBuilder", e); } }
AzureNetworkTemplateBuilder { public String build(NetworkCreationRequest networkRequest, List<SubnetRequest> subnets, String resourceGroupName) { try { Map<String, Object> model = createModel(networkRequest, subnets, resourceGroupName); String generatedTemplate = freeMarkerTemplateUtils.processTemplateIntoString(getTemplate(), model); LOGGER.debug("Generated Arm template: {}", generatedTemplate); return generatedTemplate; } catch (IOException | TemplateException e) { throw new CloudConnectorException("Failed to process the ARM TemplateBuilder", e); } } }
AzureNetworkTemplateBuilder { public String build(NetworkCreationRequest networkRequest, List<SubnetRequest> subnets, String resourceGroupName) { try { Map<String, Object> model = createModel(networkRequest, subnets, resourceGroupName); String generatedTemplate = freeMarkerTemplateUtils.processTemplateIntoString(getTemplate(), model); LOGGER.debug("Generated Arm template: {}", generatedTemplate); return generatedTemplate; } catch (IOException | TemplateException e) { throw new CloudConnectorException("Failed to process the ARM TemplateBuilder", e); } }  }
AzureNetworkTemplateBuilder { public String build(NetworkCreationRequest networkRequest, List<SubnetRequest> subnets, String resourceGroupName) { try { Map<String, Object> model = createModel(networkRequest, subnets, resourceGroupName); String generatedTemplate = freeMarkerTemplateUtils.processTemplateIntoString(getTemplate(), model); LOGGER.debug("Generated Arm template: {}", generatedTemplate); return generatedTemplate; } catch (IOException | TemplateException e) { throw new CloudConnectorException("Failed to process the ARM TemplateBuilder", e); } }  String build(NetworkCreationRequest networkRequest, List<SubnetRequest> subnets, String resourceGroupName); }
AzureNetworkTemplateBuilder { public String build(NetworkCreationRequest networkRequest, List<SubnetRequest> subnets, String resourceGroupName) { try { Map<String, Object> model = createModel(networkRequest, subnets, resourceGroupName); String generatedTemplate = freeMarkerTemplateUtils.processTemplateIntoString(getTemplate(), model); LOGGER.debug("Generated Arm template: {}", generatedTemplate); return generatedTemplate; } catch (IOException | TemplateException e) { throw new CloudConnectorException("Failed to process the ARM TemplateBuilder", e); } }  String build(NetworkCreationRequest networkRequest, List<SubnetRequest> subnets, String resourceGroupName);  }