Skip to content

Commit

Permalink
Refactor to improve code style
Browse files Browse the repository at this point in the history
These were accidentally left out from a previous PR,
where the relevant commit was.
  • Loading branch information
Leitsi committed Dec 14, 2023
1 parent 4529229 commit 83ffb31
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import kotlin.test.assertEquals

class TransactionSystemExtensionsTest {

private fun createTransactionSystemExceptionWithCause(message: String): TransactionSystemException {
return TransactionSystemException("test exception", Exception(message))
}
private fun createTransactionSystemExceptionWithCause(message: String) =
TransactionSystemException("test exception", Exception(message))

@Test
fun `resolves PassingTimeStopPointMatchingOrderError`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,20 +352,20 @@ class CombineTimetablesServiceTest @Autowired constructor(
timetablesDataInserterRunner.truncateAndInsertDataset(testData.toJSONString())

val stagingFrameId = UUID.fromString("e8d07c0d-575f-4cbe-bddb-ead5b2943638")
val exception = assertFailsWith<TransactionSystemException> {
assertFailsWith<TransactionSystemException> {
combineTimetablesService.combineTimetables(
listOf(stagingFrameId),
TimetablesPriority.STANDARD
)
}.also { exception ->
// Check that the error messages are somewhat in the format we expect. TransactionSystemExtensions depends on these.
assertEquals(exception.message, "JDBC commit failed")
val causeMessage = exception?.cause?.message
assertNotNull(causeMessage)
assertContains(causeMessage, "ERROR: conflicting schedules detected: vehicle schedule frame")
assertContains(causeMessage, "Where: PL/pgSQL function vehicle_schedule.validate_queued_schedules_uniqueness()")
assertContains(causeMessage, "SQL statement \"SELECT vehicle_schedule.validate_queued_schedules_uniqueness()")
}

// Check that the error messages are somewhat in the format we expect. TransactionSystemExtensions depends on these.
assertEquals(exception.message, "JDBC commit failed")
val causeMessage = exception?.cause?.message
assertNotNull(causeMessage)
assertContains(causeMessage, "ERROR: conflicting schedules detected: vehicle schedule frame")
assertContains(causeMessage, "Where: PL/pgSQL function vehicle_schedule.validate_queued_schedules_uniqueness()")
assertContains(causeMessage, "SQL statement \"SELECT vehicle_schedule.validate_queued_schedules_uniqueness()")
}
}

Expand Down

0 comments on commit 83ffb31

Please sign in to comment.