use of org.prebid.mobile.rendering.networking.parameters.AdRequestInput 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.networking.parameters.AdRequestInput 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.networking.parameters.AdRequestInput 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);
}
use of org.prebid.mobile.rendering.networking.parameters.AdRequestInput in project prebid-mobile-android by prebid.
the class AutoDetectedOpenRtbTest method setup.
@Before
public void setup() {
mActivity = Robolectric.buildActivity(Activity.class).create().get();
ShadowActivity shadowActivity = shadowOf(mActivity);
shadowActivity.grantPermissions("android.permission.ACCESS_FINE_LOCATION");
LocationManager locationManager = (LocationManager) mActivity.getSystemService(Context.LOCATION_SERVICE);
ShadowLocationManager shadowLocationManager = shadowOf(locationManager);
Location location = new Location("");
location.setLatitude(1);
location.setLongitude(1);
shadowLocationManager.setLastKnownLocation("gps", location);
ShadowTelephonyManager shadowTelephonyManager = shadowOf((TelephonyManager) mActivity.getSystemService(Context.TELEPHONY_SERVICE));
shadowTelephonyManager.setNetworkOperatorName("carrier");
shadowTelephonyManager.setNetworkOperator("carrier");
ManagersResolver.getInstance().prepare(mActivity);
mParamBuilderArray = new ArrayList<>();
mOriginalAdRequestInput = new AdRequestInput();
mOriginalOpenRtbParams = new BidRequest();
}
use of org.prebid.mobile.rendering.networking.parameters.AdRequestInput in project prebid-mobile-android by prebid.
the class AutoDetectedOpenRtbTest method overwrittenNetworkParameterBuilder.
@Test
public void overwrittenNetworkParameterBuilder() {
mOriginalOpenRtbParams.getDevice().mccmnc = "foo";
mOriginalOpenRtbParams.getDevice().carrier = "foo";
mOriginalOpenRtbParams.getDevice().connectiontype = 0;
mParamBuilderArray.add(new NetworkParameterBuilder());
AdRequestInput newAdRequestInput = URLBuilder.buildParameters(mParamBuilderArray, mOriginalAdRequestInput);
BidRequest newOpenRtbParams = newAdRequestInput.getBidRequest();
assertNotEquals(mOriginalOpenRtbParams.getDevice().mccmnc, newOpenRtbParams.getDevice().mccmnc);
assertNotEquals(mOriginalOpenRtbParams.getDevice().carrier, newOpenRtbParams.getDevice().carrier);
assertNotEquals(mOriginalOpenRtbParams.getDevice().connectiontype, newOpenRtbParams.getDevice().connectiontype);
}
Aggregations