use of com.cadenzauk.siesta.model.SalesAreaRow in project siesta by cadenzauk.
the class ExceptionIntegrationTest method foreignKeyViolationOnDelete.
@Test
void foreignKeyViolationOnDelete() {
Database database = TestDatabase.testDatabase(dataSource);
SalespersonRow salespersonRow = aRandomSalesperson();
database.insert(salespersonRow);
SalesAreaRow salesArea = SalesAreaRow.newBuilder().salesAreaId(newId()).salesAreaName("Far East").salespersonId(Optional.of(salespersonRow.salespersonId())).build();
database.insert(salesArea);
calling(() -> database.delete(SalespersonRow.class).where(SalespersonRow::salespersonId).isEqualTo(salespersonRow.salespersonId()).execute()).shouldThrow(RuntimeSqlException.class).with(subclass(ReferentialIntegrityException.class)).withMessage(startsWith("Foreign key constraint violated while executing 'delete "));
}
use of com.cadenzauk.siesta.model.SalesAreaRow in project siesta by cadenzauk.
the class ExceptionIntegrationTest method numericOverflowOnUpdate.
@Test
void numericOverflowOnUpdate() {
Database database = TestDatabase.testDatabase(dataSource);
SalesAreaRow salesArea = SalesAreaRow.newBuilder().salesAreaId(newId()).salesAreaName("NZ").build();
database.insert(salesArea);
calling(() -> database.update(SalesAreaRow.class).set(SalesAreaRow::salesCount).to(Integer.MAX_VALUE + 1L).where(SalesAreaRow::salesAreaId).isEqualTo(salesArea.salesAreaId()).execute()).shouldThrow(RuntimeSqlException.class).with(subclass(InvalidValueException.class)).withMessage(startsWith("Incorrect data value for data type while executing 'update "));
}
use of com.cadenzauk.siesta.model.SalesAreaRow in project siesta by cadenzauk.
the class ExceptionIntegrationTest method foreignKeyViolationOnInsert.
@Test
void foreignKeyViolationOnInsert() {
Database database = TestDatabase.testDatabase(dataSource);
SalesAreaRow salesArea = SalesAreaRow.newBuilder().salesAreaId(newId()).salesAreaName("Far East").salespersonId(Optional.of(newId())).build();
calling(() -> database.insert(salesArea)).shouldThrow(RuntimeSqlException.class).with(subclass(ReferentialIntegrityException.class)).withMessage(startsWith("Foreign key constraint violated while executing 'insert into "));
}
use of com.cadenzauk.siesta.model.SalesAreaRow in project siesta by cadenzauk.
the class ExceptionIntegrationTest method nullNotAllowedOnUpdate.
@Test
void nullNotAllowedOnUpdate() {
Database database = TestDatabase.testDatabase(dataSource);
SalesAreaRow salesArea = SalesAreaRow.newBuilder().salesAreaId(newId()).salesAreaName("Oceania").build();
database.insert(salesArea);
calling(() -> database.update(SalesAreaRow.class).set(SalesAreaRow::salesAreaName).toNull().where(SalesAreaRow::salesAreaId).isEqualTo(salesArea.salesAreaId()).execute()).shouldThrow(RuntimeSqlException.class).with(subclass(IllegalNullException.class)).withMessage(startsWith("Null value is not allowed while executing 'update "));
}
use of com.cadenzauk.siesta.model.SalesAreaRow in project siesta by cadenzauk.
the class ExceptionIntegrationTest method foreignKeyViolationOnUpdate.
@Test
void foreignKeyViolationOnUpdate() {
Database database = TestDatabase.testDatabase(dataSource);
SalespersonRow salespersonRow = aRandomSalesperson();
database.insert(salespersonRow);
SalesAreaRow salesArea = SalesAreaRow.newBuilder().salesAreaId(newId()).salesAreaName("Far East").salespersonId(Optional.of(salespersonRow.salespersonId())).build();
database.insert(salesArea);
calling(() -> database.update(SalesAreaRow.class).set(SalesAreaRow::salespersonId).to(newId()).where(SalesAreaRow::salesAreaId).isEqualTo(salesArea.salesAreaId()).execute()).shouldThrow(RuntimeSqlException.class).with(subclass(ReferentialIntegrityException.class)).withMessage(startsWith("Foreign key constraint violated while executing 'update "));
}
Aggregations