001package com.thed.zblast.util; 002 003import com.thed.model.AutomationJobDetail; 004import com.thed.model.AutomationJobReport; 005import com.thed.model.ZephyrConfigModel; 006import com.thed.util.ZeeConstants; 007import com.thed.util.ZephyrTestCaseUploader; 008import com.thed.zblast.parser.model.TCRCatalogTreeTestcase; 009 010import java.io.IOException; 011import java.util.Date; 012import java.util.List; 013import java.util.concurrent.Callable; 014import java.util.logging.Logger; 015 016public class ResultPoster implements Callable<AutomationJobReport> { 017 private Logger logger = Logger.getLogger(this.getClass().getName()); 018 private AutomationJobDetail automationJob; 019 private Long userId; 020 private List<TCRCatalogTreeTestcase> testcases; 021 private ZephyrConfigModel zephyrData; 022 private AutomationJobReport jobReport; 023 024 public ResultPoster(AutomationJobDetail automationJob, Long userId, List<TCRCatalogTreeTestcase> testcases, ZephyrConfigModel zephyrData, 025 AutomationJobReport jobReport) { 026 super(); 027 this.automationJob = automationJob; 028 this.userId= userId; 029 this.testcases=testcases; 030 this.zephyrData=zephyrData; 031 this.jobReport=jobReport; 032 } 033 034 @Override 035 public AutomationJobReport call() throws Exception { 036 try { 037 ZephyrTestCaseUploader uploader=new ZephyrTestCaseUploader(); 038 String status = ""; 039 Long scheduleId=0l; 040 if(automationJob.getFromFileWatcher()) { 041 scheduleId = automationJob.getId(); 042 }else { 043 scheduleId = automationJob.getScheduleId(); 044 } 045 046 ZephyrConfigModel zephyrConfigModel = uploader.publishcyclesandExecutions(testcases,automationJob, userId,zephyrData); 047 048 if (zephyrConfigModel != null && automationJob.getCycleId() != 0) { 049 zephyrConfigModel.setCycleId(automationJob.getCycleId()); 050 status = ZeeConstants.ZBLAST_JOB_STATUS_COMPLETE; 051 } 052 else { 053 status = ZeeConstants.ZBLAST_JOB_STATUS_ERROR; 054 } 055 RestUtil.updateStatus(scheduleId,status,automationJob,zephyrConfigModel.getCycleId()); 056 jobReport.setJobEndDate(new Date()); 057 jobReport.setJobStatus(status); 058 } catch (IOException e) { 059 logger.severe("Error while posting executions of automaiton job "+e.getMessage()); 060 throw new Exception(e); 061 } 062 return jobReport; 063 } 064}