use of com.cadenzauk.siesta.model.SalesAreaRow in project siesta by cadenzauk.
the class ExceptionIntegrationTest method numericOverflowOnInsert.
@Test
void numericOverflowOnInsert() {
Database database = TestDatabase.testDatabase(dataSource);
SalesAreaRow salesArea = SalesAreaRow.newBuilder().salesAreaId(newId()).salesAreaName("NZ").salesCount(Optional.of(Integer.MAX_VALUE + 1L)).build();
calling(() -> database.insert(salesArea)).shouldThrow(RuntimeSqlException.class).with(subclass(InvalidValueException.class)).withMessage(startsWith("Incorrect data value for data type while executing 'insert into "));
}
use of com.cadenzauk.siesta.model.SalesAreaRow in project siesta by cadenzauk.
the class ExceptionIntegrationTest method lockTimeoutOnInsert.
@Test
void lockTimeoutOnInsert() {
assumeTrue(dialect.supportsLockTimeout(), "Database does not support lock timeouts.");
Database database = TestDatabase.testDatabase(dataSource);
SalesAreaRow salesArea = SalesAreaRow.newBuilder().salesAreaId(newId()).salesAreaName("NZ").build();
try (CompositeAutoCloseable closer = new CompositeAutoCloseable()) {
Transaction transaction1 = closer.add(database.beginTransaction());
database.insert(transaction1, salesArea);
Transaction transaction2 = closer.add(database.beginTransaction());
closer.add(database.withLockTimeout(transaction2, 0, TimeUnit.MILLISECONDS));
calling(() -> database.insert(transaction2, salesArea)).shouldThrow(RuntimeSqlException.class).with(subclass(LockingException.class)).withMessage(startsWith("Locking failure while executing 'insert into"));
transaction2.rollback();
}
}
Aggregations