@@ -130,6 +130,51 @@ public void addsExplicitTraits() {
130130 assertTrue (resultShape .getTrait (SuppressTrait .class ).isPresent ());
131131 }
132132
133+ @ Test
134+ public void addsExplicitTraitsToBuiltModel () {
135+ StringShape shape = StringShape .builder ().id ("ns.foo#Bar" ).build ();
136+ SuppressTrait trait = SuppressTrait .builder ().build ();
137+ ValidatedResult <Model > result = new ModelAssembler ()
138+ .addModel (Model .assembler ().addShape (shape ).assemble ().unwrap ())
139+ .addTrait (shape .toShapeId (), trait )
140+ .assemble ();
141+
142+ assertThat (result .getValidationEvents (), empty ());
143+ Shape resultShape = result .unwrap ().getShape (ShapeId .from ("ns.foo#Bar" )).get ();
144+ assertTrue (resultShape .findTrait ("smithy.api#suppress" ).isPresent ());
145+ assertTrue (resultShape .getTrait (SuppressTrait .class ).isPresent ());
146+ }
147+
148+ @ Test
149+ public void addsExplicitTraitsToUnparsedModel () {
150+ String unparsed = "{\" smithy\" : \" " + Model .MODEL_VERSION + "\" , \" shapes\" : { \" ns.foo#Bar\" : { \" type\" : \" string\" }}}" ;
151+ SuppressTrait trait = SuppressTrait .builder ().build ();
152+ ValidatedResult <Model > result = new ModelAssembler ()
153+ .addUnparsedModel (SourceLocation .NONE .getFilename (), unparsed )
154+ .addTrait (ShapeId .from ("ns.foo#Bar" ), trait )
155+ .assemble ();
156+
157+ assertThat (result .getValidationEvents (), empty ());
158+ Shape resultShape = result .unwrap ().getShape (ShapeId .from ("ns.foo#Bar" )).get ();
159+ assertTrue (resultShape .findTrait ("smithy.api#suppress" ).isPresent ());
160+ assertTrue (resultShape .getTrait (SuppressTrait .class ).isPresent ());
161+ }
162+
163+ @ Test
164+ public void addsExplicitTraitsToParsedDocumentNode () {
165+ String unparsed = "{\" smithy\" : \" " + Model .MODEL_VERSION + "\" , \" shapes\" : { \" ns.foo#Bar\" : { \" type\" : \" string\" }}}" ;
166+ SuppressTrait trait = SuppressTrait .builder ().build ();
167+ ValidatedResult <Model > result = new ModelAssembler ()
168+ .addDocumentNode (Node .parse (unparsed , SourceLocation .NONE .getFilename ()))
169+ .addTrait (ShapeId .from ("ns.foo#Bar" ), trait )
170+ .assemble ();
171+
172+ assertThat (result .getValidationEvents (), empty ());
173+ Shape resultShape = result .unwrap ().getShape (ShapeId .from ("ns.foo#Bar" )).get ();
174+ assertTrue (resultShape .findTrait ("smithy.api#suppress" ).isPresent ());
175+ assertTrue (resultShape .getTrait (SuppressTrait .class ).isPresent ());
176+ }
177+
133178 @ Test
134179 public void addsExplicitDocumentNode_1_0_0 () {
135180 ObjectNode node = Node .objectNode ()
0 commit comments