Skip to content

Commit 2fd76c6

Browse files
committed
Update arguments processing
1 parent e230287 commit 2fd76c6

File tree

9 files changed

+187
-127
lines changed

9 files changed

+187
-127
lines changed

README.md

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,35 @@ Main features are:
2020
## Usage
2121

2222
```
23-
java -jar assertthat-bdd-standalone-1.9.4.jar
24-
25-
Required options: a, s, i, [-f Download features, -r Upload report]
26-
27-
usage: assertthat-bdd-standalone-1.6.jar
28-
-a,--accessKey <ASSERTTHAT_ACCESS_KEY> Access key
29-
-f,--features Download features
30-
-h,--help Display help
31-
-i,--projectId <ID> Jira project id
32-
-j,--jsonReportFolder <FOLDER PATH> Cucumber json files folder
33-
-m,--mode <automated|manual|both> Features to download
34-
-n,--runName <NAME> Test run name
35-
-o,--outputFolder <FOLDER PATH> Features output folder
36-
-p,--proxyPassword <PASSWORD> Proxy password
37-
-q,--jql <JQL> JQL filter for features download and Jira issues to be updated with test results
38-
-b,--tags <tags expression> Tags expression for scenarios filtering
39-
-r,--report Upload report
40-
-s,--secretKey <ASSERTTHAT_SECRET_KEY> Secret key
41-
-k,--type <cucumber|karate> Report type
42-
-t,--jsonReportIncludePattern <PATTERN> Pattern for json file names
43-
-u,--proxyUsername <USERNAME> Proxy username
44-
-x,--proxyURI <URI> Proxy URI
45-
-l,--jiraServerUrl <URI> Jira Server URL
46-
-d,--numbered <true|false> Prepend ordinal to feature name (default is true)
23+
java -jar assertthat-bdd-standalone-1.9.5.jar
24+
25+
Required options: accessKey, secretKey, projectId, [-features Download features, -report Upload report]
26+
27+
usage: assertthat-bdd-standalone-1.9.5.jar
28+
-accessKey <ASSERTTHAT_ACCESS_KEY> Access key
29+
-features Download features
30+
-h,--help Display help
31+
-ignoreCertErrors <arg> Ignore ssl certificate eerors
32+
(default is false)
33+
-jiraServerUrl <arg> Jira server URL
34+
-jql <JQL> JQL filter for features and Jira
35+
ticket to be updated with report
36+
upload
37+
-jsonReportFolder <FOLDER PATH> Cucumber json files folder
38+
-jsonReportIncludePattern <PATTERN> Pattern for json file names
39+
-metadata <{ "key" : "value"}> Report metadata json
40+
-mode <automated|manual|both> Features to download
41+
-numbered <true|false> Prepend ordinal to feature name
42+
(default is true)
43+
-outputFolder <JIRA SERVER URL> Features output folder
44+
-projectId <ID> Jira project id
45+
-proxyPassword <PASSWORD> Proxy password
46+
-proxyURI <URI> Proxy URI
47+
-proxyUsername <USERNAME> Proxy username
48+
-report Upload report
49+
-runName <NAME> Test run name
50+
-secretKey <ASSERTTHAT_SECRET_KEY> Secret key
51+
-tags <tags> Tags filter for scenarios
52+
-type <cucumber|karate> Report type
53+
4754
```

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@
165165
<configuration>
166166
<archive>
167167
<manifest>
168-
<mainClass>com.assertthat.plugins.api.Main</mainClass>
168+
<mainClass>com.assertthat.plugins.standalone.Main</mainClass>
169+
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
169170
</manifest>
170171
</archive>
171172
<descriptorRefs>

src/main/java/com/assertthat/plugins/internal/APIUtil.java renamed to src/main/java/com/assertthat/plugins/standalone/APIUtil.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.assertthat.plugins.internal;
1+
package com.assertthat.plugins.standalone;
22

33
import com.google.common.net.UrlEscapers;
44
import okhttp3.*;
@@ -70,17 +70,6 @@ public APIUtil(String projectId, String accessKey, String secretKey, String prox
7070
client = builder.build();
7171
}
7272

