Search in sources :

Example 6 with StoredAsJsonBean

use of com.hubspot.rosetta.beans.StoredAsJsonBean in project Rosetta by HubSpot.

the class StoredAsJsonTest method setup.

@Before
public void setup() {
    bean = new StoredAsJsonBean();
    inner = new InnerBean();
    inner.setStringProperty("value");
}
Also used : InnerBean(com.hubspot.rosetta.beans.InnerBean) StoredAsJsonBean(com.hubspot.rosetta.beans.StoredAsJsonBean) Before(org.junit.Before)

Example 7 with StoredAsJsonBean

use of com.hubspot.rosetta.beans.StoredAsJsonBean in project Rosetta by HubSpot.

the class StoredAsJsonTest method testAnnotatedSetterNullDeserialization.

@Test
public void testAnnotatedSetterNullDeserialization() throws JsonProcessingException {
    ObjectNode node = Rosetta.getMapper().createObjectNode();
    node.put("annotatedSetter", NullNode.getInstance());
    StoredAsJsonBean bean = Rosetta.getMapper().treeToValue(node, StoredAsJsonBean.class);
    assertThat(bean.getAnnotatedSetter()).isNull();
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) StoredAsJsonBean(com.hubspot.rosetta.beans.StoredAsJsonBean) Test(org.junit.Test)

Example 8 with StoredAsJsonBean

use of com.hubspot.rosetta.beans.StoredAsJsonBean in project Rosetta by HubSpot.

the class StoredAsJsonTest method testJsonNodeNullDeserialization.

@Test
public void testJsonNodeNullDeserialization() throws JsonProcessingException {
    ObjectNode node = Rosetta.getMapper().createObjectNode();
    node.put("jsonNodeField", NullNode.getInstance());
    StoredAsJsonBean bean = Rosetta.getMapper().treeToValue(node, StoredAsJsonBean.class);
    assertThat(bean.getJsonNodeField()).isEqualTo(NullNode.getInstance());
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) StoredAsJsonBean(com.hubspot.rosetta.beans.StoredAsJsonBean) Test(org.junit.Test)

Example 9 with StoredAsJsonBean

use of com.hubspot.rosetta.beans.StoredAsJsonBean in project Rosetta by HubSpot.

the class StoredAsJsonTest method testBinaryFieldWithDefaultNullDeserialization.

@Test
public void testBinaryFieldWithDefaultNullDeserialization() throws JsonProcessingException {
    ObjectNode node = Rosetta.getMapper().createObjectNode();
    node.put("binaryFieldWithDefault", NullNode.getInstance());
    StoredAsJsonBean bean = Rosetta.getMapper().treeToValue(node, StoredAsJsonBean.class);
    assertThat(bean.getBinaryFieldWithDefault().getStringProperty()).isEqualTo("value");
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) StoredAsJsonBean(com.hubspot.rosetta.beans.StoredAsJsonBean) Test(org.junit.Test)

Example 10 with StoredAsJsonBean

use of com.hubspot.rosetta.beans.StoredAsJsonBean in project Rosetta by HubSpot.

the class StoredAsJsonTest method testAnnotatedFieldDeserialization.

@Test
public void testAnnotatedFieldDeserialization() throws JsonProcessingException {
    ObjectNode node = Rosetta.getMapper().createObjectNode();
    node.put("annotatedField", expected);
    StoredAsJsonBean bean = Rosetta.getMapper().treeToValue(node, StoredAsJsonBean.class);
    assertThat(bean.getAnnotatedField().getStringProperty()).isEqualTo("value");
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) StoredAsJsonBean(com.hubspot.rosetta.beans.StoredAsJsonBean) Test(org.junit.Test)

Aggregations

StoredAsJsonBean (com.hubspot.rosetta.beans.StoredAsJsonBean)29 Test (org.junit.Test)28 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)24 InnerBean (com.hubspot.rosetta.beans.InnerBean)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Before (org.junit.Before)1