Skip to content

Commit

Permalink
create dedicated request/response stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
sergseven committed Dec 27, 2024
1 parent c97618b commit 1819cc5
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 49 deletions.
8 changes: 4 additions & 4 deletions src/test/java/org/prebid/server/it/OpenxTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ public void openrtb2AuctionShouldRespondWithBidsFromOpenx() throws IOException,
public void openrtb2AuctionWithNativeShouldRespondWithBidsFromOpenx() throws IOException, JSONException {
// given
WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/openx-exchange"))
.withRequestBody(equalToJson(jsonFrom("openrtb2/openx/test-native-request.json")))
.willReturn(aResponse().withBody(jsonFrom("openrtb2/openx/test-native-response.json"))));
.withRequestBody(equalToJson(jsonFrom("openrtb2/openx/test-openx-native-request.json")))
.willReturn(aResponse().withBody(jsonFrom("openrtb2/openx/test-openx-native-response.json"))));

// when
final Response response = responseFor("openrtb2/openx/test-native-request.json",
final Response response = responseFor("openrtb2/openx/test-auction-openx-native-request.json",
Endpoint.openrtb2_auction);

// then
assertJsonEquals("openrtb2/openx/test-native-response.json", response, singletonList("openx"));
assertJsonEquals("openrtb2/openx/test-auction-openx-native-response.json", response, singletonList("openx"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"id": "request_id",
"imp": [
{
"id": "imp_id",
"native": {
"request": "{\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":25}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":200,\"hmin\":200}}]}"
},
"ext": {
"openx": {
"unit": "539439964",
"delDomain": "se-demo-d.openx.net",
"customFloor": "0.5",
"customParams": {
"foo": "bar",
"multifoo": [
"bar1",
"bar2"
]
}
}
}
}
],
"tmax": 5000,
"regs": {
"ext": {
"gdpr": 0
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"id": "request_id",
"seatbid": [
{
"bid": [
{
"id": "bid_id",
"impid": "imp_id",
"exp": 300,
"price": 5.78,
"adm": "{\"native\":{\"ver\":\"1.2\",\"assets\":[{\"id\":1,\"title\":{\"text\":\"Native Ad Title\"}},{\"id\":2,\"img\":{\"url\":\"https://example.com/image.jpg\",\"w\":200,\"h\":200}}],\"link\":{\"url\":\"https://example.com/click\"},\"imptrackers\":[\"https://example.com/impression\"]}}",
"crid": "crid00",
"w": 300,
"h": 250,
"ext": {
"prebid": {
"type": "native"
},
"origbidcpm": 5.78,
"origbidcur": "USD"
}
}
],
"seat": "openx",
"group": 0
}
],
"cur": "USD",
"ext": {
"responsetimemillis": {
"openx": "{{ openx.response_time_ms }}"
},
"prebid": {
"auctiontimestamp": 0
},
"tmaxrequest": 5000
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"id": "request_id",
"imp": [
{
"id": "imp_id",
"secure": 1,
"native": {
"request": "{\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":25}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":200,\"hmin\":200}}]}"
},
"tagid": "539439964",
"bidfloor": 0.5,
"ext": {
"customParams": {
"foo": "bar",
"multifoo": [
"bar1",
"bar2"
]
},
"tid" : "${json-unit.any-string}"
}
}
],
"source": {
"tid": "${json-unit.any-string}"
},
"site": {
"domain": "www.example.com",
"page": "http://www.example.com",
"publisher": {
"domain": "example.com"
},
"ext": {
"amp": 0
}
},
"device": {
"ua": "userAgent",
"ip": "193.168.244.1"
},
"at": 1,
"tmax": "${json-unit.any-number}",
"cur": [
"USD"
],
"regs": {
"gdpr": 0
},
"ext": {
"delDomain": "se-demo-d.openx.net",
"bc": "hb_pbs_1.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
{
"id": "bidRequestId",
"id": "request_id",
"seatbid": [
{
"bid": [
{
"id": "bidId1",
"impid": "impId1",
"price": 1.5,
"id": "bid_id",
"impid": "imp_id",
"price": 5.78,
"adm": "{\"native\":{\"ver\":\"1.2\",\"assets\":[{\"id\":1,\"title\":{\"text\":\"Native Ad Title\"}},{\"id\":2,\"img\":{\"url\":\"https://example.com/image.jpg\",\"w\":200,\"h\":200}}],\"link\":{\"url\":\"https://example.com/click\"},\"imptrackers\":[\"https://example.com/impression\"]}}",
"adomain": ["example.com"],
"iurl": "https://example.com/image.jpg",
"cid": "campaignId1",
"crid": "creativeId1",
"dealid": "dealId1",
"w": 200,
"h": 200
"crid": "crid00",
"w": 300,
"h": 250
}
]
],
"seat": "seatId00",
"group": 0
}
],
"cur": "USD"
]
}

0 comments on commit 1819cc5

Please sign in to comment.