@Test
public void canReplaceMultipleMembersOfSameShape() {

    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();
    StructureShape container = StructureShape.builder()
            .id(containerId)
            .addMember(memberA)
            .addMember(memberB)
            .build();
    Model model = Model.builder()
            .addShapes(target, memberA, memberB, container)
            .build();
    ModelTransformer transformer = ModelTransformer.create();
    MemberShape newMemberA = memberA.toBuilder().addTrait(new RequiredTrait()).build();
    MemberShape newMemberB = memberB.toBuilder().addTrait(new RequiredTrait()).build();
    Model result = transformer.replaceShapes(model, Arrays.asList(newMemberA, newMemberB));
    assertThat(result.getShape(memberAId).get().getTrait(RequiredTrait.class), Matchers.not(Optional.empty()));
    assertThat(result.getShape(memberBId).get().getTrait(RequiredTrait.class), Matchers.not(Optional.empty()));
    // Make sure the members got updated inside of the container.
    assertTrue(result.getShape(containerId).get()
            .asStructureShape().get()
            .getMember("a").get()
            .hasTrait(RequiredTrait.class));
    assertTrue(result.getShape(containerId).get()
            .asStructureShape().get()
            .getMember("b").get()
            .hasTrait(RequiredTrait.class));
}