Search in sources :

Example 11 with Imp

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

the class BidRequestTest method getJsonObject.

@Test
public void getJsonObject() throws Exception {
    BidRequest bidReq = new BidRequest();
    App app = new App();
    app.id = "auid";
    bidReq.setApp(app);
    Device device = new Device();
    device.h = 1111;
    bidReq.setDevice(device);
    Imp imp = new Imp();
    imp.instl = 0;
    ArrayList<Imp> imps = new ArrayList<>();
    imps.add(imp);
    bidReq.setImp(imps);
    Regs regs = new Regs();
    regs.coppa = 0;
    bidReq.setRegs(regs);
    User user = new User();
    user.keywords = "q, o";
    bidReq.setUser(user);
    JSONObject actualObj = bidReq.getJsonObject();
    String expectedString = "{\"app\":{\"id\":\"auid\"},\"regs\":{\"coppa\":0},\"imp\":[{\"instl\":0}],\"device\":{\"h\":1111},\"user\":{\"keywords\":\"q, o\"}}";
    assertEquals("got: " + actualObj.toString(), expectedString, actualObj.toString());
    bidReq.getJsonObject();
}
Also used : App(org.prebid.mobile.rendering.models.openrtb.bidRequests.App) User(org.prebid.mobile.rendering.models.openrtb.bidRequests.User) JSONObject(org.json.JSONObject) Device(org.prebid.mobile.rendering.models.openrtb.bidRequests.Device) ArrayList(java.util.ArrayList) Regs(org.prebid.mobile.rendering.models.openrtb.bidRequests.Regs) Imp(org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp) Test(org.junit.Test)

Example 12 with Imp

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

the class BasicParameterBuilderTest method whenAppendParametersAndUseExternalBrowserFalseAndBrowserActivityAvailable_ClickBrowserEqualsZero.

@Test
public void whenAppendParametersAndUseExternalBrowserFalseAndBrowserActivityAvailable_ClickBrowserEqualsZero() {
    AdConfiguration adConfiguration = new AdConfiguration();
    adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
    adConfiguration.addSize(new AdSize(320, 50));
    PrebidRenderingSettings.useExternalBrowser = false;
    BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), mBrowserActivityAvailable);
    AdRequestInput adRequestInput = new AdRequestInput();
    builder.appendBuilderParameters(adRequestInput);
    Imp actualImp = adRequestInput.getBidRequest().getImp().get(0);
    assertEquals(0, actualImp.clickBrowser.intValue());
}
Also used : AdSize(org.prebid.mobile.rendering.bidding.data.AdSize) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) BasicParameterBuilder(org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder) Imp(org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp) Test(org.junit.Test)

Example 13 with Imp

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

the class BasicParameterBuilderTest method whenAppendParametersAndBInterstitialType_ImpWithValidBannerObject.

@Test
public void whenAppendParametersAndBInterstitialType_ImpWithValidBannerObject() throws JSONException {
    AdConfiguration adConfiguration = new AdConfiguration();
    adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.INTERSTITIAL);
    adConfiguration.setAdPosition(AdPosition.FULLSCREEN);
    BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), mBrowserActivityAvailable);
    AdRequestInput adRequestInput = new AdRequestInput();
    builder.appendBuilderParameters(adRequestInput);
    BidRequest actualBidRequest = adRequestInput.getBidRequest();
    BidRequest expectedBidRequest = getExpectedBidRequest(adConfiguration, actualBidRequest.getId());
    assertEquals(expectedBidRequest.getJsonObject().toString(), actualBidRequest.getJsonObject().toString());
    Imp actualImp = actualBidRequest.getImp().get(0);
    assertNotNull(actualImp.banner);
    Format expectedFormat = new Format(1920, 1080);
    assertTrue(actualImp.banner.getFormats().contains(expectedFormat));
    assertNull(actualImp.video);
    assertEquals(1, actualImp.secure.intValue());
    assertEquals(1, actualImp.instl.intValue());
}
Also used : Format(org.prebid.mobile.rendering.models.openrtb.bidRequests.imps.pmps.Format) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) BasicParameterBuilder(org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder) Imp(org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Aggregations

Imp (org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp)13 Test (org.junit.Test)9 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)8 BasicParameterBuilder (org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder)8 AdSize (org.prebid.mobile.rendering.bidding.data.AdSize)6 BidRequest (org.prebid.mobile.rendering.models.openrtb.BidRequest)5 JSONObject (org.json.JSONObject)3 ArrayList (java.util.ArrayList)1 JSONArray (org.json.JSONArray)1 App (org.prebid.mobile.rendering.models.openrtb.bidRequests.App)1 Device (org.prebid.mobile.rendering.models.openrtb.bidRequests.Device)1 Regs (org.prebid.mobile.rendering.models.openrtb.bidRequests.Regs)1 User (org.prebid.mobile.rendering.models.openrtb.bidRequests.User)1 Format (org.prebid.mobile.rendering.models.openrtb.bidRequests.imps.pmps.Format)1 Source (org.prebid.mobile.rendering.models.openrtb.bidRequests.source.Source)1