@Test (expectedExceptions=SchemaConversionException.class) public void testFieldsPickWrongFieldFailure() throws Exception { Schema inputSchema = new Schema.Parser().parse(getClass().getResourceAsStream("/converter/fieldPickInput.avsc")); WorkUnitState workUnitState = new WorkUnitState(); workUnitState.setProp(ConfigurationKeys.CONVERTER_AVRO_FIELD_PICK_FIELDS, "name,favorite_number,favorite_food"); try (AvroFieldsPickConverter converter = new AvroFieldsPickConverter()) { Schema converted = converter.convertSchema(inputSchema, workUnitState); Schema expected = new Schema.Parser().parse(getClass().getResourceAsStream("/converter/fieldPickExpected.avsc")); JSONAssert.assertEquals(expected.toString(), converted.toString(), false); } }
@Override public Schema convertSchema(Schema inputSchema, WorkUnitState workUnit) throws SchemaConversionException { LOG.info("Converting schema " + inputSchema); String fieldsStr = workUnit.getProp(ConfigurationKeys.CONVERTER_AVRO_FIELD_PICK_FIELDS); Preconditions.checkNotNull(fieldsStr, ConfigurationKeys.CONVERTER_AVRO_FIELD_PICK_FIELDS + " is required for converter " + this.getClass().getSimpleName()); LOG.info("Converting schema to selected fields: " + fieldsStr); try { return createSchema(inputSchema, fieldsStr); } catch (Exception e) { throw new SchemaConversionException(e); } }
AvroFieldsPickConverter extends AvroToAvroConverterBase { @Override public Schema convertSchema(Schema inputSchema, WorkUnitState workUnit) throws SchemaConversionException { LOG.info("Converting schema " + inputSchema); String fieldsStr = workUnit.getProp(ConfigurationKeys.CONVERTER_AVRO_FIELD_PICK_FIELDS); Preconditions.checkNotNull(fieldsStr, ConfigurationKeys.CONVERTER_AVRO_FIELD_PICK_FIELDS + " is required for converter " + this.getClass().getSimpleName()); LOG.info("Converting schema to selected fields: " + fieldsStr); try { return createSchema(inputSchema, fieldsStr); } catch (Exception e) { throw new SchemaConversionException(e); } } }
AvroFieldsPickConverter extends AvroToAvroConverterBase { @Override public Schema convertSchema(Schema inputSchema, WorkUnitState workUnit) throws SchemaConversionException { LOG.info("Converting schema " + inputSchema); String fieldsStr = workUnit.getProp(ConfigurationKeys.CONVERTER_AVRO_FIELD_PICK_FIELDS); Preconditions.checkNotNull(fieldsStr, ConfigurationKeys.CONVERTER_AVRO_FIELD_PICK_FIELDS + " is required for converter " + this.getClass().getSimpleName()); LOG.info("Converting schema to selected fields: " + fieldsStr); try { return createSchema(inputSchema, fieldsStr); } catch (Exception e) { throw new SchemaConversionException(e); } }  }
AvroFieldsPickConverter extends AvroToAvroConverterBase { @Override public Schema convertSchema(Schema inputSchema, WorkUnitState workUnit) throws SchemaConversionException { LOG.info("Converting schema " + inputSchema); String fieldsStr = workUnit.getProp(ConfigurationKeys.CONVERTER_AVRO_FIELD_PICK_FIELDS); Preconditions.checkNotNull(fieldsStr, ConfigurationKeys.CONVERTER_AVRO_FIELD_PICK_FIELDS + " is required for converter " + this.getClass().getSimpleName()); LOG.info("Converting schema to selected fields: " + fieldsStr); try { return createSchema(inputSchema, fieldsStr); } catch (Exception e) { throw new SchemaConversionException(e); } }  @Override Schema convertSchema(Schema inputSchema, WorkUnitState workUnit); @Override Iterable<GenericRecord> convertRecordImpl(Schema outputSchema, GenericRecord inputRecord, WorkUnitState workUnit); }
AvroFieldsPickConverter extends AvroToAvroConverterBase { @Override public Schema convertSchema(Schema inputSchema, WorkUnitState workUnit) throws SchemaConversionException { LOG.info("Converting schema " + inputSchema); String fieldsStr = workUnit.getProp(ConfigurationKeys.CONVERTER_AVRO_FIELD_PICK_FIELDS); Preconditions.checkNotNull(fieldsStr, ConfigurationKeys.CONVERTER_AVRO_FIELD_PICK_FIELDS + " is required for converter " + this.getClass().getSimpleName()); LOG.info("Converting schema to selected fields: " + fieldsStr); try { return createSchema(inputSchema, fieldsStr); } catch (Exception e) { throw new SchemaConversionException(e); } }  @Override Schema convertSchema(Schema inputSchema, WorkUnitState workUnit); @Override Iterable<GenericRecord> convertRecordImpl(Schema outputSchema, GenericRecord inputRecord, WorkUnitState workUnit);  }