use of com.cadenzauk.siesta.grammar.select.InWhereExpectingAnd in project siesta by cadenzauk.
the class ExpressionBuilderTest method testExpression.
@ParameterizedTest
@MethodSource("argsForTestExpression")
void testExpression(BiFunction<ExpressionBuilder<String, InWhereExpectingAnd<String>>, Alias<SalespersonRow>, InWhereExpectingAnd<String>> method, String expectedSql, Object[] expectedArgs) {
MockitoAnnotations.initMocks(this);
Database database = testDatabase(new AnsiDialect());
Alias<SalespersonRow> alias = database.table(SalespersonRow.class).as("s");
ExpressionBuilder<String, InWhereExpectingAnd<String>> select = database.from(alias).select(SalespersonRow::firstName, "name").where(SalespersonRow::firstName);
method.apply(select, alias).list(transaction);
verify(transaction).query(sql.capture(), args.capture(), any());
assertThat(sql.getValue(), is("select s.FIRST_NAME as name from SIESTA.SALESPERSON s where s.FIRST_NAME " + expectedSql));
assertThat(args.getValue(), is(expectedArgs));
}
use of com.cadenzauk.siesta.grammar.select.InWhereExpectingAnd in project siesta by cadenzauk.
the class BetweenBuilderTest method and.
@ParameterizedTest
@MethodSource("argsForAnd")
void and(BiFunction<BetweenBuilder<String, InWhereExpectingAnd<String>>, Alias<SalespersonRow>, InWhereExpectingAnd<String>> method, String expectedSql, Object[] expectedArgs) {
MockitoAnnotations.initMocks(this);
Database database = testDatabase(new AnsiDialect());
Alias<SalespersonRow> alias = database.table(SalespersonRow.class).as("s");
BetweenBuilder<String, InWhereExpectingAnd<String>> between = database.from(alias).select(SalespersonRow::firstName, "name").where(SalespersonRow::firstName).isBetween(SalespersonRow::middleNames);
method.apply(between, alias).list(transaction);
verify(transaction).query(sql.capture(), args.capture(), rowMapper.capture());
assertThat(sql.getValue(), is("select s.FIRST_NAME as name from SIESTA.SALESPERSON s where s.FIRST_NAME between s.MIDDLE_NAMES and " + expectedSql));
assertThat(args.getValue(), is(expectedArgs));
}
use of com.cadenzauk.siesta.grammar.select.InWhereExpectingAnd in project siesta by cadenzauk.
the class ExpressionBuilderTest method isNotInWithNoValuesShouldThrow.
@Test
void isNotInWithNoValuesShouldThrow() {
Database database = testDatabase(new AnsiDialect());
ExpressionBuilder<String, InWhereExpectingAnd<SalespersonRow>> select = database.from(SalespersonRow.class).where(SalespersonRow::firstName);
// noinspection Convert2MethodRef
calling(() -> select.isNotIn(new String[0])).shouldThrow(IllegalArgumentException.class);
}
use of com.cadenzauk.siesta.grammar.select.InWhereExpectingAnd in project siesta by cadenzauk.
the class ExpressionBuilderTest method isInWithNoValuesShouldThrow.
@Test
void isInWithNoValuesShouldThrow() {
Database database = testDatabase(new AnsiDialect());
ExpressionBuilder<String, InWhereExpectingAnd<SalespersonRow>> select = database.from(SalespersonRow.class).where(SalespersonRow::firstName);
// noinspection Convert2MethodRef
calling(() -> select.isIn(new String[0])).shouldThrow(IllegalArgumentException.class);
}
Aggregations