Skip to content

Commit 46d9f90

Browse files
Add timer and check for requests in query integration test (#143)
* Add timer and check for requests in query integration test * Check for response code 204 * Minor fix
1 parent c16b96e commit 46d9f90

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

src/integrationtest/java/com/ericsson/ei/frontend/CommonSteps.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.io.File;
66
import java.io.IOException;
77
import java.nio.file.Paths;
8+
import java.util.concurrent.TimeUnit;
89
import java.util.concurrent.TimeoutException;
910

1011
import org.apache.commons.io.FileUtils;
@@ -139,6 +140,15 @@ public void request_sent() throws Throwable {
139140
response = httpRequest.performRequest();
140141
}
141142

143+
@When("^request is sent for (\\d+) seconds until reponse code no longer matches (\\d+)$")
144+
public void request_sent_body_not_received(int seconds, int statusCode) throws Throwable {
145+
long stopTime = System.currentTimeMillis() + (seconds * 1000);
146+
do {
147+
response = httpRequest.performRequest();
148+
} while (response.getStatusCode().value() == statusCode && stopTime > System.currentTimeMillis());
149+
assertEquals(HttpStatus.OK, response.getStatusCode());
150+
}
151+
142152
@Then("^response code (\\d+) is received$")
143153
public void get_response_code(int statusCode) throws Throwable {
144154
LOGGER.debug("Response code: {}", response.getStatusCode());
@@ -163,6 +173,7 @@ public void get_response_body_from_file(String filename) throws Throwable {
163173
@Then("^response body contains \'(.*)\'$")
164174
public void response_body_contains(String contains) throws Throwable {
165175
LOGGER.debug("Response body: {}", response.getBody());
176+
LOGGER.debug("Contains: {}", contains);
166177
assertEquals(true, response.getBody().contains(contains));
167178
}
168179
}

src/integrationtest/resources/bodies/subscription_single.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"type": "ARTIFACT_1"
3636
}
3737
],
38-
"subscriptionName": "Subscription_Test",
38+
"subscriptionName": "Subscription_IT",
3939
"userName": "ABC"
4040
}
4141
]

src/integrationtest/resources/bodies/subscription_single_modify.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"type": "ARTIFACT_1"
3636
}
3737
],
38-
"subscriptionName": "Subscription_Test",
38+
"subscriptionName": "Subscription_IT",
3939
"userName": "ABC"
4040
}
4141
]

src/integrationtest/resources/features/query.feature

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ Feature: Query test
1616
And an aggregated object is created
1717
When a 'GET' request is prepared for REST API '/queryAggregatedObject'
1818
And param key 'ID' with value '6acc3c87-75e0-4b6d-88f5-b1a5d4e62b43' is added
19-
And request is sent
20-
Then response code 200 is received
19+
And request is sent for 30 seconds until reponse code no longer matches 204
2120
And response body contains '6acc3c87-75e0-4b6d-88f5-b1a5d4e62b43'
2221

2322
@QueryFreestyleScenario
@@ -26,6 +25,5 @@ Feature: Query test
2625
And an aggregated object is created
2726
When a 'POST' request is prepared for REST API '/query'
2827
And body is set to file 'queryFreestyle.json'
29-
And request is sent
30-
Then response code 200 is received
28+
And request is sent for 30 seconds until reponse code no longer matches 204
3129
And response body contains '6acc3c87-75e0-4b6d-88f5-b1a5d4e62b43'

src/integrationtest/resources/features/subscriptions.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Feature: Subscriptions test
2323
Scenario: Get subscription
2424
Given frontend is up and running
2525
When a 'GET' request is prepared for REST API '/subscriptions'
26-
And '/Subscription_Test' is appended to endpoint
26+
And '/Subscription_IT' is appended to endpoint
2727
And username "gauss" and password "password" is used as credentials
2828
And request is sent
2929
Then response code 200 is received
@@ -33,7 +33,7 @@ Feature: Subscriptions test
3333
Scenario: Delete subscription
3434
Given frontend is up and running
3535
When a 'DELETE' request is prepared for REST API '/subscriptions'
36-
And '/Subscription_Test' is appended to endpoint
36+
And '/Subscription_IT' is appended to endpoint
3737
And username "gauss" and password "password" is used as credentials
3838
And request is sent
3939
Then response code 200 is received

0 commit comments

Comments
 (0)