use of org.prebid.mobile.DataObject 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);
}
Aggregations