Skip to content

Commit 1658e21

Browse files
committed
Add integration test
1 parent cf1faa2 commit 1658e21

File tree

2 files changed

+229
-0
lines changed

2 files changed

+229
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package com.assertthat.plugins;
2+
3+
import com.assertthat.plugins.standalone.APIUtil;
4+
import org.codehaus.jettison.json.JSONException;
5+
import org.junit.Before;
6+
import org.junit.Test;
7+
8+
import java.io.File;
9+
import java.io.IOException;
10+
11+
import static org.junit.Assert.*;
12+
13+
public class APIUtilIntegrationTest {
14+
15+
private APIUtil apiUtil;
16+
private static final String PROJECT_ID = System.getenv("PROJECT_ID");
17+
private static final String ACCESS_KEY = System.getenv("ACCESS_KEY");
18+
private static final String SECRET_KEY = System.getenv("SECRET_KEY");
19+
private static final String TOKEN = System.getenv("TOKEN");
20+
private static final String JIRA_SERVER_URL = System.getenv("JIRA_SERVER_URL");
21+
22+
// @Before
23+
public void setUp() {
24+
assertNotNull("PROJECT_ID environment variable is required", PROJECT_ID);
25+
assertNotNull("ACCESS_KEY environment variable is required", ACCESS_KEY);
26+
assertNotNull("SECRET_KEY environment variable is required", SECRET_KEY);
27+
assertNotNull("TOKEN environment variable is required", TOKEN);
28+
assertNotNull("JIRA_SERVER_URL environment variable is required", JIRA_SERVER_URL);
29+
30+
apiUtil = new APIUtil(PROJECT_ID, ACCESS_KEY, SECRET_KEY, TOKEN, null, null, null, JIRA_SERVER_URL, false);
31+
}
32+
33+
//@Test
34+
public void testDownload() throws IOException {
35+
// Define target directory for downloading files
36+
File targetDir = new File("target/features");
37+
if (targetDir.exists()) {
38+
for (File f : targetDir.listFiles()) {
39+
if (f.getName().endsWith(".feature")) {
40+
f.delete();
41+
}
42+
}
43+
} else {
44+
targetDir.mkdirs();
45+
}
46+
47+
// Download features with specific parameters
48+
File downloadedFile = apiUtil.download(targetDir, "automated", null, null, true, true);
49+
50+
// Verify the downloaded file
51+
assertNotNull("Downloaded file should not be null", downloadedFile);
52+
assertTrue("Downloaded file should exist", downloadedFile.exists());
53+
assertTrue("Downloaded file should be a zip file", downloadedFile.getName().endsWith(".zip"));
54+
55+
System.out.println("Downloaded file path: " + downloadedFile.getAbsolutePath());
56+
}
57+
58+
//@Test
59+
public void testUpload() throws IOException, JSONException {
60+
// Prepare a test file to upload
61+
File testFile = new File("src/test/java/com/assertthat/plugins/cucumber.json");
62+
if (!testFile.exists()) {
63+
// Assuming this is a test integration, create a small sample file
64+
testFile.createNewFile();
65+
}
66+
67+
// Upload the file
68+
Long runId = -1L; // Example runId
69+
String runName = "IntegrationTestRun";
70+
String type = "type";
71+
String metadata = "{\"sample\":\"data\"}";
72+
73+
Long resultRunId = apiUtil.upload(runId, runName, testFile.getAbsolutePath(), type, metadata, null);
74+
75+
// Verify that upload was successful
76+
assertNotNull("Returned runId should not be null", resultRunId);
77+
assertEquals("Returned runId should match the expected", runId, resultRunId);
78+
79+
System.out.println("Uploaded run ID: " + resultRunId);
80+
}
81+
}
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
[
2+
{
3+
"line": 3,
4+
"elements": [
5+
{
6+
"start_timestamp": "2024-11-09T20:17:45.361Z",
7+
"before": [
8+
{
9+
"result": {
10+
"duration": 6093041200,
11+
"status": "passed"
12+
},
13+
"match": {
14+
"location": "com.assertthat.StepDefinition.beforeScenario(io.cucumber.java.Scenario)"
15+
}
16+
}
17+
],
18+
"line": 8,
19+
"name": "Any member of the team can easily add and edit acceptance tests for user stories",
20+
"description": "",
21+
"id": "add-acceptance-tests-to-my-user-stories-with-assertthat-for-jira;any-member-of-the-team-can-easily-add-and-edit-acceptance-tests-for-user-stories",
22+
"after": [
23+
{
24+
"result": {
25+
"duration": 1265791100,
26+
"status": "passed"
27+
},
28+
"match": {
29+
"location": "com.assertthat.StepDefinition.teardown()"
30+
}
31+
}
32+
],
33+
"type": "scenario",
34+
"keyword": "Scenario",
35+
"steps": [
36+
{
37+
"result": {
38+
"status": "undefined"
39+
},
40+
"line": 10,
41+
"name": "I navigate to a user story in Jira",
42+
"match": {},
43+
"keyword": "Given "
44+
},
45+
{
46+
"result": {
47+
"status": "skipped"
48+
},
49+
"line": 11,
50+
"name": "I link multiple scenarios from feature files to the user story",
51+
"match": {},
52+
"keyword": "When "
53+
},
54+
{
55+
"result": {
56+
"status": "skipped"
57+
},
58+
"line": 12,
59+
"name": "I amend the scenarios from within the story",
60+
"match": {},
61+
"keyword": "And "
62+
},
63+
{
64+
"result": {
65+
"status": "skipped"
66+
},
67+
"line": 13,
68+
"name": "scenarios can be managed to ensure better collaboration for my team",
69+
"match": {},
70+
"keyword": "Then "
71+
},
72+
{
73+
"result": {
74+
"status": "skipped"
75+
},
76+
"line": 14,
77+
"name": "an existing feature with multiple scenarios",
78+
"match": {},
79+
"keyword": "When "
80+
}
81+
],
82+
"tags": [
83+
{
84+
"name": "@syntax-validation"
85+
},
86+
{
87+
"name": "@import-automated-tests"
88+
},
89+
{
90+
"name": "@sdads"
91+
},
92+
{
93+
"name": "@AUTOMATED"
94+
},
95+
{
96+
"name": "@add-scenarios"
97+
},
98+
{
99+
"name": "@link-scenarios-stories"
100+
},
101+
{
102+
"name": "@edit-scenarios"
103+
},
104+
{
105+
"name": "@DEMO-2"
106+
},
107+
{
108+
"name": "@DEMO-3"
109+
},
110+
{
111+
"name": "@DEMO-24"
112+
}
113+
]
114+
}
115+
],
116+
"name": "Add acceptance tests to my user stories with AssertThat for Jira",
117+
"description": " AssertThat for Jira provides the tools to manage acceptance tests into features and scenarios and seamlessly integrate with the user stories in Jira, enabling the team to work in partnership on projects.",
118+
"id": "add-acceptance-tests-to-my-user-stories-with-assertthat-for-jira",
119+
"keyword": "Feature",
120+
"uri": "file:src/test/resources/com/assertthat/features/add-acceptance-tests-to-my-user-stories-with-assertthat-for-jira.feature",
121+
"tags": [
122+
{
123+
"name": "@syntax-validation",
124+
"type": "Tag",
125+
"location": {
126+
"line": 2,
127+
"column": 1
128+
}
129+
},
130+
{
131+
"name": "@import-automated-tests",
132+
"type": "Tag",
133+
"location": {
134+
"line": 2,
135+
"column": 23
136+
}
137+
},
138+
{
139+
"name": "@sdads",
140+
"type": "Tag",
141+
"location": {
142+
"line": 2,
143+
"column": 50
144+
}
145+
}
146+
]
147+
}
148+
]

0 commit comments

Comments
 (0)