use of org.prebid.mobile.rendering.errors.VastParseError in project prebid-mobile-android by prebid.
the class VastParserExtractor method performVastUnwrap.
private void performVastUnwrap(String vast) {
if (!vast.contains("VAST version")) {
final AdException adException = new AdException(AdException.INTERNAL_ERROR, VASTErrorCodes.VAST_SCHEMA_ERROR.toString());
mListener.onResult(createExtractorFailureResult(adException));
return;
}
mVastWrapperCount++;
// A new response has come back, either from the initial VAST request or a wrapper request.
// Parse the response.
AdResponseParserVast adResponseParserVast;
try {
adResponseParserVast = new AdResponseParserVast(vast);
} catch (VastParseError e) {
LogUtil.error(TAG, "AdResponseParserVast creation failed: " + Log.getStackTraceString(e));
final AdException adException = new AdException(AdException.INTERNAL_ERROR, e.getMessage());
mListener.onResult(createExtractorFailureResult(adException));
return;
}
// Check if this is the response from the initial request or from unwrapping a wrapper
if (mRootVastParser == null) {
// If mRootVastParser doesn't exist then it is the initial VAST request
LogUtil.debug(TAG, "Initial VAST Request");
mRootVastParser = adResponseParserVast;
} else {
// Otherwise, this is the result of unwrapping a Wrapper.
LogUtil.debug(TAG, "Unwrapping VAST Wrapper");
mLatestVastWrapperParser.setWrapper(adResponseParserVast);
}
mLatestVastWrapperParser = adResponseParserVast;
// Check if this response is a wrapper
String vastUrl = mLatestVastWrapperParser.getVastUrl();
if (!TextUtils.isEmpty(vastUrl)) {
if (mVastWrapperCount >= WRAPPER_NESTING_LIMIT) {
final AdException adException = new AdException(AdException.INTERNAL_ERROR, VASTErrorCodes.WRAPPER_LIMIT_REACH_ERROR.toString());
final VastExtractorResult extractorFailureResult = createExtractorFailureResult(adException);
mListener.onResult(extractorFailureResult);
mVastWrapperCount = 0;
return;
}
mAsyncVastLoader.loadVast(vastUrl, mResponseHandler);
} else {
final AdResponseParserBase[] parserArray = { mRootVastParser, mLatestVastWrapperParser };
mListener.onResult(new VastExtractorResult(parserArray));
}
}
use of org.prebid.mobile.rendering.errors.VastParseError in project prebid-mobile-android by prebid.
the class AdResponseParserVastTest method testWrongVastThrowError.
@Test
public void testWrongVastThrowError() throws IOException {
String wrongvast = ResourceUtils.convertResourceToString(WRONG_VAST);
AdResponseParserVastHelper vast = null;
VastParseError error = null;
try {
vast = new AdResponseParserVastHelper(wrongvast);
} catch (VastParseError vastParseError) {
vastParseError.printStackTrace();
error = vastParseError;
}
assertNotNull("Syntax error for inline->impressoin", error);
assertTrue(error instanceof VastParseError);
assertNull(vast);
}
use of org.prebid.mobile.rendering.errors.VastParseError in project prebid-mobile-android by prebid.
the class AdResponseParserVastTest method testVastWithNoVersion.
@Test
public void testVastWithNoVersion() {
String vast = "<VAST > </VAST>";
AdResponseParserVastHelper vastParserHelper = null;
VastParseError error = null;
try {
vastParserHelper = new AdResponseParserVastHelper(vast);
} catch (VastParseError vastParseError) {
vastParseError.printStackTrace();
error = vastParseError;
}
assertNull(vastParserHelper.getVast().getVersion());
assertNull(error);
}
use of org.prebid.mobile.rendering.errors.VastParseError in project prebid-mobile-android by prebid.
the class AdResponseParserVastTest method testVastWithNoAd.
@Test
public void testVastWithNoAd() throws IOException {
String vast_noad = ResourceUtils.convertResourceToString(WRONG_VAST_WITH_NO_AD);
AdResponseParserVastHelper vastParserHelper = null;
VastParseError error = null;
try {
vastParserHelper = new AdResponseParserVastHelper(vast_noad);
} catch (VastParseError vastParseError) {
vastParseError.printStackTrace();
error = vastParseError;
}
assertNull(vastParserHelper.getVast().getAds());
assertNull(error);
}
Aggregations