@Test public void testProvideWhenOnlyPublicSubnetsAndInterfaceServicesWithDifferentAzs() throws IOException, TemplateException { ObjectMapper objectMapper = new ObjectMapper(); JsonNode expectedJson = objectMapper.readTree(new File("src/test/resources/json/aws-cf-network-publicsubnet-vpcendpoints-differentazs.json")); when(freeMarkerTemplateUtils.processTemplateIntoString(any(), any())).thenCallRealMethod(); AmazonEC2Client ec2Client = mock(AmazonEC2Client.class); when(awsClient.createAccess(any(), anyString())).thenReturn(ec2Client); when(ec2Client.describeVpcEndpointServices()).thenReturn(createDescribeVpcEndpointServicesResultWithDifferentAzs()); NetworkCreationRequest networkCreationRequest = createNetworkRequest(true, true); List<SubnetRequest> subnetRequestList = createPublicSubnetRequestList(); String actual = underTest.provide(networkCreationRequest, subnetRequestList); JsonNode json = objectMapper.readTree(actual); assertEquals(expectedJson, json); verify(freeMarkerTemplateUtils).processTemplateIntoString(any(Template.class), anyMap()); }
public String provide(NetworkCreationRequest networkCreationRequest, List<SubnetRequest> subnets) { Map<String, Object> model = createModel(networkCreationRequest, subnets); try { String freeMarkerTemplate = freemarkerConfiguration.getTemplate(cloudFormationNetworkTemplatePath, "UTF-8").toString(); Template template = new Template("aws-template", freeMarkerTemplate, freemarkerConfiguration); return freeMarkerTemplateUtils.processTemplateIntoString(template, model).replaceAll("\\t|\\n| [\\s]+", ""); } catch (IOException | TemplateException e) { throw new CloudConnectorException("Failed to process CloudFormation freemarker template", e); } }
AwsNetworkCfTemplateProvider { public String provide(NetworkCreationRequest networkCreationRequest, List<SubnetRequest> subnets) { Map<String, Object> model = createModel(networkCreationRequest, subnets); try { String freeMarkerTemplate = freemarkerConfiguration.getTemplate(cloudFormationNetworkTemplatePath, "UTF-8").toString(); Template template = new Template("aws-template", freeMarkerTemplate, freemarkerConfiguration); return freeMarkerTemplateUtils.processTemplateIntoString(template, model).replaceAll("\\t|\\n| [\\s]+", ""); } catch (IOException | TemplateException e) { throw new CloudConnectorException("Failed to process CloudFormation freemarker template", e); } } }
AwsNetworkCfTemplateProvider { public String provide(NetworkCreationRequest networkCreationRequest, List<SubnetRequest> subnets) { Map<String, Object> model = createModel(networkCreationRequest, subnets); try { String freeMarkerTemplate = freemarkerConfiguration.getTemplate(cloudFormationNetworkTemplatePath, "UTF-8").toString(); Template template = new Template("aws-template", freeMarkerTemplate, freemarkerConfiguration); return freeMarkerTemplateUtils.processTemplateIntoString(template, model).replaceAll("\\t|\\n| [\\s]+", ""); } catch (IOException | TemplateException e) { throw new CloudConnectorException("Failed to process CloudFormation freemarker template", e); } }  }
AwsNetworkCfTemplateProvider { public String provide(NetworkCreationRequest networkCreationRequest, List<SubnetRequest> subnets) { Map<String, Object> model = createModel(networkCreationRequest, subnets); try { String freeMarkerTemplate = freemarkerConfiguration.getTemplate(cloudFormationNetworkTemplatePath, "UTF-8").toString(); Template template = new Template("aws-template", freeMarkerTemplate, freemarkerConfiguration); return freeMarkerTemplateUtils.processTemplateIntoString(template, model).replaceAll("\\t|\\n| [\\s]+", ""); } catch (IOException | TemplateException e) { throw new CloudConnectorException("Failed to process CloudFormation freemarker template", e); } }  String provide(NetworkCreationRequest networkCreationRequest, List<SubnetRequest> subnets); }
AwsNetworkCfTemplateProvider { public String provide(NetworkCreationRequest networkCreationRequest, List<SubnetRequest> subnets) { Map<String, Object> model = createModel(networkCreationRequest, subnets); try { String freeMarkerTemplate = freemarkerConfiguration.getTemplate(cloudFormationNetworkTemplatePath, "UTF-8").toString(); Template template = new Template("aws-template", freeMarkerTemplate, freemarkerConfiguration); return freeMarkerTemplateUtils.processTemplateIntoString(template, model).replaceAll("\\t|\\n| [\\s]+", ""); } catch (IOException | TemplateException e) { throw new CloudConnectorException("Failed to process CloudFormation freemarker template", e); } }  String provide(NetworkCreationRequest networkCreationRequest, List<SubnetRequest> subnets); static final String VPC_INTERFACE_SERVICE_ENDPOINT_NAME_PATTERN; }