Search in sources :

Example 51 with ParameterizedTest

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));
}
Also used : RuntimeSqlException(com.cadenzauk.core.sql.RuntimeSqlException) SqlSyntaxException(com.cadenzauk.core.sql.exception.SqlSyntaxException) TestDatabase(com.cadenzauk.siesta.model.TestDatabase) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 52 with ParameterizedTest

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));
}
Also used : AnsiDialect(com.cadenzauk.siesta.dialect.AnsiDialect) TestDatabase.testDatabase(com.cadenzauk.siesta.model.TestDatabase.testDatabase) Database(com.cadenzauk.siesta.Database) SalespersonRow(com.cadenzauk.siesta.model.SalespersonRow) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 53 with ParameterizedTest

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));
}
Also used : AnsiDialect(com.cadenzauk.siesta.dialect.AnsiDialect) Scope(com.cadenzauk.siesta.Scope) TestDatabase.testDatabase(com.cadenzauk.siesta.model.TestDatabase.testDatabase) Database(com.cadenzauk.siesta.Database) SalespersonRow(com.cadenzauk.siesta.model.SalespersonRow) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 54 with ParameterizedTest

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));
}
Also used : AnsiDialect(com.cadenzauk.siesta.dialect.AnsiDialect) Alias(com.cadenzauk.siesta.Alias) TestDatabase.testDatabase(com.cadenzauk.siesta.model.TestDatabase.testDatabase) Database(com.cadenzauk.siesta.Database) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 55 with ParameterizedTest

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));
}
Also used : AnsiDialect(com.cadenzauk.siesta.dialect.AnsiDialect) TestDatabase.testDatabase(com.cadenzauk.siesta.model.TestDatabase.testDatabase) Database(com.cadenzauk.siesta.Database) SalespersonRow(com.cadenzauk.siesta.model.SalespersonRow) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2045 MethodSource (org.junit.jupiter.params.provider.MethodSource)1116 EnumSource (org.junit.jupiter.params.provider.EnumSource)325 ValueSource (org.junit.jupiter.params.provider.ValueSource)302 ArgumentsSource (org.junit.jupiter.params.provider.ArgumentsSource)181 Transaction (org.neo4j.graphdb.Transaction)117 CsvSource (org.junit.jupiter.params.provider.CsvSource)113 ArrayList (java.util.ArrayList)112 ByteBuffer (java.nio.ByteBuffer)81 List (java.util.List)81 Path (java.nio.file.Path)75 Test (org.junit.jupiter.api.Test)74 InterruptAfter (io.aeron.test.InterruptAfter)72 IOException (java.io.IOException)72 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)67 TimeUnit (java.util.concurrent.TimeUnit)65 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)62 CountDownLatch (java.util.concurrent.CountDownLatch)61 SelfSignedCertificate (io.netty.handler.ssl.util.SelfSignedCertificate)60 Stream (java.util.stream.Stream)59