Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
342b264
DIAC-1514 faster case status handler
velimd Oct 9, 2025
9a8981e
update test
velimd Oct 9, 2025
fa5b7e8
add unit test
velimd Oct 10, 2025
32a9993
add handler confirmation
velimd Oct 10, 2025
a1a4739
add event to application.yaml
velimd Oct 14, 2025
35d13fd
fix naming to submit faster case status
velimd Oct 14, 2025
08cc5a9
Merge branch 'master' into DIAC-1514
velimd Oct 23, 2025
f009509
fix naming to confirmed ones
velimd Oct 27, 2025
25e6227
update to store time with date
velimd Oct 28, 2025
93ae30b
Merge branch 'master' into DIAC-1514
velimd Oct 29, 2025
26b4091
fix unit test
velimd Oct 29, 2025
ce66bbf
Merge remote-tracking branch 'origin/DIAC-1514' into DIAC-1514
velimd Oct 29, 2025
50c3dd8
split event into 2 separate events for add and removal of status.
velimd Nov 4, 2025
f242880
update role config for new event names
velimd Nov 4, 2025
39b68f4
sonar exclusion
velimd Nov 4, 2025
560b644
Revert "sonar exclusion"
velimd Nov 4, 2025
bc221d2
update/add tests
velimd Nov 4, 2025
273f5e4
update role access
velimd Nov 4, 2025
3c8c77a
Add info to case notes when event is triggered.
velimd Nov 10, 2025
eafdc02
add integration test for events
velimd Nov 11, 2025
4c50b2b
Merge branch 'master' into DIAC-1514
velimd Nov 11, 2025
09654eb
clean up
velimd Nov 11, 2025
0b626bd
fix checkstyle issue
velimd Nov 11, 2025
2cb9514
clean up confirmation + test
velimd Nov 13, 2025
6e94b2d
fix checkstyleTest
velimd Nov 17, 2025
02bd403
Merge branch 'master' into DIAC-1514
velimd Nov 17, 2025
9e10883
updating data structure and functionality to update it
velimd Nov 17, 2025
a2e8b84
update integration tests to use the new data structure
velimd Nov 18, 2025
b05fd65
set condition to check if the status is already set to the same value.
velimd Nov 18, 2025
3597499
Merge remote-tracking branch 'origin/DIAC-1514' into DIAC-1514
velimd Nov 18, 2025
759c650
Merge branch 'master' into DIAC-1514
velimd Nov 18, 2025
5e61dd1
review fix
velimd Nov 20, 2025
ac4fb02
Merge branch 'master' into DIAC-1514
velimd Nov 20, 2025
652531c
update unit tests
velimd Nov 20, 2025
bdb6d40
add 24 weeks for system
Nov 25, 2025
4079992
update home office lib
Nov 25, 2025
f62b54f
Merge branch 'master' into DIAC-1852
Nov 27, 2025
f821a15
skip duplicate of 24 weeks record after ho call
Nov 28, 2025
973f82b
increase test coverage
Nov 28, 2025
0f9c5d2
clear only when required
Nov 28, 2025
eee360e
fix duplicate
Nov 28, 2025
eb6db54
add dependency on home office pr
Dec 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/ia-case-api/values.preview.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ ia-home-office-integration-api:
enabled: true #set to true if testing against a local branch
java:
imagePullPolicy: Always
image: hmctspublic.azurecr.io/ia/home-office-integration-api:latest
image: hmctspublic.azurecr.io/ia/home-office-integration-api:pr-442
releaseNameOverride: ${SERVICE_NAME}-home-office-integration-api
ingressHost: ${SERVICE_NAME}-home-office-integration-api.preview.platform.hmcts.net
devcpuRequests: 500m
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package uk.gov.hmcts.reform.iacaseapi.domain.handlers.presubmit.statutorytimeframe24weeks;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import uk.gov.hmcts.reform.iacaseapi.domain.DateProvider;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCase;
Expand All @@ -21,9 +22,12 @@
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.STATUTORY_TIMEFRAME_24_WEEKS;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.STATUTORY_TIMEFRAME_24_WEEKS_REASON;

