generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added Pact test for ccd case disposer consuming delete end point of WA/TM Rebased from master * Updated Jenkins_Cnp file to accommodate pact testing * Updated build.gradle to resolve ANTLR dependency issue * Updated the pact version to resolve the pact publish issue * Made review changes --------- Co-authored-by: Muhammad Husain <[email protected]>
- Loading branch information
Showing
5 changed files
with
213 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/contractTest/java/uk/gov/hmcts/reform/ccd/SpringBootContractBaseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package uk.gov.hmcts.reform.ccd; | ||
|
||
import au.com.dius.pact.consumer.junit5.PactConsumerTestExt; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.test.context.TestPropertySource; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
|
||
import static org.springframework.http.HttpHeaders.AUTHORIZATION; | ||
|
||
@Slf4j | ||
@ExtendWith(PactConsumerTestExt.class) | ||
@ExtendWith(SpringExtension.class) | ||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
@TestPropertySource(locations = {"classpath:application.properties"}) | ||
public abstract class SpringBootContractBaseTest { | ||
|
||
public static final String PACT_TEST_EMAIL_VALUE = "[email protected]"; | ||
public static final String PACT_TEST_PASSWORD_VALUE = "London01"; | ||
public static final String PACT_TEST_CLIENT_ID_VALUE = "pact"; | ||
public static final String PACT_TEST_CLIENT_SECRET_VALUE = "pactsecret"; | ||
public static final String PACT_TEST_SCOPES_VALUE = "openid profile roles"; | ||
public static final String SERVICE_AUTHORIZATION = "ServiceAuthorization"; | ||
public static final String AUTH_TOKEN = "Bearer someAuthorizationToken"; | ||
public static final String SERVICE_AUTH_TOKEN = "Bearer someServiceAuthorizationToken"; | ||
|
||
|
||
public HttpHeaders getHttpHeaders() { | ||
HttpHeaders headers = new HttpHeaders(); | ||
headers.add(SERVICE_AUTHORIZATION, SERVICE_AUTH_TOKEN); | ||
headers.add(AUTHORIZATION, AUTH_TOKEN); | ||
return headers; | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...tractTest/java/uk/gov/hmcts/reform/ccd/consumer/wa/TaskManagerDeleteTaskConsumerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package uk.gov.hmcts.reform.ccd.consumer.wa; | ||
|
||
import au.com.dius.pact.consumer.MockServer; | ||
import au.com.dius.pact.consumer.dsl.PactDslWithProvider; | ||
import au.com.dius.pact.consumer.junit5.PactTestFor; | ||
import au.com.dius.pact.core.model.PactSpecVersion; | ||
import au.com.dius.pact.core.model.RequestResponsePact; | ||
import au.com.dius.pact.core.model.annotations.Pact; | ||
import io.restassured.RestAssured; | ||
import io.restassured.http.ContentType; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.http.HttpMethod; | ||
import org.springframework.http.HttpStatus; | ||
import uk.gov.hmcts.reform.ccd.SpringBootContractBaseTest; | ||
|
||
public class TaskManagerDeleteTaskConsumerTest extends SpringBootContractBaseTest { | ||
|
||
private static final String WA_URL = "/task"; | ||
private static final String WA_DELETE_TASK = WA_URL + "/delete"; | ||
|
||
@Pact(provider = "wa_task_management_api_delete_task_by_id", consumer = "wa_task_management_api") | ||
public RequestResponsePact executeDeleteTaskById201(PactDslWithProvider builder) { | ||
|
||
return builder | ||
.given("delete a task using case reference id") | ||
.uponReceiving("Request to delete") | ||
.path(WA_DELETE_TASK) | ||
.method(HttpMethod.POST.toString()) | ||
.body(deleteTaskWithRequest(), String.valueOf(ContentType.JSON)) | ||
.matchHeader(SERVICE_AUTHORIZATION, SERVICE_AUTH_TOKEN) | ||
.willRespondWith() | ||
.status(HttpStatus.CREATED.value()) | ||
.toPact(); | ||
} | ||
|
||
@Test | ||
@PactTestFor(pactMethod = "executeDeleteTaskById201", pactVersion = PactSpecVersion.V3) | ||
void testDeleteTaskByTaskId201(MockServer mockServer) { | ||
|
||
RestAssured | ||
.given() | ||
.headers(getHttpHeaders()) | ||
.contentType(ContentType.JSON) | ||
.body(deleteTaskWithRequest()) | ||
.post(mockServer.getUrl() + WA_DELETE_TASK) | ||
.then() | ||
.statusCode(201); | ||
|
||
} | ||
|
||
private String deleteTaskWithRequest() { | ||
return """ | ||
{ | ||
"deleteCaseTasksAction": { | ||
"caseRef": "1234567890123456" | ||
} | ||
} | ||
"""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
core_case_data.api.url=${ccd_casedatastore_baseurl:http://localhost:3451} | ||
ccd.jurisdictionid=SSCS | ||
ccd.casetype=Benefit | ||
ccd.eventid.create=createTestCase | ||
idam.api.url=${IDAM_API_URL:http://localhost:8891} | ||
idam.oauth2.user.email=${IDAM_LAU_SYSTEMUPDATE_USER:[email protected]} | ||
idam.oauth2.user.password=${IDAM_LAU_SYSTEMUPDATE_PASSWORD:Pa55word11} | ||
idam.client.secret=${IDAM_OAUTH2_CLIENT_SECRET:AAAAAAAAAAA} |