use of org.prebid.mobile.rendering.models.openrtb.BidRequest in project prebid-mobile-android by prebid.
the class BasicParameterBuilderTest method whenAppendParametersAndCoppaTrue_CoppaEqualsOne.
@Test
public void whenAppendParametersAndCoppaTrue_CoppaEqualsOne() {
AdConfiguration adConfiguration = new AdConfiguration();
adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
adConfiguration.addSize(new AdSize(320, 50));
PrebidRenderingSettings.isCoppaEnabled = true;
BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), mBrowserActivityAvailable);
AdRequestInput adRequestInput = new AdRequestInput();
builder.appendBuilderParameters(adRequestInput);
BidRequest actualBidRequest = adRequestInput.getBidRequest();
assertEquals(1, actualBidRequest.getRegs().coppa.intValue());
}
use of org.prebid.mobile.rendering.models.openrtb.BidRequest in project prebid-mobile-android by prebid.
the class BasicParameterBuilderTest method whenAppendParametersAndTargetingAccessControlNotEmpty_BiddersAddedToExt.
@Test
public void whenAppendParametersAndTargetingAccessControlNotEmpty_BiddersAddedToExt() throws JSONException {
Targeting.addBidderToAccessControlList("bidder");
AdConfiguration adConfiguration = new AdConfiguration();
adConfiguration.setConfigId("config");
BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), false);
AdRequestInput adRequestInput = new AdRequestInput();
builder.appendBuilderParameters(adRequestInput);
BidRequest bidRequest = adRequestInput.getBidRequest();
JSONObject prebidJson = bidRequest.getExt().getJsonObject().getJSONObject("prebid");
assertTrue(prebidJson.has("data"));
JSONArray biddersArray = prebidJson.getJSONObject("data").getJSONArray("bidders");
assertEquals("bidder", biddersArray.get(0));
}
use of org.prebid.mobile.rendering.models.openrtb.BidRequest in project prebid-mobile-android by prebid.
the class GeoLocationParameterBuilderTest method testIgnorePublisherValues.
/**
* Ignoring publisher values for geographic data, even if the SDK fails to auto-detect values
*/
@Test
public void testIgnorePublisherValues() throws Exception {
BidRequest ignoredBidRequest = new BidRequest();
ignoredBidRequest.getDevice().getGeo().lat = 100f;
ignoredBidRequest.getDevice().getGeo().lon = 200f;
ignoredBidRequest.getDevice().getGeo().type = GeoLocationParameterBuilder.LOCATION_SOURCE_GPS;
GeoLocationParameterBuilder builder = new GeoLocationParameterBuilder();
AdRequestInput adRequestInput = new AdRequestInput();
adRequestInput.setBidRequest(ignoredBidRequest);
builder.appendBuilderParameters(adRequestInput);
assertEquals("{\"lat\":1,\"lon\":-1,\"type\":1}", adRequestInput.getBidRequest().getDevice().getGeo().getJsonObject().toString());
}
use of org.prebid.mobile.rendering.models.openrtb.BidRequest in project prebid-mobile-android by prebid.
the class BasicParameterBuilder method appendUserTargetingParameters.
private void appendUserTargetingParameters(AdRequestInput adRequestInput) {
final BidRequest bidRequest = adRequestInput.getBidRequest();
final User user = bidRequest.getUser();
user.id = Targeting.getUserId();
user.yob = Targeting.getUserYob();
user.keywords = Targeting.getUserKeyWords();
user.customData = Targeting.getUserCustomData();
user.gender = Targeting.getUserGender();
user.buyerUid = Targeting.getBuyerUid();
user.ext = Targeting.getUserExt();
user.dataObjects = mAdConfiguration.getUserData();
final Map<String, Set<String>> userDataDictionary = Targeting.getUserDataDictionary();
if (!userDataDictionary.isEmpty()) {
user.getExt().put("data", Utils.toJson(userDataDictionary));
}
if (Targeting.getEids() != null) {
user.getExt().put("eids", Targeting.getEids());
}
final Pair<Float, Float> userLatLng = Targeting.getUserLatLng();
if (userLatLng != null) {
final Geo userGeo = user.getGeo();
userGeo.lat = userLatLng.first;
userGeo.lon = userLatLng.second;
}
}
use of org.prebid.mobile.rendering.models.openrtb.BidRequest in project prebid-mobile-android by prebid.
the class BasicParameterBuilderTest method whenAppendParametersAndBannerType_ImpWithValidBannerObject.
@Test
public void whenAppendParametersAndBannerType_ImpWithValidBannerObject() throws JSONException {
AdConfiguration adConfiguration = new AdConfiguration();
adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
adConfiguration.addSize(new AdSize(320, 50));
adConfiguration.setPbAdSlot("12345");
PrebidRenderingSettings.addStoredBidResponse("bidderTest", "123456");
PrebidRenderingSettings.setStoredAuctionResponse("storedResponse");
BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), mBrowserActivityAvailable);
AdRequestInput adRequestInput = new AdRequestInput();
builder.appendBuilderParameters(adRequestInput);
BidRequest actualBidRequest = adRequestInput.getBidRequest();
BidRequest expectedBidRequest = getExpectedBidRequest(adConfiguration, actualBidRequest.getId());
assertEquals(expectedBidRequest.getJsonObject().toString(), actualBidRequest.getJsonObject().toString());
Imp actualImp = actualBidRequest.getImp().get(0);
assertNotNull(actualImp.banner);
assertTrue(actualImp.banner.getFormats().containsAll(expectedBidRequest.getImp().get(0).banner.getFormats()));
assertNull(actualImp.video);
assertEquals(1, actualImp.secure.intValue());
assertEquals(0, actualImp.instl.intValue());
}
Aggregations