Skip to content

Commit

Permalink
Po 703 tests (#530)
Browse files Browse the repository at this point in the history
* updating serenity - report plugin version

* updating serenity - report plugin version

* tests for PO-703
  • Loading branch information
CadeFaulkner authored Sep 16, 2024
1 parent b3711ba commit d5322ab
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"packageRules": [
{
"matchPackageNames": ["net.serenity-bdd.serenity-gradle-plugin"],
"allowedVersions": "4.0.46"
"allowedVersions": "4.2.1"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ public class Constants {
public static final String ENFORCERS_REF_DATA_URI = "/enforcers/ref-data/Aldridge";
public static final String MAJOR_CREDITORS_URI = "/major-creditors/";
public static final String DRAFT_ACCOUNT_URI = "/draft-accounts";
public static final String RESULTS_URI = "/results";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package uk.gov.hmcts.opal.steps;

import io.cucumber.datatable.DataTable;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import net.serenitybdd.rest.SerenityRest;

import java.util.Map;

import static net.serenitybdd.rest.SerenityRest.then;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static uk.gov.hmcts.opal.config.Constants.RESULTS_URI;
import static uk.gov.hmcts.opal.steps.BearerTokenStepDef.getToken;

public class GetResultsStepDef extends BaseStepDef {
@When("I make a request to get the results {string}")
public void getResults(String resultIds) {
SerenityRest
.given()
.header("Authorization", "Bearer " + getToken())
.accept("*/*")
.contentType("application/json")
.param("result_ids", resultIds)
.when()
.get(getTestUrl() + RESULTS_URI);
}

@Then("The results response contains {int} results")
public void resultsResponseContainsCount(int count) {
then().assertThat()
.statusCode(200).body("count", equalTo(count));
}

@Then("The results response contains the following result")
public void resultsResponseContains(DataTable data) {
Map<String, String> expected = data.asMap(String.class, String.class);
String resultID = expected.get("result_id");
for (String key : expected.keySet()) {
String actual = then().extract().body().jsonPath().getString("refData.find { it.result_id == '"
+ resultID + "' }." + key);
assertEquals(expected.get(key), actual, "Values are not equal");
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
@Opal
Feature: PO-703 results happy path

@PO-703
Scenario: get results - happy path
Given I am testing as the "[email protected]" user
When I make a request to get the results ""
Then The results response contains 59 results

And The results response contains the following result
| result_id | REM |
| result_title | Final reminder of unpaid fine |
| result_title_cy | Nodyn atgoffa terfynol am ddirwy heb ei thalu |
| active | true |
| result_type | Result |
| imposition_creditor | |
| imposition_allocation_order | |


And The results response contains the following result
| result_id | UPWO |
| result_title | UNPAID WORK ORDER |
| result_title_cy | |
| active | true |
| result_type | Result |
| imposition_creditor | |
| imposition_allocation_order | |

And The results response contains the following result
| result_id | FCOMP |
| result_title | Compensation |
| result_title_cy | Iawndal |
| active | true |
| result_type | Result |
| imposition_creditor | Any |
| imposition_allocation_order | 1 |

@PO-703
Scenario: get results - happy path filtered by result id
Given I am testing as the "[email protected]" user
When I make a request to get the results "FO,ABDC"
Then The results response contains 2 results

And The results response contains the following result
| result_id | FO |
| result_title | Fine |
| result_title_cy | Dirwy |
| active | true |
| result_type | Result |
| imposition_creditor | CF |
| imposition_allocation_order | |

And The results response contains the following result
| result_id | ABDC |
| result_title | Application made for benefit deductions |
| result_title_cy | Cais am dynnu arian o fudd-daliadau |
| active | true |
| result_type | Result |
| imposition_creditor | |
| imposition_allocation_order | |


0 comments on commit d5322ab

Please sign in to comment.