Search in sources :

Example 11 with BasicParameterBuilder

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

the class BasicParameterBuilderTest method whenAppendParametersAndTargetingParamsWereSet_TargetingParamsWereAppend.

@Test
public void whenAppendParametersAndTargetingParamsWereSet_TargetingParamsWereAppend() throws JSONException {
    AdConfiguration adConfiguration = new AdConfiguration();
    adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
    adConfiguration.addSize(new AdSize(320, 50));
    Targeting.setUserId(USER_ID);
    Targeting.setUserAge(USER_AGE);
    Targeting.setUserKeywords(USER_KEYWORDS);
    Targeting.setUserCustomData(USER_CUSTOM);
    Targeting.setUserGender(UserParameters.Gender.MALE);
    Targeting.setBuyerUid(USER_BUYER_ID);
    Targeting.setUserExt(new Ext());
    Targeting.setEids(new JSONArray());
    Targeting.setUserLatLng(USER_LAT, USER_LON);
    BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), mBrowserActivityAvailable);
    AdRequestInput adRequestInput = new AdRequestInput();
    builder.appendBuilderParameters(adRequestInput);
    User actualUser = adRequestInput.getBidRequest().getUser();
    User expectedUser = getExpectedUser();
    assertEquals(expectedUser.getJsonObject().toString(), actualUser.getJsonObject().toString());
}
Also used : Ext(org.prebid.mobile.rendering.models.openrtb.bidRequests.Ext) User(org.prebid.mobile.rendering.models.openrtb.bidRequests.User) AdSize(org.prebid.mobile.rendering.bidding.data.AdSize) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) JSONArray(org.json.JSONArray) BasicParameterBuilder(org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder) Test(org.junit.Test)

Example 12 with BasicParameterBuilder

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

Example 13 with BasicParameterBuilder

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

the class BasicParameterBuilderTest method whenAppendParametersAndUseExternalBrowserFalseAndBrowserActivityAvailable_ClickBrowserEqualsZero.

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

Example 14 with BasicParameterBuilder

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

the class BasicParameterBuilderTest method whenAppendParametersAndBInterstitialType_ImpWithValidBannerObject.

@Test
public void whenAppendParametersAndBInterstitialType_ImpWithValidBannerObject() throws JSONException {
    AdConfiguration adConfiguration = new AdConfiguration();
    adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.INTERSTITIAL);
    adConfiguration.setAdPosition(AdPosition.FULLSCREEN);
    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);
    Format expectedFormat = new Format(1920, 1080);
    assertTrue(actualImp.banner.getFormats().contains(expectedFormat));
    assertNull(actualImp.video);
    assertEquals(1, actualImp.secure.intValue());
    assertEquals(1, actualImp.instl.intValue());
}
Also used : Format(org.prebid.mobile.rendering.models.openrtb.bidRequests.imps.pmps.Format) 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)

Example 15 with BasicParameterBuilder

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

the class BasicParameterBuilderTest method whenAppendParametersAndCoppaFalse_CoppaNull.

@Test
public void whenAppendParametersAndCoppaFalse_CoppaNull() {
    AdConfiguration adConfiguration = new AdConfiguration();
    adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
    adConfiguration.addSize(new AdSize(320, 50));
    BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), mBrowserActivityAvailable);
    AdRequestInput adRequestInput = new AdRequestInput();
    builder.appendBuilderParameters(adRequestInput);
    BidRequest actualBidRequest = adRequestInput.getBidRequest();
    assertNull(actualBidRequest.getRegs().coppa);
}
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)

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