use of com.cadenzauk.siesta.model.SalespersonRow in project siesta by cadenzauk.
the class DatabaseTest method update.
@Test
void update() {
Database database = Database.newBuilder().defaultSqlExecutor(sqlExecutor).build();
SalespersonRow salesperson = IntegrationTest.aRandomSalesperson();
database.update(salesperson);
verify(sqlExecutor).update(sqlCaptor.capture(), argCaptor.capture());
assertThat(sqlCaptor.getValue(), is("update SIESTA.SALESPERSON " + "set FIRST_NAME = ?, MIDDLE_NAMES = ?, SURNAME = ?, NUMBER_OF_SALES = ?, COMMISSION = ? " + "where SIESTA.SALESPERSON.SALESPERSON_ID = ?"));
assertThat(argCaptor.getValue(), arrayContaining(salesperson.firstName(), salesperson.middleNames().orElse(null), salesperson.surname(), salesperson.numberOfSales(), salesperson.commission().orElse(null), salesperson.salespersonId()));
}
use of com.cadenzauk.siesta.model.SalespersonRow in project siesta by cadenzauk.
the class DatabaseTest method updateSqlExecutor.
@Test
void updateSqlExecutor() {
Database database = Database.newBuilder().build();
SalespersonRow salesperson = IntegrationTest.aRandomSalesperson();
database.update(sqlExecutor, salesperson);
verify(sqlExecutor).update(sqlCaptor.capture(), argCaptor.capture());
assertThat(sqlCaptor.getValue(), is("update SIESTA.SALESPERSON " + "set FIRST_NAME = ?, MIDDLE_NAMES = ?, SURNAME = ?, NUMBER_OF_SALES = ?, COMMISSION = ? " + "where SIESTA.SALESPERSON.SALESPERSON_ID = ?"));
assertThat(argCaptor.getValue(), arrayContaining(salesperson.firstName(), salesperson.middleNames().orElse(null), salesperson.surname(), salesperson.numberOfSales(), salesperson.commission().orElse(null), salesperson.salespersonId()));
}
use of com.cadenzauk.siesta.model.SalespersonRow in project siesta by cadenzauk.
the class DatabaseTest method delete.
@Test
void delete() {
Database database = Database.newBuilder().defaultSqlExecutor(sqlExecutor).build();
SalespersonRow salesperson = IntegrationTest.aRandomSalesperson();
database.delete(salesperson);
verify(sqlExecutor).update(sqlCaptor.capture(), argCaptor.capture());
assertThat(sqlCaptor.getValue(), is("delete from SIESTA.SALESPERSON " + "where SIESTA.SALESPERSON.SALESPERSON_ID = ?"));
assertThat(argCaptor.getValue(), arrayContaining(salesperson.salespersonId()));
}
use of com.cadenzauk.siesta.model.SalespersonRow in project siesta by cadenzauk.
the class DatabaseTest method deleteSqlExecutor.
@Test
void deleteSqlExecutor() {
Database database = Database.newBuilder().build();
SalespersonRow salesperson = IntegrationTest.aRandomSalesperson();
database.delete(sqlExecutor, salesperson);
verify(sqlExecutor).update(sqlCaptor.capture(), argCaptor.capture());
assertThat(sqlCaptor.getValue(), is("delete from SIESTA.SALESPERSON " + "where SIESTA.SALESPERSON.SALESPERSON_ID = ?"));
assertThat(argCaptor.getValue(), arrayContaining(salesperson.salespersonId()));
}
use of com.cadenzauk.siesta.model.SalespersonRow in project siesta by cadenzauk.
the class DatabaseIntegrationTest method olapWithoutPartitionOrOrder.
@Test
void olapWithoutPartitionOrOrder() {
assumeFalse(dialect.requiresOrderByInRowNumber(), dialect.getClass().getSimpleName() + " does not support row_number() without ORDER BY.");
Database database = testDatabase(dataSource, dialect);
Tuple2<Long, Long> inserted = insertSalespeople(database, 5);
List<Tuple2<Long, Integer>> result = database.from(SalespersonRow.class).select(SalespersonRow::salespersonId).comma(Olap.rowNumber()).where(SalespersonRow::salespersonId).isBetween(inserted.item1()).and(inserted.item2()).orderBy(SalespersonRow::salespersonId).list();
assertThat(result, hasSize(5));
assertThat(result.get(0), is(Tuple.of(inserted.item1(), 1)));
assertThat(result.get(4), is(Tuple.of(inserted.item2(), 5)));
}
Aggregations