public AvroUser(CompiledSchema<Schema> schema, String name, int age, String favouriteColour) { this.schema = schema; this.record = create(name, age, favouriteColour); }
public static Schema load() { return load("/schema/user.avsc"); }
public static AvroUser create(CompiledSchema<Schema> schema, byte[] bytes) { try { return new AvroUser(schema, bytes); } catch (IOException ex) { throw new UncheckedIOException(ex); } }
public TestMessage asTestMessage() { return TestMessage.of(NAME_FIELD, getName()).append(AGE_FIELD, getAge()).append(FAVORITE_COLOR_FIELD, getFavoriteColor()); }
@Test(expected = UnsupportedContentTypeException.class) public void shouldThrowUnsupportedContentTypeExceptionWhenReceivedWrongContentType() throws IOException { // when enforcer.enforceAvro(MediaType.TEXT_PLAIN, avroMessage.asBytes(), schema.getSchema(), topic); }
public String asAvroEncodedJson() { return asAvroEncodedTestMessage().toString(); }
public AvroUser(CompiledSchema<Schema> schema, byte[] bytes) throws IOException { this.schema = schema; this.record = RecordToBytesConverter.bytesToRecord(bytes, schema.getSchema()); }
public String asJson() { return asTestMessage().toString(); }
public byte[] asBytes() { try { return recordToBytes(record, schema.getSchema()); } catch (IOException e) { throw new RuntimeException(e); } }
public TestMessage asTestMessage() { return TestMessage.of(NAME_FIELD, getName()).append(AGE_FIELD, getAge()).append(FAVORITE_COLOR_FIELD, getFavoriteColor()); }
public static AvroUser create(CompiledSchema<Schema> schema, byte[] bytes) { try { return new AvroUser(schema, bytes); } catch (IOException ex) { throw new UncheckedIOException(ex); } }
public static Schema load() { return load("/schema/user.avsc"); }
public AvroUser(CompiledSchema<Schema> schema, String name, int age, String favouriteColour) { this.schema = schema; this.record = create(name, age, favouriteColour); }
public String asAvroEncodedJson() { return asAvroEncodedTestMessage().toString(); }
public AvroUser(CompiledSchema<Schema> schema, byte[] bytes) throws IOException { this.schema = schema; this.record = RecordToBytesConverter.bytesToRecord(bytes, schema.getSchema()); }
public String asJson() { return asTestMessage().toString(); }
public byte[] asBytes() { try { return recordToBytes(record, schema.getSchema()); } catch (IOException e) { throw new RuntimeException(e); } }
public AvroUser(String name, int age, String favouriteColour) { this(new CompiledSchema<>(AvroUserSchemaLoader.load(), SchemaVersion.valueOf(1)), name, age, favouriteColour); }
public AvroUser(String name, int age, String favouriteColour) { this(new CompiledSchema<>(AvroUserSchemaLoader.load(), SchemaVersion.valueOf(1)), name, age, favouriteColour); }