ProtobufSchema implements Schema, ProvidesAlias, ProvidesValidations { @Override public void configure(Config config) { String descriptorFilePath = config.getString(DESCRIPTOR_FILEPATH_CONFIG); if (config.hasPath(DESCRIPTOR_MESSAGE_CONFIG)) { String descriptorMessage = config.getString(DESCRIPTOR_MESSAGE_CONFIG); this.descriptor = ProtobufUtils.buildDescriptor(descriptorFilePath, descriptorMessage); } else { this.descriptor = ProtobufUtils.buildDescriptor(descriptorFilePath); } this.schema = ProtobufUtils.buildSchema(descriptor); }  @Override void configure(Config config); @Override String getAlias(); @Override StructType getSchema(); @Override Validations getValidations(); Descriptors.Descriptor getDescriptor(); static final String DESCRIPTOR_FILEPATH_CONFIG; static final String DESCRIPTOR_MESSAGE_CONFIG; static final String ALIAS; }
@Test(expected = RuntimeException.class) public void configureIllegalFilepath() { Map<String, Object> configMap = new HashMap<>(); configMap.put(ComponentFactory.TYPE_CONFIG_NAME, "protobuf"); configMap.put(ProtobufSchema.DESCRIPTOR_FILEPATH_CONFIG, "not found"); Config config = ConfigFactory.parseMap(configMap); ProtobufSchema schema = new ProtobufSchema(); assertNoValidationFailures(schema, config); schema.configure(config); }
@Test (expected = RuntimeException.class) public void configMultipleNoDesignation() { String descPath = TestProtobufSchema.class.getResource(MULTIPLE_EXAMPLE).getPath(); Map<String, Object> configMap = new HashMap<>(); configMap.put(ComponentFactory.TYPE_CONFIG_NAME, "protobuf"); configMap.put(ProtobufSchema.DESCRIPTOR_FILEPATH_CONFIG, descPath); Config config = ConfigFactory.parseMap(configMap); ProtobufSchema schema = new ProtobufSchema(); assertNoValidationFailures(schema, config); schema.configure(config); }