use of com.hubspot.rosetta.beans.InnerBean in project Rosetta by HubSpot.
the class RosettaBinderTest method itBindsNestedBeanCorrectly.
@Test
public void itBindsNestedBeanCorrectly() {
InnerBean inner = new InnerBean();
inner.setStringProperty("value");
NestedBean bean = new NestedBean();
bean.setInner(inner);
assertThat(bind(bean)).isEqualTo(map("inner.stringProperty", "value"));
assertThat(bindWithPrefix("prefix", bean)).isEqualTo(map("prefix.inner.stringProperty", "value"));
}
use of com.hubspot.rosetta.beans.InnerBean in project Rosetta by HubSpot.
the class StoredAsJsonTest method setup.
@Before
public void setup() {
bean = new StoredAsJsonBean();
inner = new InnerBean();
inner.setStringProperty("value");
}
use of com.hubspot.rosetta.beans.InnerBean in project Rosetta by HubSpot.
the class RosettaBinderTest method itBindsStoredAsJsonBeanCorrectly.
@Test
public void itBindsStoredAsJsonBeanCorrectly() {
InnerBean inner = new InnerBean();
inner.setStringProperty("value");
JsonNode innerJsonNode = Rosetta.getMapper().createObjectNode().set("stringProperty", TextNode.valueOf("value"));
StoredAsJsonBean bean = new StoredAsJsonBean();
bean.setAnnotatedField(inner);
bean.setAnnotatedGetter(inner);
bean.setAnnotatedSetter(inner);
bean.setAnnotatedFieldWithDefault(inner);
bean.setAnnotatedGetterWithDefault(inner);
bean.setAnnotatedSetterWithDefault(inner);
bean.setOptionalField(Optional.of(inner));
bean.setOptionalGetter(Optional.of(inner));
bean.setOptionalSetter(Optional.of(inner));
bean.setBinaryField(inner);
bean.setBinaryFieldWithDefault(inner);
bean.setJsonNodeField(innerJsonNode);
String json = "{\"stringProperty\":\"value\"}";
List<Byte> bytes = toList(json.getBytes(StandardCharsets.UTF_8));
assertThat(bind(bean)).isEqualTo(map("annotatedField", json, "annotatedGetter", json, "annotatedSetter", json, "annotatedFieldWithDefault", json, "annotatedGetterWithDefault", json, "annotatedSetterWithDefault", json, "optionalField", json, "optionalGetter", json, "optionalSetter", json, "binaryField", bytes, "binaryFieldWithDefault", bytes, "jsonNodeField", json));
assertThat(bindWithPrefix("prefix", bean)).isEqualTo(map("prefix.annotatedField", json, "prefix.annotatedGetter", json, "prefix.annotatedSetter", json, "prefix.annotatedFieldWithDefault", json, "prefix.annotatedGetterWithDefault", json, "prefix.annotatedSetterWithDefault", json, "prefix.optionalField", json, "prefix.optionalGetter", json, "prefix.optionalSetter", json, "prefix.binaryField", bytes, "prefix.binaryFieldWithDefault", bytes, "prefix.jsonNodeField", json));
}
Aggregations