Skip to content

Commit 8e59081

Browse files
authored
Release 5.12.0
2 parents eb1650e + ed8da17 commit 8e59081

File tree

10 files changed

+158
-123
lines changed

10 files changed

+158
-123
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ on:
1111

1212
env:
1313
GH_USER_NAME: github.actor
14-
SCRIPTS_VERSION: 5.10.0
15-
BOM_VERSION: 5.11.0
14+
SCRIPTS_VERSION: 5.12.0
15+
BOM_VERSION: 5.12.1
1616

1717
jobs:
1818
release:

build.gradle

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,20 @@ repositories {
3232

3333
dependencyManagement {
3434
imports {
35-
mavenBom(releaseMode ? 'com.epam.reportportal:commons-bom:' + getProperty('bom.version') : 'com.epam.reportportal:commons-bom:5.11.0')
35+
mavenBom(releaseMode ? 'com.epam.reportportal:commons-bom:' + getProperty('bom.version') : 'com.epam.reportportal:commons-bom:5.12.1')
3636
}
3737
}
3838

3939
dependencies {
4040
if (releaseMode) {
41+
implementation 'com.epam.reportportal:commons-dao'
4142
implementation 'com.epam.reportportal:plugin-api'
4243
annotationProcessor 'com.epam.reportportal:plugin-api'
4344
} else {
44-
implementation 'com.epam.reportportal:plugin-api'
45-
annotationProcessor 'com.epam.reportportal:plugin-api'
45+
implementation 'com.github.reportportal:commons-dao:acf1ec7'
46+
implementation 'com.github.reportportal:plugin-api:188792e'
47+
annotationProcessor 'com.github.reportportal:plugin-api:188792e'
4648
}
47-
implementation 'com.saucelabs:saucerest:1.0.43'
4849
implementation 'org.hibernate:hibernate-core:5.6.15.Final'
4950

5051
// TODO: 2.5.3+ switched to camel-case models. UI updates required

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=5.11.2
1+
version=5.12.0
22
lombokVersion=1.18.34

src/main/java/com/epam/reportportal/saucelabs/AssetsCommand.java

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@
1919
import static com.epam.reportportal.saucelabs.SaucelabsExtension.JOB_ID;
2020

2121
import com.epam.reportportal.extension.PluginCommand;
22+
import com.epam.reportportal.rules.exception.ErrorType;
23+
import com.epam.reportportal.rules.exception.ReportPortalException;
2224
import com.epam.reportportal.saucelabs.client.RestClientBuilder;
2325
import com.epam.reportportal.saucelabs.model.SauceProperties;
2426
import com.epam.ta.reportportal.entity.integration.Integration;
25-
import com.epam.ta.reportportal.exception.ReportPortalException;
26-
import com.epam.ta.reportportal.ws.model.ErrorType;
2727
import com.fasterxml.jackson.databind.ObjectMapper;
28+
import com.saucelabs.saucerest.MoshiSingleton;
29+
import com.saucelabs.saucerest.model.jobs.JobAssets;
30+
import com.squareup.moshi.JsonAdapter;
31+
import com.squareup.moshi.Moshi;
2832
import java.util.Map;
2933
import lombok.SneakyThrows;
3034
import lombok.extern.slf4j.Slf4j;
@@ -40,54 +44,65 @@
4044
@Slf4j
4145
public class AssetsCommand implements PluginCommand<Object> {
4246

43-
private final RestClientBuilder restClient;
47+
private final RestClientBuilder restClient;
4448

45-
public AssetsCommand(RestClientBuilder restClient) {
46-
this.restClient = restClient;
47-
}
4849

49-
@SneakyThrows
50+
public AssetsCommand(RestClientBuilder restClient) {
51+
this.restClient = restClient;
52+
}
53+
54+
@SneakyThrows
5055
@Override
51-
public Object executeCommand(Integration integration, Map<String, Object> params) {
52-
ValidationUtils.validateParams(params);
53-
ValidationUtils.validateIntegrationParams(integration.getParams());
56+
public Object executeCommand(Integration integration, Map<String, Object> params) {
57+
ValidationUtils.validateParams(params);
58+
ValidationUtils.validateIntegrationParams(integration.getParams());
5459

5560
SauceProperties sp = new SauceProperties(integration.getParams().getParams());
5661
sp.setJobId((String) params.get(JOB_ID));
5762
RestTemplate restTemplate = restClient.buildRestTemplate(sp);
5863

5964
try {
60-
String url = "/rest/v1/" + sp.getUsername() + "/jobs/" + sp.getJobId() + "/assets";
65+
String url = "/rest/v1/" + sp.getUsername() + "/jobs/" + sp.getJobId() + "/assets";
6166
String jobAssets = restTemplate.getForObject(url, String.class);
62-
JSONObject response = new JSONObject(jobAssets);
67+
68+
JSONObject response = new JSONObject(jobAssets);
6369
response.put("assetsPrefix",
6470
sp.getDatacenter().apiServer + "rest/v1/" + sp.getUsername() + "/jobs/" + sp.getJobId()
6571
+ "/assets");
66-
return new ObjectMapper().readValue(response.toString(), Object.class);
72+
return new ObjectMapper().readValue(response.toString(), Object.class);
6773

6874
} catch (HttpClientErrorException httpException) {
6975
if (httpException.getStatusCode().is4xxClientError()) {
7076
// TODO: handle RD endpoint in a separate plugin command. UI updates required
71-
//String url = sp.getDatacenter().apiServer + "v1/rdc/jobs/" + sp.getJobId();
77+
//String url = sp.getDatacenter().apiServer + "v1/rdc/jobs/" + sp.getJobId();
7278
//DeviceJob deviceJob = restTemplate.getForObject(url, DeviceJob.class);
7379

74-
JSONObject response = new JSONObject();
80+
JSONObject response = new JSONObject();
7581
response.put("assetsPrefix",
76-
String.format("%sv1/rdc/jobs/%s/", sp.getDatacenter().apiServer, sp.getJobId()));
77-
response.put("screenshots", new JSONArray());
78-
response.put("sauce-log",
79-
String.format("%sv1/rdc/jobs/%s/deviceLogs", sp.getDatacenter().apiServer,
82+
String.format("%sv1/rdc/jobs/%s/", sp.getDatacenter().apiServer, sp.getJobId()));
83+
response.put("screenshots", new JSONArray());
84+
response.put("sauce-log",
85+
String.format("%sv1/rdc/jobs/%s/deviceLogs", sp.getDatacenter().apiServer,
8086
sp.getJobId()));
8187
return new ObjectMapper().readValue(response.toString(), Object.class);
8288

83-
} else {
84-
throw new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION, StringUtils.normalizeSpace("Failed to retrieve job assets"));
89+
} else {
90+
throw new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION,
91+
StringUtils.normalizeSpace("Failed to retrieve job assets"));
8592
}
86-
}
87-
}
93+
}
94+
}
95+
96+
@Override
97+
public String getName() {
98+
return "assets";
99+
}
100+
101+
102+
public String toJson(JobAssets jobAssets) {
103+
Moshi moshi = MoshiSingleton.getInstance();
88104

89-
@Override
90-
public String getName() {
91-
return "assets";
92-
}
105+
JsonAdapter<JobAssets> jsonAdapter = moshi.adapter(JobAssets.class).nonNull();
106+
return jsonAdapter.toJson(jobAssets);
107+
}
93108
}

