use of com.hubspot.rosetta.beans.PolymorphicStoredAsJsonBean 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);
}
use of com.hubspot.rosetta.beans.PolymorphicStoredAsJsonBean in project Rosetta by HubSpot.
the class StoredAsJsonTest method testNullPolymorphicStoredAsJsonBean.
@Test
public void testNullPolymorphicStoredAsJsonBean() {
PolymorphicStoredAsJsonBean bean = new PolymorphicStoredAsJsonBean();
bean.setAnnotatedField(new NullPolymorphicBean());
JsonNode node = Rosetta.getMapper().valueToTree(bean);
assertThat(node.get("annotatedField")).isNotNull();
assertThat(node.get("annotatedField").isNull()).isTrue();
}
Aggregations