Skip to content

Commit

Permalink
RIA-9452 bug_fix (#2335)
Browse files Browse the repository at this point in the history
* RIA-9452: Edit RequestNewHearingRequirementsDirectionHandler if hearingCentre is not presented not saving previousHearings to list

* Bumping chart version/ fixing aliases

---------

Co-authored-by: hmcts-jenkins-d-to-i <62423932+hmcts-jenkins-d-to-i[bot]@users.noreply.github.com>
  • Loading branch information
ikirsanov and hmcts-jenkins-d-to-i[bot] authored Aug 29, 2024
1 parent 95500f8 commit 5c045a6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion charts/ia-case-api/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: ia-case-api
home: https://github.com/hmcts/ia-case-api
version: 0.0.51
version: 0.0.52
description: Immigration & Asylum Case API
maintainers:
- name: HMCTS Immigration & Asylum Team
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,12 @@ public PreSubmitCallbackResponse<AsylumCase> handle(PreSubmitCallbackStage callb
asylumCase.clear(SEND_DIRECTION_PARTIES);
asylumCase.clear(SEND_DIRECTION_DATE_DUE);

writePreviousHearingsToAsylumCase(asylumCase);
final HearingCentre listCaseHearingCentre = asylumCase.read(LIST_CASE_HEARING_CENTRE, HearingCentre.class)
.orElse(HearingCentre.DECISION_WITHOUT_HEARING);

if (!listCaseHearingCentre.equals(HearingCentre.DECISION_WITHOUT_HEARING)) {
writePreviousHearingsToAsylumCase(asylumCase);
}

return new PreSubmitCallbackResponse<>(asylumCase);
}
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;

import static com.google.inject.matcher.Matchers.any;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -23,20 +24,24 @@
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.LIST_CASE_HEARING_CENTRE;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.LIST_CASE_HEARING_DATE;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.LIST_CASE_HEARING_LENGTH;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.PREVIOUS_HEARINGS;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.SEND_DIRECTION_DATE_DUE;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.SEND_DIRECTION_EXPLANATION;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.SEND_DIRECTION_PARTIES;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.YesOrNo.NO;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.YesOrNo.YES;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
Expand Down Expand Up @@ -119,8 +124,8 @@ void can_handle_request_new_hearing_requirements() {
}

@ParameterizedTest
@EnumSource(value = YesOrNo.class, names = { "YES", "NO" })
void should_append_new_direction_to_existing_directions_for_the_case(YesOrNo isIntegrated) {
@MethodSource("newHearingRequirementsData")
void should_append_new_direction_to_existing_directions_for_the_case(YesOrNo isIntegrated, HearingCentre hearingCentre) {

final List<IdValue<Direction>> existingDirections = new ArrayList<>();
final List<IdValue<Direction>> allDirections = new ArrayList<>();
Expand All @@ -137,7 +142,6 @@ void should_append_new_direction_to_existing_directions_for_the_case(YesOrNo isI
final String attendingHomeOfficeLegalRepresentative = "Jim Smith";
final HoursAndMinutes actualCaseHearingLength = new HoursAndMinutes("5", "30");
final String ariaListingReference = "LP/12345/2020";
final HearingCentre listCaseHearingCentre = HearingCentre.NEWPORT;
final String listCaseHearingDate = "13/10/2020";
final String listCaseHearingLength = "6 hours";
final String appealDecision = "Dismissed";
Expand All @@ -159,7 +163,7 @@ void should_append_new_direction_to_existing_directions_for_the_case(YesOrNo isI
.thenReturn(Optional.of(actualCaseHearingLength));
when(asylumCase.read(ARIA_LISTING_REFERENCE, String.class)).thenReturn(Optional.of(ariaListingReference));
when(asylumCase.read(LIST_CASE_HEARING_CENTRE, HearingCentre.class))
.thenReturn(Optional.of(listCaseHearingCentre));
.thenReturn(Optional.of(hearingCentre));
when(asylumCase.read(LIST_CASE_HEARING_DATE, String.class)).thenReturn(Optional.of(listCaseHearingDate));
when(asylumCase.read(IS_INTEGRATED, YesOrNo.class)).thenReturn(Optional.of(isIntegrated));

Expand Down Expand Up @@ -202,6 +206,10 @@ void should_append_new_direction_to_existing_directions_for_the_case(YesOrNo isI
verify(asylumCase).clear(SEND_DIRECTION_EXPLANATION);
verify(asylumCase).clear(SEND_DIRECTION_PARTIES);
verify(asylumCase).clear(SEND_DIRECTION_DATE_DUE);

if (hearingCentre.equals(HearingCentre.DECISION_WITHOUT_HEARING)) {
verify(asylumCase, times(0)).write(PREVIOUS_HEARINGS, any());
}
}

@Test
Expand Down Expand Up @@ -279,4 +287,11 @@ void should_not_allow_null_arguments() {
.hasMessage("callback must not be null")
.isExactlyInstanceOf(NullPointerException.class);
}

private static Stream<Arguments> newHearingRequirementsData() {
return Stream.of(
Arguments.of(YES, HearingCentre.NEWPORT),
Arguments.of(NO, HearingCentre.DECISION_WITHOUT_HEARING)
);
}
}

0 comments on commit 5c045a6

Please sign in to comment.