Skip to main content

End-to-end (E2E) API tests

This module contains end-to-end (E2E) API tests for the service.

Tests are written in Java + JUnit 5 using REST Assured for API validation and JSON Schema Validator for response shape checks.

⚙️ Configuration

Environment property files

Each environment has a .properties file under src/test/resources/. Example:

preprod.properties

base.url=https://laa-provider-details-api-preprod.apps.live.cloud-platform.service.justice.gov.uk
base.path=/api/v1

prod.properties

base.url=https://laa-provider-details-api-prod.apps.live.cloud-platform.service.justice.gov.uk
base.path=/api/v1

🔑 Supplying the auth token

The API requires the header X-Authorization.

The token can be supplied in either of the following ways:

  1. Java system property
   ./gradlew :providers-e2e:e2eTest -Dauth.token=your-secret-token
  1. Environment variable
   export AUTH_TOKEN=your-secret-token
   ./gradlew :providers-e2e:e2eTest

If no token is provided, the test run will fail early.

▶️ Running tests

Default (prod environment)

./gradlew :providers-e2e:e2eTest -Dauth.token=your-secret-token

Run against preprod

./gradlew :providers-e2e:e2eTest -Penv=preprod -Dauth.token=your-secret-token

Run against local

./gradlew :providers-e2e:e2eTest -Penv=local -Dauth.token=Dummy1

Run an individual file or test

./gradlew :providers-e2e:e2eTest --tests "uk.gov.justice.laa.e2e.ProviderFirmOfficeApiTest"

./gradlew :providers-e2e:e2eTest --tests "uk.gov.justice.laa.e2e.ProviderFirmApiTest.providerFirm_shouldMatchSchema"

These tests validate cache behavior by clearing or force-reloading the application cache, then confirming that dependent endpoints still respond correctly.

🧠 Purpose

  • Cache Clear: Ensures that when cache is cleared, endpoints relying on it still return valid data (via database fallback).

  • Cache Reload: Confirms that once the cache is reloaded, the system becomes ready and endpoints respond successfully.

🏷️ Tagging convention

Any test class that should run after all normal E2E tests must be annotated with:

@Tag("cache-end")

This tag signals Gradle to run these tests at the end of the E2E suite.

It prevents interference with normal API tests and ensures the cache state is managed cleanly.

▶️ Running tagged cache tests

Run only cache-related tests:

./gradlew :providers-e2e:e2eCacheEnd -Penv=local -Dauth.token=Dummy1

Or run all tests (normal + cache-tagged in order):

./gradlew :providers-e2e:e2eTest -Penv=local -Dauth.token=Dummy1

Tagged cache tests will automatically execute last in the sequence.

📦 Gradle notes

  • The e2eTest task is separate from the main test task.

Running ./gradlew build will not execute E2E tests by default.

  • Use ./gradlew :providers-e2e:e2eTest explicitly to run them.