Search in sources :

Example 1 with PolymorphicBeanA

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

the class StoredAsJsonTest method testSerializingOptionalStoredAsJsonBean.

@Test
public void testSerializingOptionalStoredAsJsonBean() {
    OptionalStoredAsJsonBean bean = new OptionalStoredAsJsonBean(java.util.Optional.of(new PolymorphicBeanA()));
    JsonNode node = Rosetta.getMapper().valueToTree(bean);
    assertThat(node.get("bean")).isNotNull();
    assertThat(node.get("bean").textValue()).contains("beanType");
}
Also used : OptionalStoredAsJsonBean(com.hubspot.rosetta.beans.OptionalStoredAsJsonBeanIF.OptionalStoredAsJsonBean) PolymorphicBeanA(com.hubspot.rosetta.beans.PolymorphicBeanA) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 2 with PolymorphicBeanA

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

the class StoredAsJsonTest method testPolymorphicStoredAsJsonBeans.

@Test
public void testPolymorphicStoredAsJsonBeans() throws JsonProcessingException {
    PolymorphicStoredAsJsonBean bean = new PolymorphicStoredAsJsonBean();
    bean.setAnnotatedField(new PolymorphicBeanA());
    JsonNode node = Rosetta.getMapper().valueToTree(bean);
    assertThat(node.get("annotatedField")).isNotNull();
    assertThat(node.get("annotatedField").hasNonNull("beanType"));
    assertThat(Rosetta.getMapper().treeToValue(node, PolymorphicStoredAsJsonBean.class).getAnnotatedField()).isInstanceOf(PolymorphicBeanA.class);
}
Also used : PolymorphicStoredAsJsonBean(com.hubspot.rosetta.beans.PolymorphicStoredAsJsonBean) PolymorphicBeanA(com.hubspot.rosetta.beans.PolymorphicBeanA) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 3 with PolymorphicBeanA

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

the class StoredAsJsonTest method testSerializingMapStoredAsJsonBean.

@Test
public void testSerializingMapStoredAsJsonBean() {
    MapStoredAsJsonBean bean = new MapStoredAsJsonBean(ImmutableMap.of("A", new PolymorphicBeanA()));
    JsonNode node = Rosetta.getMapper().valueToTree(bean);
    assertThat(node.get("beans")).isNotNull();
    assertThat(node.get("beans").textValue()).contains("beanType");
}
Also used : MapStoredAsJsonBean(com.hubspot.rosetta.beans.MapStoredAsJsonBean) PolymorphicBeanA(com.hubspot.rosetta.beans.PolymorphicBeanA) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 4 with PolymorphicBeanA

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

the class StoredAsJsonTest method testSerializingListStoredAsJsonBean.

@Test
public void testSerializingListStoredAsJsonBean() {
    ListStoredAsJsonBean bean = new ListStoredAsJsonBean(Arrays.asList(new PolymorphicBeanA()));
    JsonNode node = Rosetta.getMapper().valueToTree(bean);
    assertThat(node.get("beans")).isNotNull();
    assertThat(node.get("beans").textValue()).contains("beanType");
}
Also used : PolymorphicBeanA(com.hubspot.rosetta.beans.PolymorphicBeanA) JsonNode(com.fasterxml.jackson.databind.JsonNode) ListStoredAsJsonBean(com.hubspot.rosetta.beans.ListStoredAsJsonBeanIF.ListStoredAsJsonBean) Test(org.junit.Test)

Example 5 with PolymorphicBeanA

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

the class StoredAsJsonTest method testSerializingSetStoredAsJsonBean.

@Test
public void testSerializingSetStoredAsJsonBean() {
    SetStoredAsJsonBean bean = new SetStoredAsJsonBean(ImmutableSet.of(new PolymorphicBeanA()));
    JsonNode node = Rosetta.getMapper().valueToTree(bean);
    assertThat(node.get("beans")).isNotNull();
    assertThat(node.get("beans").textValue()).contains("beanType");
}
Also used : SetStoredAsJsonBean(com.hubspot.rosetta.beans.SetStoredAsJsonBean) PolymorphicBeanA(com.hubspot.rosetta.beans.PolymorphicBeanA) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)5 PolymorphicBeanA (com.hubspot.rosetta.beans.PolymorphicBeanA)5 Test (org.junit.Test)5 ListStoredAsJsonBean (com.hubspot.rosetta.beans.ListStoredAsJsonBeanIF.ListStoredAsJsonBean)1 MapStoredAsJsonBean (com.hubspot.rosetta.beans.MapStoredAsJsonBean)1 OptionalStoredAsJsonBean (com.hubspot.rosetta.beans.OptionalStoredAsJsonBeanIF.OptionalStoredAsJsonBean)1 PolymorphicStoredAsJsonBean (com.hubspot.rosetta.beans.PolymorphicStoredAsJsonBean)1 SetStoredAsJsonBean (com.hubspot.rosetta.beans.SetStoredAsJsonBean)1