Skip to content

Commit

Permalink
Merge pull request #44 from companieshouse/feature/add-delete-error-t…
Browse files Browse the repository at this point in the history
…ests

Add retry and error delete integration tests
  • Loading branch information
amartin7663 authored Jun 8, 2022
2 parents cd9e057 + e5f7bae commit 9592471
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,25 @@ public void theConsumerReceivesDelete() throws Exception {
countDown();
}

@When("the consumer receives an invalid delete payload")
public void theConsumerReceivesInvalidDelete() throws Exception {
configureWiremock();
ChsDelta delta = new ChsDelta("invalid", 1, "1", true);
kafkaTemplate.send(mainTopic, delta);

countDown();
}

@When("^the consumer receives a delete message but the data api returns a (\\d*)$")
public void theConsumerReceivesDeleteMessageButDataApiReturns(int responseCode) throws Exception{
configureWiremock();
stubDeleteDisqualification(responseCode);
ChsDelta delta = new ChsDelta(TestData.getDeleteData(), 1, "1", true);
kafkaTemplate.send(mainTopic, delta);

countDown();
}

@Then("a DELETE request is sent to the disqualifications api with the encoded Id")
public void deleteRequestIsSent() {
verify(1, deleteRequestedFor(urlMatching(
Expand Down
21 changes: 20 additions & 1 deletion src/itest/resources/features/Delete.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,23 @@ Feature: Delete
Scenario: send DELETE request to data Api
Given the application is running
When the consumer receives a delete payload
Then a DELETE request is sent to the disqualifications api with the encoded Id
Then a DELETE request is sent to the disqualifications api with the encoded Id

Scenario: send DELETE with invalid JSON
Given the application is running
When the consumer receives an invalid delete payload
Then the message should be moved to topic disqualified-officers-delta-invalid

Scenario: send DELETE with 400 from data api
Given the application is running
When the consumer receives a delete message but the data api returns a 400
Then the message should be moved to topic disqualified-officers-delta-invalid

Scenario Outline: send DELETE with retryable response from data api
Given the application is running
When the consumer receives a delete message but the data api returns a <code>
Then the message should retry 3 times and then error
Examples:
| code |
| 404 |
| 503 |

0 comments on commit 9592471

Please sign in to comment.