Search in sources :

Example 6 with BasicParameterBuilder

use of org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder 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 7 with BasicParameterBuilder

use of org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder in project prebid-mobile-android by prebid.

the class BasicParameterBuilderTest method whenAppendParametersAndSendMraidSupportParamsFalse_NoMraidApi.

@Test
public void whenAppendParametersAndSendMraidSupportParamsFalse_NoMraidApi() {
    AdConfiguration adConfiguration = new AdConfiguration();
    adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
    adConfiguration.addSize(new AdSize(320, 50));
    PrebidRenderingSettings.sendMraidSupportParams = false;
    BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), mBrowserActivityAvailable);
    AdRequestInput adRequestInput = new AdRequestInput();
    builder.appendBuilderParameters(adRequestInput);
    Imp actualImp = adRequestInput.getBidRequest().getImp().get(0);
    assertEquals(Arrays.toString(new int[] { 7 }), Arrays.toString(actualImp.banner.api));
}
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) Test(org.junit.Test)

Example 8 with BasicParameterBuilder

use of org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder in project prebid-mobile-android by prebid.

the class BasicParameterBuilderTest method whenAppendUserData_UserDataAddedToUser.

@Test
public void whenAppendUserData_UserDataAddedToUser() throws JSONException {
    AdConfiguration adConfiguration = new AdConfiguration();
    adConfiguration.setConfigId("config");
    DataObject dataObject = new DataObject();
    String testName = "testDataObject";
    dataObject.setName(testName);
    adConfiguration.addUserData(dataObject);
    BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), false);
    AdRequestInput adRequestInput = new AdRequestInput();
    builder.appendBuilderParameters(adRequestInput);
    User user = adRequestInput.getBidRequest().getUser();
    assertEquals(1, user.dataObjects.size());
    JSONObject jsonUser = user.getJsonObject();
    assertTrue(jsonUser.has("data"));
    JSONArray jsonData = jsonUser.getJSONArray("data");
    JSONObject jsonDataObject = jsonData.getJSONObject(0);
    assertTrue(jsonDataObject.has("name"));
    String dataName = jsonDataObject.getString("name");
    assertEquals(testName, dataName);
}
Also used : DataObject(org.prebid.mobile.DataObject) User(org.prebid.mobile.rendering.models.openrtb.bidRequests.User) JSONObject(org.json.JSONObject) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) JSONArray(org.json.JSONArray) BasicParameterBuilder(org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder) Test(org.junit.Test)

Example 9 with BasicParameterBuilder

use of org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder in project prebid-mobile-android by prebid.

the class Requester method getParameterBuilders.

protected List<ParameterBuilder> getParameterBuilders() {
    Context context = mContextReference.get();
    Resources resources = null;
    if (context != null) {
        resources = context.getResources();
    }
    boolean browserActivityAvailable = ExternalViewerUtils.isBrowserActivityCallable(context);
    ArrayList<ParameterBuilder> parameterBuilderArray = new ArrayList<>();
    parameterBuilderArray.add(new BasicParameterBuilder(mAdConfiguration, resources, browserActivityAvailable));
    parameterBuilderArray.add(new GeoLocationParameterBuilder());
    parameterBuilderArray.add(new AppInfoParameterBuilder(mAdConfiguration));
    parameterBuilderArray.add(new DeviceInfoParameterBuilder(mAdConfiguration));
    parameterBuilderArray.add(new NetworkParameterBuilder());
    parameterBuilderArray.add(new UserConsentParameterBuilder(mUserConsentManager));
    return parameterBuilderArray;
}
Also used : Context(android.content.Context) AppInfoParameterBuilder(org.prebid.mobile.rendering.networking.parameters.AppInfoParameterBuilder) DeviceInfoParameterBuilder(org.prebid.mobile.rendering.networking.parameters.DeviceInfoParameterBuilder) GeoLocationParameterBuilder(org.prebid.mobile.rendering.networking.parameters.GeoLocationParameterBuilder) ArrayList(java.util.ArrayList) NetworkParameterBuilder(org.prebid.mobile.rendering.networking.parameters.NetworkParameterBuilder) UserConsentParameterBuilder(org.prebid.mobile.rendering.networking.parameters.UserConsentParameterBuilder) Resources(android.content.res.Resources) GeoLocationParameterBuilder(org.prebid.mobile.rendering.networking.parameters.GeoLocationParameterBuilder) BasicParameterBuilder(org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder) NetworkParameterBuilder(org.prebid.mobile.rendering.networking.parameters.NetworkParameterBuilder) UserConsentParameterBuilder(org.prebid.mobile.rendering.networking.parameters.UserConsentParameterBuilder) ParameterBuilder(org.prebid.mobile.rendering.networking.parameters.ParameterBuilder) AppInfoParameterBuilder(org.prebid.mobile.rendering.networking.parameters.AppInfoParameterBuilder) DeviceInfoParameterBuilder(org.prebid.mobile.rendering.networking.parameters.DeviceInfoParameterBuilder) BasicParameterBuilder(org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder)

Example 10 with BasicParameterBuilder

use of org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder in project prebid-mobile-android by prebid.

the class BasicParameterBuilderTest method whenAppendParametersAndUseExternalBrowserTrueAndBrowserActivityAvailable_ClickBrowserEqualsOne.

@Test
public void whenAppendParametersAndUseExternalBrowserTrueAndBrowserActivityAvailable_ClickBrowserEqualsOne() {
    AdConfiguration adConfiguration = new AdConfiguration();
    adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
    adConfiguration.addSize(new AdSize(320, 50));
    PrebidRenderingSettings.useExternalBrowser = true;
    BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), mBrowserActivityAvailable);
    AdRequestInput adRequestInput = new AdRequestInput();
    builder.appendBuilderParameters(adRequestInput);
    Imp actualImp = adRequestInput.getBidRequest().getImp().get(0);
    assertEquals(1, actualImp.clickBrowser.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) Test(org.junit.Test)

Aggregations

BasicParameterBuilder (org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder)16 Test (org.junit.Test)15 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)15 AdSize (org.prebid.mobile.rendering.bidding.data.AdSize)9 Imp (org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp)8 BidRequest (org.prebid.mobile.rendering.models.openrtb.BidRequest)7 JSONObject (org.json.JSONObject)4 JSONArray (org.json.JSONArray)3 User (org.prebid.mobile.rendering.models.openrtb.bidRequests.User)3 Ext (org.prebid.mobile.rendering.models.openrtb.bidRequests.Ext)2 Context (android.content.Context)1 Resources (android.content.res.Resources)1 ArrayList (java.util.ArrayList)1 DataObject (org.prebid.mobile.DataObject)1 Format (org.prebid.mobile.rendering.models.openrtb.bidRequests.imps.pmps.Format)1 AppInfoParameterBuilder (org.prebid.mobile.rendering.networking.parameters.AppInfoParameterBuilder)1 DeviceInfoParameterBuilder (org.prebid.mobile.rendering.networking.parameters.DeviceInfoParameterBuilder)1 GeoLocationParameterBuilder (org.prebid.mobile.rendering.networking.parameters.GeoLocationParameterBuilder)1 NetworkParameterBuilder (org.prebid.mobile.rendering.networking.parameters.NetworkParameterBuilder)1 ParameterBuilder (org.prebid.mobile.rendering.networking.parameters.ParameterBuilder)1