Search in sources :

Example 21 with StoredAsJsonBean

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

the class StoredAsJsonTest method testAnnotatedGetterNullDeserialization.

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

Example 22 with StoredAsJsonBean

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

the class StoredAsJsonTest method testBinaryFieldNullDeserialization.

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

Example 23 with StoredAsJsonBean

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

the class StoredAsJsonTest method testOptionalGetterNullDeserialization.

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

Example 24 with StoredAsJsonBean

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

the class StoredAsJsonTest method testOptionalFieldNullDeserialization.

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

Example 25 with StoredAsJsonBean

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

the class StoredAsJsonTest method testAnnotatedGetterDeserialization.

@Test
public void testAnnotatedGetterDeserialization() throws JsonProcessingException {
    ObjectNode node = Rosetta.getMapper().createObjectNode();
    node.put("annotatedGetter", expected);
    StoredAsJsonBean bean = Rosetta.getMapper().treeToValue(node, StoredAsJsonBean.class);
    assertThat(bean.getAnnotatedGetter().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