testCases = transformer.transformToTestCases(reportPath.toString());
34 | assertThat(testCases, hasSize(1));
35 |
36 | TestCase testCase = testCases.get(0);
37 | assertThat(testCase.getName(), is("Account Correlation from Source"));
38 | assertThat(testCase.getDescription(), is("Free text"));
39 | assertThat(testCase.getUniqueId(), is("Account Correlation from Source"));
40 | assertThat(testCase.getStoryKeys(), containsInAnyOrder("EPIC-1111", "FEAT-555", "STRY-9999", "STRY-1123"));
41 | assertThat(testCase.getKey(), is(nullValue()));
42 | assertThat(testCase.getStatus(), is(PASSED));
43 | assertThat(testCase.getPriority(), is(MEDIUM));
44 | assertThat(testCase.getSeverity(), is(nullValue()));
45 | assertThat(testCase.getLabels(), containsInAnyOrder("any-label", "another-label", "SomeTags"));
46 | assertThat(testCase.getSteps(), hasSize(3));
47 |
48 | TestStep firstStep = testCase.getSteps().get(0);
49 | assertThat(firstStep.getDescription(), is("variable \"attrName\" is created with value \"X213DDF\""));
50 | assertThat(firstStep.getSteps(), is(empty()));
51 |
52 | TestStep secondStep = testCase.getSteps().get(1);
53 | assertThat(secondStep.getDescription(), is("Account 'X213DDF' is created"));
54 | assertThat(secondStep.getSteps(), is(empty()));
55 |
56 | TestStep thirdNestedStep = testCase.getSteps().get(2);
57 | assertThat(thirdNestedStep.getDescription(), is("When something happens"));
58 | assertThat(thirdNestedStep.getSteps(), hasSize(6));
59 |
60 | }
61 | }
--------------------------------------------------------------------------------
/zephyr-sync-report-allure/src/test/resources/reports/0a530bb5-c194-4b2d-b8d1-bf73da9480aa-attachment.html:
--------------------------------------------------------------------------------
1 | POST to https://eampr-ci.swissreapps-np.com/rest/workflows/Task%20Runner/launch
2 |
3 | Body
4 |
5 |
6 | {
7 | "workflowArgs": {
8 | "taskName": "Test Maintenance: Remove - Entitlements I Applications I Roles: PRE",
9 | "resultTaskName": "Test Maintenance: Remove - Entitlements I Applications I Roles: PRE b9ce7188-ac67-4900-b5da-693404008b9d",
10 | "arguments": {
11 | "objectName": "CPV2-P-STAGING-TESTAPM-NP-JWT",
12 | "objectType": "ManagedAttribute"
13 | }
14 | }
15 | }
16 |
17 |
18 | Headers
19 |
20 |
Accept: */*
21 |
Content-Type: application/json
22 |
23 |
24 |
25 | Cookies
26 |
27 |
LtpaToken2: kTnYo4nPLkkzp7iMCrmxuuWNKbhZu51gD0vaOY2uhNtgX1+OsU5tV9fUVyV9ke/GS8vBsPtHJmz3iOnaWw1ZWcVvttDeRBDN5y8zrSZTfiO2bR0pxARXVV8ICv934FtkdH/S3GckS7ioJKCUIovaPSq/Imzy5YCfJ8/D5Ypl+KxtBfANqMFxutXcFTnVUae72kpgfWsl6GL0gtkYkttubqJX4Nc0jRqvq1NBuu2iCBuOFXOonFIYqkbUrKGITDsYe0y2o1x/5v68MWuP6BOFmKgG1sH5gt5KQFljftxudl2xmTD7xxt/8D5RwxIjCgAx
28 |
29 |
30 | Curl
31 |
32 | curl -v -X POST 'https://eampr-ci.swissreapps-np.com/rest/workflows/Task%20Runner/launch' -H 'Accept: */*' -H 'Content-Type: application/json' -b 'LtpaToken2=kTnYo4nPLkkzp7iMCrmxuuWNKbhZu51gD0vaOY2uhNtgX1+OsU5tV9fUVyV9ke/GS8vBsPtHJmz3iOnaWw1ZWcVvttDeRBDN5y8zrSZTfiO2bR0pxARXVV8ICv934FtkdH/S3GckS7ioJKCUIovaPSq/Imzy5YCfJ8/D5Ypl+KxtBfANqMFxutXcFTnVUae72kpgfWsl6GL0gtkYkttubqJX4Nc0jRqvq1NBuu2iCBuOFXOonFIYqkbUrKGITDsYe0y2o1x/5v68MWuP6BOFmKgG1sH5gt5KQFljftxudl2xmTD7xxt/8D5RwxIjCgAx' -d '{
33 | "workflowArgs": {
34 | "taskName": "Test Maintenance: Remove - Entitlements I Applications I Roles: PRE",
35 | "resultTaskName": "Test Maintenance: Remove - Entitlements I Applications I Roles: PRE b9ce7188-ac67-4900-b5da-693404008b9d",
36 | "arguments": {
37 | "objectName": "CPV2-P-STAGING-TESTAPM-NP-JWT",
38 | "objectType": "ManagedAttribute"
39 | }
40 | }
41 | }'
42 |
43 |
--------------------------------------------------------------------------------
/zephyr-sync-report-allure/src/test/resources/reports/1b3bb409-55c6-40d8-a85f-5faf6f7ef1fa-container.json:
--------------------------------------------------------------------------------
1 | {"uuid":"1b3bb409-55c6-40d8-a85f-5faf6f7ef1fa","name":"Setting up group 'CPV2-INTERNAL-MANAGER' for negative test cases'","children":["7c556ea3-65dd-4ad1-95d0-38e78b6b67f0"],"befores":[],"afters":[],"start":1660918312762,"stop":1660918319501}
--------------------------------------------------------------------------------
/zephyr-sync-report-allure/src/test/resources/reports/2a83b634-b0a2-4fa4-af22-8316347b5cb6-result.json:
--------------------------------------------------------------------------------
1 | {
2 | "uuid": "2a83b634-b0a2-4fa4-af22-8316347b5cb6",
3 | "historyId": "9f5a6ed1a6ea934d4e2d7c804828bf31",
4 | "testCaseId": "[engine:junit-jupiter]/[class:com.swissre.iax.e2e.feature.cpv2.setup.CPV2TestSuiteSetupTest]/[test-factory:setCPV2GroupAggregationTestRemovedGroupData()]/[dynamic-test:#2]",
5 | "testCaseName": "Setting up group 'CPV2-NP-CUSTOM-MANAGE-TESTAPM-P-JWT' for group removed test cases'",
6 | "fullName": "com.swissre.iax.e2e.feature.cpv2.setup.CPV2TestSuiteSetupTest.setCPV2GroupAggregationTestRemovedGroupData",
7 | "labels": [
8 | {
9 | "name": "tag",
10 | "value": "SomeTags"
11 | },
12 | {
13 | "name": "junit.platform.uniqueid",
14 | "value": "[engine:junit-jupiter]/[class:com.swissre.iax.e2e.feature.cpv2.setup.CPV2TestSuiteSetupTest]/[test-factory:setCPV2GroupAggregationTestRemovedGroupData()]/[dynamic-test:#2]"
15 | },
16 | {
17 | "name": "host",
18 | "value": "LVR52430"
19 | },
20 | {
21 | "name": "thread",
22 | "value": "13852@LVR52430.ForkJoinPool-1-worker-7(19)"
23 | },
24 | {
25 | "name": "framework",
26 | "value": "junit-platform"
27 | },
28 | {
29 | "name": "language",
30 | "value": "java"
31 | },
32 | {
33 | "name": "epic",
34 | "value": "EPIC-1111"
35 | },
36 | {
37 | "name": "label",
38 | "value": "any-label"
39 | },
40 | {
41 | "name": "label",
42 | "value": "another-label"
43 | },
44 | {
45 | "name": "feature",
46 | "value": "FEAT-555"
47 | },
48 | {
49 | "name": "story",
50 | "value": "STRY-9999"
51 | },
52 | {
53 | "name": "story",
54 | "value": "STRY-1123"
55 | },
56 | {
57 | "name": "package",
58 | "value": "com.swissre.iax.e2e.feature.cpv2.setup.CPV2TestSuiteSetupTest"
59 | },
60 | {
61 | "name": "testClass",
62 | "value": "com.swissre.iax.e2e.feature.cpv2.setup.CPV2TestSuiteSetupTest"
63 | },
64 | {
65 | "name": "testMethod",
66 | "value": "setCPV2GroupAggregationTestRemovedGroupData"
67 | },
68 | {
69 | "name": "suite",
70 | "value": "Setup CPV2 Test Suite"
71 | }
72 | ],
73 | "links": [],
74 | "name": "Account Correlation from Source",
75 | "status": "passed",
76 | "stage": "finished",
77 | "description": "Free text",
78 | "steps": [
79 | {
80 | "name": "variable \"attrName\" is created with value \"X213DDF\"",
81 | "status": "passed",
82 | "stage": "finished",
83 | "steps": [],
84 | "attachments": [
85 | {
86 | "name": "Request",
87 | "source": "33a97aa8-1a94-4487-8b57-032dfedfde34-attachment.html",
88 | "type": "text/html"
89 | },
90 | {
91 | "name": "Response",
92 | "source": "cf22af2f-6215-4448-a422-384a23c40030-attachment.html",
93 | "type": "text/html"
94 | }
95 | ],
96 | "parameters": [
97 | {
98 | "name": "description",
99 | "value": "Given CPV2 group is created"
100 | }
101 | ],
102 | "start": 1660918310089,
103 | "stop": 1660918310383
104 | },
105 | {
106 | "name": "Account 'X213DDF' is created",
107 | "status": "passed",
108 | "stage": "finished",
109 | "steps": [],
110 | "attachments": [
111 | {
112 | "name": "Request",
113 | "source": "33a97aa8-1a94-4487-8b57-032dfedfde34-attachment.html",
114 | "type": "text/html"
115 | },
116 | {
117 | "name": "Response",
118 | "source": "cf22af2f-6215-4448-a422-384a23c40030-attachment.html",
119 | "type": "text/html"
120 | }
121 | ],
122 | "parameters": [
123 | {
124 | "name": "description",
125 | "value": "Given CPV2 group is created"
126 | }
127 | ],
128 | "start": 1660918310089,
129 | "stop": 1660918310383
130 | },
131 | {
132 | "name": "When something happens",
133 | "status": "passed",
134 | "stage": "finished",
135 | "steps": [
136 | {
137 | "name": "$(\"webdriver\") create()",
138 | "status": "passed",
139 | "stage": "finished",
140 | "steps": [],
141 | "attachments": [],
142 | "parameters": [],
143 | "start": 1660126114900,
144 | "stop": 1660126121597
145 | },
146 | {
147 | "name": "$(\"webdriver\") create()",
148 | "status": "passed",
149 | "stage": "finished",
150 | "steps": [],
151 | "attachments": [],
152 | "parameters": [],
153 | "start": 1660126114900,
154 | "stop": 1660126121597
155 | },
156 | {
157 | "name": "$(\"webdriver\") create()",
158 | "status": "passed",
159 | "stage": "finished",
160 | "steps": [],
161 | "attachments": [],
162 | "parameters": [],
163 | "start": 1660126114900,
164 | "stop": 1660126121597
165 | }, {
166 | "name": "$(\"webdriver\") create()",
167 | "status": "passed",
168 | "stage": "finished",
169 | "steps": [],
170 | "attachments": [],
171 | "parameters": [],
172 | "start": 1660126114900,
173 | "stop": 1660126121597
174 | },
175 | {
176 | "name": "$(\"webdriver\") create()",
177 | "status": "passed",
178 | "stage": "finished",
179 | "steps": [],
180 | "attachments": [],
181 | "parameters": [],
182 | "start": 1660126114900,
183 | "stop": 1660126121597
184 | },
185 | {
186 | "name": "$(\"webdriver\") create()",
187 | "status": "passed",
188 | "stage": "finished",
189 | "steps": [],
190 | "attachments": [],
191 | "parameters": [],
192 | "start": 1660126114900,
193 | "stop": 1660126121597
194 | }
195 | ],
196 | "attachments": [
197 | {
198 | "name": "Request",
199 | "source": "c37fb1ba-9ae0-40a3-8313-9f31584b5df7-attachment.html",
200 | "type": "text/html"
201 | },
202 | {
203 | "name": "Response",
204 | "source": "d7083dd2-7b33-4140-9f4b-8aaf1c559caa-attachment.html",
205 | "type": "text/html"
206 | },
207 | {
208 | "name": "Request",
209 | "source": "f2fcaeef-63af-45df-8ee9-281d04534a99-attachment.html",
210 | "type": "text/html"
211 | },
212 | {
213 | "name": "Response",
214 | "source": "35e9f70e-0c42-4fd2-95ef-d5acba2128ab-attachment.html",
215 | "type": "text/html"
216 | }
217 | ],
218 | "parameters": [
219 | {
220 | "name": "description",
221 | "value": "Given PRE entitlement 'CPV2-NP-CUSTOM-MANAGE-TESTAPM-P-JWT' is deleted"
222 | }
223 | ],
224 | "start": 1660918310383,
225 | "stop": 1660918315940
226 | }
227 | ],
228 | "attachments": [],
229 | "parameters": [],
230 | "start": 1660918310088,
231 | "stop": 1660918315940
232 | }
--------------------------------------------------------------------------------
/zephyr-sync-report-api/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | zephyr-sync-master
5 | lv.ctco.zephyr
6 | 0.0.18-SNAPSHOT
7 |
8 | 4.0.0
9 |
10 | zephyr-sync-report-api
11 |
12 |
13 |
--------------------------------------------------------------------------------
/zephyr-sync-report-api/src/main/java/lv/ctco/zephyr/beans/TestCase.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.beans;
2 |
3 | import lv.ctco.zephyr.enums.TestLevel;
4 | import lv.ctco.zephyr.enums.TestStatus;
5 |
6 | import java.util.List;
7 |
8 | public class TestCase {
9 |
10 | private Integer id;
11 | private String key;
12 | private String uniqueId;
13 | private String suiteName;
14 | private String name;
15 | private String description;
16 | private List storyKeys;
17 | private List labels;
18 | private List steps;
19 | private TestStatus status = TestStatus.NOT_EXECUTED;
20 | private TestLevel severity;
21 | private TestLevel priority = TestLevel.MEDIUM;
22 |
23 | public Integer getId() {
24 | return id;
25 | }
26 |
27 | public void setId(Integer id) {
28 | this.id = id;
29 | }
30 |
31 | public String getKey() {
32 | return key;
33 | }
34 |
35 | public void setKey(String key) {
36 | this.key = key;
37 | }
38 |
39 | public String getUniqueId() {
40 | return uniqueId;
41 | }
42 |
43 | public void setUniqueId(String uniqueId) {
44 | this.uniqueId = uniqueId;
45 | }
46 |
47 | public String getName() {
48 | return name;
49 | }
50 |
51 | public void setName(String name) {
52 | this.name = name;
53 | }
54 |
55 | public String getDescription() {
56 | return description;
57 | }
58 |
59 | public void setDescription(String description) {
60 | this.description = description;
61 | }
62 |
63 | public List getStoryKeys() {
64 | return storyKeys;
65 | }
66 |
67 | public void setStoryKeys(List storyKeys) {
68 | this.storyKeys = storyKeys;
69 | }
70 |
71 | public List getLabels() {
72 | return labels;
73 | }
74 |
75 | public void setLabels(List labels) {
76 | this.labels = labels;
77 | }
78 |
79 | public List getSteps() {
80 | return steps;
81 | }
82 |
83 | public void setSteps(List steps) {
84 | this.steps = steps;
85 | }
86 |
87 | public TestStatus getStatus() {
88 | return status;
89 | }
90 |
91 | public void setStatus(TestStatus status) {
92 | this.status = status;
93 | }
94 |
95 | public TestLevel getSeverity() {
96 | return severity;
97 | }
98 |
99 | public void setSeverity(TestLevel severity) {
100 | this.severity = severity;
101 | }
102 |
103 | public TestLevel getPriority() {
104 | return priority;
105 | }
106 |
107 | public void setPriority(TestLevel priority) {
108 | this.priority = priority;
109 | }
110 |
111 | public String getSuiteName() {
112 | return suiteName;
113 | }
114 |
115 | public void setSuiteName(String suiteName) {
116 | this.suiteName = suiteName;
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/zephyr-sync-report-api/src/main/java/lv/ctco/zephyr/beans/TestStep.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.beans;
2 |
3 | import java.util.List;
4 |
5 | public class TestStep {
6 |
7 | private String description;
8 | private List steps = null;
9 |
10 | public TestStep() {
11 | }
12 |
13 | public TestStep(String description) {
14 | this.description = description;
15 | }
16 |
17 | public String getDescription() {
18 | return description;
19 | }
20 |
21 | public void setDescription(String description) {
22 | this.description = description;
23 | }
24 |
25 | public List getSteps() {
26 | return steps;
27 | }
28 |
29 | public void setSteps(List steps) {
30 | this.steps = steps;
31 | }
32 | }
--------------------------------------------------------------------------------
/zephyr-sync-report-api/src/main/java/lv/ctco/zephyr/enums/TestLevel.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.enums;
2 |
3 | public enum TestLevel {
4 | LOW("Low", 10123),
5 | MEDIUM("Medium", 10122),
6 | HIGH("High", 10122),
7 | MAJOR("Major", 10122),
8 | MINOR("Minor", 10123),
9 | TRIVIAL("Trivial", 10124),
10 | BLOCKER("Blocker", 10120),
11 | CRITICAL("Critical", 10121);
12 |
13 | private String name;
14 | private Integer severityIndex;
15 |
16 | TestLevel(String name, Integer severityIndex) {
17 | this.name = name;
18 | this.severityIndex=severityIndex;
19 | }
20 |
21 | public String getName() {
22 | return name;
23 | }
24 |
25 | public Integer getIndex() {
26 | return severityIndex;
27 | }
28 | }
--------------------------------------------------------------------------------
/zephyr-sync-report-api/src/main/java/lv/ctco/zephyr/enums/TestStatus.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.enums;
2 |
3 | public enum TestStatus {
4 | NOT_EXECUTED(-1),
5 | FAILED(2),
6 | PASSED(1);
7 |
8 | private int id;
9 |
10 | TestStatus(int id) {
11 | this.id = id;
12 | }
13 |
14 | public int getId() {
15 | return id;
16 | }
17 | }
--------------------------------------------------------------------------------
/zephyr-sync-report-api/src/main/java/lv/ctco/zephyr/transformer/ReportTransformer.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.transformer;
2 |
3 | import lv.ctco.zephyr.beans.TestCase;
4 |
5 | import java.util.List;
6 |
7 | public interface ReportTransformer {
8 |
9 | String getType();
10 |
11 | List transformToTestCases(String reportPath);
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/zephyr-sync-report-cucumber/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | zephyr-sync-master
5 | lv.ctco.zephyr
6 | 0.0.18-SNAPSHOT
7 |
8 | 4.0.0
9 |
10 | zephyr-sync-report-cucumber
11 |
12 |
13 |
14 | lv.ctco.zephyr
15 | zephyr-sync-report-api
16 | ${project.version}
17 |
18 |
19 | lv.ctco.zephyr
20 | zephyr-sync-util
21 | ${project.version}
22 |
23 |
24 | junit
25 | junit
26 | test
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/zephyr-sync-report-cucumber/src/main/java/lv/ctco/zephyr/beans/testresult/cucumber/After.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.beans.testresult.cucumber;
2 |
3 | public class After {
4 | public Result result;
5 | public Match match;
6 |
7 | public After() {
8 | }
9 |
10 | public Match getMatch() {
11 | return match;
12 | }
13 |
14 | public Result getResult() {
15 | return result;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/zephyr-sync-report-cucumber/src/main/java/lv/ctco/zephyr/beans/testresult/cucumber/Before.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.beans.testresult.cucumber;
2 |
3 | public class Before {
4 | public Result result;
5 | public Match match;
6 |
7 | public Before() {
8 | }
9 |
10 | public Result getResult() {
11 | return result;
12 | }
13 |
14 | public Match getMatch() {
15 | return match;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/zephyr-sync-report-cucumber/src/main/java/lv/ctco/zephyr/beans/testresult/cucumber/Feature.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.beans.testresult.cucumber;
2 |
3 | public class Feature {
4 | public long line;
5 | public Scenario elements[];
6 | public String name;
7 | public String description;
8 | public String id;
9 | public String keyword;
10 | public String uri;
11 |
12 | public Feature() {
13 | }
14 |
15 | public long getLine() {
16 | return line;
17 | }
18 |
19 | public Scenario[] getScenarios() {
20 | return elements;
21 | }
22 |
23 | public String getName() {
24 | return name;
25 | }
26 |
27 | public String getDescription() {
28 | return description;
29 | }
30 |
31 | public String getId() {
32 | return id;
33 | }
34 |
35 | public String getKeyword() {
36 | return keyword;
37 | }
38 |
39 | public String getUri() {
40 | return uri;
41 | }
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/zephyr-sync-report-cucumber/src/main/java/lv/ctco/zephyr/beans/testresult/cucumber/Match.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.beans.testresult.cucumber;
2 |
3 | public class Match {
4 | public String location;
5 |
6 | public Match() {
7 | }
8 |
9 | public String getLocation() {
10 | return location;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/zephyr-sync-report-cucumber/src/main/java/lv/ctco/zephyr/beans/testresult/cucumber/Result.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.beans.testresult.cucumber;
2 |
3 | public class Result {
4 | public long duration;
5 | public String status;
6 |
7 | public Result() {
8 | }
9 |
10 | public long getDuration() {
11 | return duration;
12 | }
13 |
14 | public String getStatus() {
15 | return status;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/zephyr-sync-report-cucumber/src/main/java/lv/ctco/zephyr/beans/testresult/cucumber/Scenario.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.beans.testresult.cucumber;
2 |
3 | public class Scenario {
4 | public Before before[];
5 | public long line;
6 | public String name;
7 | public String description;
8 | public String id;
9 | public After after[];
10 | public String type;
11 | public String keyword;
12 | public Step steps[];
13 | public Tag tags[];
14 |
15 | public Scenario() {
16 | }
17 |
18 | public Before[] getBefore() {
19 | return before;
20 | }
21 |
22 | public long getLine() {
23 | return line;
24 | }
25 |
26 | public String getName() {
27 | return name;
28 | }
29 |
30 | public String getDescription() {
31 | return description;
32 | }
33 |
34 | public String getId() {
35 | return id;
36 | }
37 |
38 | public After[] getAfter() {
39 | return after;
40 | }
41 |
42 | public String getType() {
43 | return type;
44 | }
45 |
46 | public String getKeyword() {
47 | return keyword;
48 | }
49 |
50 | public Step[] getSteps() {
51 | return steps;
52 | }
53 |
54 | public Tag[] getTags() {
55 | return tags;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/zephyr-sync-report-cucumber/src/main/java/lv/ctco/zephyr/beans/testresult/cucumber/Step.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.beans.testresult.cucumber;
2 |
3 | public class Step {
4 | public Result result;
5 | public long line;
6 | public String name;
7 | public Match match;
8 | public String keyword;
9 |
10 | public Step() {
11 | }
12 |
13 | public Result getResult() {
14 | return result;
15 | }
16 |
17 | public long getLine() {
18 | return line;
19 | }
20 |
21 | public String getName() {
22 | return name;
23 | }
24 |
25 | public Match getMatch() {
26 | return match;
27 | }
28 |
29 | public String getKeyword() {
30 | return keyword;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/zephyr-sync-report-cucumber/src/main/java/lv/ctco/zephyr/beans/testresult/cucumber/Tag.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.beans.testresult.cucumber;
2 |
3 | public class Tag {
4 | public String name;
5 |
6 | public Tag() {
7 | }
8 |
9 | public String getName() {
10 | return name;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/zephyr-sync-report-cucumber/src/main/java/lv/ctco/zephyr/transformer/CucumberTransformer.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.transformer;
2 |
3 |
4 | import lv.ctco.zephyr.ZephyrSyncException;
5 | import lv.ctco.zephyr.beans.TestCase;
6 | import lv.ctco.zephyr.beans.TestStep;
7 | import lv.ctco.zephyr.beans.testresult.cucumber.Feature;
8 | import lv.ctco.zephyr.beans.testresult.cucumber.Scenario;
9 | import lv.ctco.zephyr.beans.testresult.cucumber.Step;
10 | import lv.ctco.zephyr.beans.testresult.cucumber.Tag;
11 | import lv.ctco.zephyr.enums.TestStatus;
12 | import lv.ctco.zephyr.util.ObjectTransformer;
13 | import lv.ctco.zephyr.util.Utils;
14 |
15 | import java.io.File;
16 | import java.io.FileInputStream;
17 | import java.io.IOException;
18 | import java.util.ArrayList;
19 | import java.util.Collections;
20 | import java.util.List;
21 |
22 |
23 | public class CucumberTransformer implements ReportTransformer {
24 |
25 | public String getType() {
26 | return "cucumber";
27 | }
28 |
29 | public List transformToTestCases(String reportPath) {
30 | return transform(readCucumberReport(reportPath));
31 | }
32 |
33 | String readCucumberReport(String path) {
34 | try {
35 | return Utils.readInputStream(new FileInputStream(new File(path)));
36 | } catch (IOException e) {
37 | throw new ZephyrSyncException("Cannot read cucumber report", e);
38 | }
39 | }
40 |
41 | List transform(String response) {
42 | List features = ObjectTransformer.deserializeList(response, Feature.class);
43 | List testCases = new ArrayList();
44 |
45 | for (Feature feature : features) {
46 | Scenario[] scenarios = feature.getScenarios();
47 | if (scenarios == null) {
48 | continue;
49 | }
50 |
51 | for (Scenario scenario : scenarios) {
52 | TestCase test = new TestCase();
53 | List jiraKeys = extractTagValues(scenario, "@TestCaseId=");
54 | if (jiraKeys != null && jiraKeys.size() == 1) {
55 | test.setKey(jiraKeys.get(0).toUpperCase());
56 | }
57 | test.setSuiteName(feature.getName());
58 | test.setName(scenario.getName() == null ? feature.getName() : scenario.getName());
59 | test.setUniqueId(generateUniqueId(feature, scenario));
60 | test.setLabels(extractTagValues(scenario, "@Labels="));
61 | test.setStoryKeys(extractTagValues(scenario, "@Stories="));
62 | test.setDescription(scenario.getDescription());
63 | test.setStatus(resolveStatus(scenario));
64 | test.setSteps(resolveTestSteps(scenario));
65 | testCases.add(test);
66 | }
67 | }
68 | return testCases;
69 | }
70 |
71 | public String generateUniqueId(Feature feature, Scenario scenario) {
72 | String id = scenario.getId();
73 | if (id == null) {
74 | id = feature.getId();
75 | }
76 | String[] tokens = id.replace(";", "-").replaceAll("[^a-zA-Z0-9\\-]", "").split("-");
77 | StringBuilder sb = new StringBuilder();
78 | for (String token : tokens) {
79 | if (token.length() > 0) {
80 | sb.append(token.charAt(0));
81 | }
82 | }
83 | return sb.toString().toUpperCase();
84 | }
85 |
86 | private TestStatus resolveStatus(Scenario scenario) {
87 | if (scenario.getSteps() == null) {
88 | return TestStatus.PASSED;
89 | }
90 | for (Step step : scenario.getSteps()) {
91 | if (step.getResult() != null && !"passed".equals(step.getResult().getStatus())) {
92 | return TestStatus.FAILED;
93 | }
94 | }
95 | return TestStatus.PASSED;
96 | }
97 |
98 | private List extractTagValues(Scenario scenario, String tagPrefix) {
99 | Tag[] tags = scenario.getTags();
100 | if (tags == null || tags.length == 0) return null;
101 |
102 | List result = new ArrayList();
103 | for (Tag tag : tags) {
104 | String tagName = tag.getName();
105 |
106 | if (tagName.toLowerCase().startsWith(tagPrefix.toLowerCase())) {
107 | String[] keys = tagName.substring(tagPrefix.length()).trim().split(",");
108 | Collections.addAll(result, keys);
109 | }
110 | }
111 | return result.size() != 0 ? result : null;
112 | }
113 |
114 | private String extractTagValue(Scenario scenario, String tagPrefix) {
115 | Tag[] tags = scenario.getTags();
116 | if (tags == null || tags.length == 0) return null;
117 |
118 | for (Tag tag : tags) {
119 | String tagName = tag.getName();
120 | if (tagName.toLowerCase().startsWith(tagPrefix.toLowerCase())) {
121 | return tagName.substring(tagPrefix.length()).trim();
122 | }
123 | }
124 | return null;
125 | }
126 |
127 | private List resolveTestSteps(Scenario scenario) {
128 | List result = new ArrayList();
129 | if (scenario.getSteps() != null) {
130 | for (Step step : scenario.getSteps()) {
131 | result.add(new TestStep(step.getKeyword() + step.getName()));
132 | }
133 | }
134 | return result;
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/zephyr-sync-report-cucumber/src/main/resources/META-INF/services/lv.ctco.zephyr.transformer.ReportTransformer:
--------------------------------------------------------------------------------
1 | lv.ctco.zephyr.transformer.CucumberTransformer
--------------------------------------------------------------------------------
/zephyr-sync-report-cucumber/src/test/java/lv/ctco/zephyr/transformer/CucumberTransformerTest.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.transformer;
2 |
3 | import lv.ctco.zephyr.beans.testresult.cucumber.Feature;
4 | import lv.ctco.zephyr.beans.testresult.cucumber.Scenario;
5 | import org.junit.Before;
6 | import org.junit.Test;
7 |
8 | import static org.hamcrest.CoreMatchers.is;
9 | import static org.hamcrest.CoreMatchers.nullValue;
10 | import static org.junit.Assert.assertThat;
11 |
12 | public class CucumberTransformerTest {
13 |
14 | private CucumberTransformer transformer;
15 |
16 | @Before
17 | public void setUp() throws Exception {
18 | transformer = new CucumberTransformer();
19 | }
20 |
21 | @Test
22 | public void testGenerateUniqueId() throws Exception {
23 | assertThat(transformer.generateUniqueId(new Feature(), scenarioWithId("")), is(""));
24 | assertThat(transformer.generateUniqueId(new Feature(), scenarioWithId("test;2")), is("T2"));
25 | assertThat(transformer.generateUniqueId(new Feature(), scenarioWithId("import-identities-from-sniam;import-an-identity-in-iiq-from-sniam-with-\\u0027life-cycle-state\\u0027;dxrstate-mapping-to-\\u0027life-cycle-state\\u0027;2")), is("IIFSIAIIIFSWUCSDMTUCS2"));
26 | assertThat(transformer.generateUniqueId(new Feature(), scenarioWithId("import-identities-from-sniam")), is("IIFS"));
27 | }
28 |
29 | @Test
30 | public void nameAndSuiteName() {
31 | assertThat(transformer.transform("[{\"name\":null, \"elements\":[{\"name\":null, \"id\":\"123\"}]}]").get(0).getName(), is(nullValue()));
32 | assertThat(transformer.transform("[{\"name\":\"fe\", \"elements\":[{\"name\":null, \"id\":\"123\"}]}]").get(0).getName(), is("fe"));
33 | assertThat(transformer.transform("[{\"name\":null, \"elements\":[{\"name\":\"sce\", \"id\":\"123\"}]}]").get(0).getName(), is("sce"));
34 | assertThat(transformer.transform("[{\"name\":\"fe\", \"elements\":[{\"name\":\"sce\", \"id\":\"123\"}]}]").get(0).getName(), is("sce"));
35 |
36 | assertThat(transformer.transform("[{\"name\":null, \"elements\":[{\"name\":null, \"id\":\"123\"}]}]").get(0).getSuiteName(), is(nullValue()));
37 | assertThat(transformer.transform("[{\"name\":\"fe\", \"elements\":[{\"name\":null, \"id\":\"123\"}]}]").get(0).getSuiteName(), is("fe"));
38 | assertThat(transformer.transform("[{\"name\":null, \"elements\":[{\"name\":\"sce\", \"id\":\"123\"}]}]").get(0).getSuiteName(), is(nullValue()));
39 | assertThat(transformer.transform("[{\"name\":\"fe\", \"elements\":[{\"name\":\"sce\", \"id\":\"123\"}]}]").get(0).getSuiteName(), is("fe"));
40 | }
41 |
42 | Scenario scenarioWithId(String id) {
43 | Scenario scenario = new Scenario();
44 | scenario.id = id;
45 | return scenario;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/zephyr-sync-report-junit/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | zephyr-sync-master
5 | lv.ctco.zephyr
6 | 0.0.18-SNAPSHOT
7 |
8 | 4.0.0
9 |
10 | zephyr-sync-report-junit
11 |
12 |
13 |
14 | lv.ctco.zephyr
15 | zephyr-sync-report-api
16 | ${project.version}
17 |
18 |
19 | lv.ctco.zephyr
20 | zephyr-sync-util
21 | ${project.version}
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/zephyr-sync-report-junit/src/main/java/lv/ctco/zephyr/beans/testresult/junit/JUnitResult.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.beans.testresult.junit;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlAttribute;
6 | import javax.xml.bind.annotation.XmlSchemaType;
7 | import javax.xml.bind.annotation.XmlType;
8 | import javax.xml.bind.annotation.XmlValue;
9 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
10 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
11 | import java.math.BigDecimal;
12 |
13 | @XmlAccessorType(XmlAccessType.FIELD)
14 | @XmlType(name = "", propOrder = {
15 | "error",
16 | "failure"
17 | })
18 | public class JUnitResult {
19 |
20 | protected Error error;
21 | protected Failure failure;
22 | @XmlAttribute(name = "name", required = true)
23 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
24 | @XmlSchemaType(name = "token")
25 | protected String name;
26 | @XmlAttribute(name = "classname", required = true)
27 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
28 | @XmlSchemaType(name = "token")
29 | protected String classname;
30 | @XmlAttribute(name = "time", required = true)
31 | protected BigDecimal time;
32 |
33 | public Error getError() {
34 | return error;
35 | }
36 |
37 | public void setError(Error value) {
38 | this.error = value;
39 | }
40 |
41 | public Failure getFailure() {
42 | return failure;
43 | }
44 |
45 | public void setFailure(Failure value) {
46 | this.failure = value;
47 | }
48 |
49 | public String getName() {
50 | return name;
51 | }
52 |
53 | public void setName(String value) {
54 | this.name = value;
55 | }
56 |
57 | public String getClassname() {
58 | return classname;
59 | }
60 |
61 | public void setClassname(String value) {
62 | this.classname = value;
63 | }
64 |
65 | public BigDecimal getTime() {
66 | return time;
67 | }
68 |
69 | public void setTime(BigDecimal value) {
70 | this.time = value;
71 | }
72 |
73 | @XmlAccessorType(XmlAccessType.FIELD)
74 | @XmlType(name = "", propOrder = {
75 | "value"
76 | })
77 | public static class Error {
78 |
79 | @XmlValue
80 | protected String value;
81 | @XmlAttribute(name = "message")
82 | protected String message;
83 | @XmlAttribute(name = "type", required = true)
84 | protected String type;
85 |
86 | public String getValue() {
87 | return value;
88 | }
89 |
90 | public void setValue(String value) {
91 | this.value = value;
92 | }
93 |
94 | public String getMessage() {
95 | return message;
96 | }
97 |
98 | public void setMessage(String value) {
99 | this.message = value;
100 | }
101 |
102 | public String getType() {
103 | return type;
104 | }
105 |
106 | public void setType(String value) {
107 | this.type = value;
108 | }
109 |
110 | }
111 |
112 | @XmlAccessorType(XmlAccessType.FIELD)
113 | @XmlType(name = "", propOrder = {
114 | "value"
115 | })
116 | public static class Failure {
117 |
118 | @XmlValue
119 | protected String value;
120 | @XmlAttribute(name = "message")
121 | protected String message;
122 | @XmlAttribute(name = "type", required = true)
123 | protected String type;
124 |
125 | public String getValue() {
126 | return value;
127 | }
128 |
129 | public void setValue(String value) {
130 | this.value = value;
131 | }
132 |
133 | public String getMessage() {
134 | return message;
135 | }
136 |
137 | public void setMessage(String value) {
138 | this.message = value;
139 | }
140 |
141 | public String getType() {
142 | return type;
143 | }
144 |
145 | public void setType(String value) {
146 | this.type = value;
147 | }
148 | }
149 | }
--------------------------------------------------------------------------------
/zephyr-sync-report-junit/src/main/java/lv/ctco/zephyr/beans/testresult/junit/JUnitResultTestSuite.java:
--------------------------------------------------------------------------------
1 |
2 | package lv.ctco.zephyr.beans.testresult.junit;
3 |
4 | import javax.xml.bind.annotation.XmlAccessType;
5 | import javax.xml.bind.annotation.XmlAccessorType;
6 | import javax.xml.bind.annotation.XmlAttribute;
7 | import javax.xml.bind.annotation.XmlElement;
8 | import javax.xml.bind.annotation.XmlRootElement;
9 | import javax.xml.bind.annotation.XmlType;
10 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
11 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
12 | import javax.xml.datatype.XMLGregorianCalendar;
13 | import java.math.BigDecimal;
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | @XmlAccessorType(XmlAccessType.FIELD)
18 | @XmlType(name = "testsuite", propOrder = {
19 | "properties",
20 | "testcase",
21 | "systemOut",
22 | "systemErr"
23 | })
24 | @XmlRootElement(name = "testsuite")
25 | public class JUnitResultTestSuite {
26 |
27 | @XmlElement(required = true)
28 | protected JUnitTCProperties properties;
29 | protected List testcase;
30 | @XmlElement(name = "system-out", required = true)
31 | protected String systemOut;
32 | @XmlElement(name = "system-err", required = true)
33 | protected String systemErr;
34 | @XmlAttribute(name = "name", required = true)
35 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
36 | protected String name;
37 | @XmlAttribute(name = "timestamp", required = true)
38 | protected XMLGregorianCalendar timestamp;
39 | @XmlAttribute(name = "hostname", required = true)
40 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
41 | protected String hostname;
42 | @XmlAttribute(name = "tests", required = true)
43 | protected int tests;
44 | @XmlAttribute(name = "failures", required = true)
45 | protected int failures;
46 | @XmlAttribute(name = "errors", required = true)
47 | protected int errors;
48 | @XmlAttribute(name = "time", required = true)
49 | protected BigDecimal time;
50 |
51 | public JUnitTCProperties getProperties() {
52 | return properties;
53 | }
54 |
55 | public void setProperties(JUnitTCProperties value) {
56 | this.properties = value;
57 | }
58 |
59 | public List getTestcase() {
60 | if (testcase == null) {
61 | testcase = new ArrayList();
62 | }
63 | return this.testcase;
64 | }
65 |
66 | public String getSystemOut() {
67 | return systemOut;
68 | }
69 |
70 | public void setSystemOut(String value) {
71 | this.systemOut = value;
72 | }
73 |
74 | public String getSystemErr() {
75 | return systemErr;
76 | }
77 |
78 | public void setSystemErr(String value) {
79 | this.systemErr = value;
80 | }
81 |
82 | public String getName() {
83 | return name;
84 | }
85 |
86 | public void setName(String value) {
87 | this.name = value;
88 | }
89 |
90 | public XMLGregorianCalendar getTimestamp() {
91 | return timestamp;
92 | }
93 |
94 | public void setTimestamp(XMLGregorianCalendar value) {
95 | this.timestamp = value;
96 | }
97 |
98 | public String getHostname() {
99 | return hostname;
100 | }
101 |
102 | public void setHostname(String value) {
103 | this.hostname = value;
104 | }
105 |
106 | public int getTests() {
107 | return tests;
108 | }
109 |
110 | public void setTests(int value) {
111 | this.tests = value;
112 | }
113 |
114 | public int getFailures() {
115 | return failures;
116 | }
117 |
118 | public void setFailures(int value) {
119 | this.failures = value;
120 | }
121 |
122 | public int getErrors() {
123 | return errors;
124 | }
125 |
126 | public void setErrors(int value) {
127 | this.errors = value;
128 | }
129 |
130 | public BigDecimal getTime() {
131 | return time;
132 | }
133 |
134 | public void setTime(BigDecimal value) {
135 | this.time = value;
136 | }
137 | }
--------------------------------------------------------------------------------
/zephyr-sync-report-junit/src/main/java/lv/ctco/zephyr/beans/testresult/junit/JUnitTCProperties.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.beans.testresult.junit;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlAttribute;
6 | import javax.xml.bind.annotation.XmlType;
7 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
8 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | @XmlAccessorType(XmlAccessType.FIELD)
13 | @XmlType(name = "", propOrder = {
14 | "property"
15 | })
16 | public class JUnitTCProperties {
17 |
18 | protected List property;
19 |
20 | public List getProperty() {
21 | if (property == null) {
22 | property = new ArrayList();
23 | }
24 | return this.property;
25 | }
26 |
27 | @XmlAccessorType(XmlAccessType.FIELD)
28 | @XmlType(name = "")
29 | public static class Property {
30 |
31 | @XmlAttribute(name = "name", required = true)
32 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
33 | protected String name;
34 | @XmlAttribute(name = "value", required = true)
35 | protected String value;
36 |
37 | public String getName() {
38 | return name;
39 | }
40 |
41 | public void setName(String value) {
42 | this.name = value;
43 | }
44 |
45 | public String getValue() {
46 | return value;
47 | }
48 |
49 | public void setValue(String value) {
50 | this.value = value;
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/zephyr-sync-report-junit/src/main/java/lv/ctco/zephyr/transformer/JUnitTransformer.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.transformer;
2 |
3 | import lv.ctco.zephyr.ZephyrSyncException;
4 | import lv.ctco.zephyr.beans.TestCase;
5 | import lv.ctco.zephyr.beans.testresult.junit.JUnitResult;
6 | import lv.ctco.zephyr.beans.testresult.junit.JUnitResultTestSuite;
7 | import lv.ctco.zephyr.enums.TestStatus;
8 | import lv.ctco.zephyr.util.Utils;
9 |
10 | import javax.xml.bind.JAXBContext;
11 | import javax.xml.bind.JAXBException;
12 | import java.io.File;
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | public class JUnitTransformer implements ReportTransformer {
17 |
18 | public String getType() {
19 | return "junit";
20 | }
21 |
22 | public List transformToTestCases(String reportPath) {
23 | return transform(readJUnitReport(reportPath));
24 | }
25 |
26 | JUnitResultTestSuite readJUnitReport(String path) {
27 | try {
28 | JAXBContext jaxbContext = JAXBContext.newInstance(JUnitResultTestSuite.class);
29 | return (JUnitResultTestSuite) jaxbContext.createUnmarshaller().unmarshal(new File(path));
30 | } catch (JAXBException e) {
31 | throw new ZephyrSyncException("Cannot process JUnit report", e);
32 | }
33 | }
34 |
35 | List transform(JUnitResultTestSuite resultTestSuite) {
36 | if (resultTestSuite.getTestcase() == null) {
37 | return new ArrayList();
38 | }
39 |
40 | List result = new ArrayList();
41 | for (JUnitResult testCase : resultTestSuite.getTestcase()) {
42 | TestCase test = new TestCase();
43 | test.setName(testCase.getName());
44 | test.setUniqueId(generateUniqueId(testCase));
45 | test.setStatus(testCase.getError() != null || testCase.getFailure() != null ? TestStatus.FAILED : TestStatus.PASSED);
46 | result.add(test);
47 | }
48 | return result;
49 | }
50 |
51 | String generateUniqueId(JUnitResult testCase) {
52 | return String.join("-", Utils.normalizeKey(testCase.getClassname()), Utils.normalizeKey(testCase.getName()));
53 | }
54 | }
--------------------------------------------------------------------------------
/zephyr-sync-report-junit/src/main/resources/META-INF/services/lv.ctco.zephyr.transformer.ReportTransformer:
--------------------------------------------------------------------------------
1 | lv.ctco.zephyr.transformer.JUnitTransformer
--------------------------------------------------------------------------------
/zephyr-sync-report-nunit/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | zephyr-sync-master
5 | lv.ctco.zephyr
6 | 0.0.18-SNAPSHOT
7 |
8 | 4.0.0
9 |
10 | zephyr-sync-report-nunit
11 |
12 |
13 |
14 | lv.ctco.zephyr
15 | zephyr-sync-report-api
16 | ${project.version}
17 |
18 |
19 | lv.ctco.zephyr
20 | zephyr-sync-util
21 | ${project.version}
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/zephyr-sync-report-nunit/src/main/java/lv/ctco/zephyr/beans/testresult/nunit/NUnitResultTestRun.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.beans.testresult.nunit;
2 |
3 | import javax.xml.bind.annotation.*;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | @XmlAccessorType(XmlAccessType.FIELD)
8 | @XmlType(name = "test-run", propOrder = {
9 | "testSuites"
10 | })
11 | @XmlRootElement(name = "test-run")
12 | public class NUnitResultTestRun {
13 |
14 | @XmlElement(name = "test-suite")
15 | private List testSuites;
16 |
17 | public List getTestSuite() {
18 | if (testSuites == null) {
19 | testSuites = new ArrayList<>();
20 | }
21 | return this.testSuites;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/zephyr-sync-report-nunit/src/main/java/lv/ctco/zephyr/beans/testresult/nunit/NUnitTestCase.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.beans.testresult.nunit;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlAttribute;
6 | import javax.xml.bind.annotation.XmlRootElement;
7 |
8 | @XmlAccessorType(XmlAccessType.FIELD)
9 | @XmlRootElement(name = "test-case")
10 | public class NUnitTestCase {
11 |
12 | @XmlAttribute(name = "id")
13 | protected String id;
14 | @XmlAttribute(name = "name")
15 | protected String name;
16 | @XmlAttribute(name = "result")
17 | protected String result;
18 |
19 | public String getId() {
20 | return this.id;
21 | }
22 |
23 | public String getName() {
24 | return this.name;
25 | }
26 |
27 | public String getResult() {
28 | return this.result;
29 | }
30 |
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/zephyr-sync-report-nunit/src/main/java/lv/ctco/zephyr/beans/testresult/nunit/NUnitTestSuite.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.beans.testresult.nunit;
2 |
3 | import javax.xml.bind.annotation.*;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | @XmlAccessorType(XmlAccessType.FIELD)
8 | @XmlType(name = "test-suite", propOrder = {
9 | "testSuite",
10 | "testcase"
11 | })
12 | @XmlRootElement(name = "test-suite")
13 | public class NUnitTestSuite {
14 |
15 | @XmlMixed
16 | @XmlElementRef(name = "test-suite", type = NUnitTestSuite.class, required = true)
17 | private List testSuite;
18 |
19 | @XmlElement(name = "test-case")
20 | private List testcase;
21 |
22 | @XmlAttribute(name = "id")
23 | private String id;
24 | @XmlAttribute(name = "name")
25 | private String name;
26 | @XmlAttribute(name = "type")
27 | private String type;
28 |
29 | public List getTestSuite() {
30 | if (testSuite == null) {
31 | testSuite = new ArrayList<>();
32 | }
33 | return this.testSuite;
34 | }
35 |
36 | public List getTestCases() {
37 | if (testcase == null) {
38 | testcase = new ArrayList<>();
39 | }
40 | return this.testcase;
41 | }
42 |
43 | public List flattenTestSuite() {
44 | List result = new ArrayList<>();
45 | result.add(this);
46 | for (NUnitTestSuite nUnitTestSuite : getTestSuite()) {
47 | result.addAll(nUnitTestSuite.flattenTestSuite());
48 | }
49 |
50 | return result;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/zephyr-sync-report-nunit/src/main/java/lv/ctco/zephyr/transformer/NUnitTransformer.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.transformer;
2 |
3 | import lv.ctco.zephyr.ZephyrSyncException;
4 | import lv.ctco.zephyr.beans.TestCase;
5 | import lv.ctco.zephyr.beans.testresult.nunit.NUnitResultTestRun;
6 | import lv.ctco.zephyr.beans.testresult.nunit.NUnitTestCase;
7 | import lv.ctco.zephyr.beans.testresult.nunit.NUnitTestSuite;
8 | import lv.ctco.zephyr.enums.TestStatus;
9 |
10 | import javax.xml.bind.JAXBContext;
11 | import javax.xml.stream.XMLInputFactory;
12 | import javax.xml.stream.XMLStreamReader;
13 | import javax.xml.transform.stream.StreamSource;
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 |
18 | public class NUnitTransformer implements ReportTransformer {
19 |
20 | private static final String NUNIT_PASSED = "Passed";
21 |
22 | public String getType() {
23 | return "nunit";
24 | }
25 |
26 | public List transformToTestCases(String reportPath) {
27 | return transform(readNunitReport(reportPath));
28 | }
29 |
30 | NUnitResultTestRun readNunitReport(String path) {
31 | try {
32 | JAXBContext jaxbContext = JAXBContext.newInstance(NUnitResultTestRun.class);
33 |
34 | XMLInputFactory xif = XMLInputFactory.newFactory();
35 | XMLStreamReader xsr = xif.createXMLStreamReader(new StreamSource(path));
36 | xsr = xif.createFilteredReader(xsr, r -> r.getEventType() != XMLStreamReader.CHARACTERS || r.getText().trim().length() > 0);
37 | return (NUnitResultTestRun) jaxbContext.createUnmarshaller().unmarshal(xsr);
38 | } catch (Exception e) {
39 | throw new ZephyrSyncException("Cannot process NUnit report", e);
40 | }
41 | }
42 |
43 | List transform(NUnitResultTestRun resultTestSuite) {
44 | // NUnit places project name to the first test suite
45 | List nUnitTestSuites = resultTestSuite.getTestSuite().stream().findFirst().get().flattenTestSuite();
46 | List result = new ArrayList<>();
47 | for (NUnitTestSuite testSuite : nUnitTestSuites) {
48 | for (NUnitTestCase testCase : testSuite.getTestCases()) {
49 | TestCase test = new TestCase();
50 | test.setName(testCase.getName());
51 | test.setUniqueId(testCase.getId());
52 | test.setStatus(NUNIT_PASSED.equals(testCase.getResult()) ? TestStatus.PASSED : TestStatus.FAILED);
53 | result.add(test);
54 | }
55 | }
56 | return result;
57 | }
58 |
59 | }
--------------------------------------------------------------------------------
/zephyr-sync-report-nunit/src/main/resources/META-INF/services/lv.ctco.zephyr.transformer.ReportTransformer:
--------------------------------------------------------------------------------
1 | lv.ctco.zephyr.transformer.NUnitTransformer
--------------------------------------------------------------------------------
/zephyr-sync-util/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | zephyr-sync-master
5 | lv.ctco.zephyr
6 | 0.0.18-SNAPSHOT
7 |
8 | 4.0.0
9 |
10 | zephyr-sync-util
11 |
12 |
13 |
14 | com.fasterxml.jackson.core
15 | jackson-core
16 | 2.7.0
17 |
18 |
19 | com.fasterxml.jackson.core
20 | jackson-databind
21 | 2.7.0
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/zephyr-sync-util/src/main/java/lv/ctco/zephyr/ZephyrSyncException.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr;
2 |
3 | public class ZephyrSyncException extends RuntimeException {
4 |
5 | public ZephyrSyncException(String message) {
6 | super(message);
7 | }
8 |
9 | public ZephyrSyncException(String message, Throwable cause) {
10 | super(message, cause);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/zephyr-sync-util/src/main/java/lv/ctco/zephyr/util/ObjectTransformer.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.util;
2 |
3 | import com.fasterxml.jackson.annotation.JsonInclude;
4 | import com.fasterxml.jackson.core.JsonProcessingException;
5 | import com.fasterxml.jackson.databind.DeserializationFeature;
6 | import com.fasterxml.jackson.databind.JavaType;
7 | import com.fasterxml.jackson.databind.ObjectMapper;
8 | import com.fasterxml.jackson.databind.PropertyNamingStrategy;
9 |
10 | import java.io.IOException;
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 |
15 | public class ObjectTransformer {
16 | private static final ObjectMapper mapper = getObjectMapper();
17 |
18 | public static void setPropertyNamingStrategy(PropertyNamingStrategy strategy) {
19 | mapper.setPropertyNamingStrategy(strategy);
20 | }
21 |
22 | private static ObjectMapper getObjectMapper() {
23 | ObjectMapper mapper = new ObjectMapper();
24 | mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
25 | mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
26 | return mapper;
27 | }
28 |
29 | public static String serialize(Object obj) {
30 | try {
31 | return mapper.writeValueAsString(obj);
32 | } catch (JsonProcessingException e) {
33 | //TODO use logging
34 | e.printStackTrace();
35 | return null;
36 | }
37 | }
38 |
39 | public static T deserialize(String response, Class clazz) {
40 | JavaType typeRef = mapper.getTypeFactory().constructType(clazz);
41 | try {
42 | return mapper.readValue(response, typeRef);
43 | } catch (IOException e) {
44 | //TODO use logging
45 | e.printStackTrace();
46 | return null;
47 | }
48 | }
49 |
50 | public static List deserializeList(String response, Class clazz) {
51 | JavaType typeRef = mapper.getTypeFactory().constructCollectionType(List.class, clazz);
52 | try {
53 | return mapper.readValue(response, typeRef);
54 | } catch (IOException e) {
55 | //TODO use logging
56 | e.printStackTrace();
57 | return new ArrayList();
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/zephyr-sync-util/src/main/java/lv/ctco/zephyr/util/Utils.java:
--------------------------------------------------------------------------------
1 | package lv.ctco.zephyr.util;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 | import java.io.InputStreamReader;
7 |
8 | public class Utils {
9 |
10 | public static void log(String msg) {
11 | System.out.println("##### " + msg);
12 | }
13 |
14 | public static void log(String msg, Exception e) {
15 | System.out.println("##### " + msg);
16 | e.printStackTrace(System.out);
17 | }
18 |
19 | public static String readInputStream(InputStream is) throws IOException {
20 | InputStreamReader isr = new InputStreamReader(is, "UTF-8");
21 | BufferedReader br = new BufferedReader(isr);
22 |
23 | String inputLine;
24 | StringBuilder response = new StringBuilder();
25 | while ((inputLine = br.readLine()) != null) {
26 | response.append(inputLine);
27 | }
28 | br.close();
29 | return response.toString();
30 | }
31 |
32 | public static String normalizeKey(String input) {
33 | if (input != null && input.length() > 0) {
34 | String[] tokens = input.split(" ");
35 | input = "";
36 | for (String token : tokens) {
37 | input += token.substring(0, 1).toUpperCase();
38 | }
39 | }
40 | return input;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------