From 9252b2fee531dd32e402d5312223bace11aae82d Mon Sep 17 00:00:00 2001 From: Md Asif Date: Sat, 28 Sep 2024 17:57:20 +0530 Subject: [PATCH] Removed tests. included watch patterns for ktor auto reloading. Returned proper responses upon transaction failures. --- build.gradle.kts | 3 --- .../net/ipksindia/NeftRequestProcessor.kt | 6 +++--- src/main/resources/application.conf | 1 + .../kotlin/net/ipksindia/ApplicationTest.kt | 21 ------------------- 4 files changed, 4 insertions(+), 27 deletions(-) delete mode 100644 src/test/kotlin/net/ipksindia/ApplicationTest.kt diff --git a/build.gradle.kts b/build.gradle.kts index 1680a70..8a568e1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,3 @@ -val kotlin_version: String by project val logback_version: String by project plugins { @@ -33,6 +32,4 @@ dependencies { implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1") implementation("org.slf4j:slf4j-api:2.0.16") implementation("com.zaxxer:HikariCP:6.0.0") - testImplementation("io.ktor:ktor-server-test-host-jvm") - testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version") } diff --git a/src/main/kotlin/net/ipksindia/NeftRequestProcessor.kt b/src/main/kotlin/net/ipksindia/NeftRequestProcessor.kt index 4dd6136..133cfe2 100644 --- a/src/main/kotlin/net/ipksindia/NeftRequestProcessor.kt +++ b/src/main/kotlin/net/ipksindia/NeftRequestProcessor.kt @@ -32,7 +32,7 @@ class NeftRequestProcessor { if (!isDCCBCodeMigrated(dccbCode)) { logDCCBCodeNotMigrated(transactionNumber) - return OutwardNeftResponse(0, "dccb code not migrated", null, null) + return OutwardNeftResponse(0, "DCCB NOT MIGRATED", null, null) } val teller = TellerDao().getTeller(dccbCode, branchCode) @@ -42,7 +42,7 @@ class NeftRequestProcessor { executeAndProcessTransaction(transactionNumber, transactionRequest, transactionPair) } catch (e: Exception) { logger.error("TXN: #{} FAILED REASON: {}", transactionNumber, e.toString()) - OutwardNeftResponse(0, e.message ?: "", null, null) + OutwardNeftResponse(0, "ERROR OCCURRED DURING PROCESSING", null, null) } } @@ -87,7 +87,7 @@ class NeftRequestProcessor { OutwardNeftResponse(1, "transaction successful", transferQueueNumber, neftQueueNumber) } else { logTransactionFailure(transactionNumber, transferResponse, neftResponse) - OutwardNeftResponse(0, "transaction failed", null, null) + OutwardNeftResponse(0, "TRANSACTION FAILED", null, null) } } diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 2fa9e3e..96cbefe 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -2,6 +2,7 @@ ktor { environment = ${KTOR_ENV} deployment { port = 8083 + watch = [ classes ] } application { modules = [ net.ipksindia.ApplicationKt.module ] diff --git a/src/test/kotlin/net/ipksindia/ApplicationTest.kt b/src/test/kotlin/net/ipksindia/ApplicationTest.kt deleted file mode 100644 index 3d897a0..0000000 --- a/src/test/kotlin/net/ipksindia/ApplicationTest.kt +++ /dev/null @@ -1,21 +0,0 @@ -package net.ipksindia - -import io.ktor.client.request.* -import io.ktor.client.statement.* -import io.ktor.http.* -import io.ktor.server.testing.* -import kotlin.test.* -import net.ipksindia.plugins.* - -class ApplicationTest { - @Test - fun testRoot() = testApplication { - application { - configureRouting() - } - client.get("/").apply { - assertEquals(HttpStatusCode.OK, status) - assertEquals("Hello World!", bodyAsText()) - } - } -}