Skip to content

Commit

Permalink
Ref data Rest assured tests (#357)
Browse files Browse the repository at this point in the history
* removing docker-compose.yml file

* removed unused imports

* reformatted the files

* reformatted the files to avoid violations

* removed unused import

* tidied up unused code

* code has been changed slightly

* using logged info and changed assertion

* Fix checkstyle issues

* applied filter to reduce the no.of records displaying on console

---------

Co-authored-by: rajanigandra <Rajani Gandra>
Co-authored-by: Cade Faulkner <147704481+CadeFaulkner@users.noreply.github.com>
Co-authored-by: Sabah u din Irfan <sabah.irfan@gmail.com>
  • Loading branch information
3 people committed May 20, 2024
1 parent 73a7923 commit c321e25
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
@IncludeEngines("cucumber")
@SelectClasspathResource("features")
public class Junit5RunnerTest {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package uk.gov.hmcts.opal.config;

public class Constants {

public static final String COURTS_REF_DATA_URI = "/api/court/ref-data/";
public static final String LJA_REF_DATA_URI = "/api/local-justice-area/ref-data/";
public static final String OFFENCES_REF_DATA_URI = "/api/offence/ref-data/";
}
23 changes: 23 additions & 0 deletions src/functionalTest/java/uk/gov/hmcts/opal/steps/Courts.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package uk.gov.hmcts.opal.steps;

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

import static uk.gov.hmcts.opal.config.Constants.COURTS_REF_DATA_URI;
import static uk.gov.hmcts.opal.steps.BearerTokenStepDef.getToken;

public class Courts extends BaseStepDef {

@When("I make a request to the court ref data api with")
public void getRequestToCourtsRefData() {
SerenityRest
.given()
.accept("*/*")
.header("Authorization", "Bearer " + getToken())
.contentType("application/json")
.when()
.get(getTestUrl() + COURTS_REF_DATA_URI);

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package uk.gov.hmcts.opal.steps;


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

import static uk.gov.hmcts.opal.config.Constants.LJA_REF_DATA_URI;
import static uk.gov.hmcts.opal.steps.BearerTokenStepDef.getToken;

public class LocalJusticeArea extends BaseStepDef {

@When("I make a request to the LJA ref data api with")
public void getRequestToLJARefData() {
SerenityRest
.given()
.accept("*/*")
.header("Authorization", "Bearer " + getToken())
.contentType("application/json")
.when()
.get(getTestUrl() + LJA_REF_DATA_URI);

}

}
44 changes: 44 additions & 0 deletions src/functionalTest/java/uk/gov/hmcts/opal/steps/Offences.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package uk.gov.hmcts.opal.steps;

import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import net.serenitybdd.rest.SerenityRest;
import org.hamcrest.Matchers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static net.serenitybdd.rest.SerenityRest.then;
import static uk.gov.hmcts.opal.config.Constants.OFFENCES_REF_DATA_URI;
import static uk.gov.hmcts.opal.steps.BearerTokenStepDef.getToken;


public class Offences extends BaseStepDef {

static Logger log = LoggerFactory.getLogger(Offences.class.getName());

@When("I make a request to the offence ref data api filtering by cjs code {string}")
public void getRequestToOffencesRefData(String filter) {
SerenityRest
.given()
.accept("*/*")
.header("Authorization", "Bearer " + getToken())
.contentType("application/json")
.when()
.get(getTestUrl() + OFFENCES_REF_DATA_URI + filter);

}

@Then("the LJA ref data matching to result")
@Then("the court ref data matching to result")
@Then("the offence ref data matching to result")
public void theRefDataMatchingToResult() {
int totalCount = then().extract().jsonPath().getInt("count");
int refDataList = then().extract().jsonPath().getList("refData").size();
log.info("total count is : " + totalCount);
log.info("Total records in the json response" + refDataList);
then().assertThat()
.statusCode(200)
.body("count", Matchers.equalTo(refDataList));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Feature: Test the Offence Reference data for end points

@PO-311 @Opal
#PO-311
Scenario: Checking the end points for Offence ref data
Given I am testing as the "opal-test@hmcts.net" user
When I make a request to the offence ref data api filtering by cjs code "AA06"
Then the offence ref data matching to result
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Feature: Test the Court data for end points

@PO-315 @Opal
#PO-315
Scenario: Checking the end points for court ref data
Given I am testing as the "opal-test@hmcts.net" user
When I make a request to the court ref data api with
Then the court ref data matching to result
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Feature: Test the LJA Reference data for end points

@PO-312 @Opal
#PO-312
Scenario: Checking the end points for LJA ref data
Given I am testing as the "opal-test@hmcts.net" user
When I make a request to the LJA ref data api with
Then the LJA ref data matching to result

0 comments on commit c321e25

Please sign in to comment.