ListShape extends CollectionShape implements ToSmithyBuilder<ListShape> { public static Builder builder() { return new Builder(); } private  ListShape(Builder builder); static Builder builder(); @Override Builder toBuilder(); @Override R accept(ShapeVisitor<R> cases); @Override Optional<ListShape> asListShape();  }
@Test public void returnsAppropriateType() { ListShape shape = ListShape.builder() .id("ns.foo#bar") .member(MemberShape.builder().id("ns.foo#bar$member").target("ns.foo#bam").build()) .build(); assertEquals(shape.getType(), ShapeType.LIST); }
@Test public void mustNotContainMembersInShapeId() { Assertions.assertThrows(SourceException.class, () -> { ListShape.builder() .id("ns.foo#bar$baz") .member(MemberShape.builder().id("ns.foo#bar$member").target("ns.foo#bam").build()) .build(); }); }
@Test public void requiresMember() { Assertions.assertThrows(IllegalStateException.class, () -> { ListShape.builder().id("ns.foo#bar").build(); }); }
@Test public void hasMember() { MemberShape member = MemberShape.builder().id("ns.foo#bar$member").target("ns.foo#bam").build(); ListShape shape = ListShape.builder() .id("ns.foo#bar") .member(member) .build(); assertEquals(member, shape.getMember()); }
@Test public void differentTypesAreNotEqual() { MemberShape member = MemberShape.builder().id("ns.foo#bar$member").target("ns.foo#bam").build(); ListShape shape = ListShape.builder().id("ns.foo#bar").member(member).build(); assertNotEquals(shape, ""); }
@Test public void sameInstanceIsEqual() { MemberShape member = MemberShape.builder().id("ns.foo#bar$member").target("ns.foo#bam").build(); ListShape shape = ListShape.builder().id("ns.foo#bar").member(member).build(); assertEquals(shape, shape); }
@Test public void differentMemberAreNotEqual() { MemberShape member1 = MemberShape.builder().id("ns.foo#bar$member").target("ns.foo#bam").build(); ListShape shape1 = ListShape.builder().id("ns.foo#bar").member(member1).build(); MemberShape member2 = MemberShape.builder().id("ns.foo#bar$member").target("ns.foo#qux").build(); ListShape shape2 = ListShape.builder().id("ns.foo#bar").member(member2).build(); assertNotEquals(shape1, shape2); }
@Test public void addMemberWithTarget() { ListShape shape = ListShape.builder() .id("ns.foo#bar") .member(ShapeId.from("ns.foo#bam")) .build(); assertEquals(shape.getMember(), MemberShape.builder().id(shape.getId().withMember("member")).target("ns.foo#bam").build()); }
@Test public void addMemberWithConsumer() { ListShape shape = ListShape.builder() .id("ns.foo#bar") .member(ShapeId.from("ns.foo#bam"), builder -> builder.addTrait(new SensitiveTrait())) .build(); assertEquals(shape.getMember(), MemberShape.builder() .id(shape.getId().withMember("member")) .target("ns.foo#bam") .addTrait(new SensitiveTrait()) .build()); }
@Test public void returnsMembers() { ListShape shape = ListShape.builder().id("ns.foo#bar").member(ShapeId.from("ns.foo#bam")).build(); assertThat(shape.members(), hasSize(1)); }
@Test public void builderUpdatesMemberId() { ListShape shape = ListShape.builder() .id("ns.foo#bar") .member(ShapeId.from("ns.foo#bam")) .id("ns.bar#bar") .build(); assertThat(shape.getMember().getId(), equalTo(ShapeId.from("ns.bar#bar$member"))); assertThat(shape.getMember().getTarget(), equalTo(ShapeId.from("ns.foo#bam"))); }