@Slf4j
@Service
public class UpdateStatutoryTimeframe24WeeksService {

public static final String HOME_OFFICE_INITIAL_DETERMINATION = "Home Office initial determination";

private final Appender<StatutoryTimeframe24WeeksHistory> statutoryTimeframe24WeeksHistoryAppender;
private final Appender<CaseNote> caseNoteAppender;
private final DateProvider dateProvider;
Expand All @@ -49,7 +53,8 @@ public AsylumCase updateAsylumCase(AsylumCase asylumCase, YesOrNo statutoryTimef
Optional<StatutoryTimeframe24Weeks> maybeExistingStatutoryTimeframe24Weeks =
asylumCase.read(STATUTORY_TIMEFRAME_24_WEEKS);

if (maybeExistingStatutoryTimeframe24Weeks.isPresent() && maybeExistingStatutoryTimeframe24Weeks.get().getCurrentStatusAutoGenerated() == statutoryTimeframe24WeeksStatus) {
if (maybeExistingStatutoryTimeframe24Weeks.isPresent() && maybeExistingStatutoryTimeframe24Weeks.get().getCurrentStatusAutoGenerated() == statutoryTimeframe24WeeksStatus
&& !statutoryTimeframe24WeeksReason.contains(HOME_OFFICE_INITIAL_DETERMINATION)) {
throw new IllegalStateException("The current status is already set to " + statutoryTimeframe24WeeksStatus);
}

Expand All @@ -58,16 +63,20 @@ public AsylumCase updateAsylumCase(AsylumCase asylumCase, YesOrNo statutoryTimef
StatutoryTimeframe24Weeks updatedStatutoryTimeframe24Weeks =
buildNewStatutoryTimeframe24Weeks(statutoryTimeframe24WeeksStatus, statutoryTimeframe24WeeksReason, userDetails, maybeExistingStatutoryTimeframe24Weeks);

asylumCase.write(STATUTORY_TIMEFRAME_24_WEEKS, updatedStatutoryTimeframe24Weeks);
if (!statutoryTimeframe24WeeksReason.contains(HOME_OFFICE_INITIAL_DETERMINATION)) {
log.info("Writing STATUTORY_TIMEFRAME_24_WEEKS with status: {}", statutoryTimeframe24WeeksStatus);
asylumCase.write(STATUTORY_TIMEFRAME_24_WEEKS, updatedStatutoryTimeframe24Weeks);
asylumCase.clear(STATUTORY_TIMEFRAME_24_WEEKS_REASON);
} else {
log.info("Skipping write of STATUTORY_TIMEFRAME_24_WEEKS for '{}'", HOME_OFFICE_INITIAL_DETERMINATION);
}

Optional<List<IdValue<CaseNote>>> maybeExistingCaseNotes = asylumCase.read(CASE_NOTES);
List<IdValue<CaseNote>> allCaseNotes = caseNoteAppender.append(
buildNewCaseNote(statutoryTimeframe24WeeksStatus, statutoryTimeframe24WeeksReason, userDetails), maybeExistingCaseNotes.orElse(Collections.emptyList()));

asylumCase.write(CASE_NOTES, allCaseNotes);

asylumCase.clear(STATUTORY_TIMEFRAME_24_WEEKS_REASON);

return asylumCase;
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,7 @@ security:
- "UpdateNextHearingInfo"
- "removeCaseManagerBulk"
- "hearingCancelled"
- "addStatutoryTimeframe24Weeks"
caseworker-ia-internal:
- "revokeCaseAccess"
- "removeCaseManagerBulk"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.anyList;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -201,4 +203,47 @@ void should_throw_when_statutory_timeframe_24_weeks_status_is_already_set_to_no(
.hasMessage("The current status is already set to " + currentStatus)
.isExactlyInstanceOf(IllegalStateException.class);
}

@Test
void should_write_statutory_timeframe_when_reason_does_not_contain_home_office_initial_determination() {
when(asylumCase.read(STATUTORY_TIMEFRAME_24_WEEKS_REASON, String.class))
.thenReturn(Optional.of("Some other reason"));
when(asylumCase.read(STATUTORY_TIMEFRAME_24_WEEKS)).thenReturn(Optional.empty());

updateStatutoryTimeframe24WeeksService.updateAsylumCase(asylumCase, YesOrNo.YES);

verify(asylumCase, times(1)).write(eq(STATUTORY_TIMEFRAME_24_WEEKS), any());
}

@Test
void should_skip_write_statutory_timeframe_when_reason_contains_home_office_initial_determination() {
when(asylumCase.read(STATUTORY_TIMEFRAME_24_WEEKS_REASON, String.class))
.thenReturn(Optional.of("Home Office initial determination"));
when(asylumCase.read(STATUTORY_TIMEFRAME_24_WEEKS)).thenReturn(Optional.empty());

updateStatutoryTimeframe24WeeksService.updateAsylumCase(asylumCase, YesOrNo.YES);

verify(asylumCase, never()).write(eq(STATUTORY_TIMEFRAME_24_WEEKS), any());
}

@Test
void should_not_throw_when_status_matches_but_reason_contains_home_office_initial_determination() {
YesOrNo currentStatus = YesOrNo.YES;
StatutoryTimeframe24WeeksHistory statutoryTimeframe24WeeksHistory =
new StatutoryTimeframe24WeeksHistory(currentStatus, "Home Office initial determination",
forename + " " + surname, nowWithTime.toString());
List<IdValue<StatutoryTimeframe24WeeksHistory>> existingHistory =
Arrays.asList(new IdValue<>("1", statutoryTimeframe24WeeksHistory));
StatutoryTimeframe24Weeks existingStatutoryTimeframe24Weeks =
new StatutoryTimeframe24Weeks(currentStatus, existingHistory);

when(asylumCase.read(STATUTORY_TIMEFRAME_24_WEEKS)).thenReturn(Optional.of(existingStatutoryTimeframe24Weeks));
when(asylumCase.read(STATUTORY_TIMEFRAME_24_WEEKS_REASON, String.class))
.thenReturn(Optional.of("Home Office initial determination"));

// Should NOT throw even though status matches
updateStatutoryTimeframe24WeeksService.updateAsylumCase(asylumCase, currentStatus);

verify(asylumCase, never()).write(eq(STATUTORY_TIMEFRAME_24_WEEKS), any());
}
}
Loading