Skip to content

Commit

Permalink
fix(init-templates): update init templates for csharp and java (#5059)
Browse files Browse the repository at this point in the history
Changed C#/Java parameter naming to match ts

Removed unnecessary null param in C#

Significant Java init template revision to create empty app with correct structure using templated naming instead of sample app with static naming
  • Loading branch information
NGL321 authored and shivlaks committed Nov 18, 2019
1 parent 399ce29 commit 2d92ab3
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 411 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace %name.PascalCased%
{
public class %name.PascalCased%Stack : Stack
{
public %name.PascalCased%Stack(Construct parent, string id, IStackProps props) : base(parent, id, props)
public %name.PascalCased%Stack(Construct scope, string id, IStackProps props) : base(scope, id, props)
{
// The code that defines your stack goes here
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Program
{
static void Main(string[] args)
{
var app = new App(null);
var app = new App();
new %name.PascalCased%Stack(app, "%name.PascalCased%Stack", new StackProps());
app.Synth();
}
Expand Down
29 changes: 1 addition & 28 deletions packages/aws-cdk/lib/init-templates/app/java/pom.template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<mainClass>com.myorg.HelloApp</mainClass>
<mainClass>com.myorg.%name.PascalCased%App</mainClass>
</configuration>
</plugin>
</plugins>
Expand All @@ -42,33 +42,6 @@
<version>%cdk-version%.DEVPREVIEW</version>
</dependency>

<!-- Respective AWS Construct Libraries -->
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>iam</artifactId>
<version>%cdk-version%.DEVPREVIEW</version>
</dependency>
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>s3</artifactId>
<version>%cdk-version%.DEVPREVIEW</version>
</dependency>
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>sns</artifactId>
<version>%cdk-version%.DEVPREVIEW</version>
</dependency>
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>sns-subscriptions</artifactId>
<version>%cdk-version%.DEVPREVIEW</version>
</dependency>
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>sqs</artifactId>
<version>%cdk-version%.DEVPREVIEW</version>
</dependency>

<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@

import java.util.Arrays;

public class HelloApp {
public class %name.PascalCased%App {
public static void main(final String argv[]) {
App app = new App();

new HelloStack(app, "hello-cdk-1");
new HelloStack(app, "hello-cdk-2");
new %name.PascalCased%Stack(app, "%name.PascalCased%Stack");

// required until https://github.com/aws/jsii/issues/456 is resolved
app.synth();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.myorg;

import software.amazon.awscdk.core.Stack;
import software.amazon.awscdk.core.Construct;

public class %name.PascalCased%Stack extends Stack {
public %name.PascalCased%Stack(final Construct scope, final String id) {
super(scope, id, null);

// The code that defines your stack goes here
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@

import java.io.IOException;

import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertEquals;

public class HelloStackTest {
public class %name.PascalCased%Test {
private final static ObjectMapper JSON =
new ObjectMapper().configure(SerializationFeature.INDENT_OUTPUT, true);

@Test
public void testStack() throws IOException {
App app = new App();
HelloStack stack = new HelloStack(app, "test");
%name.PascalCased%Stack stack = new %name.PascalCased%Stack(app, "test");

// synthesize the stack to a CloudFormation template and compare against
// a checked-in JSON file.
JsonNode actual = JSON.valueToTree(app.synth().getStackArtifact(stack.getArtifactId()).getTemplate());
JsonNode expected = JSON.readTree(getClass().getResource("expected.cfn.json"));
assertEquals(expected, actual);
assertEquals(new ObjectMapper().createObjectNode(), actual);
}
}
Loading

0 comments on commit 2d92ab3

Please sign in to comment.