Skip to content

Commit

Permalink
Tests for PO-647 (#605)
Browse files Browse the repository at this point in the history
* Tests added for PO-647

* updated draft account get steps

* updated as per the functional checks

* updated the endpoints

---------

Co-authored-by: rajanigandra <Rajani Gandra>
  • Loading branch information
rajanigandra authored Oct 24, 2024
1 parent c4e5cc1 commit 7a5bfce
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public class Constants {
public static final String ENFORCERS_REF_DATA_URI = "/enforcers?q=Aldridge";
public static final String MAJOR_CREDITORS_URI = "/major-creditors";
public static final String DRAFT_ACCOUNT_URI = "/draft-accounts";
public static final String DRAFT_ACCOUNTS_URI = "/draft-accounts";
public static final String RESULTS_URI = "/results";
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import io.cucumber.java.en.And;
import io.cucumber.java.en.When;
import net.serenitybdd.rest.SerenityRest;
import org.json.JSONException;
import uk.gov.hmcts.opal.steps.BaseStepDef;
import uk.gov.hmcts.opal.utils.DraftAccountUtils;

Expand All @@ -28,6 +27,7 @@ public void getDraftAccount(String draftAccountId) {
.get(getTestUrl() + DRAFT_ACCOUNT_URI + "/" + draftAccountId);
}


@When("I get the draft account trying to provoke an internal server error")
public void getDraftAccountInternalServerError() {
SerenityRest
Expand All @@ -41,7 +41,7 @@ public void getDraftAccountInternalServerError() {
}

@When("I attempt to get a draft account with an invalid token")
public void getDraftAccountWithInvalidToken() throws JSONException {
public void getDraftAccountWithInvalidToken() {
SerenityRest
.given()
.header("Authorization", "Bearer " + "invalidToken")
Expand All @@ -52,7 +52,7 @@ public void getDraftAccountWithInvalidToken() throws JSONException {
}

@When("I attempt to get a draft account with an unsupported content type")
public void getDraftAccountWithUnsupportedContentType() throws JSONException {
public void getDraftAccountWithUnsupportedContentType() {
assertEquals(
1,
DraftAccountUtils.getAllDraftAccountIds().size(),
Expand Down Expand Up @@ -211,4 +211,39 @@ public void draftAccountFilteredResponseDoesNotContainAccountsSubmittedBy(String
assertNotEquals(filter, submittedBy, "should not contain " + filter);
}
}

@When("I attempt to get draft accounts with an invalid token")
public void getDraftAccountsWithAnInvalidToken() {
SerenityRest
.given()
.header("Authorization", "Bearer " + "invalidToken")
.accept("*/*")
.contentType("application/json")
.when()
.get(getTestUrl() + DRAFT_ACCOUNT_URI);
}

@When("I attempt to get draft accounts with an unsupported content type")
public void getDraftAccountsWithAnUnsupportedContentType() {
//String draftAccountId = DraftAccountUtils.getAllDraftAccountIds().getLast();
SerenityRest
.given()
.header("Authorization", "Bearer " + getToken())
.accept("text/plain")
.contentType("application/json")
.when()
.get(getTestUrl() + DRAFT_ACCOUNT_URI);
}

@When("I get the draft accounts trying to provoke an internal server error")
public void getDraftAccountsToProvokeInternalServerError() {
SerenityRest
.given()
.urlEncodingEnabled(false)
.header("Authorization", "Bearer " + getToken())
.accept("*/*")
.contentType("application/json")
.when()
.get(getTestUrl() + DRAFT_ACCOUNT_URI + "?business_unit=%20");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@Opal
Feature: PO-647 get draft accounts error handling

@PO-647 @cleanUpData
Scenario: Get draft account - CEP2 - Invalid or No Access Token
Given I am testing as the "opal-test@hmcts.net" user
When I attempt to get draft accounts with an invalid token
Then The draft account response returns 401

@PO-647 @cleanUpData
Scenario: Get draft account - CEP5 - Unsupported Content Type
Given I am testing as the "opal-test@hmcts.net" user
When I create a draft account with the following details
| business_unit_id | 73 |
| account | draftAccounts/accountJson/account.json |
| account_type | Fine |
| account_status | |
| submitted_by | BUUID |
| timeline_data | |
Then The draft account response returns 201
And I store the created draft account ID
When I create a draft account with the following details
| business_unit_id | 65 |
| account | draftAccounts/accountJson/adultAccount.json |
| account_type | Fine |
| account_status | |
| submitted_by | BUUID |
| timeline_data | |
Then The draft account response returns 201
And I store the created draft account ID

When I attempt to get draft accounts with an unsupported content type
Then The draft account response returns 406

@PO-647 @cleanUpData
Scenario: Get draft account - CEP9 - Other Server Error
Given I am testing as the "opal-test@hmcts.net" user
When I get the draft accounts trying to provoke an internal server error
Then The draft account response returns 500

0 comments on commit 7a5bfce

Please sign in to comment.