Search in sources :

Example 6 with DummyRecord

use of com.fasterxml.jackson.dataformat.avro.interop.DummyRecord in project jackson-dataformats-binary by FasterXML.

the class RecordWithComplexTest method testRecordWithMapFields.

@Test
public void testRecordWithMapFields() throws IOException {
    RecursiveDummyRecord original = new RecursiveDummyRecord("Hello", 12353, new DummyRecord("World", 234));
    original.simpleMap.put("Hello World", 9682584);
    // 
    RecursiveDummyRecord result = roundTrip(RecursiveDummyRecord.class, original);
    // 
    assertThat(result).isEqualTo(original);
    assertThat(result.simpleMap.get("Hello World")).isEqualTo(original.simpleMap.get("Hello World"));
}
Also used : DummyRecord(com.fasterxml.jackson.dataformat.avro.interop.DummyRecord) Test(org.junit.Test)

Example 7 with DummyRecord

use of com.fasterxml.jackson.dataformat.avro.interop.DummyRecord in project jackson-dataformats-binary by FasterXML.

the class RecordWithComplexTest method testRecordWithOptionalEnumField.

@Test
public void testRecordWithOptionalEnumField() {
    RecursiveDummyRecord original = new RecursiveDummyRecord("Hello", 12353, new DummyRecord("World", 234));
    original.optionalEnum = DummyEnum.SOUTH;
    // 
    RecursiveDummyRecord result = roundTrip(RecursiveDummyRecord.class, original);
    // 
    assertThat(result).isEqualTo(original);
}
Also used : DummyRecord(com.fasterxml.jackson.dataformat.avro.interop.DummyRecord) Test(org.junit.Test)

Example 8 with DummyRecord

use of com.fasterxml.jackson.dataformat.avro.interop.DummyRecord in project jackson-dataformats-binary by FasterXML.

the class RecordWithComplexTest method testRecordWithMissingRequiredEnumFields.

@Test
public void testRecordWithMissingRequiredEnumFields() {
    RecursiveDummyRecord original = new RecursiveDummyRecord("Hello", 12353, new DummyRecord("World", 234));
    original.requiredEnum = null;
    // 
    try {
        roundTrip(RecursiveDummyRecord.class, original);
        fail("Should throw an exception");
    } catch (JacksonException e) {
        // sometimes we get this
        assertThat(e).isInstanceOf(DatabindException.class);
    } catch (AvroTypeException e) {
        // sometimes (not wrapped)
        ;
    }
}
Also used : JacksonException(com.fasterxml.jackson.core.JacksonException) DummyRecord(com.fasterxml.jackson.dataformat.avro.interop.DummyRecord) DatabindException(com.fasterxml.jackson.databind.DatabindException) AvroTypeException(org.apache.avro.AvroTypeException) Test(org.junit.Test)

Aggregations

DummyRecord (com.fasterxml.jackson.dataformat.avro.interop.DummyRecord)8 Test (org.junit.Test)8 DatabindException (com.fasterxml.jackson.databind.DatabindException)2 JacksonException (com.fasterxml.jackson.core.JacksonException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AvroTypeException (org.apache.avro.AvroTypeException)1