Skip to content

Commit 2bd550c

Browse files
DIAC-1475 call Home Office Integration API (#2958)
* Initial change to create PR * Set home-office-integration-api to Preview * Now with the correct PR number * Added event for Home Office appellant information * Fixed test * Refactoring of Nilay's CCD service code (amongst other things) * Almost there * Unit tests now in place - thanks ChatGPT * Boosting test coverage * Increasing test coverage * More fighting with tests * Refactor because first design was never going to work * Adding debugging information * Adding debugging information * Trying to call the Home Office integration API using the midEvent instead of appealSubmitted * Trying to call the Home Office integration API using the midEvent instead of appealSubmitted - Part Deux * No-op change to trigger the build * Removing unused event * Resolving merge conflicts * Adding suppression that the other team should have added * Nearly ready for merging - a few bits still to go * Increasing test coverage * More coverage * Bug fix * Now ready for merging * Tests now passing again * Responding to review comments * Replacing HO API image --------- Co-authored-by: rajeshthuraiyur <48379561+rajeshthuraiyur@users.noreply.github.com>
1 parent 50b4129 commit 2bd550c

27 files changed

+1117
-888
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# ia-case-api
33

4-
Immigration &amp; Asylum case API
4+
Immigration &amp; Asylum case API.
55

66
## Purpose
77

src/functionalTest/resources/application-functional.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ core_case_data:
2929

3030
spring:
3131
cache:
32-
cache-names: userInfoCache, accessTokenCache, homeOfficeReferenceDataCache, legalRepATokenCache, caseOfficerTokenCache, adminOfficerTokenCache, homeOfficeApcTokenCache, homeOfficeLartTokenCache, homeOfficePouTokenCache, homeOfficeGenericTokenCache, legalRepShareCaseATokenCache, legalRepOrgSuccessTokenCache, legalRepOrgDeletedTokenCache, judgeTokenCache, citizenTokenCache, systemTokenCache
32+
cache-names: userInfoCache, accessTokenCache, legalRepATokenCache, caseOfficerTokenCache, adminOfficerTokenCache, homeOfficeApcTokenCache, homeOfficeLartTokenCache, homeOfficePouTokenCache, homeOfficeGenericTokenCache, legalRepShareCaseATokenCache, legalRepOrgSuccessTokenCache, legalRepOrgDeletedTokenCache, judgeTokenCache, citizenTokenCache, systemTokenCache
3333
caffeine:
3434
spec: expireAfterWrite=3600s
3535
security:

src/functionalTest/resources/scenarios/RIA-3680-home-office-reference-mid-event.json

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/functionalTest/resources/scenarios/RIA-3680-home-office-reference-mid-event_edit_appeal.json

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/entities/AsylumCaseFieldDefinition.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ public enum AsylumCaseFieldDefinition {
3838
HOME_OFFICE_DECISION_DATE(
3939
"homeOfficeDecisionDate", new TypeReference<String>(){}),
4040

41+
HOME_OFFICE_APPELLANT_API_RESPONSE_STATUS(
42+
"homeOfficeAppellantApiResponseStatus", new TypeReference<HomeOfficeApiResponseStatusType>(){}),
43+
44+
HOME_OFFICE_APPELLANT_CLAIM_DATE(
45+
"homeOfficeAppellantClaimDate", new TypeReference<String>(){}),
46+
47+
HOME_OFFICE_APPELLANT_DECISION_DATE(
48+
"homeOfficeAppellantDecisionDate", new TypeReference<String>() {}),
49+
50+
HOME_OFFICE_APPELLANT_DECISION_LETTER_DATE(
51+
"homeOfficeAppellantDecisionLetterDate", new TypeReference<String>(){}),
52+
53+
HOME_OFFICE_APPELLANTS(
54+
"homeOfficeAppellants", new TypeReference<List<IdValue<HomeOfficeAppellant>>>(){}),
55+
4156
APPELLANT_GIVEN_NAMES(
4257
"appellantGivenNames", new TypeReference<String>(){}),
4358

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package uk.gov.hmcts.reform.iacaseapi.domain.entities;
2+
3+
import com.fasterxml.jackson.annotation.JsonEnumDefaultValue;
4+
import com.fasterxml.jackson.annotation.JsonValue;
5+
6+
public enum HomeOfficeApiResponseStatusType {
7+
8+
OTHER_APPLICATION_DATA(-3, "otherApplicationData", UserFacingErrorText.SERVER, "The Home Office validation API's response contained data from a different application."),
9+
NO_DATA(-2, "noData", UserFacingErrorText.SERVER, "The Home Office validation API's response contained no data."),
10+
DID_NOT_RESPOND(-1, "didNotRespond", UserFacingErrorText.SERVER, "The Home Office validation API did not respond."),
11+
OK(200, "ok", "", ""),
12+
BAD_REQUEST(400, "badRequest", UserFacingErrorText.CLIENT, "The request to the Home Office validation API was not correctly formed."),
13+
NOT_AUTHENTICATED(401, "notAuthenticated", UserFacingErrorText.CLIENT, "The request to the Home Office validation API could not be authenticated."),
14+
NOT_AUTHORISED(403, "notAuthorised", UserFacingErrorText.CLIENT, "The request to the Home Office validation API was authenticated but not authorised."),
15+
NOT_FOUND(404, "notFound", UserFacingErrorText.USER, "No application matching Home Office reference number XYZYX was found."),
16+
INTERNAL_SERVER_ERROR(500, "internalServerError", UserFacingErrorText.SERVER, "The Home Office validation API was not available."),
17+
NOT_IMPLEMENTED(501, "notImplemented", UserFacingErrorText.SERVER, "The Home Office validation API has not been implemented yet."),
18+
BAD_GATEWAY(502, "badGateway", UserFacingErrorText.SERVER, "The Home Office validation API was not available due to a gateway error."),
19+
SERVICE_UNAVAILABLE(503, "serviceUnavailable", UserFacingErrorText.SERVER, "The Home Office validation API was not available because the server could not process the request."),
20+
GATEWAY_TIMEOUT(504, "gatewayTimeout", UserFacingErrorText.SERVER, "The Home Office validation API was not available due to a gateway time-out."),
21+
22+
@JsonEnumDefaultValue
23+
UNKNOWN(0, "unknown", UserFacingErrorText.CLIENT, "The Home Office validation API did not return the required information for an unknown reason.");
24+
25+
@JsonValue
26+
private final int statusCode;
27+
private final String name;
28+
private final String userFacingErrorText;
29+
private final String hoIntegrationErrorText;
30+
31+
private static final String REPLACEMENT_STRING = "XYZYX";
32+
33+
HomeOfficeApiResponseStatusType(int statusCode, String name, String userFacingErrorText, String hoIntegrationErrorText) {
34+
this.statusCode = statusCode;
35+
this.name = name;
36+
this.userFacingErrorText = userFacingErrorText;
37+
this.hoIntegrationErrorText = hoIntegrationErrorText;
38+
}
39+
40+
public int getStatusCode() {
41+
return statusCode;
42+
}
43+
44+
public String getUserFacingErrorText(String hoReference) {
45+
return userFacingErrorText.replace(REPLACEMENT_STRING, hoReference);
46+
}
47+
48+
public String getHoIntegrationErrorText(String hoReference) {
49+
return hoIntegrationErrorText.replace(REPLACEMENT_STRING, hoReference);
50+
}
51+
52+
@Override
53+
public String toString() {
54+
return name;
55+
}
56+
57+
private final class UserFacingErrorText {
58+
private static final String CLIENT = "An error occurred. Please report this to HMCTS.";
59+
private static final String SERVER = "An error occurred. Please try again in 15-20 minutes. If it occurs again, please report this to HMCTS.";
60+
private static final String USER = "The Home Office reference number XYZYX does not match any existing case records in Home Office systems. Please check your decision letter and try again.";
61+
}
62+
}
63+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd;
2+
3+
import lombok.Data;
4+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.YesOrNo;
5+
6+
@Data
7+
public class HomeOfficeAppellant {
8+
9+
private String pp;
10+
private String familyName;
11+
private String givenNames;
12+
private String dateOfBirth;
13+
private String nationality;
14+
private YesOrNo roa;
15+
private YesOrNo asylumSupport;
16+
private YesOrNo hoFeeWaiver;
17+
private String language;
18+
private YesOrNo interpreterNeeded;
19+
20+
}

src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/entities/homeoffice/HomeOfficeReferenceData.java

Lines changed: 0 additions & 80 deletions
This file was deleted.

src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/postsubmit/RetriggerWaTasksForFixedCaseIdHandler.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public class RetriggerWaTasksForFixedCaseIdHandler implements PreSubmitCallbackH
2020

2121
private final CcdDataService ccdDataService;
2222

23-
2423
public RetriggerWaTasksForFixedCaseIdHandler(CcdDataService ccdDataService) {
2524
this.ccdDataService = ccdDataService;
2625
}
@@ -56,7 +55,7 @@ public PreSubmitCallbackResponse<AsylumCase> handle(
5655
log.info("No valid Case Ids found to re-trigger WA tasks");
5756
return new PreSubmitCallbackResponse<>(asylumCase);
5857
} else {
59-
ccdDataService.retriggerWaTasks(trimmedCaseId);
58+
ccdDataService.raiseEvent(trimmedCaseId, Event.RE_TRIGGER_WA_TASKS);
6059
asylumCase.clear(CASE_ID_LIST);
6160
return new PreSubmitCallbackResponse<>(asylumCase);
6261
}
@@ -70,7 +69,7 @@ public PreSubmitCallbackResponse<AsylumCase> handle(
7069
log.info("Invalid Case Id found to re-trigger WA tasks: {}", trimmedCaseId);
7170
return;
7271
}
73-
ccdDataService.retriggerWaTasks(trimmedCaseId);
72+
ccdDataService.raiseEvent(trimmedCaseId, Event.RE_TRIGGER_WA_TASKS);
7473
}
7574
);
7675
asylumCase.clear(CASE_ID_LIST);

0 commit comments

Comments
 (0)