src/main/java/com/epam/reportportal/saucelabs/GenerateAuthTokenCommand.java

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import static com.epam.reportportal.saucelabs.ValidationUtils.validateParams;
88

99
import com.epam.reportportal.extension.PluginCommand;
10+
import com.epam.reportportal.rules.exception.ReportPortalException;
1011
import com.epam.ta.reportportal.entity.integration.Integration;
11-
import com.epam.ta.reportportal.exception.ReportPortalException;
1212
import java.nio.charset.StandardCharsets;
1313
import java.util.Collections;
1414
import java.util.Map;
@@ -22,38 +22,36 @@
2222
*/
2323
public class GenerateAuthTokenCommand implements PluginCommand<Object> {
2424

25-
private final BasicTextEncryptor textEncryptor;
25+
private final BasicTextEncryptor textEncryptor;
2626

27-
public GenerateAuthTokenCommand(BasicTextEncryptor textEncryptor) {
28-
this.textEncryptor = textEncryptor;
29-
}
27+
public GenerateAuthTokenCommand(BasicTextEncryptor textEncryptor) {
28+
this.textEncryptor = textEncryptor;
29+
}
3030

31-
@Override
32-
public Object executeCommand(Integration integration, Map params) {
33-
try {
34-
validateParams(params);
31+
@Override
32+
public Object executeCommand(Integration integration, Map params) {
33+
try {
34+
validateParams(params);
3535
validateIntegrationParams(integration.getParams());
3636

37-
String username = USERNAME.getParam(integration.getParams())
38-
;
39-
String accessToken = textEncryptor.decrypt(ACCESS_TOKEN.getParam(integration.getParams())
40-
41-
);
42-
43-
SecretKeySpec keySpec = new SecretKeySpec((username + ":" + accessToken).getBytes(StandardCharsets.UTF_8), "HmacMD5");
44-
Mac mac = Mac.getInstance("HmacMD5");
45-
mac.init(keySpec);
46-
return Collections.singletonMap(
47-
"token",
48-
Hex.encodeHexString(mac.doFinal(params.get(JOB_ID).toString().getBytes(StandardCharsets.UTF_8)))
49-
);
50-
} catch (Exception e) {
51-
throw new ReportPortalException(e.getMessage());
52-
}
53-
}
54-
55-
@Override
56-
public String getName() {
57-
return "token";
58-
}
37+
String username = USERNAME.getParam(integration.getParams());
38+
String accessToken = textEncryptor.decrypt(ACCESS_TOKEN.getParam(integration.getParams()));
39+
40+
SecretKeySpec keySpec =
41+
new SecretKeySpec((username + ":" + accessToken).getBytes(StandardCharsets.UTF_8),
42+
"HmacMD5"
43+
);
44+
Mac mac = Mac.getInstance("HmacMD5");
45+
mac.init(keySpec);
46+
return Collections.singletonMap("token", Hex.encodeHexString(
47+
mac.doFinal(params.get(JOB_ID).toString().getBytes(StandardCharsets.UTF_8))));
48+
} catch (Exception e) {
49+
throw new ReportPortalException(e.getMessage());
50+
}
51+
}
52+
53+
@Override
54+
public String getName() {
55+
return "token";
56+
}
5957
}

