use of org.junit.jupiter.params.ParameterizedTest in project siesta by cadenzauk.
the class ExceptionIntegrationTest method columnNameIncorrect.
@ParameterizedTest
@MethodSource("columnNames")
<T> void columnNameIncorrect(Class<T> table, Function1<T, String> column) {
Database database = TestDatabase.testDatabase(dataSource);
calling(() -> database.from(table).select(column).list()).shouldThrow(RuntimeSqlException.class).with(subclass(SqlSyntaxException.class));
}
use of org.junit.jupiter.params.ParameterizedTest in project siesta by cadenzauk.
the class OlapFunctionTest method addPartitionByAndParitionBy.
@ParameterizedTest(name = "{index}: {1}")
@MethodSource("parametersForRowNumber")
void addPartitionByAndParitionBy(BiFunction<InOlapExpectingPartitionBy<Integer>, Alias<SalespersonRow>, TypedExpression<Integer>> f, String expected, Object[] expectedArgs) {
Database database = testDatabase(new AnsiDialect());
Alias<SalespersonRow> s = database.table(SalespersonRow.class).as("s");
database.from(s).select(f.apply(Olap.rowNumber(), s)).list(transaction);
verify(transaction).query(sql.capture(), args.capture(), any());
assertThat(sql.getValue(), is("select row_number() over (" + expected + ") as row_number_1 " + "from SIESTA.SALESPERSON s"));
assertThat(args.getValue(), is(expectedArgs));
}
use of org.junit.jupiter.params.ParameterizedTest in project siesta by cadenzauk.
the class OlapTest method olapFunction.
@ParameterizedTest(name = "{index}: {1}")
@MethodSource("parametersForOlapTest")
void olapFunction(Function<Alias<SalespersonRow>, InOlapExpectingPartitionBy<?>> f, String expectedSql) {
Database database = testDatabase(new AnsiDialect());
Alias<SalespersonRow> s = database.table(SalespersonRow.class).as("s");
Scope scope = new Scope(database, s);
InOlapExpectingPartitionBy<?> result = f.apply(s);
assertThat(result.sql(scope), is(expectedSql));
assertThat(result.precedence(), is(Precedence.UNARY));
}
use of org.junit.jupiter.params.ParameterizedTest in project siesta by cadenzauk.
the class ExpectingJoinTest method testJoin.
@ParameterizedTest
@MethodSource("argsForJoin")
void testJoin(BiFunction<ExpectingJoin1<SalespersonRow>, Alias<SalespersonRow>[], ExpectingSelect<?>> method, String expectedSql) {
MockitoAnnotations.initMocks(this);
Database database = testDatabase(new AnsiDialect());
@SuppressWarnings("unchecked") Alias<SalespersonRow>[] alias = toArray(database.table(SalespersonRow.class).as("s1"), database.table(SalespersonRow.class).as("s2"), database.table(SalespersonRow.class).as("s3"), database.table(SalespersonRow.class).as("s4"), database.table(SalespersonRow.class).as("s5"), database.table(SalespersonRow.class).as("s6"), database.table(SalespersonRow.class).as("s7"), database.table(SalespersonRow.class).as("s8"), database.table(SalespersonRow.class).as("s9"));
method.apply(database.from(alias[0]), alias).select(alias[0], SalespersonRow::firstName, "name").list(transaction);
verify(transaction).query(sql.capture(), args.capture(), rowMapper.capture());
assertThat(sql.getValue(), is("select s1.FIRST_NAME as name from SIESTA.SALESPERSON s1 " + expectedSql));
assertThat(args.getValue(), arrayWithSize(0));
}
use of org.junit.jupiter.params.ParameterizedTest in project siesta by cadenzauk.
the class ExpectingSelectTest method testSelect.
@ParameterizedTest
@MethodSource("argsForSelect")
void testSelect(BiFunction<ExpectingSelect<SalespersonRow>, Alias<SalespersonRow>, Select<?>> method, String expectedSql) {
MockitoAnnotations.initMocks(this);
Database database = testDatabase(new AnsiDialect());
Alias<SalespersonRow> alias = database.table(SalespersonRow.class).as("s");
method.apply(database.from(alias), alias).list(transaction);
verify(transaction).query(sql.capture(), args.capture(), rowMapper.capture());
assertThat(sql.getValue(), is("select " + expectedSql + " from SIESTA.SALESPERSON s"));
assertThat(args.getValue(), arrayWithSize(0));
}
Aggregations