From 68ac44bd8ba902aac6c2c7c8ae859c51d310ed52 Mon Sep 17 00:00:00 2001 From: amartin7663 Date: Wed, 8 Jun 2022 12:43:19 +0100 Subject: [PATCH 1/2] add retry and erro delete integration tests --- .../delta/steps/CommonSteps.java | 20 ++++++++++++++++++ src/itest/resources/features/Delete.feature | 21 ++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/itest/java/uk/gov/companieshouse/disqualifiedofficers/delta/steps/CommonSteps.java b/src/itest/java/uk/gov/companieshouse/disqualifiedofficers/delta/steps/CommonSteps.java index 1becf2d..793461a 100644 --- a/src/itest/java/uk/gov/companieshouse/disqualifiedofficers/delta/steps/CommonSteps.java +++ b/src/itest/java/uk/gov/companieshouse/disqualifiedofficers/delta/steps/CommonSteps.java @@ -133,6 +133,26 @@ public void theConsumerReceivesDelete() throws Exception { countDown(); } + @When("the consumer receives an invalid delete payload") + public void theConsumerReceivesInvalidDelete() throws Exception { + configureWiremock(); + stubDeleteDisqualification(200); + 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( diff --git a/src/itest/resources/features/Delete.feature b/src/itest/resources/features/Delete.feature index 7997435..b9de504 100644 --- a/src/itest/resources/features/Delete.feature +++ b/src/itest/resources/features/Delete.feature @@ -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 \ No newline at end of file + 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 + Then the message should retry 3 times and then error + Examples: + | code | + | 404 | + | 503 | \ No newline at end of file From e5f7bae405c0720789a8a63bf8523b5dda0ad7c7 Mon Sep 17 00:00:00 2001 From: amartin7663 Date: Wed, 8 Jun 2022 13:39:04 +0100 Subject: [PATCH 2/2] remove unnecessary stubbing --- .../disqualifiedofficers/delta/steps/CommonSteps.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/itest/java/uk/gov/companieshouse/disqualifiedofficers/delta/steps/CommonSteps.java b/src/itest/java/uk/gov/companieshouse/disqualifiedofficers/delta/steps/CommonSteps.java index 793461a..724f318 100644 --- a/src/itest/java/uk/gov/companieshouse/disqualifiedofficers/delta/steps/CommonSteps.java +++ b/src/itest/java/uk/gov/companieshouse/disqualifiedofficers/delta/steps/CommonSteps.java @@ -136,7 +136,6 @@ public void theConsumerReceivesDelete() throws Exception { @When("the consumer receives an invalid delete payload") public void theConsumerReceivesInvalidDelete() throws Exception { configureWiremock(); - stubDeleteDisqualification(200); ChsDelta delta = new ChsDelta("invalid", 1, "1", true); kafkaTemplate.send(mainTopic, delta);