@@ -62,6 +62,7 @@ class TargetingSpec extends BaseSpec {
6262 private static final String HB_ENV_AMP = " amp"
6363 private static final Integer MAIN_RANK = 1
6464 private static final Integer SUBORDINATE_RANK = 2
65+ private static final String EMPTY_CPM = " 0.0"
6566
6667 def " PBS should include targeting bidder specific keys when alwaysIncludeDeals is true and deal bid wins" () {
6768 given : " Bid request with alwaysIncludeDeals = true"
@@ -543,6 +544,30 @@ class TargetingSpec extends BaseSpec {
543544 assert targetingKeyMap[" hb_pb" ] == String . format(" %,.2f" , max. setScale(precision, RoundingMode . DOWN ))
544545 }
545546
547+ def " PBS auction shouldn't delete bid and update targeting if price equal zero and dealId present" () {
548+ given : " Default bid request with stored response"
549+ def bidRequest = BidRequest . defaultBidRequest. tap {
550+ ext. prebid. targeting = Targeting . createWithAllValuesSetTo(true )
551+ }
552+
553+ and : " Bid response with zero price"
554+ def bidResponse = BidResponse . getDefaultBidResponse(bidRequest). tap {
555+ seatbid[0 ]. bid[0 ]. price = 0
556+ seatbid[0 ]. bid[0 ]. dealid = PBSUtils . randomString
557+ }
558+
559+ and : " Set bidder response"
560+ bidder. setResponse(bidRequest. id, bidResponse)
561+
562+ when : " PBS processes auction request"
563+ def response = defaultPbsService. sendAuctionRequest(bidRequest)
564+
565+ then : " Response should contain proper targeting hb_pb"
566+ def targetingKeyMap = response. seatbid?. first()?. bid?. first()?. ext?. prebid?. targeting
567+ assert targetingKeyMap[" hb_pb" ] == EMPTY_CPM
568+ assert targetingKeyMap[" hb_pb_generic" ] == EMPTY_CPM
569+ }
570+
546571 def " PBS auction should use default targeting prefix when ext.prebid.targeting.prefix is biggest that twenty" () {
547572 given : " Bid request with long targeting prefix"
548573 def prefix = PBSUtils . getRandomString(30 )
0 commit comments