Search in sources :

Example 11 with BidRequest

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());
}
Also used : AdSize(org.prebid.mobile.rendering.bidding.data.AdSize) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) BasicParameterBuilder(org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Example 12 with BidRequest

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));
}
Also used : JSONObject(org.json.JSONObject) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) JSONArray(org.json.JSONArray) BasicParameterBuilder(org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Example 13 with BidRequest

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());
}
Also used : BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Example 14 with BidRequest

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;
    }
}
Also used : Geo(org.prebid.mobile.rendering.models.openrtb.bidRequests.devices.Geo) User(org.prebid.mobile.rendering.models.openrtb.bidRequests.User) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest)

Example 15 with BidRequest

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());
}
Also used : AdSize(org.prebid.mobile.rendering.bidding.data.AdSize) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) BasicParameterBuilder(org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder) Imp(org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Aggregations

BidRequest (org.prebid.mobile.rendering.models.openrtb.BidRequest)24 Test (org.junit.Test)20 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)11 AdRequestInput (org.prebid.mobile.rendering.networking.parameters.AdRequestInput)8 BasicParameterBuilder (org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder)7 Imp (org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp)5 AdSize (org.prebid.mobile.rendering.bidding.data.AdSize)4 NetworkInfo (android.net.NetworkInfo)2 JSONObject (org.json.JSONObject)2 Device (org.prebid.mobile.rendering.models.openrtb.bidRequests.Device)2 Activity (android.app.Activity)1 Location (android.location.Location)1 LocationManager (android.location.LocationManager)1 JSONArray (org.json.JSONArray)1 JSONException (org.json.JSONException)1 Before (org.junit.Before)1 ContentObject (org.prebid.mobile.ContentObject)1 App (org.prebid.mobile.rendering.models.openrtb.bidRequests.App)1 User (org.prebid.mobile.rendering.models.openrtb.bidRequests.User)1 Geo (org.prebid.mobile.rendering.models.openrtb.bidRequests.devices.Geo)1