Skip to content

Commit 73ad971

Browse files
authored
code cleanup (#91)
* code cleanup * add missing links to requirements * bump to 0.9.0
1 parent 51d51e2 commit 73ad971

12 files changed

Lines changed: 30 additions & 66 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Fixed
1313

14+
## [0.9.0] - 2025-05-06
15+
16+
### Added
17+
18+
- fixes #92 (code quality issues) by @bitcoder in #91
19+
1420
## [0.8.0] - 2024-08-14
1521

1622
### Added

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Add the following dependency to your pom.xml, where the `<configuration>` is opt
3636
<plugin>
3737
<groupId>app.getxray</groupId>
3838
<artifactId>xray-maven-plugin</artifactId>
39-
<version>0.8.0</version>
39+
<version>0.9.0</version>
4040
<scope>test</scope>
4141
<configuration>
4242
<clientId>215FFD69FE46447280000000000</clientId>

src/test/java/app/getxray/xray/CommonCloudTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ void authenticateXrayAPIKeyCredentialsTest() throws Exception{
4444
when(remoteCall.execute()).thenReturn(response);
4545
when(client.newCall(any())).thenReturn(remoteCall);
4646

47-
// OkHttpClient client2 = mockHttpClient("\""+expectedToken+"\"");
4847
String authToken = CommonCloud.authenticateXrayAPIKeyCredentials(log, true, client, clientId, clientSecret, cloudApiBaseUrl);
4948
assertEquals(expectedToken, authToken);
5049

src/test/java/app/getxray/xray/CommonUtilsTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.mockito.Mockito;
2121

2222
import app.getxray.xray.it.TestingUtils;
23-
import junit.framework.Assert;
2423
import okhttp3.MediaType;
2524
import okhttp3.OkHttpClient;
2625
import okhttp3.Request;
@@ -81,7 +80,7 @@ void testUnzipContentsToFolder() throws Exception {
8180
File tempDir = Files.createTempDirectory("dummy").toFile();
8281
byte[] zippedContent = TestingUtils.readRawResourceFile("import_features/XrayDatacenterIT/multiple_features/features.zip");
8382
InputStream zippedContentStream = new ByteArrayInputStream(zippedContent);
84-
unzipContentsToFolder(zippedContentStream, tempDir.getAbsolutePath().toString());
83+
unzipContentsToFolder(zippedContentStream, tempDir.getAbsolutePath());
8584
assertThat(tempDir.listFiles()).hasSize(2);
8685
assertThat(tempDir.listFiles()).extracting(File::getName).containsExactlyInAnyOrder("core", "other");
8786
assertThat((new File(tempDir, "core")).listFiles()).extracting(File::getName).containsExactlyInAnyOrder("positive_sum.feature");

src/test/java/app/getxray/xray/ImportResultsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import static org.junit.jupiter.api.Assertions.assertNotNull;
55
import org.junit.jupiter.api.Test;
66
import app.getxray.xray.XrayResultsImporter.CloudBuilder;
7-
import app.getxray.xray.XrayResultsImporter.ServerDCBuilder;;
7+
import app.getxray.xray.XrayResultsImporter.ServerDCBuilder;
88

99
class ImportResultsTest {
1010

src/test/java/app/getxray/xray/it/TestingUtils.java

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,11 @@
11
package app.getxray.xray.it;
22

3-
import static org.mockito.ArgumentMatchers.any;
4-
import static org.mockito.Mockito.mock;
5-
import static org.mockito.Mockito.when;
6-
73
import java.io.IOException;
84
import java.nio.file.Files;
95
import java.nio.file.Paths;
106

11-
import okhttp3.Call;
12-
import okhttp3.MediaType;
13-
import okhttp3.OkHttpClient;
14-
import okhttp3.Protocol;
15-
import okhttp3.Request;
16-
import okhttp3.Response;
17-
import okhttp3.ResponseBody;
18-
197
public class TestingUtils {
208

21-
private static OkHttpClient mockHttpClient(final String serializedBody) throws IOException {
22-
final OkHttpClient okHttpClient = mock(OkHttpClient.class);
23-
24-
final Call remoteCall = mock(Call.class);
25-
26-
final Response response = new Response.Builder()
27-
.request(new Request.Builder().url("https://xray.cloud.getxray.app/api/v2/authenticate").build())
28-
.protocol(Protocol.HTTP_1_1)
29-
.code(200).message("").body(
30-
ResponseBody.create(
31-
serializedBody,
32-
MediaType.parse("application/json")
33-
))
34-
.build();
35-
36-
when(remoteCall.execute()).thenReturn(response);
37-
when(okHttpClient.newCall(any())).thenReturn(remoteCall);
38-
39-
return okHttpClient;
40-
}
41-
429
public static String readFile(String path) throws IOException {
4310
String content = null;
4411
content = new String ( Files.readAllBytes( Paths.get(path) ) );

src/test/java/app/getxray/xray/it/export_features/XrayCloudIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class XrayCloudIT {
4343

4444
static WireMockServer wm;
4545
@BeforeAll
46-
public static void setup () {
46+
static void setup () {
4747
wm = new WireMockServer(
4848
options()
4949
.port(PORT_NUMBER)
@@ -53,7 +53,7 @@ public static void setup () {
5353
setupStub();
5454
}
5555
@AfterAll
56-
public static void teardown () {
56+
static void teardown () {
5757
wm.stop();
5858
}
5959

src/test/java/app/getxray/xray/it/import_features/XrayCloudIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class XrayCloudIT {
5252

5353
static WireMockServer wm;
5454
@BeforeAll
55-
public static void setup () {
55+
static void setup () {
5656
wm = new WireMockServer(
5757
options()
5858
.port(PORT_NUMBER)
@@ -62,7 +62,7 @@ public static void setup () {
6262
setupStub();
6363
}
6464
@AfterAll
65-
public static void teardown () {
65+
static void teardown () {
6666
wm.stop();
6767
}
6868

src/test/java/app/getxray/xray/it/import_features/XrayDatacenterIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ public class XrayDatacenterIT {
4949
static final int PORT_NUMBER = 18080;
5050

5151
@BeforeAll
52-
public static void setup () {
52+
static void setup () {
5353
wm = new WireMockServer(options().port(PORT_NUMBER));
5454
wm.start();
5555
setupStub();
5656
}
5757

5858
@AfterAll
59-
public static void teardown () {
59+
static void teardown () {
6060
wm.stop();
6161
}
6262

@@ -252,7 +252,7 @@ void multiple_features_from_directory(MavenExecutionResult result) throws IOExce
252252
ServeEvent request = allServeEvents.get(0);
253253
byte[] zippedContent = request.getRequest().getPart("file").getBody().asBytes();
254254
InputStream zippedContentStream = new ByteArrayInputStream(zippedContent);
255-
unzipContentsToFolder(zippedContentStream, tempDir.getAbsolutePath().toString());
255+
unzipContentsToFolder(zippedContentStream, tempDir.getAbsolutePath());
256256
assertThat(tempDir.listFiles()).hasSize(2);
257257
assertThat(tempDir.listFiles()).extracting(File::getName).containsExactlyInAnyOrder("core", "other");
258258
assertThat((new File(tempDir, "core")).listFiles()).extracting(File::getName).containsExactlyInAnyOrder("positive_sum.feature");

src/test/java/app/getxray/xray/it/import_results/TimeoutHandlingIT.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class TimeoutHandlingIT {
4040
static final int PORT_NUMBER = 18080;
4141

4242
@BeforeAll
43-
public static void setup () {
43+
static void setup () {
4444
wm = new WireMockServer(
4545
options()
4646
.port(PORT_NUMBER)
@@ -51,7 +51,7 @@ public static void setup () {
5151
}
5252

5353
@AfterAll
54-
public static void teardown () {
54+
static void teardown () {
5555
wm.stop();
5656
}
5757

@@ -180,7 +180,7 @@ void below_configured_timeout(MavenExecutionResult result) throws IOException {
180180
@SystemProperty(value = "xray.reportFile", content = "junit.xml")
181181
@SystemProperty(value = "xray.projectKey", content = "DELAY3")
182182
@SystemProperty(value = "xray.timeout", content = "2")
183-
void exceed_configured_timeout(MavenExecutionResult result) throws IOException {
183+
void exceed_configured_timeout(MavenExecutionResult result) {
184184
assertThat(result.getMavenLog().getStdout().toString()).contains("timeout");
185185
assertThat(result).isFailure();
186186
}
@@ -219,7 +219,7 @@ void below_default_timeout(MavenExecutionResult result) throws IOException {
219219
@SystemProperty(value = "xray.reportFormat", content = "junit")
220220
@SystemProperty(value = "xray.reportFile", content = "junit.xml")
221221
@SystemProperty(value = "xray.projectKey", content = "DELAY51")
222-
void exceed_default_timeout(MavenExecutionResult result) throws IOException {
222+
void exceed_default_timeout(MavenExecutionResult result) {
223223
assertThat(result.getMavenLog().getStdout().toString()).contains("timeout");
224224
assertThat(result).isFailure();
225225
}
@@ -258,7 +258,7 @@ void below_configured_timeout_cloud(MavenExecutionResult result) throws IOExcept
258258
@SystemProperty(value = "xray.projectKey", content = "DELAY3")
259259
@SystemProperty(value = "xray.timeout", content = "2")
260260
@SystemProperty(value = "xray.useInternalTestProxy", content = "true")
261-
void exceed_configured_timeout_cloud(MavenExecutionResult result) throws IOException {
261+
void exceed_configured_timeout_cloud(MavenExecutionResult result) {
262262
assertThat(result.getMavenLog().getStdout().toString()).contains("timeout");
263263
assertThat(result).isFailure();
264264
}
@@ -298,7 +298,7 @@ void below_default_timeout_cloud(MavenExecutionResult result) throws IOException
298298
@SystemProperty(value = "xray.reportFile", content = "junit.xml")
299299
@SystemProperty(value = "xray.projectKey", content = "DELAY51")
300300
@SystemProperty(value = "xray.useInternalTestProxy", content = "true")
301-
void exceed_default_timeout_cloud(MavenExecutionResult result) throws IOException {
301+
void exceed_default_timeout_cloud(MavenExecutionResult result) {
302302
assertThat(result.getMavenLog().getStdout().toString()).contains("timeout");
303303
assertThat(result).isFailure();
304304
}

0 commit comments

Comments
 (0)