diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/AnnotationTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/AnnotationTraitTest.java deleted file mode 100644 index 7cfb02cbadc..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/AnnotationTraitTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import com.example.traits.BasicAnnotationTraitTrait; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; - - -class AnnotationTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("annotation-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct$fieldA")); - shape.expectTrait(BasicAnnotationTraitTrait.class); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - TraitFactory provider = TraitFactory.createServiceFactory(); - Trait trait = - provider.createTrait(BasicAnnotationTraitTrait.ID, id, Node.objectNode()).orElseThrow(RuntimeException::new); - BasicAnnotationTraitTrait annotation = (BasicAnnotationTraitTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals(trait, - provider.createTrait(BasicAnnotationTraitTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/BigDecimalTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/BigDecimalTraitTest.java deleted file mode 100644 index fa294759d4d..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/BigDecimalTraitTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import com.example.traits.HttpCodeBigDecimalTrait; -import java.math.BigDecimal; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; - -class BigDecimalTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("big-decimal-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - HttpCodeBigDecimalTrait trait = shape.expectTrait(HttpCodeBigDecimalTrait.class); - assertEquals(new BigDecimal("100.01"), trait.getValue()); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - TraitFactory provider = TraitFactory.createServiceFactory(); - Trait trait = - provider.createTrait(HttpCodeBigDecimalTrait.ID, id, Node.from(1)).orElseThrow(RuntimeException::new); - HttpCodeBigDecimalTrait annotation = (HttpCodeBigDecimalTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals(trait, - provider.createTrait(HttpCodeBigDecimalTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/BigIntegerTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/BigIntegerTraitTest.java deleted file mode 100644 index b31e3d61b41..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/BigIntegerTraitTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import com.example.traits.HttpCodeBigIntegerTrait; -import java.math.BigInteger; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; - -class BigIntegerTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("big-integer-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - HttpCodeBigIntegerTrait trait = shape.expectTrait(HttpCodeBigIntegerTrait.class); - assertEquals(new BigInteger("100"), trait.getValue()); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - TraitFactory provider = TraitFactory.createServiceFactory(); - Trait trait = - provider.createTrait(HttpCodeBigIntegerTrait.ID, id, Node.from(1)).orElseThrow(RuntimeException::new); - HttpCodeBigIntegerTrait annotation = (HttpCodeBigIntegerTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals(trait, - provider.createTrait(HttpCodeBigIntegerTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/ByteTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/ByteTraitTest.java deleted file mode 100644 index 8695db5f13d..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/ByteTraitTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import com.example.traits.HttpCodeByteTrait; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; - -class ByteTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("byte-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - HttpCodeByteTrait trait = shape.expectTrait(HttpCodeByteTrait.class); - byte expected = 1; - assertEquals(expected, trait.getValue()); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - TraitFactory provider = TraitFactory.createServiceFactory(); - Trait trait = provider.createTrait(HttpCodeByteTrait.ID, id, Node.from(1)).orElseThrow(RuntimeException::new); - HttpCodeByteTrait annotation = (HttpCodeByteTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals(trait, - provider.createTrait(HttpCodeByteTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/CreatesTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/CreatesTraitTest.java new file mode 100644 index 00000000000..35e1e550033 --- /dev/null +++ b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/CreatesTraitTest.java @@ -0,0 +1,113 @@ +package software.amazon.smithy.traitcodegen.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.example.traits.BasicAnnotationTraitTrait; +import com.example.traits.HttpCodeBigDecimalTrait; +import com.example.traits.HttpCodeBigIntegerTrait; +import com.example.traits.HttpCodeByteTrait; +import com.example.traits.HttpCodeDoubleTrait; +import com.example.traits.HttpCodeFloatTrait; +import com.example.traits.HttpCodeIntegerTrait; +import com.example.traits.HttpCodeLongTrait; +import com.example.traits.HttpCodeShortTrait; +import com.example.traits.JsonMetadataTrait; +import com.example.traits.ListMember; +import com.example.traits.MapValue; +import com.example.traits.NestedA; +import com.example.traits.NestedB; +import com.example.traits.NumberListTraitTrait; +import com.example.traits.NumberSetTraitTrait; +import com.example.traits.ResponseTypeIntTrait; +import com.example.traits.ResponseTypeTrait; +import com.example.traits.StringListTraitTrait; +import com.example.traits.StringSetTraitTrait; +import com.example.traits.StringStringMapTrait; +import com.example.traits.StringToStructMapTrait; +import com.example.traits.StringTraitTrait; +import com.example.traits.StructureListTraitTrait; +import com.example.traits.StructureSetTraitTrait; +import com.example.traits.StructureTraitTrait; +import java.util.stream.Stream; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import software.amazon.smithy.model.SourceLocation; +import software.amazon.smithy.model.node.ArrayNode; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.shapes.ShapeId; +import software.amazon.smithy.model.traits.Trait; +import software.amazon.smithy.model.traits.TraitFactory; +import software.amazon.smithy.utils.ListUtils; +import software.amazon.smithy.utils.MapUtils; + +public class CreatesTraitTest { + private static final ShapeId DUMMY_ID = ShapeId.from("ns.foo#foo"); + private final TraitFactory provider = TraitFactory.createServiceFactory(); + + static Stream createTraitTests() { + return Stream.of( + Arguments.of(BasicAnnotationTraitTrait.ID, Node.objectNode()), + Arguments.of(HttpCodeBigDecimalTrait.ID, Node.from(1)), + Arguments.of(HttpCodeBigIntegerTrait.ID, Node.from(1)), + Arguments.of(HttpCodeByteTrait.ID, Node.from(1)), + Arguments.of(JsonMetadataTrait.ID, Node.objectNodeBuilder() + .withMember("metadata", "woo") + .withMember("more", "yay") + .build() + ), + Arguments.of(HttpCodeDoubleTrait.ID, Node.from(1.2)), + Arguments.of(ResponseTypeTrait.ID, Node.from("no")), + Arguments.of(HttpCodeFloatTrait.ID, Node.from(1.2)), + Arguments.of(HttpCodeIntegerTrait.ID, Node.from(1)), + Arguments.of(ResponseTypeIntTrait.ID, Node.from(2)), + Arguments.of(HttpCodeLongTrait.ID, Node.from(1L)), + Arguments.of(NumberListTraitTrait.ID, ArrayNode.fromNodes( + Node.from(1), Node.from(2), Node.from(3)) + ), + Arguments.of(NumberSetTraitTrait.ID, ArrayNode.fromNodes( + Node.from(1), Node.from(2), Node.from(3)) + ), + Arguments.of(HttpCodeShortTrait.ID, Node.from(1)), + Arguments.of(StringListTraitTrait.ID, ArrayNode.fromStrings("a", "b", "c")), + Arguments.of(StringSetTraitTrait.ID, ArrayNode.fromStrings("a", "b", "c")), + Arguments.of(StringStringMapTrait.ID, StringStringMapTrait.builder() + .putValues("a", "first").putValues("b", "other").build().toNode() + ), + Arguments.of(StringToStructMapTrait.ID, StringToStructMapTrait.builder() + .putValues("one", MapValue.builder().a("foo").b(2).build()) + .putValues("two", MapValue.builder().a("bar").b(4).build()) + .build().toNode() + ), + Arguments.of(StringTraitTrait.ID, Node.from("SPORKZ SPOONS YAY! Utensils.")), + Arguments.of(StructureListTraitTrait.ID, ArrayNode.fromNodes( + ListMember.builder().a("first").b(1).c("other").build().toNode(), + ListMember.builder().a("second").b(2).c("more").build().toNode() + )), + Arguments.of(StructureSetTraitTrait.ID, ArrayNode.fromNodes( + ListMember.builder().a("first").b(1).c("other").build().toNode(), + ListMember.builder().a("second").b(2).c("more").build().toNode() + )), + Arguments.of(StructureTraitTrait.ID, StructureTraitTrait.builder() + .fieldA("a") + .fieldB(true) + .fieldC(NestedA.builder() + .fieldN("nested") + .fieldQ(false) + .fieldZ(NestedB.B) + .build() + ) + .fieldD(ListUtils.of("a", "b", "c")) + .fieldE(MapUtils.of("a", "one", "b", "two")) + .build().toNode() + )); + } + + @ParameterizedTest + @MethodSource("createTraitTests") + void createsTraitFromNode(ShapeId traitId, Node fromNode) { + Trait trait = provider.createTrait(traitId, DUMMY_ID, fromNode).orElseThrow(RuntimeException::new); + assertEquals(SourceLocation.NONE, trait.getSourceLocation()); + assertEquals(trait, provider.createTrait(traitId, DUMMY_ID, trait.toNode()).orElseThrow(RuntimeException::new)); + } +} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/DocumentTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/DocumentTraitTest.java deleted file mode 100644 index ae0d63201d4..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/DocumentTraitTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import com.example.traits.JsonMetadataTrait; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; - -class DocumentTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("document-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - JsonMetadataTrait trait = shape.expectTrait(JsonMetadataTrait.class); - Node expected = Node.objectNodeBuilder() - .withMember("metadata", "woo") - .withMember("more", "yay") - .build(); - assertEquals(expected, trait.toNode()); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - TraitFactory provider = TraitFactory.createServiceFactory(); - Node expected = Node.objectNodeBuilder() - .withMember("metadata", "woo") - .withMember("more", "yay") - .build(); - Trait trait = - provider.createTrait(JsonMetadataTrait.ID, id, expected).orElseThrow(RuntimeException::new); - JsonMetadataTrait annotation = (JsonMetadataTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals(trait, - provider.createTrait(JsonMetadataTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/DoubleTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/DoubleTraitTest.java deleted file mode 100644 index e072fd70f63..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/DoubleTraitTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import com.example.traits.HttpCodeDoubleTrait; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; - -class DoubleTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("double-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - HttpCodeDoubleTrait trait = shape.expectTrait(HttpCodeDoubleTrait.class); - assertEquals(1.1, trait.getValue()); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - TraitFactory provider = TraitFactory.createServiceFactory(); - Trait trait = - provider.createTrait(HttpCodeDoubleTrait.ID, id, Node.from(1.2)).orElseThrow(RuntimeException::new); - HttpCodeDoubleTrait annotation = (HttpCodeDoubleTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals(trait, - provider.createTrait(HttpCodeDoubleTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/EnumTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/EnumTraitTest.java deleted file mode 100644 index 40759213c72..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/EnumTraitTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.example.traits.ResponseTypeTrait; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; - -public class EnumTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("enum-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - ResponseTypeTrait trait = shape.expectTrait(ResponseTypeTrait.class); - assertTrue(trait.isYes()); - assertEquals("yes", trait.getValue()); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - Node node = Node.from("no"); - TraitFactory provider = TraitFactory.createServiceFactory(); - Trait trait = provider.createTrait(ResponseTypeTrait.ID, id, node).orElseThrow(RuntimeException::new); - ResponseTypeTrait enumTrait = (ResponseTypeTrait) trait; - assertEquals(SourceLocation.NONE, enumTrait.getSourceLocation()); - assertEquals("no", enumTrait.getValue()); - assertEquals(trait, - provider.createTrait(ResponseTypeTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/FloatTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/FloatTraitTest.java deleted file mode 100644 index 59abab5b7a4..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/FloatTraitTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import com.example.traits.HttpCodeFloatTrait; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; - -class FloatTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("float-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - HttpCodeFloatTrait trait = shape.expectTrait(HttpCodeFloatTrait.class); - assertEquals(1.1, trait.getValue(), 0.0001); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - TraitFactory provider = TraitFactory.createServiceFactory(); - Trait trait = - provider.createTrait(HttpCodeFloatTrait.ID, id, Node.from(1.2)).orElseThrow(RuntimeException::new); - HttpCodeFloatTrait annotation = (HttpCodeFloatTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals(trait, - provider.createTrait(HttpCodeFloatTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/IdRefTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/IdRefTest.java deleted file mode 100644 index 716c8cb328e..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/IdRefTest.java +++ /dev/null @@ -1,57 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertIterableEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.example.traits.IdRefListTrait; -import com.example.traits.IdRefMapTrait; -import com.example.traits.IdRefStringTrait; -import com.example.traits.IdRefStructTrait; -import com.example.traits.IdRefStructWithNestedIdsTrait; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.utils.ListUtils; - -class IdRefTest { - private static final ShapeId TARGET_ONE = ShapeId.from("test.smithy.traitcodegen#IdRefTarget1"); - private static final ShapeId TARGET_TWO = ShapeId.from("test.smithy.traitcodegen#IdRefTarget2"); - - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("id-ref.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - - // Single string representing an IdRef - IdRefStringTrait idRefStringTrait = shape.expectTrait(IdRefStringTrait.class); - assertEquals(TARGET_ONE, idRefStringTrait.getValue()); - - // List of ShapeIDs - IdRefListTrait idRefListTrait = shape.expectTrait(IdRefListTrait.class); - assertIterableEquals(ListUtils.of(TARGET_ONE, TARGET_TWO), idRefListTrait.getValues()); - - // Map of ShapeIDs - IdRefMapTrait idRefMapTrait = shape.expectTrait(IdRefMapTrait.class); - assertEquals(2, idRefMapTrait.getValues().size()); - assertEquals(TARGET_ONE, idRefMapTrait.getValues().get("a")); - assertEquals(TARGET_TWO, idRefMapTrait.getValues().get("b")); - - // Shape ID as member of a structure - IdRefStructTrait idRefStructTrait = shape.expectTrait(IdRefStructTrait.class); - assertTrue(idRefStructTrait.getFieldA().isPresent()); - assertEquals(TARGET_ONE, idRefStructTrait.getFieldA().get()); - - IdRefStructWithNestedIdsTrait idRefStructWithNestedIds = shape.expectTrait(IdRefStructWithNestedIdsTrait.class); - assertEquals(TARGET_ONE, idRefStructWithNestedIds.getIdRefHolder().getId()); - assertIterableEquals(ListUtils.of(TARGET_ONE, TARGET_TWO), idRefStructWithNestedIds.getIdList()); - assertEquals(TARGET_ONE, idRefStructWithNestedIds.getIdMap().get("a")); - assertEquals(TARGET_TWO, idRefStructWithNestedIds.getIdMap().get("b")); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/IntEnumTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/IntEnumTraitTest.java deleted file mode 100644 index 3153dd680db..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/IntEnumTraitTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.example.traits.ResponseTypeIntTrait; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; - -class IntEnumTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("int-enum-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - ResponseTypeIntTrait trait = shape.expectTrait(ResponseTypeIntTrait.class); - assertTrue(trait.isYes()); - assertEquals(1, trait.getValue()); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - Node node = Node.from(2); - TraitFactory provider = TraitFactory.createServiceFactory(); - Trait trait = provider.createTrait(ResponseTypeIntTrait.ID, id, node).orElseThrow(RuntimeException::new); - ResponseTypeIntTrait enumTrait = (ResponseTypeIntTrait) trait; - assertEquals(SourceLocation.NONE, enumTrait.getSourceLocation()); - assertEquals(2, enumTrait.getValue()); - assertEquals(trait, - provider.createTrait(ResponseTypeIntTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/IntegerTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/IntegerTraitTest.java deleted file mode 100644 index 4bac861f754..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/IntegerTraitTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import com.example.traits.HttpCodeIntegerTrait; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; - -class IntegerTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("integer-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - HttpCodeIntegerTrait trait = shape.expectTrait(HttpCodeIntegerTrait.class); - assertEquals(1, trait.getValue()); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - TraitFactory provider = TraitFactory.createServiceFactory(); - Trait trait = - provider.createTrait(HttpCodeIntegerTrait.ID, id, Node.from(1)).orElseThrow(RuntimeException::new); - HttpCodeIntegerTrait annotation = (HttpCodeIntegerTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals(trait, - provider.createTrait(HttpCodeIntegerTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/LoadsFromModelTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/LoadsFromModelTest.java new file mode 100644 index 00000000000..1f490adafdc --- /dev/null +++ b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/LoadsFromModelTest.java @@ -0,0 +1,182 @@ +package software.amazon.smithy.traitcodegen.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertIterableEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.example.traits.BasicAnnotationTraitTrait; +import com.example.traits.HttpCodeBigDecimalTrait; +import com.example.traits.HttpCodeBigIntegerTrait; +import com.example.traits.HttpCodeByteTrait; +import com.example.traits.HttpCodeDoubleTrait; +import com.example.traits.HttpCodeFloatTrait; +import com.example.traits.HttpCodeIntegerTrait; +import com.example.traits.HttpCodeLongTrait; +import com.example.traits.HttpCodeShortTrait; +import com.example.traits.IdRefListTrait; +import com.example.traits.IdRefMapTrait; +import com.example.traits.IdRefStringTrait; +import com.example.traits.IdRefStructTrait; +import com.example.traits.IdRefStructWithNestedIdsTrait; +import com.example.traits.JsonMetadataTrait; +import com.example.traits.ListMember; +import com.example.traits.MapValue; +import com.example.traits.NestedA; +import com.example.traits.NestedB; +import com.example.traits.NestedIdRefHolder; +import com.example.traits.NumberListTraitTrait; +import com.example.traits.NumberSetTraitTrait; +import com.example.traits.ResponseTypeIntTrait; +import com.example.traits.ResponseTypeTrait; +import com.example.traits.StringListTraitTrait; +import com.example.traits.StringSetTraitTrait; +import com.example.traits.StringStringMapTrait; +import com.example.traits.StringToStructMapTrait; +import com.example.traits.StringTraitTrait; +import com.example.traits.StructureListTraitTrait; +import com.example.traits.StructureSetTraitTrait; +import com.example.traits.StructureTraitTrait; +import java.lang.reflect.InvocationTargetException; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Stream; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import software.amazon.smithy.model.Model; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.shapes.Shape; +import software.amazon.smithy.model.shapes.ShapeId; +import software.amazon.smithy.model.traits.Trait; +import software.amazon.smithy.utils.ListUtils; +import software.amazon.smithy.utils.MapUtils; +import software.amazon.smithy.utils.SetUtils; + +public class LoadsFromModelTest { + private static final ShapeId ID = ShapeId.from("test.smithy.traitcodegen#myStruct"); + private static final ShapeId TARGET_ONE = ShapeId.from("test.smithy.traitcodegen#IdRefTarget1"); + private static final ShapeId TARGET_TWO = ShapeId.from("test.smithy.traitcodegen#IdRefTarget2"); + + + static Stream loadsModelTests() { + return Stream.of( + Arguments.of("annotation-trait.smithy", BasicAnnotationTraitTrait.class, + Collections.emptyMap()), + Arguments.of("big-decimal-trait.smithy", HttpCodeBigDecimalTrait.class, + MapUtils.of("getValue", new BigDecimal("100.01"))), + Arguments.of("big-integer-trait.smithy", HttpCodeBigIntegerTrait.class, + MapUtils.of("getValue", new BigInteger("100"))), + Arguments.of("byte-trait.smithy", HttpCodeByteTrait.class, + MapUtils.of("getValue", (byte) 1)), + Arguments.of("document-trait.smithy", JsonMetadataTrait.class, + MapUtils.of("toNode", Node.objectNodeBuilder() + .withMember("metadata", "woo") + .withMember("more", "yay") + .build())), + Arguments.of("double-trait.smithy", HttpCodeDoubleTrait.class, + MapUtils.of("getValue", 1.1)), + Arguments.of("enum-trait.smithy", ResponseTypeTrait.class, + MapUtils.of("getValue", "yes", "isYes", true)), + Arguments.of("float-trait.smithy", HttpCodeFloatTrait.class, + MapUtils.of("getValue", (float) 1.1)), + Arguments.of("id-ref.smithy", IdRefStringTrait.class, + MapUtils.of("getValue", TARGET_ONE)), + Arguments.of("id-ref.smithy", IdRefListTrait.class, + MapUtils.of("getValues", ListUtils.of(TARGET_ONE, TARGET_TWO))), + Arguments.of("id-ref.smithy", IdRefMapTrait.class, + MapUtils.of("getValues", MapUtils.of("a", TARGET_ONE, "b", TARGET_TWO))), + Arguments.of("id-ref.smithy", IdRefStructTrait.class, + MapUtils.of("getFieldA", Optional.of(TARGET_ONE))), + Arguments.of("id-ref.smithy", IdRefStructWithNestedIdsTrait.class, + MapUtils.of("getIdRefHolder", NestedIdRefHolder.builder().id(TARGET_ONE).build(), + "getIdList", ListUtils.of(TARGET_ONE, TARGET_TWO), + "getIdMap", MapUtils.of("a", TARGET_ONE, "b", TARGET_TWO))), + Arguments.of("integer-trait.smithy", HttpCodeIntegerTrait.class, + MapUtils.of("getValue", 1)), + Arguments.of("long-trait.smithy", HttpCodeLongTrait.class, + MapUtils.of("getValue", 1L)), + Arguments.of("number-list-trait.smithy", NumberListTraitTrait.class, + MapUtils.of("getValues", ListUtils.of(1, 2, 3, 4, 5))), + Arguments.of("number-set-trait.smithy", NumberSetTraitTrait.class, + MapUtils.of("getValues", SetUtils.of(1, 2, 3, 4))), + Arguments.of("short-trait.smithy", HttpCodeShortTrait.class, + MapUtils.of("getValue", (short) 1)), + Arguments.of("int-enum-trait.smithy", ResponseTypeIntTrait.class, + MapUtils.of("getValue", 1, "isYes", true)), + Arguments.of("string-list-trait.smithy", StringListTraitTrait.class, + MapUtils.of("getValues", ListUtils.of("a", "b", "c", "d"))), + Arguments.of("string-set-trait.smithy", StringSetTraitTrait.class, + MapUtils.of("getValues", SetUtils.of("a", "b", "c", "d"))), + Arguments.of("structure-list-trait.smithy", StructureListTraitTrait.class, + MapUtils.of("getValues", ListUtils.of( + ListMember.builder().a("first").b(1).c("other").build(), + ListMember.builder().a("second").b(2).c("more").build()))), + Arguments.of("string-trait.smithy", StringTraitTrait.class, + MapUtils.of("getValue","Testing String Trait")), + Arguments.of("structure-set-trait.smithy", StructureSetTraitTrait.class, + MapUtils.of("getValues", ListUtils.of( + ListMember.builder().a("first").b(1).c("other").build(), + ListMember.builder().a("second").b(2).c("more").build()))), + Arguments.of("string-string-map-trait.smithy", StringStringMapTrait.class, + MapUtils.of("getValues", MapUtils.of("a", "stuff", + "b", "other", "c", "more!"))), + Arguments.of("string-struct-map-trait.smithy", StringToStructMapTrait.class, + MapUtils.of("getValues", MapUtils.of( + "one", MapValue.builder().a("foo").b(2).build(), + "two", MapValue.builder().a("bar").b(4).build()))), + Arguments.of("struct-trait.smithy", StructureTraitTrait.class, + MapUtils.of( + "getFieldA", "first", + "getFieldB", Optional.of(false), + "getFieldC", Optional.of(NestedA.builder() + .fieldN("nested") + .fieldQ(true) + .fieldZ(NestedB.A) + .build()), + "getFieldD", ListUtils.of("a", "b", "c"), + "getFieldE", MapUtils.of("a", "one", "b", "two"), + "getFieldF", Optional.of(new BigDecimal("100.01")), + "getFieldG", Optional.of(new BigInteger("100")))) + ); + } + + @ParameterizedTest + @MethodSource("loadsModelTests") + void executeTests(String resourceFile, + Class traitClass, + Map valueChecks + ) { + Model result = Model.assembler() + .discoverModels(getClass().getClassLoader()) + .addImport(Objects.requireNonNull(getClass().getResource(resourceFile))) + .assemble() + .unwrap(); + T trait = result.expectShape(ID).expectTrait(traitClass); + valueChecks.forEach((k, v) -> checkValue(traitClass, trait, k, v)); + } + + void checkValue(Class traitClass, T trait, String accessor, Object expected) { + try { + Object value = traitClass.getMethod(accessor).invoke(trait); + // Float values need a delta specified for equals checks + if (value instanceof Float) { + assertEquals((Float) expected, (Float) value, 0.0001, + "Value of accessor `" + accessor + "` invalid for " + trait); + } if (value instanceof Iterable) { + assertIterableEquals((Iterable) expected, (Iterable) value); + } else { + assertEquals(expected, value, "Value of accessor `" + accessor + + "` invalid for " + trait); + } + + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + throw new RuntimeException("Failed to invoke accessor " + accessor + " for " + trait, e); + } + } +} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/LongTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/LongTraitTest.java deleted file mode 100644 index 4812bef418b..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/LongTraitTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import com.example.traits.HttpCodeLongTrait; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; - -class LongTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("long-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - HttpCodeLongTrait trait = shape.expectTrait(HttpCodeLongTrait.class); - assertEquals(1L, trait.getValue()); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - TraitFactory provider = TraitFactory.createServiceFactory(); - Trait trait = provider.createTrait(HttpCodeLongTrait.ID, id, Node.from(1L)).orElseThrow(RuntimeException::new); - HttpCodeLongTrait annotation = (HttpCodeLongTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals(trait, - provider.createTrait(HttpCodeLongTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/NumberListTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/NumberListTraitTest.java deleted file mode 100644 index 5cf6069c6f6..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/NumberListTraitTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertIterableEquals; - -import com.example.traits.NumberListTraitTrait; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.ArrayNode; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; -import software.amazon.smithy.utils.ListUtils; - -class NumberListTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("number-list-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - NumberListTraitTrait trait = shape.expectTrait(NumberListTraitTrait.class); - assertIterableEquals(ListUtils.of(1, 2, 3, 4, 5), trait.getValues()); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - TraitFactory provider = TraitFactory.createServiceFactory(); - ArrayNode input = ArrayNode.fromNodes(Node.from(1), Node.from(2), Node.from(3)); - Trait trait = provider.createTrait(NumberListTraitTrait.ID, id, input).orElseThrow(RuntimeException::new); - NumberListTraitTrait annotation = (NumberListTraitTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals(trait, - provider.createTrait(NumberListTraitTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/NumberSetTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/NumberSetTraitTest.java deleted file mode 100644 index 5bdce99d071..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/NumberSetTraitTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertIterableEquals; - -import com.example.traits.NumberSetTraitTrait; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.ArrayNode; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; -import software.amazon.smithy.utils.SetUtils; - -class NumberSetTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("number-set-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - NumberSetTraitTrait trait = shape.expectTrait(NumberSetTraitTrait.class); - assertIterableEquals(SetUtils.of(1, 2, 3, 4), trait.getValues()); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - TraitFactory provider = TraitFactory.createServiceFactory(); - ArrayNode input = ArrayNode.fromNodes(Node.from(1), Node.from(2), Node.from(3)); - Trait trait = provider.createTrait(NumberSetTraitTrait.ID, id, input).orElseThrow(RuntimeException::new); - NumberSetTraitTrait annotation = (NumberSetTraitTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals(trait, - provider.createTrait(NumberSetTraitTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/ShortTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/ShortTraitTest.java deleted file mode 100644 index 3c59174b324..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/ShortTraitTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import com.example.traits.HttpCodeShortTrait; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; - -class ShortTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("short-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - HttpCodeShortTrait trait = shape.expectTrait(HttpCodeShortTrait.class); - assertEquals((short) 1, trait.getValue()); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - TraitFactory provider = TraitFactory.createServiceFactory(); - Trait trait = provider.createTrait(HttpCodeShortTrait.ID, id, Node.from(1)).orElseThrow(RuntimeException::new); - HttpCodeShortTrait annotation = (HttpCodeShortTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals(trait, - provider.createTrait(HttpCodeShortTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StringListTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StringListTraitTest.java deleted file mode 100644 index 5e682349035..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StringListTraitTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertIterableEquals; - -import com.example.traits.StringListTraitTrait; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.ArrayNode; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; -import software.amazon.smithy.utils.ListUtils; - -class StringListTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("string-list-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - StringListTraitTrait trait = shape.expectTrait(StringListTraitTrait.class); - assertIterableEquals(ListUtils.of("a", "b", "c", "d"), trait.getValues()); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - TraitFactory provider = TraitFactory.createServiceFactory(); - ArrayNode input = ArrayNode.fromStrings("a", "b", "c"); - Trait trait = provider.createTrait(StringListTraitTrait.ID, id, input).orElseThrow(RuntimeException::new); - StringListTraitTrait annotation = (StringListTraitTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals(trait, - provider.createTrait(StringListTraitTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StringSetTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StringSetTraitTest.java deleted file mode 100644 index d0afe123acc..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StringSetTraitTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import com.example.traits.StringSetTraitTrait; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.ArrayNode; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; -import software.amazon.smithy.utils.SetUtils; - -class StringSetTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("string-set-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - StringSetTraitTrait trait = shape.expectTrait(StringSetTraitTrait.class); - assertEquals(SetUtils.of("a", "b", "c", "d"), trait.getValues()); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - TraitFactory provider = TraitFactory.createServiceFactory(); - ArrayNode input = ArrayNode.fromStrings("a", "b", "c"); - Trait trait = provider.createTrait(StringSetTraitTrait.ID, id, input).orElseThrow(RuntimeException::new); - StringSetTraitTrait annotation = (StringSetTraitTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals(trait, - provider.createTrait(StringSetTraitTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StringStringMapTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StringStringMapTraitTest.java deleted file mode 100644 index 07f83946819..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StringStringMapTraitTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertIterableEquals; - -import com.example.traits.StringStringMapTrait; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; -import software.amazon.smithy.utils.MapUtils; - -class StringStringMapTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("string-string-map-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - StringStringMapTrait trait = shape.expectTrait(StringStringMapTrait.class); - assertIterableEquals(MapUtils.of("a", "stuff", "b", "other", "c", "more!").entrySet(), - trait.getValues().entrySet()); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - TraitFactory provider = TraitFactory.createServiceFactory(); - Node node = StringStringMapTrait.builder() - .putValues("a", "first") - .putValues("b", "other").build().toNode(); - Trait trait = provider.createTrait(StringStringMapTrait.ID, id, node).orElseThrow(RuntimeException::new); - StringStringMapTrait annotation = (StringStringMapTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals(trait, - provider.createTrait(StringStringMapTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StringToStructMapTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StringToStructMapTraitTest.java deleted file mode 100644 index 7c8e1205138..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StringToStructMapTraitTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import com.example.traits.MapValue; -import com.example.traits.StringToStructMapTrait; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; - -class StringToStructMapTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("string-struct-map-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - StringToStructMapTrait trait = shape.expectTrait(StringToStructMapTrait.class); - - MapValue one = trait.getValues().get("one"); - MapValue two = trait.getValues().get("two"); - assertEquals("foo", one.getA().orElseThrow(RuntimeException::new)); - assertEquals(2, one.getB().orElseThrow(RuntimeException::new)); - assertEquals("bar", two.getA().orElseThrow(RuntimeException::new)); - assertEquals(4, two.getB().orElseThrow(RuntimeException::new)); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - TraitFactory provider = TraitFactory.createServiceFactory(); - Node node = StringToStructMapTrait.builder() - .putValues("one", MapValue.builder().a("foo").b(2).build()) - .putValues("two", MapValue.builder().a("bar").b(4).build()) - .build().toNode(); - Trait trait = provider.createTrait(StringToStructMapTrait.ID, id, node).orElseThrow(RuntimeException::new); - StringToStructMapTrait annotation = (StringToStructMapTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals(trait, - provider.createTrait(StringToStructMapTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StringTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StringTraitTest.java deleted file mode 100644 index 23f702ba1af..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StringTraitTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import com.example.traits.StringTraitTrait; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; - -class StringTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("string-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct$fieldA")); - StringTraitTrait trait = shape.expectTrait(StringTraitTrait.class); - assertEquals(trait.getValue(), "Testing String Trait"); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - Node node = Node.from("SPORKZ SPOONS YAY! Utensils."); - TraitFactory provider = TraitFactory.createServiceFactory(); - Trait trait = provider.createTrait(StringTraitTrait.ID, id, node).orElseThrow(RuntimeException::new); - StringTraitTrait annotation = (StringTraitTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals("SPORKZ SPOONS YAY! Utensils.", annotation.getValue()); - assertEquals(trait, - provider.createTrait(StringTraitTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StructureListTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StructureListTraitTest.java deleted file mode 100644 index 463bdd85b1e..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StructureListTraitTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertIterableEquals; - -import com.example.traits.ListMember; -import com.example.traits.StructureListTraitTrait; -import java.util.List; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.ArrayNode; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; -import software.amazon.smithy.utils.ListUtils; - -class StructureListTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("structure-list-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - StructureListTraitTrait trait = shape.expectTrait(StructureListTraitTrait.class); - List actual = trait.getValues(); - List expected = ListUtils.of( - ListMember.builder().a("first").b(1).c("other").build(), - ListMember.builder().a("second").b(2).c("more").build() - ); - assertIterableEquals(expected, actual); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - TraitFactory provider = TraitFactory.createServiceFactory(); - Node input = ArrayNode.fromNodes( - ListMember.builder().a("first").b(1).c("other").build().toNode(), - ListMember.builder().a("second").b(2).c("more").build().toNode() - ); - Trait trait = provider.createTrait(StructureListTraitTrait.ID, id, input).orElseThrow(RuntimeException::new); - StructureListTraitTrait annotation = (StructureListTraitTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals(trait, - provider.createTrait(StructureListTraitTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StructureSetTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StructureSetTraitTest.java deleted file mode 100644 index c9c28a817cd..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StructureSetTraitTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertIterableEquals; - -import com.example.traits.ListMember; -import com.example.traits.StructureSetTraitTrait; -import java.util.List; -import java.util.Objects; -import java.util.Set; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.node.ArrayNode; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; -import software.amazon.smithy.utils.ListUtils; - -class StructureSetTraitTest { - - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("structure-set-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - StructureSetTraitTrait trait = shape.expectTrait(StructureSetTraitTrait.class); - Set actual = trait.getValues(); - List expected = ListUtils.of( - ListMember.builder().a("first").b(1).c("other").build(), - ListMember.builder().a("second").b(2).c("more").build() - ); - assertIterableEquals(expected, actual); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - TraitFactory provider = TraitFactory.createServiceFactory(); - Node input = ArrayNode.fromNodes( - ListMember.builder().a("first").b(1).c("other").build().toNode(), - ListMember.builder().a("second").b(2).c("more").build().toNode() - ); - Trait trait = provider.createTrait(StructureSetTraitTrait.ID, id, input).orElseThrow(RuntimeException::new); - StructureSetTraitTrait annotation = (StructureSetTraitTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals(trait, - provider.createTrait(StructureSetTraitTrait.ID, id, trait.toNode()).orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StructureTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StructureTraitTest.java deleted file mode 100644 index 3e719ddc8b9..00000000000 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/StructureTraitTest.java +++ /dev/null @@ -1,70 +0,0 @@ -package software.amazon.smithy.traitcodegen.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import com.example.traits.NestedA; -import com.example.traits.NestedB; -import com.example.traits.StructureTraitTrait; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.Objects; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.SourceLocation; -import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; -import software.amazon.smithy.utils.ListUtils; -import software.amazon.smithy.utils.MapUtils; - -class StructureTraitTest { - @Test - void loadsFromModel() { - Model result = Model.assembler() - .discoverModels(getClass().getClassLoader()) - .addImport(Objects.requireNonNull(getClass().getResource("struct-trait.smithy"))) - .assemble() - .unwrap(); - Shape shape = result.expectShape(ShapeId.from("test.smithy.traitcodegen#myStruct")); - StructureTraitTrait trait = shape.expectTrait(StructureTraitTrait.class); - StructureTraitTrait expectedTrait = StructureTraitTrait.builder() - .fieldA("first") - .fieldB(false) - .fieldC(NestedA.builder() - .fieldN("nested") - .fieldQ(true) - .fieldZ(NestedB.A) - .build() - ).fieldD(ListUtils.of("a", "b", "c")) - .fieldE(MapUtils.of("a", "one", "b", "two")) - .fieldF(new BigDecimal("100.01")) - .fieldG(new BigInteger("100")) - .build(); - assertEquals(expectedTrait, trait); - } - - @Test - void createsTrait() { - ShapeId id = ShapeId.from("ns.foo#foo"); - TraitFactory provider = TraitFactory.createServiceFactory(); - StructureTraitTrait struct = StructureTraitTrait.builder() - .fieldA("a") - .fieldB(true) - .fieldC(NestedA.builder() - .fieldN("nested") - .fieldQ(false) - .fieldZ(NestedB.B) - .build() - ) - .fieldD(ListUtils.of("a", "b", "c")) - .fieldE(MapUtils.of("a", "one", "b", "two")) - .build(); - Trait trait = provider.createTrait(StructureTraitTrait.ID, id, struct.toNode()) - .orElseThrow(RuntimeException::new); - StructureTraitTrait annotation = (StructureTraitTrait) trait; - assertEquals(SourceLocation.NONE, annotation.getSourceLocation()); - assertEquals(trait, provider.createTrait(StructureTraitTrait.ID, id, trait.toNode()) - .orElseThrow(RuntimeException::new)); - } -} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/annotation-trait.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/annotation-trait.smithy index 46f6645e487..97b3eb6700f 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/annotation-trait.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/annotation-trait.smithy @@ -2,7 +2,7 @@ $version: "2.0" namespace test.smithy.traitcodegen +@basicAnnotationTrait structure myStruct { - @basicAnnotationTrait fieldA: String -} \ No newline at end of file +} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/errorfiles/annotation-trait-errors.errors b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/errorfiles/annotation-trait-errors.errors deleted file mode 100644 index f74eb1d8e6a..00000000000 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/errorfiles/annotation-trait-errors.errors +++ /dev/null @@ -1 +0,0 @@ -[ERROR] test.smithy.traitcodegen#myStruct: Trait `test.smithy.traitcodegen#basicAnnotationTrait` cannot be applied to `test.smithy.traitcodegen#myStruct`. This trait may only be applied to shapes that match the following selector: structure > :test(member > string) | TraitTarget diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/errorfiles/annotation-trait-errors.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/errorfiles/annotation-trait-errors.smithy deleted file mode 100644 index 7644878723c..00000000000 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/errorfiles/annotation-trait-errors.smithy +++ /dev/null @@ -1,8 +0,0 @@ -$version: "2.0" - -namespace test.smithy.traitcodegen - -@basicAnnotationTrait -structure myStruct { - fieldA: String -} \ No newline at end of file diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/string-trait.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/string-trait.smithy index 40ade8fff5b..71f3edb3200 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/string-trait.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/string-trait.smithy @@ -2,7 +2,7 @@ $version: "2.0" namespace test.smithy.traitcodegen +@stringTrait("Testing String Trait") structure myStruct { - @stringTrait("Testing String Trait") fieldA: String -} \ No newline at end of file +} diff --git a/smithy-trait-codegen/src/test/resources/META-INF/smithy/test-traits.smithy b/smithy-trait-codegen/src/test/resources/META-INF/smithy/test-traits.smithy index cd94ce4b6d5..db974e32731 100644 --- a/smithy-trait-codegen/src/test/resources/META-INF/smithy/test-traits.smithy +++ b/smithy-trait-codegen/src/test/resources/META-INF/smithy/test-traits.smithy @@ -3,11 +3,11 @@ $version: "2.0" namespace test.smithy.traitcodegen /// A basic annotation trait -@trait(selector: "structure > :test(member > string)") +@trait structure basicAnnotationTrait {} /// Simple String trait -@trait(selector: "member") +@trait string stringTrait // ===============