use of org.eclipse.jnosql.mapping.util.ParamsBinder in project jnosql-diana by eclipse.
the class ParamsBinderTest method shouldConvert2.
@Test
public void shouldConvert2() {
Method method = Stream.of(PersonRepository.class.getMethods()).filter(m -> m.getName().equals("findByAgeAndName")).findFirst().get();
ClassMapping classMapping = mappings.get(Person.class);
RepositoryDocumentObserverParser parser = new RepositoryDocumentObserverParser(classMapping);
paramsBinder = new ParamsBinder(classMapping, converters);
SelectMethodProvider selectMethodFactory = SelectMethodProvider.get();
SelectQuery selectQuery = selectMethodFactory.apply(method, classMapping.getName());
SelectQueryConverter converter = ServiceLoaderProvider.get(SelectQueryConverter.class);
DocumentQueryParams queryParams = converter.apply(selectQuery, parser);
Params params = queryParams.getParams();
paramsBinder.bind(params, new Object[] { 10L, "Ada" }, method);
DocumentQuery query = queryParams.getQuery();
DocumentCondition columnCondition = query.getCondition().get();
List<DocumentCondition> conditions = columnCondition.getDocument().get(new TypeReference<List<DocumentCondition>>() {
});
List<Object> values = conditions.stream().map(DocumentCondition::getDocument).map(Document::getValue).map(Value::get).collect(Collectors.toList());
assertEquals(10, values.get(0));
assertEquals("Ada", values.get(1));
}
use of org.eclipse.jnosql.mapping.util.ParamsBinder in project jnosql-diana by eclipse.
the class ParamsBinderTest method shouldConvert.
@Test
public void shouldConvert() {
Method method = Stream.of(PersonRepository.class.getMethods()).filter(m -> m.getName().equals("findByAge")).findFirst().get();
ClassMapping classMapping = mappings.get(Person.class);
RepositoryDocumentObserverParser parser = new RepositoryDocumentObserverParser(classMapping);
paramsBinder = new ParamsBinder(classMapping, converters);
SelectMethodProvider selectMethodFactory = SelectMethodProvider.get();
SelectQuery selectQuery = selectMethodFactory.apply(method, classMapping.getName());
SelectQueryConverter converter = ServiceLoaderProvider.get(SelectQueryConverter.class);
DocumentQueryParams columnQueryParams = converter.apply(selectQuery, parser);
Params params = columnQueryParams.getParams();
Object[] args = { 10 };
paramsBinder.bind(params, args, method);
DocumentQuery query = columnQueryParams.getQuery();
DocumentCondition columnCondition = query.getCondition().get();
Value value = columnCondition.getDocument().getValue();
assertEquals(10, value.get());
}
use of org.eclipse.jnosql.mapping.util.ParamsBinder in project jnosql-diana by eclipse.
the class ParamsBinderTest method shouldConvert2.
@Test
public void shouldConvert2() {
Method method = Stream.of(PersonRepository.class.getMethods()).filter(m -> m.getName().equals("findByAgeAndName")).findFirst().get();
ClassMapping classMapping = mappings.get(Person.class);
RepositoryColumnObserverParser parser = new RepositoryColumnObserverParser(classMapping);
paramsBinder = new ParamsBinder(classMapping, converters);
SelectMethodProvider selectMethodFactory = SelectMethodProvider.get();
SelectQuery selectQuery = selectMethodFactory.apply(method, classMapping.getName());
SelectQueryConverter converter = ServiceLoaderProvider.get(SelectQueryConverter.class);
ColumnQueryParams queryParams = converter.apply(selectQuery, parser);
Params params = queryParams.getParams();
paramsBinder.bind(params, new Object[] { 10L, "Ada" }, method);
ColumnQuery query = queryParams.getQuery();
ColumnCondition columnCondition = query.getCondition().get();
List<ColumnCondition> conditions = columnCondition.getColumn().get(new TypeReference<List<ColumnCondition>>() {
});
List<Object> values = conditions.stream().map(ColumnCondition::getColumn).map(Column::getValue).map(Value::get).collect(Collectors.toList());
assertEquals(10, values.get(0));
assertEquals("Ada", values.get(1));
}
use of org.eclipse.jnosql.mapping.util.ParamsBinder in project jnosql-diana by eclipse.
the class ParamsBinderTest method shouldConvert.
@Test
public void shouldConvert() {
Method method = Stream.of(PersonRepository.class.getMethods()).filter(m -> m.getName().equals("findByAge")).findFirst().get();
ClassMapping classMapping = mappings.get(Person.class);
RepositoryColumnObserverParser parser = new RepositoryColumnObserverParser(classMapping);
paramsBinder = new ParamsBinder(classMapping, converters);
SelectMethodProvider selectMethodFactory = SelectMethodProvider.get();
SelectQuery selectQuery = selectMethodFactory.apply(method, classMapping.getName());
SelectQueryConverter converter = ServiceLoaderProvider.get(SelectQueryConverter.class);
ColumnQueryParams columnQueryParams = converter.apply(selectQuery, parser);
Params params = columnQueryParams.getParams();
Object[] args = { 10 };
paramsBinder.bind(params, args, method);
ColumnQuery query = columnQueryParams.getQuery();
ColumnCondition columnCondition = query.getCondition().get();
Value value = columnCondition.getColumn().getValue();
assertEquals(10, value.get());
}
Aggregations