use of org.prebid.mobile.rendering.video.vast.InLine in project prebid-mobile-android by prebid.
the class AdResponseParserVastTest method testGetCompanionAd.
@Test
public void testGetCompanionAd() {
InLine mockInLine;
ArrayList<Companion> companions;
Companion mockCompanionA;
Companion mockCompanionB;
Companion result;
// Null creatives
mockInLine = setupInLine();
mockInLine.setCreatives(null);
result = AdResponseParserVast.getCompanionAd(mockInLine);
assertNull(result);
// Empty creatives list
mockInLine = setupInLine();
mockInLine.setCreatives(new ArrayList<>());
result = AdResponseParserVast.getCompanionAd(mockInLine);
assertNull(result);
// Empty companion ad list
mockInLine = setupInLine();
mockInLine.getCreatives().get(0).setCompanionAds(new ArrayList<>());
result = AdResponseParserVast.getCompanionAd(mockInLine);
assertNull(result);
// One companion
mockInLine = setupInLine();
companions = mockInLine.getCreatives().get(0).getCompanionAds();
mockCompanionA = mock(Companion.class);
companions.add(mockCompanionA);
result = AdResponseParserVast.getCompanionAd(mockInLine);
assertEquals(mockCompanionA, result);
// Companion B format better than Companion A format
mockInLine = setupInLine();
companions = mockInLine.getCreatives().get(0).getCompanionAds();
mockCompanionA = mock(Companion.class);
when(mockCompanionA.getWidth()).thenReturn("2");
when(mockCompanionA.getHeight()).thenReturn("2");
when(mockCompanionA.getStaticResource()).thenReturn(mock(StaticResource.class));
companions.add(mockCompanionA);
mockCompanionB = mock(Companion.class);
when(mockCompanionB.getWidth()).thenReturn("1");
when(mockCompanionB.getHeight()).thenReturn("1");
when(mockCompanionB.getHtmlResource()).thenReturn(mock(HTMLResource.class));
companions.add(mockCompanionB);
result = AdResponseParserVast.getCompanionAd(mockInLine);
assertEquals(mockCompanionB, result);
// Same format for Companion A & B, but B has better resolution
mockInLine = setupInLine();
companions = mockInLine.getCreatives().get(0).getCompanionAds();
mockCompanionA = mock(Companion.class);
when(mockCompanionA.getWidth()).thenReturn("1");
when(mockCompanionA.getHeight()).thenReturn("1");
when(mockCompanionA.getStaticResource()).thenReturn(mock(StaticResource.class));
companions.add(mockCompanionA);
mockCompanionB = mock(Companion.class);
when(mockCompanionB.getWidth()).thenReturn("2");
when(mockCompanionB.getHeight()).thenReturn("2");
when(mockCompanionB.getStaticResource()).thenReturn(mock(StaticResource.class));
companions.add(mockCompanionB);
result = AdResponseParserVast.getCompanionAd(mockInLine);
assertEquals(mockCompanionB, result);
}
use of org.prebid.mobile.rendering.video.vast.InLine in project prebid-mobile-android by prebid.
the class AdResponseParserVastTest method setupInLine.
private InLine setupInLine() {
InLine mockInLine = mock(InLine.class);
mockInLine.setCreatives(new ArrayList<>());
Creative mockCreative = mock(Creative.class);
when(mockCreative.getCompanionAds()).thenReturn(new ArrayList<>());
ArrayList<Creative> creatives = new ArrayList<>();
creatives.add(mockCreative);
when(mockInLine.getCreatives()).thenReturn(creatives);
return mockInLine;
}
Aggregations