NodeValidationVisitor implements ShapeVisitor<List<ValidationEvent>> { public static Builder builder() { return new Builder(); } private  NodeValidationVisitor(Builder builder); static Builder builder(); @Override List<ValidationEvent> blobShape(BlobShape shape); @Override List<ValidationEvent> booleanShape(BooleanShape shape); @Override List<ValidationEvent> byteShape(ByteShape shape); @Override List<ValidationEvent> shortShape(ShortShape shape); @Override List<ValidationEvent> integerShape(IntegerShape shape); @Override List<ValidationEvent> longShape(LongShape shape); @Override List<ValidationEvent> bigIntegerShape(BigIntegerShape shape); @Override List<ValidationEvent> floatShape(FloatShape shape); @Override List<ValidationEvent> documentShape(DocumentShape shape); @Override List<ValidationEvent> doubleShape(DoubleShape shape); @Override List<ValidationEvent> bigDecimalShape(BigDecimalShape shape); @Override List<ValidationEvent> stringShape(StringShape shape); @Override List<ValidationEvent> timestampShape(TimestampShape shape); @Override List<ValidationEvent> listShape(ListShape shape); @Override List<ValidationEvent> setShape(SetShape shape); @Override List<ValidationEvent> mapShape(MapShape shape); @Override List<ValidationEvent> structureShape(StructureShape shape); @Override List<ValidationEvent> unionShape(UnionShape shape); @Override List<ValidationEvent> memberShape(MemberShape shape); @Override List<ValidationEvent> operationShape(OperationShape shape); @Override List<ValidationEvent> resourceShape(ResourceShape shape); @Override List<ValidationEvent> serviceShape(ServiceShape shape);  }
@Test public void doesNotAllowNullByDefault() { NodeValidationVisitor cases = NodeValidationVisitor.builder() .value(Node.nullNode()) .model(MODEL) .build(); List<ValidationEvent> events = MODEL .expectShape(ShapeId.from("smithy.api#String")) .accept(cases); assertThat(events, not(empty())); }
@Test public void canConfigureToSupportNull() { NodeValidationVisitor cases = NodeValidationVisitor.builder() .value(Node.nullNode()) .model(MODEL) .allowBoxedNull(true) .build(); List<ValidationEvent> events = MODEL .expectShape(ShapeId.from("smithy.api#String")) .accept(cases); assertThat(events, empty()); }
@Test public void canSuccessfullyValidateTimestampsAsUnixTimestamps() { NodeValidationVisitor cases = NodeValidationVisitor.builder() .value(Node.from(1234)) .model(MODEL) .timestampValidationStrategy(TimestampValidationStrategy.EPOCH_SECONDS) .build(); List<ValidationEvent> events = MODEL .expectShape(ShapeId.from("ns.foo#TimestampList$member")) .accept(cases); assertThat(events, empty()); }
@Test public void canUnsuccessfullyValidateTimestampsAsUnixTimestamps() { NodeValidationVisitor cases = NodeValidationVisitor.builder() .value(Node.from("foo")) .model(MODEL) .timestampValidationStrategy(TimestampValidationStrategy.EPOCH_SECONDS) .build(); List<ValidationEvent> events = MODEL .expectShape(ShapeId.from("ns.foo#TimestampList$member")) .accept(cases); assertThat(events, not(empty())); }