Skip to content

Commit

Permalink
Remove ReferenceServerTests in favor of Sep24Tests.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
lijamie98 committed Nov 8, 2023
1 parent 9d32784 commit 1587ce1
Showing 1 changed file with 1 addition and 80 deletions.
Original file line number Diff line number Diff line change
@@ -1,82 +1,3 @@
package org.stellar.anchor.platform.integrationtest

import io.ktor.http.*
import java.util.UUID
import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.skyscreamer.jsonassert.JSONAssert
import org.stellar.anchor.api.callback.SendEventRequest
import org.stellar.anchor.platform.AbstractIntegrationTests
import org.stellar.anchor.platform.TestConfig
import org.stellar.anchor.platform.gson
import org.stellar.anchor.util.StringHelper.json
import org.stellar.reference.client.AnchorReferenceServerClient

class ReferenceServerTests : AbstractIntegrationTests(TestConfig(testProfileName = "default")) {
@Test
fun `test if the reference server records the events sent by sendEvent() method`() {
val client = AnchorReferenceServerClient(Url("http://localhost:8091"))
val sendEventRequest1 = gson.fromJson(sendEventRequestJson, SendEventRequest::class.java)
val sendEventRequest2 = gson.fromJson(sendEventRequestJson2, SendEventRequest::class.java)
sendEventRequest1.id = UUID.randomUUID().toString()
sendEventRequest2.id = UUID.randomUUID().toString()
runBlocking {
// Send event1
client.sendEvent(sendEventRequest1)
// send event2
client.sendEvent(sendEventRequest2)
// check if these events are recorded
client
.getEvents()
.stream()
.filter { it.id == sendEventRequest1.id }
.findFirst()
.get()
.apply { JSONAssert.assertEquals(json(this), json(sendEventRequest1), true) }
client
.getEvents()
.stream()
.filter { it.id == sendEventRequest2.id }
.findFirst()
.get()
.apply { JSONAssert.assertEquals(json(this), json(sendEventRequest2), true) }
}
}

companion object {
val sendEventRequestJson =
"""
{
"timestamp": "2011-10-05T14:48:00.000Z",
"id": "2a419880-0dde-4821-90cb-f3bfcb671ea3",
"type": "transaction_created",
"payload": {
"transaction": {
"amount_in": {
"amount": "10.0",
"asset": "USDC"
}
}
}
}
"""
.trimIndent()

val sendEventRequestJson2 =
"""
{
"id": "2a419880-0dde-4821-90cb-f3bfcb671ea3",
"timestamp": "2011-10-05T14:48:00.000Z",
"type": "quote_created",
"payload": {
"quote": {
"sell_amount": "10.0",
"buy_amount": "1"
}
}
}
"""
.trimIndent()
}
}
// The test is removed in favor of Sep24Tests.kt

0 comments on commit 1587ce1

Please sign in to comment.