@Test public void createIconAsset() { NativeRequest nativeRequest = new NativeRequest.Builder() .setMediaAssetTypes(MediaAssetType.Icon) .build(); UnifiedNativeAdRequestParams nativeAdRequestParams = TestUtils.createUnifiedNativeAdRequestParams( nativeRequest, new TargetingParams(), mock(DataRestrictions.class)); Placement.DisplayPlacement.NativeFormat.AssetFormat assetFormat = NativePlacementBuilder .createIconAsset(nativeAdRequestParams); assertTrue(assetFormat.getReq()); nativeRequest = new NativeRequest.Builder() .setMediaAssetTypes(MediaAssetType.Image) .build(); nativeAdRequestParams = TestUtils.createUnifiedNativeAdRequestParams( nativeRequest, new TargetingParams(), mock(DataRestrictions.class)); assetFormat = NativePlacementBuilder .createIconAsset(nativeAdRequestParams); assertFalse(assetFormat.getReq()); }
@VisibleForTesting static Placement.DisplayPlacement.NativeFormat.AssetFormat createIconAsset(@NonNull UnifiedNativeAdRequestParams adRequestParams) { Placement.DisplayPlacement.NativeFormat.AssetFormat.Builder asset = Placement.DisplayPlacement.NativeFormat.AssetFormat.newBuilder(); asset.setId(ICON_ASSET_ID); asset.setReq(adRequestParams.containsAssetType(MediaAssetType.Icon)); asset.setImg(Placement.DisplayPlacement.NativeFormat.AssetFormat.ImageAssetFormat.newBuilder() .setType(NativeImageAssetType.NATIVE_IMAGE_ASSET_TYPE_ICON_IMAGE) .addAllMime(Arrays.asList(Constants.IMAGE_MIME_TYPES)) .build()); return asset.build(); }
NativePlacementBuilder extends PlacementBuilder<UnifiedNativeAdRequestParams> { @VisibleForTesting static Placement.DisplayPlacement.NativeFormat.AssetFormat createIconAsset(@NonNull UnifiedNativeAdRequestParams adRequestParams) { Placement.DisplayPlacement.NativeFormat.AssetFormat.Builder asset = Placement.DisplayPlacement.NativeFormat.AssetFormat.newBuilder(); asset.setId(ICON_ASSET_ID); asset.setReq(adRequestParams.containsAssetType(MediaAssetType.Icon)); asset.setImg(Placement.DisplayPlacement.NativeFormat.AssetFormat.ImageAssetFormat.newBuilder() .setType(NativeImageAssetType.NATIVE_IMAGE_ASSET_TYPE_ICON_IMAGE) .addAllMime(Arrays.asList(Constants.IMAGE_MIME_TYPES)) .build()); return asset.build(); } }
NativePlacementBuilder extends PlacementBuilder<UnifiedNativeAdRequestParams> { @VisibleForTesting static Placement.DisplayPlacement.NativeFormat.AssetFormat createIconAsset(@NonNull UnifiedNativeAdRequestParams adRequestParams) { Placement.DisplayPlacement.NativeFormat.AssetFormat.Builder asset = Placement.DisplayPlacement.NativeFormat.AssetFormat.newBuilder(); asset.setId(ICON_ASSET_ID); asset.setReq(adRequestParams.containsAssetType(MediaAssetType.Icon)); asset.setImg(Placement.DisplayPlacement.NativeFormat.AssetFormat.ImageAssetFormat.newBuilder() .setType(NativeImageAssetType.NATIVE_IMAGE_ASSET_TYPE_ICON_IMAGE) .addAllMime(Arrays.asList(Constants.IMAGE_MIME_TYPES)) .build()); return asset.build(); } NativePlacementBuilder(boolean supportHeaderBidding); }
NativePlacementBuilder extends PlacementBuilder<UnifiedNativeAdRequestParams> { @VisibleForTesting static Placement.DisplayPlacement.NativeFormat.AssetFormat createIconAsset(@NonNull UnifiedNativeAdRequestParams adRequestParams) { Placement.DisplayPlacement.NativeFormat.AssetFormat.Builder asset = Placement.DisplayPlacement.NativeFormat.AssetFormat.newBuilder(); asset.setId(ICON_ASSET_ID); asset.setReq(adRequestParams.containsAssetType(MediaAssetType.Icon)); asset.setImg(Placement.DisplayPlacement.NativeFormat.AssetFormat.ImageAssetFormat.newBuilder() .setType(NativeImageAssetType.NATIVE_IMAGE_ASSET_TYPE_ICON_IMAGE) .addAllMime(Arrays.asList(Constants.IMAGE_MIME_TYPES)) .build()); return asset.build(); } NativePlacementBuilder(boolean supportHeaderBidding); @Override void createPlacement(@NonNull ContextProvider contextProvider,
                                @NonNull UnifiedNativeAdRequestParams adRequestParams,
                                @NonNull AdsType adsType,
                                @NonNull Collection<NetworkConfig> networkConfigs,
                                @NonNull PlacementCreateCallback callback); @Override AdObjectParams createAdObjectParams(@NonNull ContextProvider contextProvider,
                                               @NonNull UnifiedNativeAdRequestParams adRequest,
                                               @NonNull Response.Seatbid seatbid,
                                               @NonNull Response.Seatbid.Bid bid,
                                               @NonNull Ad ad); }
NativePlacementBuilder extends PlacementBuilder<UnifiedNativeAdRequestParams> { @VisibleForTesting static Placement.DisplayPlacement.NativeFormat.AssetFormat createIconAsset(@NonNull UnifiedNativeAdRequestParams adRequestParams) { Placement.DisplayPlacement.NativeFormat.AssetFormat.Builder asset = Placement.DisplayPlacement.NativeFormat.AssetFormat.newBuilder(); asset.setId(ICON_ASSET_ID); asset.setReq(adRequestParams.containsAssetType(MediaAssetType.Icon)); asset.setImg(Placement.DisplayPlacement.NativeFormat.AssetFormat.ImageAssetFormat.newBuilder() .setType(NativeImageAssetType.NATIVE_IMAGE_ASSET_TYPE_ICON_IMAGE) .addAllMime(Arrays.asList(Constants.IMAGE_MIME_TYPES)) .build()); return asset.build(); } NativePlacementBuilder(boolean supportHeaderBidding); @Override void createPlacement(@NonNull ContextProvider contextProvider,
                                @NonNull UnifiedNativeAdRequestParams adRequestParams,
                                @NonNull AdsType adsType,
                                @NonNull Collection<NetworkConfig> networkConfigs,
                                @NonNull PlacementCreateCallback callback); @Override AdObjectParams createAdObjectParams(@NonNull ContextProvider contextProvider,
                                               @NonNull UnifiedNativeAdRequestParams adRequest,
                                               @NonNull Response.Seatbid seatbid,
                                               @NonNull Response.Seatbid.Bid bid,
                                               @NonNull Ad ad);  }