-
-
Save pcarrier/14d3a8e249d804cfbdee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.twitter.autobake.misc; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | |
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; | |
import lombok.Builder; | |
import lombok.Data; | |
import org.junit.Test; | |
import java.io.IOException; | |
import static org.junit.Assert.assertEquals; | |
public class LombokJacksonTest { | |
@Test | |
public void testJsonBuilders() throws IOException { | |
final ObjectMapper mapper = new ObjectMapper(); | |
final JsonTest hello = new JsonTest(10, "hello"); | |
final byte[] bytes = mapper.writeValueAsBytes(hello); | |
final JsonTest read = mapper.readValue(bytes, JsonTest.class); | |
assertEquals(10, read.getInteger()); | |
assertEquals("hello", read.getString()); | |
} | |
@JsonDeserialize(builder = JsonTest.JsonTestBuilder.class) | |
@Builder | |
@Data | |
public static final class JsonTest { | |
private final int integer; | |
private final String string; | |
@JsonPOJOBuilder(withPrefix = "") | |
public static final class JsonTestBuilder { | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a ton ! 👍
I was stuck into this lombok + jackson for a long time....