Search in sources :

Example 1 with SubmittedResult

use of com.qasymphony.ci.plugin.model.SubmittedResult in project jenkin-qtest-plugin by QASymphony.

the class StoreResultServiceTests method testStore.

@LocalData
@Test
public void testStore() throws Exception {
    project.scheduleBuild2(0).get(1, TimeUnit.MINUTES);
    int currentBuild = project.getNextBuildNumber() - 1;
    SubmittedResult result = new SubmittedResult().setSubmitStatus(JunitSubmitterResult.STATUS_SUCCESS).setTestSuiteName(project.getName()).setNumberTestResult(0).setNumberTestLog(0).setBuildNumber(currentBuild).setStatusBuild("SUCCESS");
    storeResultService.store(project, result);
    Map<Integer, SubmittedResult> resMap = storeResultService.fetchAll(new ReadSubmitLogRequest().setProject(project)).getResults();
    assertEquals("Result size is: ", 1, resMap.size());
    SubmittedResult submittedResult = resMap.get(1);
    assertNotNull("submittedResult is ", submittedResult);
    assertEquals("Build number is: ", result.getBuildNumber(), submittedResult.getBuildNumber());
    assertEquals("Status build is: ", result.getStatusBuild(), submittedResult.getStatusBuild());
    assertEquals("TestSuite name is: ", result.getTestSuiteName(), submittedResult.getTestSuiteName());
    assertEquals("Submit status is: ", result.getSubmitStatus(), submittedResult.getSubmitStatus());
    assertEquals("Number of testCase is: ", result.getNumberTestResult(), submittedResult.getNumberTestResult());
    assertEquals("Number of testLog is: ", result.getNumberTestLog(), submittedResult.getNumberTestLog());
}
Also used : SubmittedResult(com.qasymphony.ci.plugin.model.SubmittedResult) LocalData(org.jvnet.hudson.test.recipes.LocalData) Test(org.junit.Test)

Example 2 with SubmittedResult

use of com.qasymphony.ci.plugin.model.SubmittedResult in project jenkin-qtest-plugin by QASymphony.

the class StoreResultServiceImpl method fetchAll.

@Override
public ReadSubmitLogResult fetchAll(ReadSubmitLogRequest request) throws StoreResultException {
    FilePath resultPath = JobUtils.isPipelineJob(request.getJob()) == false ? getResultFolder(request.getProject()) : getResultFolder(request.getJob());
    Map<Integer, SubmittedResult> buildResults = new HashMap<>();
    int numOrder = request.getCurrentBuildNumber() / BREAK_FILE_BY;
    // get saved configuration
    Configuration configuration = null;
    if (JobUtils.isFreeStyleProjectJob(request.getProject()) == true) {
        configuration = ConfigService.getPluginConfiguration(request.getProject());
    }
    String qTestUrl = configuration == null ? "" : configuration.getUrl();
    Long projectId = configuration == null ? 0L : configuration.getProjectId();
    try {
        if (numOrder <= 0) {
            FilePath resultFile = getResultFile(resultPath, numOrder);
            buildResults.putAll(readResult(resultFile, qTestUrl, projectId));
        } else {
            for (int i = 0; i < numOrder; i++) {
                FilePath resultFile = getResultFile(resultPath, i);
                buildResults.putAll(readResult(resultFile, qTestUrl, projectId));
            }
        }
    } catch (Exception e) {
        throw new StoreResultException(e);
    }
    return new ReadSubmitLogResult().setResults(buildResults).setTotal(buildResults.size());
}
Also used : FilePath(hudson.FilePath) SubmittedResult(com.qasymphony.ci.plugin.model.SubmittedResult) Configuration(com.qasymphony.ci.plugin.model.Configuration) StoreResultException(com.qasymphony.ci.plugin.exception.StoreResultException) IOException(java.io.IOException) StoreResultException(com.qasymphony.ci.plugin.exception.StoreResultException)

Example 3 with SubmittedResult

use of com.qasymphony.ci.plugin.model.SubmittedResult in project jenkin-qtest-plugin by QASymphony.

the class StoreResultServiceImpl method fetch.

