use of jakarta.nosql.mapping.PreparedStatement in project jnosql-diana by eclipse.
the class AbstractGraphTemplateTest method shouldExecutePrepareStatementSingleton.
@Test
public void shouldExecutePrepareStatementSingleton() {
getGraphTemplate().insert(Person.builder().withAge().withName("Otavio").build());
PreparedStatement prepare = getGraphTemplate().prepare("g.V().hasLabel(param)");
prepare.bind("param", "Person");
Optional<Person> otavio = prepare.getSingleResult();
assertTrue(otavio.isPresent());
}
use of jakarta.nosql.mapping.PreparedStatement in project jnosql-diana by eclipse.
the class AbstractGraphTemplateTest method shouldExecutePrepareStatement.
@Test
public void shouldExecutePrepareStatement() {
getGraphTemplate().insert(Person.builder().withAge().withName("Otavio").build());
PreparedStatement prepare = getGraphTemplate().prepare("g.V().hasLabel(param)");
prepare.bind("param", "Person");
List<Person> people = prepare.<Person>getResult().collect(Collectors.toList());
MatcherAssert.assertThat(people.stream().map(Person::getName).collect(toList()), Matchers.contains("Otavio"));
}
use of jakarta.nosql.mapping.PreparedStatement in project jnosql-diana by eclipse.
the class ColumnReactiveRepositoryProxyTest method shouldExecuteJNoSQLPrepare.
@Test
public void shouldExecuteJNoSQLPrepare() {
PreparedStatement statement = Mockito.mock(PreparedStatement.class);
when(template.prepare(Mockito.anyString())).thenReturn(statement);
final Publisher<Person> publisher = personRepository.findByQuery("Ada");
final CompletionSubscriber<Person, List<Person>> subscriber = ReactiveStreams.<Person>builder().toList().build();
publisher.subscribe(subscriber);
final CompletionStage<List<Person>> completion = subscriber.getCompletion();
AtomicReference<List<Person>> reference = new AtomicReference<>();
completion.thenAccept(reference::set);
final List<Person> people = reference.get();
assertNotNull(people);
verify(statement).bind("id", "Ada");
}
use of jakarta.nosql.mapping.PreparedStatement in project jnosql-diana by eclipse.
the class KeyValueRepositoryProxyTest method shouldFindByQueryWithParameter.
@Test
public void shouldFindByQueryWithParameter() {
User user = new User("12", "Ada", 10);
List<String> keys = Arrays.asList("key", "key2");
PreparedStatement prepare = Mockito.mock(PreparedStatement.class);
when(repository.prepare("get @id", User.class)).thenReturn(prepare);
userRepository.findByQuery("id");
verify(repository).prepare("get @id", User.class);
}
use of jakarta.nosql.mapping.PreparedStatement in project jnosql-diana by eclipse.
the class DocumentRepositoryProxyTest method shouldExecuteJNoSQLPrepare.
@Test
public void shouldExecuteJNoSQLPrepare() {
PreparedStatement statement = Mockito.mock(PreparedStatement.class);
when(template.prepare(Mockito.anyString())).thenReturn(statement);
personRepository.findByQuery("Ada");
verify(statement).bind("id", "Ada");
}
Aggregations