use of jakarta.nosql.column.ColumnPreparedStatement in project jnosql-diana by eclipse.
the class DefaultColumnQueryParserTest method shouldReturnErrorSingleResult.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God where age = @age" })
public void shouldReturnErrorSingleResult(String query) {
ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
Mockito.when(manager.select(Mockito.any(ColumnQuery.class))).thenReturn(Stream.of(mock(ColumnEntity.class), mock(ColumnEntity.class)));
ColumnPreparedStatement prepare = parser.prepare(query, manager, ColumnObserverParser.EMPTY);
prepare.bind("age", 12);
assertThrows(NonUniqueResultException.class, () -> prepare.getSingleResult());
}
use of jakarta.nosql.column.ColumnPreparedStatement in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldExecutePrepareStatement.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where age = @age" })
public void shouldExecutePrepareStatement(String query) {
ArgumentCaptor<ColumnDeleteQuery> captor = ArgumentCaptor.forClass(ColumnDeleteQuery.class);
ColumnPreparedStatement prepare = parser.prepare(query, manager, observer);
prepare.bind("age", 12);
prepare.getResult();
Mockito.verify(manager).delete(captor.capture());
ColumnDeleteQuery columnQuery = captor.getValue();
ColumnCondition columnCondition = columnQuery.getCondition().get();
Column column = columnCondition.getColumn();
assertEquals(Condition.EQUALS, columnCondition.getCondition());
assertEquals("age", column.getName());
assertEquals(12, column.get());
}
use of jakarta.nosql.column.ColumnPreparedStatement in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnErrorWhenDontBindParameters.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where age = @age" })
public void shouldReturnErrorWhenDontBindParameters(String query) {
ColumnPreparedStatement prepare = parser.prepare(query, manager, observer);
assertThrows(QueryException.class, prepare::getResult);
}
use of jakarta.nosql.column.ColumnPreparedStatement in project jnosql-diana by eclipse.
the class SelectQueryParserTest method shouldReturnErrorWhenDontBindParameters.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God where age = @age" })
public void shouldReturnErrorWhenDontBindParameters(String query) {
ColumnPreparedStatement prepare = parser.prepare(query, manager, observer);
assertThrows(QueryException.class, prepare::getResult);
}
use of jakarta.nosql.column.ColumnPreparedStatement in project jnosql-diana by eclipse.
the class SelectQueryParserTest method shouldExecutePrepareStatement.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select * from God where age = @age" })
public void shouldExecutePrepareStatement(String query) {
ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
ColumnPreparedStatement prepare = parser.prepare(query, manager, observer);
prepare.bind("age", 12);
prepare.getResult();
Mockito.verify(manager).select(captor.capture());
ColumnQuery columnQuery = captor.getValue();
ColumnCondition columnCondition = columnQuery.getCondition().get();
Column column = columnCondition.getColumn();
assertEquals(Condition.EQUALS, columnCondition.getCondition());
assertEquals("age", column.getName());
assertEquals(12, column.get());
}
Aggregations