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());
}
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());
}
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());
}
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());
}
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);
}
Aggregations