Search in sources :

Example 1 with Geo

use of org.prebid.mobile.rendering.models.openrtb.bidRequests.devices.Geo in project prebid-mobile-android by prebid.

the class DeviceTest method getJsonObjectTest.

@Test
public void getJsonObjectTest() throws Exception {
    Geo testGeo = new Geo();
    mTestDevice.setGeo(testGeo);
    assertEquals(testGeo, mTestDevice.getGeo());
    mTestDevice.lmt = 1;
    mTestDevice.devicetype = 1;
    mTestDevice.make = "LG";
    mTestDevice.model = "Nexus 5";
    mTestDevice.os = "5.0";
    mTestDevice.osv = "5";
    mTestDevice.hwv = "5";
    mTestDevice.flashver = "1";
    mTestDevice.language = "en";
    mTestDevice.carrier = "T-mobile";
    mTestDevice.mccmnc = "321-444";
    mTestDevice.ifa = "1111";
    mTestDevice.didsha1 = "3414dsfd";
    mTestDevice.didmd5 = "didmd5";
    mTestDevice.dpidsha1 = "didsha1";
    mTestDevice.dpidmd5 = "dpidmd5";
    mTestDevice.h = 1221;
    mTestDevice.w = 567;
    mTestDevice.ppi = 11;
    mTestDevice.js = 1;
    mTestDevice.connectiontype = 1;
    mTestDevice.pxratio = 22f;
    mTestDevice.geo = testGeo;
    JSONObject actualObj = mTestDevice.getJsonObject();
    String expectedString = "{\"os\":\"5.0\",\"didmd5\":\"didmd5\",\"ifa\":\"1111\",\"hwv\":\"5\",\"h\":1221,\"ppi\":11,\"js\":1,\"language\":\"en\",\"devicetype\":1,\"pxratio\":22,\"geo\":{},\"lmt\":1,\"carrier\":\"T-mobile\",\"osv\":\"5\",\"dpidmd5\":\"dpidmd5\",\"mccmnc\":\"321-444\",\"flashver\":\"1\",\"didsha1\":\"3414dsfd\",\"w\":567,\"model\":\"Nexus 5\",\"connectiontype\":1,\"make\":\"LG\",\"dpidsha1\":\"didsha1\"}";
    assertEquals("got: " + actualObj.toString(), expectedString, actualObj.toString());
    mTestDevice.getJsonObject();
}
Also used : Geo(org.prebid.mobile.rendering.models.openrtb.bidRequests.devices.Geo) JSONObject(org.json.JSONObject) Test(org.junit.Test)

Example 2 with Geo

use of org.prebid.mobile.rendering.models.openrtb.bidRequests.devices.Geo in project prebid-mobile-android by prebid.

the class UserTest method geoTest.

@Test
public void geoTest() throws Exception {
    // Get default empty geo
    User user = new User();
    assertEquals(new Geo().getJsonObject().toString(), user.getGeo().getJsonObject().toString());
    // Set geo
    Geo geo = new Geo();
    geo.lat = 1.2f;
    geo.lon = 3.4f;
    user.setGeo(geo);
    assertEquals(geo, user.getGeo());
    // Unset geo
    user.setGeo(null);
    assertEquals(new Geo().getJsonObject().toString(), user.getGeo().getJsonObject().toString());
}
Also used : Geo(org.prebid.mobile.rendering.models.openrtb.bidRequests.devices.Geo) Test(org.junit.Test)

Example 3 with Geo

use of org.prebid.mobile.rendering.models.openrtb.bidRequests.devices.Geo in project prebid-mobile-android by prebid.

the class BasicParameterBuilder method appendUserTargetingParameters.

private void appendUserTargetingParameters(AdRequestInput adRequestInput) {
    final BidRequest bidRequest = adRequestInput.getBidRequest();
    final User user = bidRequest.getUser();
    user.id = Targeting.getUserId();
    user.yob = Targeting.getUserYob();
    user.keywords = Targeting.getUserKeyWords();
    user.customData = Targeting.getUserCustomData();
    user.gender = Targeting.getUserGender();
    user.buyerUid = Targeting.getBuyerUid();
    user.ext = Targeting.getUserExt();
    user.dataObjects = mAdConfiguration.getUserData();
    final Map<String, Set<String>> userDataDictionary = Targeting.getUserDataDictionary();
    if (!userDataDictionary.isEmpty()) {
        user.getExt().put("data", Utils.toJson(userDataDictionary));
    }
    if (Targeting.getEids() != null) {
        user.getExt().put("eids", Targeting.getEids());
    }
    final Pair<Float, Float> userLatLng = Targeting.getUserLatLng();
    if (userLatLng != null) {
        final Geo userGeo = user.getGeo();
        userGeo.lat = userLatLng.first;
        userGeo.lon = userLatLng.second;
    }
}
Also used : Geo(org.prebid.mobile.rendering.models.openrtb.bidRequests.devices.Geo) User(org.prebid.mobile.rendering.models.openrtb.bidRequests.User) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest)

Example 4 with Geo

use of org.prebid.mobile.rendering.models.openrtb.bidRequests.devices.Geo in project prebid-mobile-android by prebid.

the class BasicParameterBuilderTest method getExpectedUser.

private User getExpectedUser() {
    final User user = new User();
    user.id = USER_ID;
    user.yob = USER_YOB;
    user.keywords = USER_KEYWORDS;
    user.customData = USER_CUSTOM;
    user.gender = USER_GENDER;
    user.buyerUid = USER_BUYER_ID;
    user.ext = new Ext();
    user.ext.put("eids", Targeting.getEids());
    final Geo userGeo = user.getGeo();
    userGeo.lat = USER_LAT;
    userGeo.lon = USER_LON;
    return user;
}
Also used : Ext(org.prebid.mobile.rendering.models.openrtb.bidRequests.Ext) Geo(org.prebid.mobile.rendering.models.openrtb.bidRequests.devices.Geo) User(org.prebid.mobile.rendering.models.openrtb.bidRequests.User)

Example 5 with Geo

use of org.prebid.mobile.rendering.models.openrtb.bidRequests.devices.Geo in project prebid-mobile-android by prebid.

the class DeviceTest method checkGeoTest.

@Test
public void checkGeoTest() {
    Geo actualGeo = mTestDevice.getGeo();
    assertNotNull("Geo isn't null.", actualGeo);
    Geo geo = new Geo();
    geo.lat = 35.012345f;
    geo.lon = -115.12345f;
    geo.type = 1;
    geo.accuracy = 1;
    geo.lastfix = 1;
    geo.country = "USA";
    geo.region = "CA";
    geo.regionfips104 = "USA";
    geo.metro = "803";
    geo.city = "Los Angeles";
    geo.zip = "90049";
    geo.utcoffset = 1;
    mTestDevice.setGeo(geo);
    assertSame("Set and received geo values must match.", geo, mTestDevice.getGeo());
}
Also used : Geo(org.prebid.mobile.rendering.models.openrtb.bidRequests.devices.Geo) Test(org.junit.Test)

Aggregations

Geo (org.prebid.mobile.rendering.models.openrtb.bidRequests.devices.Geo)6 Test (org.junit.Test)4 JSONObject (org.json.JSONObject)2 User (org.prebid.mobile.rendering.models.openrtb.bidRequests.User)2 BidRequest (org.prebid.mobile.rendering.models.openrtb.BidRequest)1 Ext (org.prebid.mobile.rendering.models.openrtb.bidRequests.Ext)1