Search in sources :

Example 1 with DataObject

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);
}
Also used : DataObject(org.prebid.mobile.DataObject) User(org.prebid.mobile.rendering.models.openrtb.bidRequests.User) JSONObject(org.json.JSONObject) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) JSONArray(org.json.JSONArray) BasicParameterBuilder(org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder) Test(org.junit.Test)

Aggregations

JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1 Test (org.junit.Test)1 DataObject (org.prebid.mobile.DataObject)1 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)1 User (org.prebid.mobile.rendering.models.openrtb.bidRequests.User)1 BasicParameterBuilder (org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder)1