Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

Commit

Permalink
IMP-110 Change method type return and adjust code
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanBA92 committed Sep 21, 2018
1 parent 3fd4a33 commit 796a7df
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 20 deletions.
@@ -1,7 +1,8 @@
package com.agiletestware.pangolin;

import java.io.Serializable;
import java.util.List;

import com.agiletestware.pangolin.shared.model.testresults.UploadResponse.RunInfo;

import hudson.model.Action;

Expand All @@ -18,8 +19,8 @@ public class PangolinPostBuildAction implements Action, Serializable {
static final String TEST_RAIL_RUN_URL = "Test Rail Run URL";
private final String testRailRunUrl;

public PangolinPostBuildAction(final List<String> runUrls) {
this.testRailRunUrl = runUrls.get(0);
public PangolinPostBuildAction(final RunInfo runInfo) {
this.testRailRunUrl = runInfo.getRunUrl();
}

@Override
Expand Down
Expand Up @@ -36,6 +36,7 @@
import com.agiletestware.pangolin.client.upload.BulkUpdateParameters;
import com.agiletestware.pangolin.encryption.CustomSecret;
import com.agiletestware.pangolin.encryption.DefaultCustomSecret;
import com.agiletestware.pangolin.shared.model.testresults.UploadResponse.RunInfo;
import com.agiletestware.pangolin.util.PangolinUtility;
import com.agiletestware.pangolin.validator.GlobalConfigValidator;

Expand Down Expand Up @@ -211,9 +212,9 @@ private void doBulkUpdate(final GlobalConfig globalConfig, final PangolinConfigu
if (channel == null) {
throw new IllegalStateException("VirtualChannel is null");
}
final List<String> runUrls = channel.call(remoteExecutor);
if (runUrls != null && !runUrls.isEmpty()) {
run.addAction(new PangolinPostBuildAction(runUrls));
final RunInfo runInfo = channel.call(remoteExecutor);
if (runInfo != null) {
run.addAction(new PangolinPostBuildAction(runInfo));
}
}

Expand Down
Expand Up @@ -16,14 +16,14 @@
package com.agiletestware.pangolin;

import java.io.Serializable;
import java.util.List;

import org.jenkinsci.remoting.RoleChecker;

import com.agiletestware.pangolin.client.DefaultPangolinClientFactory;
import com.agiletestware.pangolin.client.PangolinClientFactory;
import com.agiletestware.pangolin.client.upload.BulkUpdateParameters;
import com.agiletestware.pangolin.client.upload.TestResultsUploader;
import com.agiletestware.pangolin.shared.model.testresults.UploadResponse.RunInfo;

import hudson.FilePath;
import hudson.model.TaskListener;
Expand All @@ -34,7 +34,7 @@
*
* @author Sergey Oplavin.
*/
public class PangolinRemoteExecutor implements Callable<List<String>, Exception>, Serializable {
public class PangolinRemoteExecutor implements Callable<RunInfo, Exception>, Serializable {

private static final long serialVersionUID = -8132991309548833113L;
private final JenkinsBuildLogger logger;
Expand Down Expand Up @@ -66,7 +66,7 @@ public PangolinRemoteExecutor(final FilePath workspace,
}

@Override
public List<String> call() throws Exception {
public RunInfo call() throws Exception {
return execute();
}

Expand All @@ -76,7 +76,7 @@ public List<String> call() throws Exception {
* @throws Exception
* the exception
*/
public List<String> execute() throws Exception {
public RunInfo execute() throws Exception {
final DefaultReportFilesProvider reportFilesProvider = new DefaultReportFilesProvider(workspace);
final TestResultsUploader testResultsUploader = new TestResultsUploader(clientFactory, DefaultMessagesProvider.THE_INSTANCE, reportFilesProvider);
return testResultsUploader.upload(parameters, logger);
Expand Down
Expand Up @@ -4,11 +4,9 @@
import static com.agiletestware.pangolin.PangolinPostBuildAction.TEST_RAIL_RUN_URL;
import static org.junit.Assert.assertEquals;

import java.util.List;

import org.junit.Test;

import com.google.common.collect.ImmutableList;
import com.agiletestware.pangolin.shared.model.testresults.UploadResponse.RunInfo;

/**
* Tests for {@link PangolinPostBuildAction}.
Expand All @@ -19,8 +17,7 @@
public class PangolinPostBuildActionTest {

private static final String URL = "url";
private static final List<String> RUN_URLS = ImmutableList.<String> builder().add(URL).add(URL).build();
private final PangolinPostBuildAction pangolinPostBuildAction = new PangolinPostBuildAction(RUN_URLS);
private final PangolinPostBuildAction pangolinPostBuildAction = new PangolinPostBuildAction(new RunInfo(1, URL));

@Test
public void testGetIconFileName() {
Expand Down
Expand Up @@ -28,7 +28,6 @@
import java.io.IOException;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.List;

import org.junit.Before;
import org.junit.Rule;
Expand Down Expand Up @@ -91,10 +90,8 @@ public void executeTest() throws Exception {
final UploadResultsParameters expected1 = new UploadTestReportParameters(params, file1);
final UploadResultsParameters expected2 = new UploadTestReportParameters(params, file2);
expected2.setTestRunId(runId);
final List<String> runUrls = new PangolinRemoteExecutor(new FilePath(tempFolder.getRoot()), params, listener, clientFactory).execute();
assertEquals(2, runUrls.size());
assertEquals("url", runUrls.get(0));
assertEquals("url", runUrls.get(1));
final RunInfo runInfo = new PangolinRemoteExecutor(new FilePath(tempFolder.getRoot()), params, listener, clientFactory).execute();
assertEquals("url", runInfo.getRunUrl());
verify(client).sendResultsToTestrail(eq(expected1), any());
verify(client).sendResultsToTestrail(eq(expected2), any());
verify(log, times(2)).println("Results have been added to run: url");
Expand Down

0 comments on commit 796a7df

Please sign in to comment.