Search in sources :

Example 1 with DummyRecord

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

the class RecordWithComplexTest method testRecordWithRecordValues.

@Test
public void testRecordWithRecordValues() {
    RecursiveDummyRecord original = new RecursiveDummyRecord("Hello", 12353, new DummyRecord("World", 234));
    // 
    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 2 with DummyRecord

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

the class RecordWithComplexTest method testRecordWithNullRequiredFields.

@Test
public void testRecordWithNullRequiredFields() {
    RecursiveDummyRecord original = new RecursiveDummyRecord(null, 12353, new DummyRecord("World", 234));
    // 
    try {
        roundTrip(RecursiveDummyRecord.class, original);
        fail("Should throw an exception");
    } catch (DatabindException e) {
    // 28-Feb-2017, tatu: Sometimes we get this (probably when using ObjectWriter)
    } catch (NullPointerException e) {
    // 28-Feb-2017, tatu: Should NOT just pass NPE, but for now nothing much we can do
    // !!! 22-Feb-2021, tatu: Really should figure out how to improve...
    }
}
Also used : DummyRecord(com.fasterxml.jackson.dataformat.avro.interop.DummyRecord) DatabindException(com.fasterxml.jackson.databind.DatabindException) Test(org.junit.Test)

Example 3 with DummyRecord

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

the class RecordWithComplexTest method testRecordWithListFields.

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

Example 4 with DummyRecord

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

the class ListWithComplexTest method testListWithRecordElements.

@Test
public void testListWithRecordElements() throws IOException {
    List<DummyRecord> original = new ArrayList<>();
    original.add(new DummyRecord("test", 2));
    original.add(new DummyRecord("test 2", 1235));
    original.add(new DummyRecord("test 3", -234));
    // 
    List<DummyRecord> result = roundTrip(type(List.class, DummyRecord.class), original);
    // 
    assertThat(result).isEqualTo(original);
}
Also used : ArrayList(java.util.ArrayList) DummyRecord(com.fasterxml.jackson.dataformat.avro.interop.DummyRecord) List(java.util.List) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with DummyRecord

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

the class MapWithComplexTest method testMapWithRecordValues.

@Test
public void testMapWithRecordValues() throws IOException {
    Map<String, DummyRecord> original = new HashMap<>();
    original.put("one", new DummyRecord("test", 2));
    original.put("two", new DummyRecord("test 2", 1235));
    original.put("three", new DummyRecord("test 3", -234));
    // 
    Map<String, DummyRecord> result = roundTrip(type(Map.class, String.class, DummyRecord.class), original);
    // 
    assertThat(result).isEqualTo(original);
}
Also used : DummyRecord(com.fasterxml.jackson.dataformat.avro.interop.DummyRecord) 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