73-
public static void copyInputStream(InputStream in, OutputStream out) throws IOException {
74-
byte[] buffer = new byte[1024];
75-
int len = in.read(buffer);
76-
while (len >= 0) {
77-
out.write(buffer, 0, len);
78-
len = in.read(buffer);
79-
}
80-
in.close();
81-
out.close();
82-
}
83-
8473
public File download(File targetDir, String mode, String jql,
8574
String tags, boolean isNumbered) throws IOException {
8675
if (targetDir.exists()) {

src/main/java/com/assertthat/plugins/internal/Arguments.java renamed to src/main/java/com/assertthat/plugins/standalone/Arguments.java

Lines changed: 25 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.assertthat.plugins.internal;
1+
package com.assertthat.plugins.standalone;
22

33
import java.text.SimpleDateFormat;
44
import java.util.Date;
@@ -46,23 +46,24 @@ public class Arguments {
4646
private boolean numbered;
4747
private boolean ignoreCertErrors;
4848

49-
public Arguments(String accessKey,
50-
String secretKey,
51-
String projectId,
52-
String runName,
53-
String outputFolder,
54-
String jsonReportFolder,
55-
String jsonReportIncludePattern,
56-
String proxyURI,
57-
String proxyUsername,
58-
String proxyPassword,
59-
String mode,
60-
String jql,
61-
String tags,
62-
String type,
63-
String jiraServerUrl,
64-
boolean numbered,
65-
boolean ignoreCertErrors) {
49+
Arguments(String accessKey,
50+
String secretKey,
51+
String projectId,
52+
String runName,
53+
String outputFolder,
54+
String jsonReportFolder,
55+
String jsonReportIncludePattern,
56+
String proxyURI,
57+
String proxyUsername,
58+
String proxyPassword,
59+
String mode,
60+
String jql,
61+
String tags,
62+
String type,
63+
String jiraServerUrl,
64+
String metadata,
65+
boolean numbered,
66+
boolean ignoreCertErrors) {
6667
this.accessKey = System.getenv("ASSERTTHAT_ACCESS_KEY");
6768
this.secretKey = System.getenv("ASSERTTHAT_SECRET_KEY");
6869
if (accessKey != null && !accessKey.trim().isEmpty()) {
@@ -89,13 +90,17 @@ public Arguments(String accessKey,
8990
} else {
9091
this.runName = "Test run " + new SimpleDateFormat("dd MMM yyyy HH:mm:ss").format(new Date());
9192
}
92-
if (type != null) {
93+
if (type != null && !type.isEmpty()) {
9394
this.type = type;
9495
}
95-
if (tags != null) {
96+
if (tags != null && !tags.isEmpty()) {
9697
this.tags = tags;
9798
}
9899

100+
if (metadata != null && !metadata.isEmpty()) {
101+
this.metadata = metadata;
102+
}
103+
99104
if (jsonReportFolder != null && !jsonReportFolder.trim().isEmpty()) {
100105
this.jsonReportFolder = jsonReportFolder;
101106
this.jsonReportFolder += jsonReportFolder.endsWith("/") ? "" : "/";
@@ -105,30 +110,6 @@ public Arguments(String accessKey,
105110
this.ignoreCertErrors = ignoreCertErrors;
106111
}
107112

108-
public Arguments(String accessKey,
109-
String secretKey,
110-
String projectId,
111-
String runName,
112-
String outputFolder,
113-
String jsonReportFolder,
114-
String jsonReportIncludePattern,
115-
String proxyURI,
116-
String proxyUsername,
117-
String proxyPassword,
118-
String mode,
119-
String jql,
120-
String tags,
121-
String type,
122-
String jiraServerUrl,
123-
String metadata,
124-
boolean numbered,
125-
boolean ignoreCertErrors) {
126-
this(accessKey, secretKey, projectId, runName, outputFolder, jsonReportFolder, jsonReportIncludePattern, proxyURI, proxyUsername, proxyPassword, mode, jql, tags, type, jiraServerUrl, numbered, ignoreCertErrors);
127-
this.metadata = metadata;
128-
129-
130-
}
131-
132113
public boolean isIgnoreCertErrors() {
133114
return ignoreCertErrors;
134115
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.assertthat.plugins.standalone;
2+
3+
public class ArgumentsFeatures extends Arguments{
4+
5+
public ArgumentsFeatures(String accessKey,
6+
String secretKey,
7+
String projectId,
8+
String outputFolder,
9+
String proxyURI,
10+
String proxyUsername,
11+
String proxyPassword,
12+
String mode,
13+
String jql,
14+
String tags,
15+
String jiraServerUrl,
16+
boolean numbered,
17+
boolean ignoreCertErrors) {
18+
super(accessKey,
19+
secretKey,
20+
projectId,
21+
null,
22+
outputFolder,
23+
null,
24+
null,
25+
proxyURI,
26+
proxyUsername,
27+
proxyPassword,
28+
mode,
29+
jql,
30+
tags,
31+
null,
32+
jiraServerUrl,
33+
null,
34+
numbered,
35+
ignoreCertErrors);
36+
}
37+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.assertthat.plugins.standalone;
2+
3+
public class ArgumentsReport extends Arguments{
4+
5+
public ArgumentsReport(String accessKey,
6+
String secretKey,
7+
String projectId,
8+
String runName,
9+
String jsonReportFolder,
10+
String jsonReportIncludePattern,
11+
String proxyURI,
12+
String proxyUsername,
13+
String proxyPassword,
14+
String jql,
15+
String type,
16+
String jiraServerUrl,
17+
String metadata,
18+
boolean ignoreCertErrors) {
19+
20+
super(accessKey,
21+
secretKey,
22+
projectId,
23+
runName,
24+
null,
25+
jsonReportFolder,
26+
jsonReportIncludePattern,
27+
proxyURI,
28+
proxyUsername,
29+
proxyPassword,
30+
null,
31+
jql,
32+
null,
33+
type,
34+
jiraServerUrl,
35+
metadata,
36+
false,
37+
ignoreCertErrors);
38+
39+
}
40+
}

src/main/java/com/assertthat/plugins/internal/FileUtil.java renamed to src/main/java/com/assertthat/plugins/standalone/FileUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.assertthat.plugins.internal;
1+
package com.assertthat.plugins.standalone;
22

33
import org.codehaus.plexus.util.DirectoryScanner;
44

@@ -78,7 +78,7 @@ public File unpackArchive(File theFile, File targetDir) throws IOException {
7878
}
7979

8080

81-
public void copyInputStream(InputStream in, OutputStream out) throws IOException {
81+
private void copyInputStream(InputStream in, OutputStream out) throws IOException {
8282
byte[] buffer = new byte[1024];
8383
int len = in.read(buffer);
8484
while (len >= 0) {
@@ -89,7 +89,7 @@ public void copyInputStream(InputStream in, OutputStream out) throws IOException
8989
out.close();
9090
}
9191

92-
public boolean buildDirectory(File file) {
92+
private boolean buildDirectory(File file) {
9393
return file.exists() || file.mkdirs();
9494
}
9595
}

0 commit comments

Comments
 (0)