@Test
public void updatesTaggedUnionShapeWhenMemberChanges() {

    ShapeId stringId = ShapeId.from("ns.foo#String");
    ShapeId containerId = ShapeId.from("ns.foo#Container");
    ShapeId memberAId = ShapeId.from("ns.foo#Container$a");
    ShapeId memberBId = ShapeId.from("ns.foo#Container$b");
    StringShape target = StringShape.builder().id(stringId).build();
    MemberShape memberA = MemberShape.builder().id(memberAId).target(stringId).build();
    MemberShape memberB = MemberShape.builder().id(memberBId).target(stringId).build();
    UnionShape container = UnionShape.builder()
            .id(containerId)
            .addMember(memberA)
            .addMember(memberB)
            .build();
    Model model = Model.builder()
            .addShapes(target, memberA, memberB, container)
            .build();
    ModelTransformer transformer = ModelTransformer.create();
    MemberShape newMemberB = MemberShape.builder()
            .id(memberBId)
            .target(stringId)
            .addTrait(new SensitiveTrait())
            .build();
    Model result = transformer.replaceShapes(model, Arrays.asList(newMemberB));
    // Make sure the member has the trait that was applied.
    assertThat(result.getShape(memberBId).get().getTrait(SensitiveTrait.class), Matchers.not(Optional.empty()));
    // Ensure that the union that contains the shape was updated.
    assertThat(result.getShape(containerId).get().asUnionShape().get().getMember("b").get(),
               Matchers.is(newMemberB));
}