use of org.prebid.mobile.rendering.models.openrtb.bidRequests.User in project prebid-mobile-android by prebid.
the class BasicParameterBuilderTest method whenAppendParametersAndTargetingUserDataNotEmpty_UserDataAddedToUserExt.
@Test
public void whenAppendParametersAndTargetingUserDataNotEmpty_UserDataAddedToUserExt() throws JSONException {
Targeting.addUserData("user", "userData");
AdConfiguration adConfiguration = new AdConfiguration();
adConfiguration.setConfigId("config");
BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), false);
AdRequestInput adRequestInput = new AdRequestInput();
builder.appendBuilderParameters(adRequestInput);
User user = adRequestInput.getBidRequest().getUser();
assertTrue(user.getExt().getMap().containsKey("data"));
JSONObject userDataJson = (JSONObject) user.getExt().getMap().get("data");
assertTrue(userDataJson.has("user"));
assertEquals("userData", userDataJson.getJSONArray("user").get(0));
}
use of org.prebid.mobile.rendering.models.openrtb.bidRequests.User in project prebid-mobile-android by prebid.
the class BasicParameterBuilderTest method whenAppendUserData_UserDataAddedToUser.
@Test
public void whenAppendUserData_UserDataAddedToUser() throws JSONException {
AdConfiguration adConfiguration = new AdConfiguration();
adConfiguration.setConfigId("config");
DataObject dataObject = new DataObject();
String testName = "testDataObject";
dataObject.setName(testName);
adConfiguration.addUserData(dataObject);
BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), false);
AdRequestInput adRequestInput = new AdRequestInput();
builder.appendBuilderParameters(adRequestInput);
User user = adRequestInput.getBidRequest().getUser();
assertEquals(1, user.dataObjects.size());
JSONObject jsonUser = user.getJsonObject();
assertTrue(jsonUser.has("data"));
JSONArray jsonData = jsonUser.getJSONArray("data");
JSONObject jsonDataObject = jsonData.getJSONObject(0);
assertTrue(jsonDataObject.has("name"));
String dataName = jsonDataObject.getString("name");
assertEquals(testName, dataName);
}
use of org.prebid.mobile.rendering.models.openrtb.bidRequests.User 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;
}
}
use of org.prebid.mobile.rendering.models.openrtb.bidRequests.User 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());
}
use of org.prebid.mobile.rendering.models.openrtb.bidRequests.User 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;
}
Aggregations