Skip to content

Comments

Test: Replaceing mock server with wiremock#4390

Open
marki1an wants to merge 5 commits intomasterfrom
replaceing-mock-server-with-wire-mock
Open

Test: Replaceing mock server with wiremock#4390
marki1an wants to merge 5 commits intomasterfrom
replaceing-mock-server-with-wire-mock

Conversation

@marki1an
Copy link
Collaborator

🔧 Type of changes

  • new bid adapter
  • bid adapter update
  • new feature
  • new analytics adapter
  • new module
  • module update
  • bugfix
  • documentation
  • configuration
  • dependency update
  • tech debt (test coverage, refactorings, etc.)

✨ What's the context?

What's the context for the changes?

🧠 Rationale behind the change

Why did you choose to make these changes? Were there any trade-offs you had to consider?

🔎 New Bid Adapter Checklist

  • verify email contact works
  • NO fully dynamic hostnames
  • geographic host parameters are NOT required
  • direct use of HTTP is prohibited - implement an existing Bidder interface that will do all the job
  • if the ORTB is just forwarded to the endpoint, use the generic adapter - define the new adapter as the alias of the generic adapter
  • cover an adapter configuration with an integration test

🧪 Test plan

How do you know the changes are safe to ship to production?

🏎 Quality check

  • Are your changes following our code style guidelines?
  • Are there any breaking changes in your code?
  • Does your test coverage exceed 90%?
  • Are there any erroneous console logs, debuggers or leftover code in your changes?

@marki1an marki1an self-assigned this Feb 18, 2026
@marki1an marki1an added work in progress Signals not finished work tests Functional or other tests labels Feb 18, 2026
@marki1an marki1an removed the work in progress Signals not finished work label Feb 19, 2026
@@ -0,0 +1,18 @@
package org.prebid.server.functional.model

enum HttpStatusCode {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use org.apache.http.HttpStatus instead of our own codes

wireMockClient.register(post(urlPathEqualTo(endpoint))
.atPriority(Integer.MAX_VALUE)
.willReturn(aResponse()
.withTransformers("response-template")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can add global-response-templating and remove this from all responses https://wiremock.org/docs/standalone/docker/#building-your-own-image


private static final String rfcEndpoint= "/stored-requests-rfc"
private static final HttpSettings httpSettings = new HttpSettings(networkServiceContainer)
private static final HttpSettings httpSettingsWithRFC = new HttpSettings(networkServiceContainer, rfcEndpoint)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


def cleanupSpec() {
bidder.reset()
prebidCache.reset()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to remove it?

request().withMethod("GET")
.withPath(endpoint)
protected RequestPatternBuilder getRequest(String bidRequestId) {
return null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning null here and in similar methods is a bad practice. We should either refactor this logic or throw UnsupportedOperationException to avoid potential NPEs

Comment on lines +142 to +151
List<Map<String, List<String>>> result = []
requests.each { req ->
Map<String, List<String>> headersMap = [:]
req.headers.all().each { header ->
headersMap[header.key() as String] = header.values()*.toString()
}
result << headersMap
}

result
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can simplify:

    List<Map<String, List<String>>> getRecordedRequestsHeaders(RequestPatternBuilder builder) {
        wireMockClient.find(builder).collect { req ->
            req.headers.all().collectEntries { [it.key(), it.values()*.toString()] }
        }
    }

Comment on lines +61 to +64
RequestPattern getRequest(String bidRequestId, String requestMatchPath) {
postRequestedFor(urlMatching("^$endpoint(\\?.*)?\$"))
.withRequestBody(matchingJsonPath("\$[?(@." + requestMatchPath + " == '" + bidRequestId + "')]"))
.build()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be simplified:

RequestPattern getRequest(String bidRequestId, String requestMatchPath) {
    postRequestedFor(urlMatching("^${endpoint}(\\?.*)?\$"))
        .withRequestBody(matchingJsonPath("\$[?(@.${requestMatchPath} == '${bidRequestId}')]"))
        .build()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not port tests Functional or other tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants