Skip to content

Instantly share code, notes, and snippets.

@odrotbohm
Created June 29, 2020 21:08
Show Gist options
  • Save odrotbohm/125d15ec154a1ac72f74754ef1b03764 to your computer and use it in GitHub Desktop.
Save odrotbohm/125d15ec154a1ac72f74754ef1b03764 to your computer and use it in GitHub Desktop.

Revisions

  1. odrotbohm revised this gist Jun 29, 2020. No changes.
  2. odrotbohm revised this gist Jun 29, 2020. No changes.
  3. odrotbohm created this gist Jun 29, 2020.
    20 changes: 20 additions & 0 deletions Sample.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    @SpringBootTest
    @RequiredArgsConstructor
    class Sample {

    private final ObjectMapper jackson;

    @Test
    void deserializesThroughConstructor() throws Exception {

    var result = jackson.readValue("{\"firstname\" : \"Dave\", \"lastname\" : \"Matthews\" }", SomeSample.class);

    assertThat(result.getFirstname()).isEqualTo("Dave");
    assertThat(result.getLastname()).isEqualTo("Matthews");
    }

    @Value
    static class SomeSample {
    String firstname, lastname;
    }
    }