use of org.prebid.mobile.rendering.models.CreativeModel in project prebid-mobile-android by prebid.
the class TransactionTest method testTransactionInit.
@Test
public void testTransactionInit() throws Exception {
List<CreativeModel> creativeModels = new ArrayList<>();
CreativeModel mockCreativeModel = mock(CreativeModel.class);
creativeModels.add(mockCreativeModel);
Transaction.Listener mockOxTransactionListener = mock(Transaction.Listener.class);
// Valid
InterstitialManager mockInterstitialManager = mock(InterstitialManager.class);
Transaction transaction = Transaction.createTransaction(mMockContext, createModelResult(creativeModels, "ts"), mockInterstitialManager, mockOxTransactionListener);
assertNotNull(transaction);
// No context
boolean hasException = false;
try {
Transaction.createTransaction(null, createModelResult(creativeModels, "ts"), mockInterstitialManager, mockOxTransactionListener);
} catch (AdException e) {
hasException = true;
}
assertTrue(hasException);
// No creative models
hasException = false;
try {
Transaction.createTransaction(mMockContext, createModelResult(null, "ts"), mockInterstitialManager, mockOxTransactionListener);
} catch (AdException e) {
hasException = true;
}
assertTrue(hasException);
// Empty creative models
hasException = false;
try {
Transaction.createTransaction(mMockContext, createModelResult(new ArrayList<>(), "ts"), mockInterstitialManager, mockOxTransactionListener);
} catch (AdException e) {
hasException = true;
}
assertTrue(hasException);
// No listener
hasException = false;
try {
Transaction.createTransaction(mMockContext, createModelResult(creativeModels, "ts"), mockInterstitialManager, null);
} catch (AdException e) {
hasException = true;
}
assertTrue(hasException);
}
use of org.prebid.mobile.rendering.models.CreativeModel in project prebid-mobile-android by prebid.
the class TransactionTest method testStartCreativeFactories.
// Tests that CreativeFactory is started
@Test
public void testStartCreativeFactories() throws Exception {
CreativeModel mockCreativeModel = mock(CreativeModel.class);
List<CreativeModel> creativeModels = new ArrayList<>();
creativeModels.add(mockCreativeModel);
Transaction.Listener mockOxTransactionListener = mock(Transaction.Listener.class);
final Transaction transaction = Transaction.createTransaction(mMockContext, createModelResult(creativeModels, "ts"), mock(InterstitialManager.class), mockOxTransactionListener);
transaction.startCreativeFactories();
verify(mockOxTransactionListener).onTransactionFailure(any(AdException.class), anyString());
}
use of org.prebid.mobile.rendering.models.CreativeModel in project prebid-mobile-android by prebid.
the class PrebidWebViewBannerTest method initTwoPartAndLoadTest.
@Test
public void initTwoPartAndLoadTest() throws IOException {
mBanner.mCreative = mock(HTMLCreative.class);
CreativeModel mockModel = mock(CreativeModel.class);
when(mockModel.getHtml()).thenReturn(ResourceUtils.convertResourceToString("ad_contains_iframe"));
when(mBanner.mCreative.getCreativeModel()).thenReturn(mockModel);
mBanner.initTwoPartAndLoad(mAdHTML);
assertNotNull(mBanner.mMraidWebView);
assertEquals("twopart", mBanner.mMraidWebView.mMRAIDBridgeName);
}
use of org.prebid.mobile.rendering.models.CreativeModel in project prebid-mobile-android by prebid.
the class PrebidWebViewInterstitialTest method loadHTMLTest.
@Test
public void loadHTMLTest() throws IOException {
mPrebidWebViewInterstitial.mCreative = mock(HTMLCreative.class);
CreativeModel mockModel = mock(CreativeModel.class);
when(mPrebidWebViewInterstitial.mCreative.getCreativeModel()).thenReturn(mockModel);
when(mockModel.getHtml()).thenReturn(ResourceUtils.convertResourceToString("ad_contains_iframe"));
when(mockModel.getAdConfiguration()).thenReturn(new AdConfiguration());
mPrebidWebViewInterstitial.loadHTML(mAdHTML, 100, 200);
assertNotNull(mPrebidWebViewInterstitial.mWebView);
assertEquals("WebViewInterstitial", mPrebidWebViewInterstitial.mWebView.mMRAIDBridgeName);
}
use of org.prebid.mobile.rendering.models.CreativeModel in project prebid-mobile-android by prebid.
the class TransactionTest method onSuccessWithCreativeTimeout_TransactionListenerSuccessNotCalled.
@Test
public void onSuccessWithCreativeTimeout_TransactionListenerSuccessNotCalled() throws Exception {
List<CreativeModel> creativeModels = Arrays.asList(mock(CreativeModel.class), mock(CreativeModel.class));
Transaction.Listener mockListener = mock(Transaction.Listener.class);
InterstitialManager mockInterstitialManager = mock(InterstitialManager.class);
Transaction transaction = Transaction.createTransaction(mMockContext, createModelResult(creativeModels, ""), mockInterstitialManager, mockListener);
Transaction.CreativeFactoryListener creativeFactoryListener = new Transaction.CreativeFactoryListener(transaction);
Iterator<CreativeFactory> mockIterator = mock(Iterator.class);
when(mockIterator.hasNext()).thenReturn(true);
when(mockIterator.next()).thenReturn(mock(CreativeFactory.class));
WhiteBox.setInternalState(transaction, "mCreativeFactoryIterator", mockIterator);
creativeFactoryListener.onSuccess();
verify(mockListener, never()).onTransactionSuccess(transaction);
AdException adException = new AdException(AdException.INTERNAL_ERROR, "CreativeFactory Timeout");
creativeFactoryListener.onFailure(adException);
verify(mockListener).onTransactionFailure(eq(adException), anyString());
}
Aggregations