diff options
-rwxr-xr-x | integration-tests/test-sandbox.py | 25 | ||||
-rw-r--r-- | sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt | 11 | ||||
-rw-r--r-- | sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 20 |
3 files changed, 45 insertions, 11 deletions
diff --git a/integration-tests/test-sandbox.py b/integration-tests/test-sandbox.py index 47bcab5a..1671e08d 100755 --- a/integration-tests/test-sandbox.py +++ b/integration-tests/test-sandbox.py @@ -106,17 +106,24 @@ assertResponse( ) # Generate a few payments related to such account. -assertResponse( - post( - "http://localhost:5000/admin/payments", - json=dict( - creditorIban="ES9121000418450200051332", - debitorIban="GB33BUKB20201555555555", - amount="EUR:0.99", - subject="test service" +for i in range(1, 3): + assertResponse( + post( + "http://localhost:5000/admin/payments", + json=dict( + creditorIban="ES9121000418450200051332", + debitorIban="GB33BUKB20201555555555", + amount="EUR:0.99", + subject="test service #{}".format(i) + ) ) ) + +resp = assertResponse( + get("http://localhost:5000/admin/payments") ) +print(resp.text) + sandbox.terminate() -print("Test passed!") +print("\nTest passed!") diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt index 092b0223..eeb75780 100644 --- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt +++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt @@ -19,8 +19,7 @@ package tech.libeufin.sandbox -import io.ktor.http.HttpStatusCode -import java.lang.Exception +import tech.libeufin.util.RawPayment /** * Used to show the list of Ebics hosts that exist @@ -45,6 +44,14 @@ data class EbicsHostCreateRequest( ) /** + * List type that show all the payments existing in the system. + */ +data class PaymentsResponse( + val payments: MutableList<RawPayment> = mutableListOf() +) + + +/** * Used to create AND show one Ebics subscriber in the system. */ data class EbicsSubscriberElement( diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt index f7650e7b..f8c7ec9c 100644 --- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt +++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -60,6 +60,7 @@ import com.fasterxml.jackson.databind.exc.MismatchedInputException import com.fasterxml.jackson.module.kotlin.KotlinModule import com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import io.ktor.http.toHttpDateString import java.time.Instant import java.time.LocalDate import java.time.LocalDateTime @@ -160,6 +161,25 @@ fun main() { get("/") { call.respondText("Hello Sandbox!\n", ContentType.Text.Plain) } + get("/admin/payments") { + val ret = PaymentsResponse() + transaction { + PaymentEntity.all().forEach { + ret.payments.add( + RawPayment( + creditorIban = it.creditorIban, + debitorIban = it.debitorIban, + subject = it.subject, + date = it.date.toHttpDateString(), + amount = it.amount + ) + ) + } + } + call.respond(ret) + return@get + } + /** * Adds a new payment to the book. */ |