private void mockDownloadReports(final int numberOfFiles) throws InterruptedException, ValidationException {
Mockito.doAnswer(new Answer<Collection<File>>() {
@Override
public Collection<File> answer(InvocationOnMock invocation) throws Throwable {
ReportDefinitionReportType reportType =
((ReportDefinition) invocation.getArguments()[1]).getReportType();
// returns the appropriate gZip files depending on the report type
if (reportType.equals(ReportDefinitionReportType.ACCOUNT_PERFORMANCE_REPORT)) {
return getReportFiles(
"reportDownload-ACCOUNT_PERFORMANCE_REPORT-2602198216-1370030134500.report",
numberOfFiles);
}
if (reportType.equals(ReportDefinitionReportType.AD_EXTENSIONS_PERFORMANCE_REPORT)) {
return getReportFiles(
"reportDownload-AD_EXTENSIONS_PERFORMANCE_REPORT-2602198216-1370029629538.report",
numberOfFiles);
}
if (reportType.equals(ReportDefinitionReportType.ADGROUP_PERFORMANCE_REPORT)) {
return getReportFiles(
"reportDownload-ADGROUP_PERFORMANCE_REPORT-2450945640-1370030054471.report",
numberOfFiles);
}
if (reportType.equals(ReportDefinitionReportType.AD_PERFORMANCE_REPORT)) {
return getReportFiles(
"reportDownload-AD_PERFORMANCE_REPORT-1001270004-1369848354724.report",
numberOfFiles);
}
if (reportType.equals(
ReportDefinitionReportType.CAMPAIGN_NEGATIVE_KEYWORDS_PERFORMANCE_REPORT)) {
return getReportFiles("reportDownload-CAMPAIGN_NEGATIVE_KEYWORDS_PERFORMANCE_REPORT"
+ "-2602198216-1370029913872.report", numberOfFiles);
}
if (reportType.equals(ReportDefinitionReportType.CAMPAIGN_PERFORMANCE_REPORT)) {
return getReportFiles(
"reportDownload-CAMPAIGN_PERFORMANCE_REPORT-1252422563-1370029981335.report",
numberOfFiles);
}
if (reportType.equals(ReportDefinitionReportType.KEYWORDS_PERFORMANCE_REPORT)) {
return getReportFiles(
"reportDownload-KEYWORDS_PERFORMANCE_REPORT-8661954824-1370029730794.report",
numberOfFiles);
}
if (reportType.equals(ReportDefinitionReportType.PLACEHOLDER_FEED_ITEM_REPORT)) {
return getReportFiles(
"reportDownload-PLACEHOLDER_FEED_ITEM_REPORT-128401167-1378740342878.report",
numberOfFiles);
}
if (reportType.equals(ReportDefinitionReportType.CRITERIA_PERFORMANCE_REPORT)) {
return getReportFiles(
"reportDownload-CRITERIA_PERFORMANCE_REPORT-2752283680-1378903912127.report",
numberOfFiles);
}
if (reportType.equals(ReportDefinitionReportType.SEARCH_QUERY_PERFORMANCE_REPORT)) {
return getReportFiles(
"reportDownload-SEARCH_QUERY_PERFORMANCE_REPORT-2084918008-570857839140990020.report",
numberOfFiles);
}
if (reportType.equals(ReportDefinitionReportType.CAMPAIGN_LOCATION_TARGET_REPORT)) {
return getReportFiles(
"reportDownload-CAMPAIGN_LOCATION_TARGET_REPORT-9250931436-3311462434933679712.report",
numberOfFiles);
}
if (reportType.equals(ReportDefinitionReportType.GEO_PERFORMANCE_REPORT)) {
return getReportFiles(
"reportDownload-GEO_PERFORMANCE_REPORT-2084918008-570857839140990020.report10",
numberOfFiles);
}
if (reportType.equals(ReportDefinitionReportType.PLACEMENT_PERFORMANCE_REPORT)) {
return getReportFiles(
"reportDownload-PLACEMENT_PERFORMANCE_REPORT-501111125-37111114339129.report10",
numberOfFiles);
}
if (reportType.equals(ReportDefinitionReportType.DISPLAY_KEYWORD_PERFORMANCE_REPORT)) {
return getReportFiles(
"reportDownload-DISPLAY_KEYWORD_PERFORMANCE_REPORT-1056270861-4656938936183294408.report",
numberOfFiles);
}
if (reportType.equals(ReportDefinitionReportType.SHOPPING_PERFORMANCE_REPORT)) {
return getReportFiles(
"reportDownload-SHOPPING_PERFORMANCE_REPORT-4159595773-1835647307310030649.report",
numberOfFiles);
}
// Undefined report type on this test
throw (new Exception("Undefined report type on Tests: " + reportType.value()));
}
}).when(mockedMultipleClientReportDownloader).downloadReports(
Mockito.<AdWordsSessionBuilderSynchronizer>anyObject(), Mockito.<ReportDefinition>anyObject(),
Mockito.<Set<Long>>anyObject());
}