Search in sources :

Example 1 with OptionalStoredAsJsonBean

use of com.hubspot.rosetta.beans.OptionalStoredAsJsonBeanIF.OptionalStoredAsJsonBean 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 OptionalStoredAsJsonBean

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

the class StoredAsJsonTest method testSerializingOptionalStoredAsJsonSubtypeBean.

@Test
public void testSerializingOptionalStoredAsJsonSubtypeBean() {
    OptionalStoredAsJsonBean bean = new OptionalStoredAsJsonBean(java.util.Optional.of(new PolymorphicBeanASubTypeA()));
    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) JsonNode(com.fasterxml.jackson.databind.JsonNode) PolymorphicBeanASubTypeA(com.hubspot.rosetta.beans.PolymorphicBeanASubTypeA) Test(org.junit.Test)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)2 OptionalStoredAsJsonBean (com.hubspot.rosetta.beans.OptionalStoredAsJsonBeanIF.OptionalStoredAsJsonBean)2 Test (org.junit.Test)2 PolymorphicBeanA (com.hubspot.rosetta.beans.PolymorphicBeanA)1 PolymorphicBeanASubTypeA (com.hubspot.rosetta.beans.PolymorphicBeanASubTypeA)1