@Test public void testInvalidEmbeddedField() { final List<RecordField> accountFields = new ArrayList<>(); accountFields.add(new RecordField("name", RecordFieldType.STRING.getDataType())); accountFields.add(new RecordField("balance", RecordFieldType.DOUBLE.getDataType())); final RecordSchema accountSchema = new SimpleRecordSchema(accountFields); final List<RecordField> fields = new ArrayList<>(); fields.add(new RecordField("id", RecordFieldType.INT.getDataType())); fields.add(new RecordField("account", RecordFieldType.RECORD.getRecordDataType(accountSchema))); final RecordSchema schema = new SimpleRecordSchema(fields); final Map<String, Object> accountValues = new HashMap<>(); accountValues.put("name", "account-1"); accountValues.put("balance", "123.45"); final Record accountRecord = new MapRecord(accountSchema, accountValues); final Map<String, Object> valueMap = new LinkedHashMap<>(); valueMap.put("id", 1); valueMap.put("account", accountRecord); Record record = new MapRecord(schema, valueMap, false, false); final SchemaValidationContext strictValidationContext = new SchemaValidationContext(schema, false, true); final SchemaValidationContext lenientValidationContext = new SchemaValidationContext(schema, false, false); StandardSchemaValidator validator = new StandardSchemaValidator(strictValidationContext); SchemaValidationResult result = validator.validate(record); assertFalse(result.isValid()); assertNotNull(result.getValidationErrors()); assertEquals(1, result.getValidationErrors().size()); final ValidationError validationError = result.getValidationErrors().iterator().next(); assertEquals("/account/balance", validationError.getFieldName().get()); validator = new StandardSchemaValidator(lenientValidationContext); 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);  }