use of com.hubspot.rosetta.beans.StoredAsJsonBean in project Rosetta by HubSpot.
the class RosettaBinderTest method itBindsNullStoredAsJsonBeanCorrectly.
@Test
public void itBindsNullStoredAsJsonBeanCorrectly() {
StoredAsJsonBean bean = new StoredAsJsonBean();
String json = "{\"stringProperty\":\"value\"}";
List<Byte> bytes = toList(json.getBytes(StandardCharsets.UTF_8));
assertThat(bind(bean)).isEqualTo(map("annotatedField", null, "annotatedGetter", null, "annotatedSetter", null, "annotatedFieldWithDefault", json, "annotatedGetterWithDefault", json, "annotatedSetterWithDefault", json, "optionalField", null, "optionalGetter", null, "optionalSetter", null, "binaryField", null, "binaryFieldWithDefault", bytes, "jsonNodeField", null));
assertThat(bindWithPrefix("prefix", bean)).isEqualTo(map("prefix.annotatedField", null, "prefix.annotatedGetter", null, "prefix.annotatedSetter", null, "prefix.annotatedFieldWithDefault", json, "prefix.annotatedGetterWithDefault", json, "prefix.annotatedSetterWithDefault", json, "prefix.optionalField", null, "prefix.optionalGetter", null, "prefix.optionalSetter", null, "prefix.binaryField", null, "prefix.binaryFieldWithDefault", bytes, "prefix.jsonNodeField", null));
}
use of com.hubspot.rosetta.beans.StoredAsJsonBean in project Rosetta by HubSpot.
the class RosettaMapperTest method itMapsNullStoredAsJsonBeanCorrectly.
@Test
public void itMapsNullStoredAsJsonBeanCorrectly() {
initializeResultSet("table.annotatedField", null, "table.annotatedGetter", null, "table.annotatedSetter", null, "table.annotatedFieldWithDefault", null, "table.annotatedGetterWithDefault", null, "table.annotatedSetterWithDefault", null);
StoredAsJsonBean bean = map(StoredAsJsonBean.class);
assertThat(bean.getAnnotatedField()).isNull();
assertThat(bean.getAnnotatedGetter()).isNull();
assertThat(bean.getAnnotatedSetter()).isNull();
assertThat(bean.getAnnotatedFieldWithDefault().getStringProperty()).isEqualTo("value");
assertThat(bean.getAnnotatedGetterWithDefault().getStringProperty()).isEqualTo("value");
assertThat(bean.getAnnotatedSetterWithDefault().getStringProperty()).isEqualTo("value");
}
use of com.hubspot.rosetta.beans.StoredAsJsonBean in project Rosetta by HubSpot.
the class StoredAsJsonTest method testJsonNodeFieldDeserialization.
@Test
public void testJsonNodeFieldDeserialization() throws JsonProcessingException {
ObjectNode node = Rosetta.getMapper().createObjectNode();
node.put("jsonNodeField", expected);
StoredAsJsonBean bean = Rosetta.getMapper().treeToValue(node, StoredAsJsonBean.class);
assertThat(bean.getJsonNodeField()).isEqualTo(innerJsonNode);
}
use of com.hubspot.rosetta.beans.StoredAsJsonBean in project Rosetta by HubSpot.
the class StoredAsJsonTest method testAnnotatedFieldWithDefaultNullDeserialization.
@Test
public void testAnnotatedFieldWithDefaultNullDeserialization() throws JsonProcessingException {
ObjectNode node = Rosetta.getMapper().createObjectNode();
node.put("annotatedFieldWithDefault", NullNode.getInstance());
StoredAsJsonBean bean = Rosetta.getMapper().treeToValue(node, StoredAsJsonBean.class);
assertThat(bean.getAnnotatedFieldWithDefault().getStringProperty()).isEqualTo("value");
}
use of com.hubspot.rosetta.beans.StoredAsJsonBean in project Rosetta by HubSpot.
the class StoredAsJsonTest method testAnnotatedFieldWithDefaultDeserialization.
@Test
public void testAnnotatedFieldWithDefaultDeserialization() throws JsonProcessingException {
ObjectNode node = Rosetta.getMapper().createObjectNode();
node.put("annotatedFieldWithDefault", expected);
StoredAsJsonBean bean = Rosetta.getMapper().treeToValue(node, StoredAsJsonBean.class);
assertThat(bean.getAnnotatedFieldWithDefault().getStringProperty()).isEqualTo("value");
}
Aggregations