use of org.immutables.criteria.javabean.JavaBean1 in project immutables by immutables.
the class KeyExtractorTest method javaBean.
@Test
void javaBean() {
KeyExtractor extractor = KeyExtractor.defaultFactory().create(JavaBean1.class);
check(extractor.metadata().isKeyDefined());
check(extractor.metadata().isExpression());
check(extractor.metadata().keys()).hasSize(1);
Member member = (Member) Visitors.toPath(extractor.metadata().keys().get(0)).element();
check(member.getName()).is("string1");
JavaBean1 bean1 = new JavaBean1();
bean1.setString1("foo");
check(extractor.extract(bean1)).is("foo");
}
use of org.immutables.criteria.javabean.JavaBean1 in project immutables by immutables.
the class IdAnnotationModuleTest method javaBean.
/**
* Check annotation lookup for java beans
*/
@ParameterizedTest
@MethodSource("mappers")
void javaBean(ObjectMapper mapper) throws IOException {
JavaBean1 bean1 = new JavaBean1();
bean1.setString1("id123");
bean1.setInt1(42);
bean1.setBase("base1");
ObjectNode node = mapper.valueToTree(bean1);
check(ImmutableList.copyOf(node.fieldNames())).has("_id");
check(node.get("_id").asText()).is("id123");
check(ImmutableList.copyOf(node.fieldNames())).not().has("string1");
JavaBean1 bean2 = mapper.treeToValue(node, JavaBean1.class);
check(bean2.getString1()).is("id123");
check(bean2.getInt1()).is(42);
check(bean2.getBase()).is("base1");
}
Aggregations