@Override
public ReadSubmitLogResult fetch(ReadSubmitLogRequest request) throws StoreResultException {
    FilePath resultPath = getResultFolder(request.getProject());
    int numOrder = request.getCurrentBuildNumber() / BREAK_FILE_BY;
    List<FileReader> readerList = getReaderList(resultPath, numOrder);
    // get saved configuration
    Configuration configuration = ConfigService.getPluginConfiguration(request.getProject());
    String qTestUrl = configuration == null ? "" : configuration.getUrl();
    Long projectId = configuration == null ? 0L : configuration.getProjectId();
    int total = 0;
    Map<Integer, SubmittedResult> resultMap = new HashMap<>();
    for (FileReader reader : readerList) {
        total += reader.size();
        try {
            resultMap.putAll(buildSubmittedResult(reader.readAll(), qTestUrl, projectId));
        } catch (IOException e) {
            throw new StoreResultException(e.getMessage(), e);
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                throw new StoreResultException(e.getMessage(), e);
            }
        }
    }
    return new ReadSubmitLogResult().setTotal(total).setResults(resultMap);
}
Also used : FilePath(hudson.FilePath) SubmittedResult(com.qasymphony.ci.plugin.model.SubmittedResult) Configuration(com.qasymphony.ci.plugin.model.Configuration) StoreResultException(com.qasymphony.ci.plugin.exception.StoreResultException) IOException(java.io.IOException) FileReader(com.qasymphony.ci.plugin.store.file.FileReader)

Example 4 with SubmittedResult

use of com.qasymphony.ci.plugin.model.SubmittedResult in project jenkin-qtest-plugin by QASymphony.

the class JunitQtestSubmitterImpl method storeSubmittedResult.

@Override
public SubmittedResult storeSubmittedResult(JunitSubmitterRequest junitSubmitterRequest, Run build, String buildResult, JunitSubmitterResult result) throws StoreResultException {
    String qTestUrl = junitSubmitterRequest.getqTestURL();
    Long projectId = junitSubmitterRequest.getProjectID();
    SubmittedResult submitResult = new SubmittedResult().setUrl(qTestUrl).setProjectId(projectId).setBuildNumber(build.getNumber()).setStatusBuild(buildResult).setTestSuiteId(result.getTestSuiteId()).setTestSuiteName(result.getTestSuiteName()).setSubmitStatus(result.getSubmittedStatus()).setNumberTestLog(result.getNumberOfTestLog()).setNumberTestResult(result.getNumberOfTestResult());
    try {
        storeResultService.store(build.getParent(), submitResult);
        return submitResult;
    } catch (Exception e) {
        LOG.log(Level.WARNING, e.getMessage(), e);
        throw new StoreResultException("Cannot store result." + e.getMessage(), e);
    }
}
Also used : SubmittedResult(com.qasymphony.ci.plugin.model.SubmittedResult) StoreResultException(com.qasymphony.ci.plugin.exception.StoreResultException) ClientRequestException(com.qasymphony.ci.plugin.utils.ClientRequestException) StoreResultException(com.qasymphony.ci.plugin.exception.StoreResultException) SubmittedException(com.qasymphony.ci.plugin.exception.SubmittedException)

Example 5 with SubmittedResult

use of com.qasymphony.ci.plugin.model.SubmittedResult in project jenkin-qtest-plugin by QASymphony.

the class PipelineStatisticsAction method getTreeResult.

/**
 * use to get result in qTest Plugin page
 *
 * @param page page submitted result
 * @return submitted result data
 */
@JavaScriptMethod
public JSONObject getTreeResult(int page) {
    Map<Integer, SubmittedResult> results = null;
    try {
        Job job = this.getJob();
        results = storeResultService.fetchAll(new ReadSubmitLogRequest().setJob(job).setStart(0).setSize(-1)).getResults();
    } catch (Exception e) {
        LOG.log(Level.WARNING, e.getMessage());
    }
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("data", null == results ? "" : results.values());
    return jsonObject;
}
Also used : SubmittedResult(com.qasymphony.ci.plugin.model.SubmittedResult) JSONObject(net.sf.json.JSONObject) ReadSubmitLogRequest(com.qasymphony.ci.plugin.store.ReadSubmitLogRequest) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) Job(hudson.model.Job) JavaScriptMethod(org.kohsuke.stapler.bind.JavaScriptMethod)

Aggregations

SubmittedResult (com.qasymphony.ci.plugin.model.SubmittedResult)7 StoreResultException (com.qasymphony.ci.plugin.exception.StoreResultException)3 Configuration (com.qasymphony.ci.plugin.model.Configuration)2 ReadSubmitLogRequest (com.qasymphony.ci.plugin.store.ReadSubmitLogRequest)2 FilePath (hudson.FilePath)2 IOException (java.io.IOException)2 JSONObject (net.sf.json.JSONObject)2 Test (org.junit.Test)2 LocalData (org.jvnet.hudson.test.recipes.LocalData)2 JavaScriptMethod (org.kohsuke.stapler.bind.JavaScriptMethod)2 SubmittedException (com.qasymphony.ci.plugin.exception.SubmittedException)1 FileReader (com.qasymphony.ci.plugin.store.file.FileReader)1 ClientRequestException (com.qasymphony.ci.plugin.utils.ClientRequestException)1 AbstractProject (hudson.model.AbstractProject)1 Job (hudson.model.Job)1 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)1