Skip to content

Commit

Permalink
Remove FacebookNative (#1691)
Browse files Browse the repository at this point in the history
  • Loading branch information
yevhenii-viktorov authored and marki1an committed Feb 1, 2022
1 parent 2e8061a commit 0e47f1b
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 31 deletions.
6 changes: 2 additions & 4 deletions src/main/java/com/iab/openrtb/request/Native.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.iab.openrtb.request;

import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.util.List;

Expand All @@ -27,8 +26,7 @@
* the offered types.
*/
@Data
@SuperBuilder(toBuilder = true)
@NoArgsConstructor
@Builder(toBuilder = true)
public class Native {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.prebid.server.bidder.Bidder;
import org.prebid.server.bidder.facebook.proto.FacebookAdMarkup;
import org.prebid.server.bidder.facebook.proto.FacebookExt;
import org.prebid.server.bidder.facebook.proto.FacebookNative;
import org.prebid.server.bidder.model.BidderBid;
import org.prebid.server.bidder.model.BidderError;
import org.prebid.server.bidder.model.HttpCall;
Expand Down Expand Up @@ -246,9 +245,7 @@ private static boolean isBannerHeightValid(Integer h) {
* Add Width and Height (not available in standard openRTB) and exclude native.request and native.ver fields
*/
private static Native modifyNative(Native xNative) {
return FacebookNative.builder()
.w(-1)
.h(-1)
return Native.builder()
.api(xNative.getApi())
.battr(xNative.getBattr())
.ext(xNative.getExt())
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void makeBidsShouldReturnNativeBid() throws JsonProcessingException {
// given
final HttpCall<BidRequest> httpCall = givenHttpCall(
BidRequest.builder().imp(singletonList(Imp.builder().id("123")
.xNative(new Native())
.xNative(Native.builder().build())
.build())).build(),
mapper.writeValueAsString(givenBidResponse(
bidBuilder -> bidBuilder.impid("123").ext(createBidExtPrebidWithType("native")))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.junit.Test;
import org.prebid.server.VertxTest;
import org.prebid.server.bidder.facebook.proto.FacebookExt;
import org.prebid.server.bidder.facebook.proto.FacebookNative;
import org.prebid.server.bidder.model.BidderBid;
import org.prebid.server.bidder.model.BidderError;
import org.prebid.server.bidder.model.HttpCall;
Expand Down Expand Up @@ -423,18 +422,16 @@ public void makeHttpRequestsShouldModifyImpNativeByAddingWidthAndHeightAndRemovi
// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue()).hasSize(1)
// use payload as deserializing from body json string converts native to parent class, which
// is not aware of child's fields
.extracting(HttpRequest::getPayload)
.flatExtracting(BidRequest::getImp)
.extracting(Imp::getXNative)
.containsOnly(FacebookNative.builder().w(-1).h(-1).api(singletonList(1)).build());
.containsOnly(Native.builder().api(singletonList(1)).build());

// extra check to assure that data in body is displayed correctly
assertThat(result.getValue())
.extracting(value -> new String(value.getBody()))
.allSatisfy(s -> assertThat(s)
.contains("\"native\":{\"api\":[1],\"w\":-1,\"h\":-1},\"tagid\":\"pubId_placementId\"}"));
.contains("\"native\":{\"api\":[1]},\"tagid\":\"pubId_placementId\"}"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3084,7 +3084,7 @@ public void validateShouldReturnValidationMessageWhenRequestHaveDuplicatedImpIds
}

private static BidRequest givenBidRequest(
UnaryOperator<Native.NativeBuilder<?, ?>> nativeCustomizer) {
UnaryOperator<Native.NativeBuilder> nativeCustomizer) {
return validBidRequestBuilder()
.imp(singletonList(validImpBuilder()
.xNative(nativeCustomizer.apply(Native.builder()).build()).build())).build();
Expand Down

0 comments on commit 0e47f1b

Please sign in to comment.