src/main/java/com/epam/reportportal/saucelabs/GetLogsCommand.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
import static com.epam.reportportal.saucelabs.SaucelabsExtension.JOB_ID;
2020

2121
import com.epam.reportportal.extension.PluginCommand;
22+
import com.epam.reportportal.rules.exception.ErrorType;
23+
import com.epam.reportportal.rules.exception.ReportPortalException;
2224
import com.epam.reportportal.saucelabs.client.RestClientBuilder;
2325
import com.epam.reportportal.saucelabs.model.SauceProperties;
2426
import com.epam.ta.reportportal.entity.integration.Integration;
25-
import com.epam.ta.reportportal.exception.ReportPortalException;
26-
import com.epam.ta.reportportal.ws.model.ErrorType;
2727
import java.util.Map;
2828
import lombok.extern.slf4j.Slf4j;
2929
import org.apache.commons.lang3.StringUtils;
@@ -46,15 +46,19 @@ public GetLogsCommand(RestClientBuilder restClient) {
4646
public Object executeCommand(Integration integration, Map<String, Object> params) {
4747
ValidationUtils.validateParams(params);
4848
ValidationUtils.validateIntegrationParams(integration.getParams());
49+
4950
SauceProperties sp = new SauceProperties(integration.getParams().getParams());
5051
sp.setJobId((String) params.get(JOB_ID));
52+
5153
return getWebDriverLogs(restClient.buildRestTemplate(sp), sp);
5254
}
5355

56+
5457
private Object getWebDriverLogs(RestTemplate restTemplate, SauceProperties sp) {
5558
try {
5659
String url = getJobAssetsUrl(sp) + "/log.json";
5760
return restTemplate.getForObject(url, Object.class);
61+
5862
} catch (HttpClientErrorException httpException) {
5963

6064
if (httpException.getStatusCode().is4xxClientError()) {
@@ -67,6 +71,7 @@ private Object getWebDriverLogs(RestTemplate restTemplate, SauceProperties sp) {
6771
}
6872
}
6973

74+
7075
// TODO: handle RD endpoint in a separate plugin command. UI updates required
7176
private Object getRealDeviceLogs(RestTemplate restTemplate, SauceProperties sp) {
7277
String url = "/v1/rdc/jobs/" + sp.getJobId() + "/deviceLogs";
@@ -87,4 +92,5 @@ private String getJobAssetsUrl(SauceProperties sp) {
8792
.append("/assets")
8893
.toString();
8994
}
95+
9096
}

src/main/java/com/epam/reportportal/saucelabs/JobInfoCommand.java

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
import static com.epam.reportportal.saucelabs.utils.OldDatacenterResolver.resolveDatacenterDeprecatedName;
2222

2323
import com.epam.reportportal.extension.PluginCommand;
24+
import com.epam.reportportal.rules.exception.ErrorType;
25+
import com.epam.reportportal.rules.exception.ReportPortalException;
2426
import com.epam.reportportal.saucelabs.utils.JsonUtils;
2527
import com.epam.ta.reportportal.entity.integration.Integration;
26-
import com.epam.ta.reportportal.exception.ReportPortalException;
27-
import com.epam.ta.reportportal.ws.model.ErrorType;
2828
import com.fasterxml.jackson.databind.ObjectMapper;
2929
import com.saucelabs.saucerest.SauceException;
3030
import com.saucelabs.saucerest.SauceREST;
@@ -41,47 +41,49 @@
4141
@Slf4j
4242
public class JobInfoCommand implements PluginCommand<Object> {
4343

44-
private final SauceRestClient sauceRestClient;
44+
private final SauceRestClient sauceRestClient;
4545

46-
public JobInfoCommand(SauceRestClient sauceRestClient) {
47-
this.sauceRestClient = sauceRestClient;
48-
}
46+
public JobInfoCommand(SauceRestClient sauceRestClient) {
47+
this.sauceRestClient = sauceRestClient;
48+
}
49+
50+
@Override
51+
public Object executeCommand(Integration integration, Map params) {
52+
ValidationUtils.validateParams(params);
53+
String datacenter = (String) params.get(DATA_CENTER.getName());
4954

50-
@Override
51-
public Object executeCommand(Integration integration, Map params) {
52-
ValidationUtils.validateParams(params);
53-
String datacenter = (String) params.get(DATA_CENTER.getName());
54-
SauceREST sauce =
55+
SauceREST sauce =
5556
sauceRestClient.buildSauceClient(integration, resolveDatacenterDeprecatedName(datacenter));
56-
String jobId = (String) params.get(JOB_ID);
57-
try {
58-
return findJobById(sauce,jobId);
59-
} catch (IOException e) {
60-
throw new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION,
61-
StringUtils.normalizeSpace(e.getMessage()));
57+
String jobId = (String) params.get(JOB_ID);
58+
59+
try {
60+
return findJobById(sauce, jobId);
61+
} catch (IOException e) {
62+
throw new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION,
63+
StringUtils.normalizeSpace(e.getMessage()));
6264
}
6365
}
6466

6567
private Object findJobById(SauceREST sauce, String jobId)
66-
throws IOException {
68+
throws IOException {
6769
Object response;
6870
try {
69-
// find job if exists
70-
Job jobInfo = sauce.getJobsEndpoint().getJobDetails(jobId);
71+
// find job if exists
72+
Job jobInfo = sauce.getJobsEndpoint().getJobDetails(jobId);
7173
response = new ObjectMapper().readValue(jobInfo.toJson(), Object.class);
72-
} catch (SauceException jobException) {
74+
} catch (SauceException jobException) {
7375
// If job not exists find real device job
7476
// TODO: introduce separate plugin command. UI updates required
7577
DeviceJob dj = sauce.getRealDevicesEndpoint().getSpecificDeviceJob(jobId);
7678
JsonUtils.toJson(dj, DeviceJob.class);
77-
response = new ObjectMapper()
79+
response = new ObjectMapper()
7880
.readValue(JsonUtils.toJson(dj, DeviceJob.class), Object.class);
7981
}
80-
return response;
81-
}
82+
return response;
83+
}
8284

83-
@Override
84-
public String getName() {
85-
return "jobInfo";
86-
}
85+
@Override
86+
public String getName() {
87+
return "jobInfo";
88+
}
8789
}

0 commit comments

Comments
 (0)