Conversation
…rest assured with Ktor
Co-authored-by: mhupalo <mhupalo@rubiconproject.com>
f3f41ed to
1e1b7f4
Compare
| val xmlPayloadTransfer = PayloadTransfer.getDefaultXmlPayloadTransfer() | ||
| xmlPayloadTransfer.key = uuid |
There was a problem hiding this comment.
What about to use apply? Also, please, check for similar occurences.
val xmlPayloadTransfer = PayloadTransfer.getDefaultXmlPayloadTransfer().apply { key = uuid }
| val uuid = getRandomUuid() | ||
| val xmlPayloadTransfer = PayloadTransfer.getDefaultXmlPayloadTransfer() | ||
| xmlPayloadTransfer.key = uuid | ||
| val requestObject = RequestObject(listOf(xmlPayloadTransfer)) |
There was a problem hiding this comment.
What about to add static constructor method to RequestObject which accept vararg of PayloadTransfer?
fun of(vararg puts: PayloadTransfer): RequestObject =
RequestObject(puts = puts.asList())
Than you can don't use every time listOf(...)
| fun getPrebidCacheApi(config: Map<String, String> = prebidCacheConfig.getBaseRedisConfig("false")): PrebidCacheApi { | ||
| val prebidCacheContainer = | ||
| ContainerDependencies.prebidCacheContainerPool.getPrebidCacheContainer(config) | ||
| return PrebidCacheApi(prebidCacheContainer.host, prebidCacheContainer.getHostPort()) | ||
| } |
There was a problem hiding this comment.
What about to replace method body with this approach?
ContainerDependencies.prebidCacheContainerPool.getPrebidCacheContainer(config)
.let { container -> PrebidCacheApi(container.host, container.getHostPort()) }
| webCacheContainerClient.getProxyCacheHostRecordedRequestCount() shouldBe initialProxyCacheHostRequestCount + 1 | ||
|
|
||
| val proxyCacheHostRequest = webCacheContainerClient.getProxyCacheHostRecordedRequests()!!.last() | ||
| proxyCacheHostRequest.queryStringParameters?.containsEntry("uuid", requestUuid) |
There was a problem hiding this comment.
Do there need to be some assertion?
| secondaryCacheRecordedRequests?.size shouldBe 1 | ||
|
|
||
| // and: Request contained secondaryCache=yes query parameter | ||
| secondaryCacheRecordedRequests!!.first().queryStringParameters?.containsEntry("secondaryCache", "yes") |
There was a problem hiding this comment.
Do there need to be some assertion?
| var type: MediaType, | ||
| var key: String? = null, | ||
| var value: String, |
There was a problem hiding this comment.
Fields with default values are usually listed after other fields.
|
|
||
| companion object { | ||
| private val MAX_CONTAINER_COUNT: Int = (System.getProperty("max.containers.count") ?: "3").toInt() | ||
| private val prebidCacheContainerMap: MutableMap<Map<String, String>, PrebidCacheContainer> = mutableMapOf() |
There was a problem hiding this comment.
Does this property need to be static?
| private const val FIXED_EXPOSED_APPLICATION_PORT = 49100 | ||
| private const val FIXED_EXPOSED_DEBUG_PORT = 49101 | ||
|
|
||
| private val USE_FIXED_PORTS = (System.getProperty("useFixedContainerPorts") ?: "false").toBoolean() |
There was a problem hiding this comment.
System.getProperty("useFixedContainerPorts")?.toBoolean() ?: false
| fun getRandomString(length: Int = 16): String { | ||
| val allowedChars = ('A'..'Z') + ('a'..'z') + ('0'..'9') | ||
| return (1..length).map { allowedChars.random() } | ||
| .joinToString("") | ||
| } |
There was a problem hiding this comment.
What about this approach?
List(length) { ALLOWED_CHARS.random() }.joinToString("")
Created test framework to cover existing functionality of Prebid Cache with tests written in Kotlin