diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptDelegator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptDelegator.java index eceac52b7ea..d6d6013d2ab 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptDelegator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptDelegator.java @@ -91,9 +91,6 @@ void useShapeWriter(Shape shape, Consumer writerConsumer) { // Checkout/create the appropriate writer for the shape. Symbol symbol = symbolProvider.toSymbol(shape); String fileName = symbol.getDefinitionFile(); - if (!fileName.startsWith(Paths.get(".", CodegenUtils.SOURCE_FOLDER).toString())) { - fileName = Paths.get(".", CodegenUtils.SOURCE_FOLDER, fileName).toString(); - } TypeScriptWriter writer = checkoutWriter(fileName); // Add any needed DECLARE symbols. diff --git a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/CodegenVisitorTest.java b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/CodegenVisitorTest.java index 142635153bd..cb97ccf9ea2 100644 --- a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/CodegenVisitorTest.java +++ b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/CodegenVisitorTest.java @@ -3,13 +3,12 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Optional; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import software.amazon.smithy.build.MockManifest; import software.amazon.smithy.build.PluginContext; -import software.amazon.smithy.codegen.core.CodegenException; import software.amazon.smithy.model.Model; import software.amazon.smithy.model.node.Node; import software.amazon.smithy.model.node.ObjectNode; @@ -36,10 +35,10 @@ public void generatesRuntimeConfigFiles() { // Did we generate the runtime config files? // note that asserting the contents of runtime config files is handled in its own unit tests. - Assertions.assertTrue(manifest.hasFile("package.json")); - Assertions.assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/runtimeConfig.browser.ts")); - Assertions.assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/runtimeConfig.ts")); - Assertions.assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/index.ts")); + assertTrue(manifest.hasFile("package.json")); + assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/runtimeConfig.browser.ts")); + assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/runtimeConfig.ts")); + assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/index.ts")); // Does the package.json file point to the runtime config? String packageJsonContents = manifest.getFileString("package.json").get(); @@ -69,8 +68,8 @@ public void decoratesSymbolProvider() { new TypeScriptCodegenPlugin().execute(context); - Assertions.assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/Foo.ts")); - assertThat(manifest.getFileString(CodegenUtils.SOURCE_FOLDER + "/Foo.ts").get(), containsString("export class Foo")); + assertTrue(manifest.hasFile("Foo.ts")); + assertThat(manifest.getFileString("Foo.ts").get(), containsString("export class Foo")); } @Test @@ -91,11 +90,11 @@ public void generatesServiceClients() { .build(); new TypeScriptCodegenPlugin().execute(context); - Assertions.assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/Example.ts")); + assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/Example.ts")); assertThat(manifest.getFileString(CodegenUtils.SOURCE_FOLDER + "/Example.ts").get(), containsString("export class Example extends ExampleClient")); - Assertions.assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/ExampleClient.ts")); + assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/ExampleClient.ts")); assertThat(manifest.getFileString(CodegenUtils.SOURCE_FOLDER + "/ExampleClient.ts").get(), containsString("export class ExampleClient")); } diff --git a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/TypeScriptDelegatorTest.java b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/TypeScriptDelegatorTest.java index 6fd20c777de..1f983ca9c2c 100644 --- a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/TypeScriptDelegatorTest.java +++ b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/TypeScriptDelegatorTest.java @@ -1,5 +1,11 @@ package software.amazon.smithy.typescript.codegen; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.equalTo; + +import java.util.ArrayList; +import java.util.List; import org.junit.jupiter.api.Test; import software.amazon.smithy.build.MockManifest; import software.amazon.smithy.codegen.core.Symbol; @@ -11,13 +17,6 @@ import software.amazon.smithy.utils.ListUtils; import software.amazon.smithy.utils.Pair; -import java.util.ArrayList; -import java.util.List; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.Matchers.equalTo; - public class TypeScriptDelegatorTest { @Test public void vendsWritersForShapes() { @@ -32,7 +31,7 @@ public void vendsWritersForShapes() { delegator.useShapeWriter(fooShape, writer -> writer.write("Hello!")); delegator.flushWriters(); - assertThat(manifest.getFileString(CodegenUtils.SOURCE_FOLDER + "/Foo.txt").get(), equalTo("Hello!\n")); + assertThat(manifest.getFileString("Foo.txt").get(), equalTo("Hello!\n")); } @Test @@ -61,7 +60,7 @@ public void appendsToOpenedWriterWithNewline() { delegator.useShapeWriter(fooShape, writer -> writer.write("Goodbye!")); delegator.flushWriters(); - assertThat(manifest.getFileString(CodegenUtils.SOURCE_FOLDER + "/Foo.txt").get(), equalTo("Hello!\n\nGoodbye!\n")); + assertThat(manifest.getFileString("Foo.txt").get(), equalTo("Hello!\n\nGoodbye!\n")); } @Test