Search in sources :

Example 26 with StoredAsJsonBean

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

the class StoredAsJsonTest method testOptionalGetterDeserialization.

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

Example 27 with StoredAsJsonBean

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

the class StoredAsJsonTest method testOptionalSetterDeserialization.

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

Example 28 with StoredAsJsonBean

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

the class StoredAsJsonTest method testOptionalFieldDeserialization.

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

Example 29 with StoredAsJsonBean

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

the class StoredAsJsonTest method testBinaryFieldDeserialization.

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