Search in sources :

Example 1 with ConcreteStoredAsJsonList

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

the class StoredAsJsonTest method itHandlesSubTypes.

@Test
public void itHandlesSubTypes() throws JsonProcessingException {
    ConcreteStoredAsJsonList typeInfoBean = new ConcreteStoredAsJsonList();
    typeInfoBean.setInnerBeans(Collections.singletonList(inner));
    TextNode expectedList = TextNode.valueOf("[{\"stringProperty\":\"value\"}]");
    JsonNode node = Rosetta.getMapper().valueToTree(typeInfoBean);
    assertThat(node.get("innerBeans")).isEqualTo(expectedList);
    assertThat(Rosetta.getMapper().treeToValue(node, StoredAsJsonListTypeInfoBean.class).getInnerBeans().get(0).getStringProperty()).isEqualTo("value");
    assertThat(Rosetta.getMapper().treeToValue(node, ConcreteStoredAsJsonList.class).getInnerBeans().get(0).getStringProperty()).isEqualTo("value");
}
Also used : StoredAsJsonListTypeInfoBean(com.hubspot.rosetta.beans.StoredAsJsonListTypeInfoBean) ConcreteStoredAsJsonList(com.hubspot.rosetta.beans.StoredAsJsonListTypeInfoBean.ConcreteStoredAsJsonList) TextNode(com.fasterxml.jackson.databind.node.TextNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 TextNode (com.fasterxml.jackson.databind.node.TextNode)1 StoredAsJsonListTypeInfoBean (com.hubspot.rosetta.beans.StoredAsJsonListTypeInfoBean)1 ConcreteStoredAsJsonList (com.hubspot.rosetta.beans.StoredAsJsonListTypeInfoBean.ConcreteStoredAsJsonList)1 Test (org.junit.Test)1