diff --git a/smithy-aws-endpoints/src/main/java/software/amazon/smithy/rulesengine/aws/traits/PartitionSpecialCase.java b/smithy-aws-endpoints/src/main/java/software/amazon/smithy/rulesengine/aws/traits/PartitionSpecialCase.java index 857e74c5fa7..1dc0c9a838e 100644 --- a/smithy-aws-endpoints/src/main/java/software/amazon/smithy/rulesengine/aws/traits/PartitionSpecialCase.java +++ b/smithy-aws-endpoints/src/main/java/software/amazon/smithy/rulesengine/aws/traits/PartitionSpecialCase.java @@ -6,6 +6,7 @@ package software.amazon.smithy.rulesengine.aws.traits; import java.util.Objects; +import java.util.Optional; import software.amazon.smithy.model.FromSourceLocation; import software.amazon.smithy.model.SourceLocation; import software.amazon.smithy.model.node.Node; @@ -64,10 +65,10 @@ public Boolean getFips() { @Override public Node toNode() { return Node.objectNodeBuilder() - .withMember(ENDPOINT, endpoint) - .withMember(DUAL_STACK, dualStack.toString()) - .withMember(FIPS, fips.toString()) - .build(); + .withMember(ENDPOINT, endpoint) + .withOptionalMember(DUAL_STACK, Optional.ofNullable(dualStack).map(Node::from)) + .withOptionalMember(FIPS, Optional.ofNullable(fips).map(Node::from)) + .build(); } @Override diff --git a/smithy-aws-endpoints/src/main/java/software/amazon/smithy/rulesengine/aws/traits/StandardRegionalEndpointsTrait.java b/smithy-aws-endpoints/src/main/java/software/amazon/smithy/rulesengine/aws/traits/StandardRegionalEndpointsTrait.java index 0b867846b77..52d9b5dd1f6 100644 --- a/smithy-aws-endpoints/src/main/java/software/amazon/smithy/rulesengine/aws/traits/StandardRegionalEndpointsTrait.java +++ b/smithy-aws-endpoints/src/main/java/software/amazon/smithy/rulesengine/aws/traits/StandardRegionalEndpointsTrait.java @@ -79,7 +79,7 @@ protected Node createNode() { return ObjectNode.objectNodeBuilder() .sourceLocation(getSourceLocation()) .withMember(PARTITION_SPECIAL_CASES, partitionSpecialCasesNodeBuilder.build()) - .withMember(REGION_SPECIAL_CASES, partitionSpecialCasesNodeBuilder.build()) + .withMember(REGION_SPECIAL_CASES, regionSpecialCasesNodeBuilder.build()) .build(); } diff --git a/smithy-aws-endpoints/src/test/java/software/amazon/smithy/rulesengine/aws/traits/StandardRegionalEndpointsTraitTest.java b/smithy-aws-endpoints/src/test/java/software/amazon/smithy/rulesengine/aws/traits/StandardRegionalEndpointsTraitTest.java index 9630ecd4c8e..3ac3adc12f7 100644 --- a/smithy-aws-endpoints/src/test/java/software/amazon/smithy/rulesengine/aws/traits/StandardRegionalEndpointsTraitTest.java +++ b/smithy-aws-endpoints/src/test/java/software/amazon/smithy/rulesengine/aws/traits/StandardRegionalEndpointsTraitTest.java @@ -6,6 +6,7 @@ import java.util.List; import org.junit.jupiter.api.Test; import software.amazon.smithy.model.Model; +import software.amazon.smithy.model.node.Node; import software.amazon.smithy.model.shapes.ShapeId; class StandardRegionalEndpointsTraitTest { @@ -25,12 +26,12 @@ public void loadsFromModel() { trait = getTraitFromService(model, "ns.foo#Service2"); - assertEquals(trait.getRegionSpecialCases().size(), 0); + assertEquals(trait.getPartitionSpecialCases().size(), 0); assertEquals(trait.getRegionSpecialCases().size(), 0); trait = getTraitFromService(model, "ns.foo#Service3"); - assertEquals(trait.getRegionSpecialCases().size(), 1); + assertEquals(trait.getPartitionSpecialCases().size(), 1); assertEquals(trait.getRegionSpecialCases().size(), 1); List partitionSpecialCases = trait.getPartitionSpecialCases().get("aws-us-gov"); @@ -46,6 +47,8 @@ public void loadsFromModel() { List regionSpecialCases = trait.getRegionSpecialCases().get("us-east-1"); assertEquals(regionSpecialCases.size(), 0); + + Node.assertEquals(trait.toNode(), trait.toBuilder().build().toNode()); } private StandardRegionalEndpointsTrait getTraitFromService(Model model, String service) {