use of org.apache.nifi.serialization.record.SchemaIdentifier in project nifi by apache.
the class TestHortonworksAttributeSchemaReferenceWriter method testValidateWithInvalidSchema.
@Test(expected = SchemaNotFoundException.class)
public void testValidateWithInvalidSchema() throws SchemaNotFoundException {
final SchemaIdentifier schemaIdentifier = SchemaIdentifier.builder().name("test").build();
final RecordSchema recordSchema = createRecordSchema(schemaIdentifier);
final SchemaAccessWriter schemaAccessWriter = new HortonworksAttributeSchemaReferenceWriter();
schemaAccessWriter.validateSchema(recordSchema);
}
use of org.apache.nifi.serialization.record.SchemaIdentifier in project nifi by apache.
the class TestSchemaNameAsAttribute method testValidateSchemaWhenValid.
@Test
public void testValidateSchemaWhenValid() throws SchemaNotFoundException {
final SchemaIdentifier schemaIdentifier = SchemaIdentifier.builder().name("person").id(1L).build();
final RecordSchema schema = new SimpleRecordSchema(fields, schemaIdentifier);
schemaAccessWriter.validateSchema(schema);
}
use of org.apache.nifi.serialization.record.SchemaIdentifier in project nifi by apache.
the class TestSchemaNameAsAttribute method testWriteOnlyName.
@Test
public void testWriteOnlyName() {
final SchemaIdentifier schemaIdentifier = SchemaIdentifier.builder().name("person").id(1L).build();
final RecordSchema schema = new SimpleRecordSchema(fields, schemaIdentifier);
final Map<String, String> attributes = schemaAccessWriter.getAttributes(schema);
Assert.assertEquals(1, attributes.size());
Assert.assertEquals(schemaIdentifier.getName().get(), attributes.get(SchemaNameAsAttribute.SCHEMA_NAME_ATTRIBUTE));
}
use of org.apache.nifi.serialization.record.SchemaIdentifier in project nifi by apache.
the class TestSchemaNameAsAttribute method testValidateSchemaWhenNoName.
@Test(expected = SchemaNotFoundException.class)
public void testValidateSchemaWhenNoName() throws SchemaNotFoundException {
final SchemaIdentifier schemaIdentifier = SchemaIdentifier.builder().id(1L).build();
final RecordSchema schema = new SimpleRecordSchema(fields, schemaIdentifier);
schemaAccessWriter.validateSchema(schema);
}
use of org.apache.nifi.serialization.record.SchemaIdentifier in project nifi by apache.
the class TestSchemaNamePropertyStrategy method testNameAndVersion.
@Test
public void testNameAndVersion() throws SchemaNotFoundException, IOException {
final PropertyValue nameValue = new MockPropertyValue("person");
final PropertyValue branchValue = new MockPropertyValue(null);
final PropertyValue versionValue = new MockPropertyValue("1");
final SchemaNamePropertyStrategy schemaNamePropertyStrategy = new SchemaNamePropertyStrategy(schemaRegistry, nameValue, branchValue, versionValue);
final SchemaIdentifier expectedSchemaIdentifier = SchemaIdentifier.builder().name(nameValue.getValue()).version(versionValue.asInteger()).build();
when(schemaRegistry.retrieveSchema(argThat(new SchemaIdentifierMatcher(expectedSchemaIdentifier)))).thenReturn(recordSchema);
final RecordSchema retrievedSchema = schemaNamePropertyStrategy.getSchema(Collections.emptyMap(), null, recordSchema);
assertNotNull(retrievedSchema);
}
Aggregations