Search in sources :

Example 1 with BidRequest

use of org.prebid.mobile.rendering.models.openrtb.BidRequest in project prebid-mobile-android by prebid.

the class URLComponentsTest method testEncoding.

/**
 * Test urlencoding of keys
 */
@Test
public void testEncoding() throws Exception {
    BidRequest bidRequest = new BidRequest();
    AdRequestInput mockAdRequestInput = new AdRequestInput();
    Device device = new Device();
    device.carrier = "tmobile";
    bidRequest.setId("123");
    bidRequest.setDevice(device);
    mockAdRequestInput.setBidRequest(bidRequest);
    URLComponents urlComponents = new URLComponents("", mockAdRequestInput);
    String expected = "openrtb=%7B%22id%22%3A%22123%22%2C%22device%22%3A%7B%22carrier%22%3A%22tmobile%22%7D%7D";
    assertEquals(expected, urlComponents.getQueryArgString());
}
Also used : AdRequestInput(org.prebid.mobile.rendering.networking.parameters.AdRequestInput) Device(org.prebid.mobile.rendering.models.openrtb.bidRequests.Device) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Example 2 with BidRequest

use of org.prebid.mobile.rendering.models.openrtb.BidRequest in project prebid-mobile-android by prebid.

the class URLComponentsTest method getQueryArgStringThrowsException_EmptyString.

/**
 * Tests when JSONException is thrown and the OpenRTB object is not appended to query arg string and the result query is empty
 */
@Test
public void getQueryArgStringThrowsException_EmptyString() throws Exception {
    BidRequest mockBidRequest = mock(BidRequest.class);
    when(mockBidRequest.getJsonObject()).thenThrow(new JSONException((String) null));
    when(mockBidRequest.getApp()).thenCallRealMethod();
    mockBidRequest.getApp().name = "ignored";
    AdRequestInput mockAdRequestInput = mock(AdRequestInput.class);
    when(mockAdRequestInput.getBidRequest()).thenReturn(mockBidRequest);
    URLComponents urlComponents = new URLComponents("", mockAdRequestInput);
    assertTrue(urlComponents.getQueryArgString().isEmpty());
}
Also used : AdRequestInput(org.prebid.mobile.rendering.networking.parameters.AdRequestInput) JSONException(org.json.JSONException) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Example 3 with BidRequest

use of org.prebid.mobile.rendering.models.openrtb.BidRequest in project prebid-mobile-android by prebid.

the class NetworkParameterBuilderTest method whenTestAppendBuilderParametersAndCell_CellType.

@Test
public void whenTestAppendBuilderParametersAndCell_CellType() throws JSONException {
    NetworkInfo mockInfo = mock(NetworkInfo.class);
    when(mockInfo.getType()).thenReturn(ConnectivityManager.TYPE_MOBILE);
    when(mockInfo.isConnected()).thenReturn(true);
    mShadowConnectivityManager.setActiveNetworkInfo(mockInfo);
    BidRequest expectedBidRequest = new BidRequest();
    expectedBidRequest.getDevice().mccmnc = "car-rier";
    expectedBidRequest.getDevice().carrier = NETWORK_CARRIER;
    expectedBidRequest.getDevice().connectiontype = NetworkParameterBuilder.CONNECTION_TYPE_CELL_UNKNOWN_G;
    NetworkParameterBuilder builder = new NetworkParameterBuilder();
    AdRequestInput adRequestInput = new AdRequestInput();
    builder.appendBuilderParameters(adRequestInput);
    assertEquals(expectedBidRequest.getJsonObject().toString(), adRequestInput.getBidRequest().getJsonObject().toString());
}
Also used : NetworkInfo(android.net.NetworkInfo) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Example 4 with BidRequest

use of org.prebid.mobile.rendering.models.openrtb.BidRequest in project prebid-mobile-android by prebid.

the class NetworkParameterBuilderTest method whenTestAppendBuilderParametersAndWifi_WiFiType.

@Test
public void whenTestAppendBuilderParametersAndWifi_WiFiType() throws JSONException {
    NetworkInfo mockInfo = mock(NetworkInfo.class);
    when(mockInfo.getType()).thenReturn(ConnectivityManager.TYPE_WIFI);
    when(mockInfo.isConnected()).thenReturn(true);
    mShadowConnectivityManager.setActiveNetworkInfo(mockInfo);
    BidRequest expectedBidRequest = new BidRequest();
    expectedBidRequest.getDevice().mccmnc = "car-rier";
    expectedBidRequest.getDevice().carrier = NETWORK_CARRIER;
    expectedBidRequest.getDevice().connectiontype = NetworkParameterBuilder.CONNECTION_TYPE_WIFI;
    NetworkParameterBuilder builder = new NetworkParameterBuilder();
    AdRequestInput adRequestInput = new AdRequestInput();
    builder.appendBuilderParameters(adRequestInput);
    assertEquals(expectedBidRequest.getJsonObject().toString(), adRequestInput.getBidRequest().getJsonObject().toString());
}
Also used : NetworkInfo(android.net.NetworkInfo) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Example 5 with BidRequest

use of org.prebid.mobile.rendering.models.openrtb.BidRequest in project prebid-mobile-android by prebid.

the class AutoDetectedOpenRtbTest method overwrittenGeoLocationParameterBuilderTest.

@Test
public void overwrittenGeoLocationParameterBuilderTest() {
    mOriginalOpenRtbParams.getDevice().getGeo().lat = 0f;
    mOriginalOpenRtbParams.getDevice().getGeo().lon = 0f;
    mOriginalOpenRtbParams.getDevice().getGeo().type = 0;
    mOriginalAdRequestInput.setBidRequest(mOriginalOpenRtbParams);
    mParamBuilderArray.add(new GeoLocationParameterBuilder());
    AdRequestInput newAdRequestInput = URLBuilder.buildParameters(mParamBuilderArray, mOriginalAdRequestInput);
    BidRequest newOpenRtbParams = newAdRequestInput.getBidRequest();
    assertNotEquals(mOriginalOpenRtbParams.getDevice().getGeo().lat, newOpenRtbParams.getDevice().getGeo().lat);
    assertNotEquals(mOriginalOpenRtbParams.getDevice().getGeo().lon, newOpenRtbParams.getDevice().getGeo().lon);
    assertNotEquals(mOriginalOpenRtbParams.getDevice().getGeo().type, newOpenRtbParams.getDevice().getGeo().type);
}
Also used : AdRequestInput(org.prebid.mobile.rendering.networking.parameters.AdRequestInput) GeoLocationParameterBuilder(org.prebid.mobile.rendering.networking.parameters.GeoLocationParameterBuilder) 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