diff --git a/src/test/java/org/prebid/server/auction/ExchangeServiceTest.java b/src/test/java/org/prebid/server/auction/ExchangeServiceTest.java index 97427d15cab..90453e5d872 100644 --- a/src/test/java/org/prebid/server/auction/ExchangeServiceTest.java +++ b/src/test/java/org/prebid/server/auction/ExchangeServiceTest.java @@ -1192,13 +1192,47 @@ public void shouldCleanImpExtContextDataWhenFirstPartyDataNotPermittedForBidder( exchangeService.holdAuction(givenRequestContext(bidRequest)); // then - final BidRequest capturedRequestExt = captureBidRequest(); - assertThat(capturedRequestExt.getImp()) + final BidRequest capturedRequest = captureBidRequest(); + assertThat(capturedRequest.getImp()) .extracting(Imp::getExt) .extracting(impExtNode -> impExtNode.get("context")) .containsOnly(mapper.createObjectNode().put("otherField", "value")); } + @Test + public void shouldDeepCopyImpExtContextToEachImpressionAndNotRemoveDataForAllWhenDeprecatedOnlyOneBidder() { + // given + final ObjectNode impExt = mapper.createObjectNode().put("someBidder", 1).put("deprecatedBidder", 2) + .set("context", mapper.createObjectNode().put("data", "data").put("otherField", "value")); + final BidRequest bidRequest = givenBidRequest(singletonList(Imp.builder() + .id("impId") + .banner(Banner.builder() + .format(singletonList(Format.builder().w(400).h(300).build())) + .build()).ext(impExt).build()), + builder -> builder.ext(ExtRequest.of(ExtRequestPrebid.builder() + .data(ExtRequestPrebidData.of(singletonList("someBidder"))) + .build()))); + given(httpBidderRequester.requestBids(any(), any(), any(), anyBoolean())) + .willReturn(Future.succeededFuture(givenSeatBid(singletonList( + givenBid(Bid.builder().price(TEN).build()))))); + + // when + exchangeService.holdAuction(givenRequestContext(bidRequest)); + + // then + final ArgumentCaptor bidRequestCaptor = ArgumentCaptor.forClass(BidRequest.class); + verify(httpBidderRequester, times(2)).requestBids(any(), bidRequestCaptor.capture(), any(), anyBoolean()); + assertThat(bidRequestCaptor.getAllValues()) + .flatExtracting(BidRequest::getImp) + .extracting(Imp::getExt) + .extracting(impExtNode -> impExtNode.get("context")) + .containsOnly( + // data erased for deprecatedBidder + mapper.createObjectNode().put("otherField", "value"), + // data present for someBidder + mapper.createObjectNode().put("data", "data").put("otherField", "value")); + } + @Test public void shouldSetUserBuyerIdsFromUserExtPrebidAndClearPrebidBuyerIdsAfterwards() { // given @@ -1241,8 +1275,8 @@ public void shouldCleanRequestExtPrebidData() { exchangeService.holdAuction(givenRequestContext(bidRequest)); // then - final ExtRequest capturedRequestExt = captureBidRequest().getExt(); - assertThat(capturedRequestExt).isEqualTo(ExtRequest.of(ExtRequestPrebid.builder() + final ExtRequest capturedRequest = captureBidRequest().getExt(); + assertThat(capturedRequest).isEqualTo(ExtRequest.of(ExtRequestPrebid.builder() .aliases(singletonMap("someBidder", "alias_should_stay")) .auctiontimestamp(1000L) .build()));