Search in sources :

Example 16 with Bid

use of org.prebid.mobile.rendering.bidding.data.bid.Bid in project prebid-mobile-android by prebid.

the class MacrosResolutionHelperTest method resolveAuctionMacros_MultipleMatch_LocatedMacrosAreReplaced.

@Test
public void resolveAuctionMacros_MultipleMatch_LocatedMacrosAreReplaced() throws IOException, JSONException {
    String actualResponseWithMacros = ResourceUtils.convertResourceToString("native_bid_response_macros.json");
    String expectedResponseWithMacros = ResourceUtils.convertResourceToString("native_bid_response_macros_expected.json");
    Map<String, MacrosModel> macrosModelMap = new HashMap<>();
    Bid bid = Bid.fromJSONObject(new JSONObject(actualResponseWithMacros));
    String id = bid.getId();
    String price = String.valueOf(bid.getPrice());
    String base64Price = Base64.getEncoder().encodeToString(price.getBytes());
    macrosModelMap.put(MACROS_AUCTION_BID_ID, new MacrosModel(id));
    macrosModelMap.put(MacrosModel.MACROS_AUCTION_PRICE, new MacrosModel(price));
    macrosModelMap.put(MacrosModel.MACROS_AUCTION_PRICE_BASE_64, new MacrosModel(base64Price));
    String macrosAfterResolution = MacrosResolutionHelper.resolveAuctionMacros(actualResponseWithMacros, macrosModelMap);
    assertEquals(expectedResponseWithMacros, macrosAfterResolution);
}
Also used : JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) Bid(org.prebid.mobile.rendering.bidding.data.bid.Bid) MacrosModel(org.prebid.mobile.rendering.models.internal.MacrosModel) Test(org.junit.Test)

Example 17 with Bid

use of org.prebid.mobile.rendering.bidding.data.bid.Bid in project prebid-mobile-android by prebid.

the class CreativeModelMakerBids method parseAcj.

private void parseAcj(AdConfiguration adConfiguration, BidResponse bidResponse) {
    CreativeModelsMaker.Result result = new CreativeModelsMaker.Result();
    result.creativeModels = new ArrayList<>();
    Bid bid = bidResponse.getWinningBid();
    String adHtml = getAdHtml(adConfiguration, bid);
    CreativeModel model = new CreativeModel(TrackingManager.getInstance(), new OmEventTracker(), adConfiguration);
    model.setName("HTML");
    model.setHtml(adHtml);
    model.setWidth(bid != null ? bid.getWidth() : 0);
    model.setHeight(bid != null ? bid.getHeight() : 0);
    model.setRequireImpressionUrl(false);
    adConfiguration.setInterstitialSize(model.getWidth(), model.getHeight());
    result.creativeModels.add(model);
    result.transactionState = "bid";
    mListener.onCreativeModelReady(result);
}
Also used : OmEventTracker(org.prebid.mobile.rendering.video.OmEventTracker) Bid(org.prebid.mobile.rendering.bidding.data.bid.Bid) VastExtractorResult(org.prebid.mobile.rendering.models.internal.VastExtractorResult)

Aggregations

Bid (org.prebid.mobile.rendering.bidding.data.bid.Bid)17 Test (org.junit.Test)14 BidResponse (org.prebid.mobile.rendering.bidding.data.bid.BidResponse)11 BidRequesterListener (org.prebid.mobile.rendering.bidding.listeners.BidRequesterListener)5 AdException (org.prebid.mobile.rendering.errors.AdException)4 Prebid (org.prebid.mobile.rendering.bidding.data.bid.Prebid)3 Before (org.junit.Before)2 InterstitialController (org.prebid.mobile.rendering.bidding.display.InterstitialController)2 BannerEventListener (org.prebid.mobile.rendering.bidding.listeners.BannerEventListener)2 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)2 Activity (android.app.Activity)1 Context (android.content.Context)1 HashMap (java.util.HashMap)1 JSONObject (org.json.JSONObject)1 InterstitialEventListener (org.prebid.mobile.rendering.bidding.listeners.InterstitialEventListener)1 RewardedVideoEventListener (org.prebid.mobile.rendering.bidding.listeners.RewardedVideoEventListener)1 MacrosModel (org.prebid.mobile.rendering.models.internal.MacrosModel)1 VastExtractorResult (org.prebid.mobile.rendering.models.internal.VastExtractorResult)1 OmEventTracker (org.prebid.mobile.rendering.video.OmEventTracker)1