diff --git a/src/functionalTest/java/uk/gov/hmcts/opal/config/Constants.java b/src/functionalTest/java/uk/gov/hmcts/opal/config/Constants.java index fb339d81a..d4a2e8127 100644 --- a/src/functionalTest/java/uk/gov/hmcts/opal/config/Constants.java +++ b/src/functionalTest/java/uk/gov/hmcts/opal/config/Constants.java @@ -2,6 +2,7 @@ public class Constants { + public static final String BUSINESS_UNIT_REF_DATA_URI = "/api/business-unit/ref-data/"; 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/"; diff --git a/src/functionalTest/java/uk/gov/hmcts/opal/steps/BusinessUnitsStepDef.java b/src/functionalTest/java/uk/gov/hmcts/opal/steps/BusinessUnitsStepDef.java new file mode 100644 index 000000000..6ee36378f --- /dev/null +++ b/src/functionalTest/java/uk/gov/hmcts/opal/steps/BusinessUnitsStepDef.java @@ -0,0 +1,42 @@ +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.BUSINESS_UNIT_REF_DATA_URI; +import static uk.gov.hmcts.opal.steps.BearerTokenStepDef.getToken; + +public class BusinessUnitsStepDef extends BaseStepDef { + + static Logger log = LoggerFactory.getLogger(BusinessUnitsStepDef.class.getName()); + + @When("I make a request to the business unit ref data api filtering by business unit type {string}") + public void getRequestToBusinessUnitRefData(String filter) { + + SerenityRest + .given() + .accept("*/*") + .header("Authorization", "Bearer " + getToken()) + .contentType("application/json") + .when() + .get(getTestUrl() + BUSINESS_UNIT_REF_DATA_URI + filter); + + } + + @Then("the business unit 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)); + } + +} diff --git a/src/functionalTest/resources/features/opalMode/businessUnitFeatures.feature b/src/functionalTest/resources/features/opalMode/businessUnitFeatures.feature new file mode 100644 index 000000000..606f339f5 --- /dev/null +++ b/src/functionalTest/resources/features/opalMode/businessUnitFeatures.feature @@ -0,0 +1,9 @@ +@Opal @PO-313 +Feature: Verifying the end points for business units + + + Scenario: verifying the end points for API for Business Units Ref Data + Given I am testing as the "opal-test@hmcts.net" user + When I make a request to the business unit ref data api filtering by business unit type "area" + Then the business unit ref data matching to result +