From 83ffb319c3522ddd3fd6a082701890f8e33583c6 Mon Sep 17 00:00:00 2001 From: Tommi Leinamo Date: Thu, 14 Dec 2023 09:21:13 +0200 Subject: [PATCH] Refactor to improve code style These were accidentally left out from a previous PR, where the relevant commit was. --- .../util/TransactionSystemExtensionsTest.kt | 5 ++--- .../service/CombineTimetablesServiceTest.kt | 18 +++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/test/kotlin/fi/hsl/jore4/timetables/api/util/TransactionSystemExtensionsTest.kt b/src/test/kotlin/fi/hsl/jore4/timetables/api/util/TransactionSystemExtensionsTest.kt index 6af7763..8a714b6 100644 --- a/src/test/kotlin/fi/hsl/jore4/timetables/api/util/TransactionSystemExtensionsTest.kt +++ b/src/test/kotlin/fi/hsl/jore4/timetables/api/util/TransactionSystemExtensionsTest.kt @@ -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`() { diff --git a/src/test/kotlin/fi/hsl/jore4/timetables/service/CombineTimetablesServiceTest.kt b/src/test/kotlin/fi/hsl/jore4/timetables/service/CombineTimetablesServiceTest.kt index 6c4a38f..6c9b7db 100644 --- a/src/test/kotlin/fi/hsl/jore4/timetables/service/CombineTimetablesServiceTest.kt +++ b/src/test/kotlin/fi/hsl/jore4/timetables/service/CombineTimetablesServiceTest.kt @@ -352,20 +352,20 @@ class CombineTimetablesServiceTest @Autowired constructor( timetablesDataInserterRunner.truncateAndInsertDataset(testData.toJSONString()) val stagingFrameId = UUID.fromString("e8d07c0d-575f-4cbe-bddb-ead5b2943638") - val exception = assertFailsWith { + assertFailsWith { 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()") } }