use of org.eclipse.jnosql.mapping.reflection.ClassMapping in project jnosql-diana by eclipse.
the class SelectQueryConverterTest method shouldRunQuery6.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "findByAgeGreaterThanEqual" })
public void shouldRunQuery6(String methodName) {
Method method = Stream.of(PersonRepository.class.getMethods()).filter(m -> m.getName().equals(methodName)).findFirst().get();
graph.addVertex(T.label, "Person", "name", "Otavio", "age", 30);
graph.addVertex(T.label, "Person", "name", "Ada", "age", 40);
graph.addVertex(T.label, "Person", "name", "Poliana", "age", 25);
ClassMapping mapping = mappings.get(Person.class);
GraphQueryMethod queryMethod = new GraphQueryMethod(mapping, graph.traversal().V(), converters, method, new Object[] { 30 });
List<Vertex> vertices = converter.apply(queryMethod, null).collect(Collectors.toList());
assertEquals(2, vertices.size());
assertNotEquals("Poliana", vertices.get(0).value("name"));
assertNotEquals("Poliana", vertices.get(1).value("name"));
}
use of org.eclipse.jnosql.mapping.reflection.ClassMapping in project jnosql-diana by eclipse.
the class SelectQueryConverterTest method shouldRunQuery9.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "findByAgeLessThanOrderByNameDesc" })
public void shouldRunQuery9(String methodName) {
Method method = Stream.of(PersonRepository.class.getMethods()).filter(m -> m.getName().equals(methodName)).findFirst().get();
graph.addVertex(T.label, "Person", "name", "Otavio", "age", 30);
graph.addVertex(T.label, "Person", "name", "Ada", "age", 40);
graph.addVertex(T.label, "Person", "name", "Poliana", "age", 25);
ClassMapping mapping = mappings.get(Person.class);
GraphQueryMethod queryMethod = new GraphQueryMethod(mapping, graph.traversal().V(), converters, method, new Object[] { 100 });
List<Vertex> vertices = converter.apply(queryMethod, null).collect(Collectors.toList());
List<Object> names = vertices.stream().map(v -> v.value("name")).collect(Collectors.toList());
assertEquals(3, vertices.size());
MatcherAssert.assertThat(names, Matchers.contains("Poliana", "Otavio", "Ada"));
}
use of org.eclipse.jnosql.mapping.reflection.ClassMapping in project jnosql-diana by eclipse.
the class DeleteQueryConverterTest method shouldRunQuery3.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "deleteByAgeLessThan" })
public void shouldRunQuery3(String methodName) {
Method method = Stream.of(PersonRepository.class.getMethods()).filter(m -> m.getName().equals(methodName)).findFirst().get();
graph.addVertex(T.label, "Person", "name", "Otavio", "age", 30);
graph.addVertex(T.label, "Person", "name", "Ada", "age", 40);
graph.addVertex(T.label, "Person", "name", "Poliana", "age", 25);
ClassMapping mapping = mappings.get(Person.class);
GraphQueryMethod queryMethod = new GraphQueryMethod(mapping, graph.traversal().V(), converters, method, new Object[] { 30 });
List<Vertex> vertices = converter.apply(queryMethod);
assertEquals(1, vertices.size());
assertEquals("Poliana", vertices.get(0).value("name"));
}
use of org.eclipse.jnosql.mapping.reflection.ClassMapping in project jnosql-diana by eclipse.
the class DeleteQueryConverterTest method checkEquals.
private void checkEquals(String methodName) {
Method method = Stream.of(PersonRepository.class.getMethods()).filter(m -> m.getName().equals(methodName)).findFirst().get();
graph.addVertex("Person").property("name", "Otavio");
graph.addVertex("Person").property("name", "Ada");
graph.addVertex("Person").property("name", "Poliana");
ClassMapping mapping = mappings.get(Person.class);
GraphQueryMethod queryMethod = new GraphQueryMethod(mapping, graph.traversal().V(), converters, method, new Object[] { "Ada" });
List<Vertex> vertices = converter.apply(queryMethod);
assertEquals(1, vertices.size());
assertEquals("Ada", vertices.get(0).value("name"));
}
use of org.eclipse.jnosql.mapping.reflection.ClassMapping in project jnosql-diana by eclipse.
the class DeleteQueryConverterTest method shouldRunQuery12.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "deleteByNameIn" })
public void shouldRunQuery12(String methodName) {
Method method = Stream.of(PersonRepository.class.getMethods()).filter(m -> m.getName().equals(methodName)).findFirst().get();
graph.addVertex(T.label, "Person", "name", "Otavio", "age", 30);
graph.addVertex(T.label, "Person", "name", "Ada", "age", 40);
graph.addVertex(T.label, "Person", "name", "Poliana", "age", 25);
ClassMapping mapping = mappings.get(Person.class);
GraphQueryMethod queryMethod = new GraphQueryMethod(mapping, graph.traversal().V(), converters, method, new Object[] { Arrays.asList("Otavio", "Ada", "Poliana") });
List<Vertex> vertices = converter.apply(queryMethod);
List<Object> names = vertices.stream().map(v -> v.value("name")).sorted().collect(Collectors.toList());
assertEquals(3, vertices.size());
MatcherAssert.assertThat(names, Matchers.contains("Ada", "Otavio", "Poliana"));
}
Aggregations