@Test public void testValidateCorrectSimpleTypesStrictValidation() throws ParseException { final List<RecordField> fields = new ArrayList<>(); for (final RecordFieldType fieldType : RecordFieldType.values()) { if (fieldType == RecordFieldType.CHOICE) { final List<DataType> possibleTypes = new ArrayList<>(); possibleTypes.add(RecordFieldType.INT.getDataType()); possibleTypes.add(RecordFieldType.LONG.getDataType()); fields.add(new RecordField(fieldType.name().toLowerCase(), fieldType.getChoiceDataType(possibleTypes))); } else if (fieldType == RecordFieldType.MAP) { fields.add(new RecordField(fieldType.name().toLowerCase(), fieldType.getMapDataType(RecordFieldType.INT.getDataType()))); } else { fields.add(new RecordField(fieldType.name().toLowerCase(), fieldType.getDataType())); } } final DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS"); df.setTimeZone(TimeZone.getTimeZone("gmt")); final long time = df.parse("2017/01/01 17:00:00.000").getTime(); final Map<String, Object> intMap = new LinkedHashMap<>(); intMap.put("height", 48); intMap.put("width", 96); final RecordSchema schema = new SimpleRecordSchema(fields); final Map<String, Object> valueMap = new LinkedHashMap<>(); valueMap.put("string", "string"); valueMap.put("boolean", true); valueMap.put("byte", (byte) 1); valueMap.put("char", 'c'); valueMap.put("short", (short) 8); valueMap.put("int", 9); valueMap.put("bigint", BigInteger.valueOf(8L)); valueMap.put("long", 8L); valueMap.put("float", 8.0F); valueMap.put("double", 8.0D); valueMap.put("date", new Date(time)); valueMap.put("time", new Time(time)); valueMap.put("timestamp", new Timestamp(time)); valueMap.put("record", null); valueMap.put("array", null); valueMap.put("choice", 48L); valueMap.put("map", intMap); final Record record = new MapRecord(schema, valueMap); final SchemaValidationContext validationContext = new SchemaValidationContext(schema, false, true); final StandardSchemaValidator validator = new StandardSchemaValidator(validationContext); final SchemaValidationResult result = validator.validate(record); assertTrue(result.isValid()); assertNotNull(result.getValidationErrors()); assertTrue(result.getValidationErrors().isEmpty()); }
@Override public SchemaValidationResult validate(final Record record) { return validate(record, validationContext.getSchema(), ""); }
StandardSchemaValidator implements RecordSchemaValidator { @Override public SchemaValidationResult validate(final Record record) { return validate(record, validationContext.getSchema(), ""); } }
StandardSchemaValidator implements RecordSchemaValidator { @Override public SchemaValidationResult validate(final Record record) { return validate(record, validationContext.getSchema(), ""); } StandardSchemaValidator(final SchemaValidationContext validationContext); }
StandardSchemaValidator implements RecordSchemaValidator { @Override public SchemaValidationResult validate(final Record record) { return validate(record, validationContext.getSchema(), ""); } StandardSchemaValidator(final SchemaValidationContext validationContext); @Override SchemaValidationResult validate(final Record record); }
StandardSchemaValidator implements RecordSchemaValidator { @Override public SchemaValidationResult validate(final Record record) { return validate(record, validationContext.getSchema(), ""); } StandardSchemaValidator(final SchemaValidationContext validationContext); @Override SchemaValidationResult validate(final Record record);  }