use of com.cadenzauk.siesta.model.SalespersonRow 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);
}
use of com.cadenzauk.siesta.model.SalespersonRow in project siesta by cadenzauk.
the class DatabaseIntegrationTestH2 method ormUpdate.
@Test
void ormUpdate() {
Database database = testDatabase(dataSource);
SalespersonRow salespersonRow = aRandomSalesperson();
SalespersonRow updated = SalespersonRow.newBuilder(salespersonRow).numberOfSales(salespersonRow.numberOfSales() + 10).build();
database.insert(salespersonRow);
database.update(updated);
Integer valueInDatabase = database.from(SalespersonRow.class).select(SalespersonRow::numberOfSales).where(SalespersonRow::salespersonId).isEqualTo(salespersonRow.salespersonId()).single();
assertThat(valueInDatabase, is(updated.numberOfSales()));
}
use of com.cadenzauk.siesta.model.SalespersonRow in project siesta by cadenzauk.
the class DatabaseTest method deleteTransaction.
@Test
void deleteTransaction() {
Database database = Database.newBuilder().build();
SalespersonRow salesperson = IntegrationTest.aRandomSalesperson();
database.delete(transaction, salesperson);
verify(transaction).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 updateTransaction.
@Test
void updateTransaction() {
Database database = Database.newBuilder().build();
SalespersonRow salesperson = IntegrationTest.aRandomSalesperson();
database.update(transaction, salesperson);
verify(transaction).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()));
}
Aggregations