Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"replacements": {
"appellantsRepresentation": "Yes",
"isAdmin": "Yes",
"journeyType": null
"journeyType": null,
"legalRepresentativeName": null,
"legalRepresentativeEmailAddress": null
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"replacements": {
"appellantsRepresentation": "Yes",
"isAdmin": "Yes",
"journeyType": null
"journeyType": null,
"legalRepresentativeName": null,
"legalRepresentativeEmailAddress": null
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCase;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.Callback;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.PreSubmitCallbackResponse;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.PreSubmitCallbackStage;
import uk.gov.hmcts.reform.iacaseapi.domain.handlers.HandlerUtils;
import uk.gov.hmcts.reform.iacaseapi.domain.handlers.PreSubmitCallbackHandler;

import static java.util.Objects.requireNonNull;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.APPELLANTS_REPRESENTATION;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.CHANGE_ORGANISATION_REQUEST_FIELD;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.IS_ADMIN;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.JOURNEY_TYPE;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.*;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.Event.APPELLANT_IN_PERSON_MANUAL;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.YesOrNo.YES;

Expand Down Expand Up @@ -57,6 +55,18 @@ public PreSubmitCallbackResponse<AsylumCase> handle(
return response;
}

if (!hasAddedLegalRepDetails && isRepJourney) {
asylumCase.clear(AsylumCaseFieldDefinition.LEGAL_REP_NAME);
asylumCase.clear(AsylumCaseFieldDefinition.LEGAL_REPRESENTATIVE_NAME);
asylumCase.clear(AsylumCaseFieldDefinition.LEGAL_REPRESENTATIVE_EMAIL_ADDRESS);
asylumCase.clear(AsylumCaseFieldDefinition.LEGAL_REP_COMPANY);
asylumCase.clear(AsylumCaseFieldDefinition.LEGAL_REP_COMPANY_NAME);
asylumCase.clear(AsylumCaseFieldDefinition.LEGAL_REP_COMPANY_ADDRESS);
asylumCase.clear(AsylumCaseFieldDefinition.LEGAL_REP_REFERENCE_NUMBER);
asylumCase.clear(AsylumCaseFieldDefinition.LEGAL_REP_INDIVIDUAL_PARTY_ID);
asylumCase.clear(AsylumCaseFieldDefinition.LEGAL_REP_ORGANISATION_PARTY_ID);
}

asylumCase.write(APPELLANTS_REPRESENTATION, YES);
asylumCase.write(IS_ADMIN, YES);
asylumCase.clear(JOURNEY_TYPE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCase;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ContactPreference;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.OutOfCountryDecisionType;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.CaseDetails;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.Event;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.State;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.Callback;
Expand Down Expand Up @@ -86,7 +87,19 @@ public PreSubmitCallbackResponse<AsylumCase> handle(
.getCaseDetails()
.getCaseData();

asylumCase.write(HAS_ADDED_LEGAL_REP_DETAILS, YesOrNo.YES);

final String legalRepReferenceNumber = asylumCase.read(LEGAL_REP_REFERENCE_NUMBER, String.class)
.orElse("");
Optional<CaseDetails<AsylumCase>> caseDetailsBefore = callback.getCaseDetailsBefore();
if (caseDetailsBefore.isPresent()) {
final String prevLegalRepReferenceNumber = caseDetailsBefore
.get().getCaseData().read(LEGAL_REP_REFERENCE_NUMBER, String.class).orElse("");
if (!legalRepReferenceNumber.equals(prevLegalRepReferenceNumber)) {
asylumCase.write(HAS_ADDED_LEGAL_REP_DETAILS, YesOrNo.YES);
}
}



Optional<OutOfCountryDecisionType> outOfCountryDecisionTypeOptional = asylumCase.read(OUT_OF_COUNTRY_DECISION_TYPE, OutOfCountryDecisionType.class);
YesOrNo appellantInUk = asylumCase.read(APPELLANT_IN_UK, YesOrNo.class).orElse(NO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.PreSubmitCallbackResponse;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.PreSubmitCallbackStage;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.YesOrNo;
import uk.gov.hmcts.reform.iacaseapi.domain.handlers.HandlerUtils;
import uk.gov.hmcts.reform.iacaseapi.domain.handlers.PreSubmitCallbackHandler;

@Component
Expand Down Expand Up @@ -44,22 +43,7 @@ public PreSubmitCallbackResponse<AsylumCase> handle(

asylumCase.write(HAS_ADDED_LEGAL_REP_DETAILS, YesOrNo.NO);


boolean isAdmin = HandlerUtils.isInternalCase(asylumCase);

if (isInCountryDetainedAppeal(asylumCase) && !isAdmin) {
asylumCase.clear(LEGAL_REP_COMPANY);
asylumCase.clear(LEGAL_REP_COMPANY_ADDRESS);
asylumCase.clear(LEGAL_REP_NAME);
asylumCase.clear(LEGAL_REPRESENTATIVE_NAME);
asylumCase.clear(LEGAL_REP_REFERENCE_NUMBER);
}

return new PreSubmitCallbackResponse<>(asylumCase);
}

private boolean isInCountryDetainedAppeal(AsylumCase asylumCase) {
return (HandlerUtils.isAppellantInDetention(asylumCase)
&& asylumCase.read(APPELLANT_IN_UK, YesOrNo.class).map(value -> value.equals(YesOrNo.YES)).orElse(true));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class EditAppealAfterSubmitHandlerTest {
@Mock
private AsylumCase asylumCase;
@Mock
private CaseDetails<AsylumCase> caseDetailsBefore;
@Mock
private AsylumCase asylumCaseBefore;
@Mock
private DateProvider dateProvider;
@Mock
private DueDateService dueDateService;
Expand Down Expand Up @@ -109,6 +113,10 @@ public void setUp() {

@Test
void should_set_current_case_state_visible_to_case_officer_and_clear_application_flags_when_in_time() {
when(callback.getCaseDetailsBefore()).thenReturn(Optional.of(caseDetailsBefore));
when(caseDetailsBefore.getCaseData()).thenReturn(asylumCaseBefore);
when(asylumCaseBefore.read(LEGAL_REP_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of("LRRef"));
when(asylumCase.read(LEGAL_REP_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of("NewLRRef"));

when(dateProvider.now()).thenReturn(LocalDate.parse("2020-04-08"));
when(asylumCase.read(HOME_OFFICE_DECISION_DATE)).thenReturn(Optional.of("2020-04-08"));
Expand Down Expand Up @@ -559,6 +567,11 @@ void handles_ada_case_when_in_time() {
final ZonedDateTime zonedDateTime = LocalDate.parse(receivedLetterDate).atStartOfDay(ZoneOffset.UTC);
final ZonedDateTime zonedDueDateTime = LocalDate.parse(dueDate).atStartOfDay(ZoneOffset.UTC);

when(callback.getCaseDetailsBefore()).thenReturn(Optional.of(caseDetailsBefore));
when(caseDetailsBefore.getCaseData()).thenReturn(asylumCaseBefore);
when(asylumCaseBefore.read(LEGAL_REP_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of("LRRef"));
when(asylumCase.read(LEGAL_REP_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of("NewLRRef"));

when(dateProvider.now()).thenReturn(LocalDate.parse(nowDate));
when(asylumCase.read(DECISION_LETTER_RECEIVED_DATE)).thenReturn(Optional.of(receivedLetterDate));
when(dueDateService.calculateDueDate(zonedDateTime, APPEAL_OUT_OF_TIME_ADA_WORKING_DAYS)).thenReturn(zonedDueDateTime);
Expand Down Expand Up @@ -593,8 +606,8 @@ void handles_ada_case_when_out_of_time() {

editAppealAfterSubmitHandler.handle(PreSubmitCallbackStage.MID_EVENT, callback);

verify(asylumCase, times(3)).write(asylumExtractor.capture(), outOfTime.capture());
verify(asylumCase, times(3)).write(asylumExtractor.capture(), recordedOutOfTimeDecision.capture());
verify(asylumCase, times(2)).write(asylumExtractor.capture(), outOfTime.capture());
verify(asylumCase, times(2)).write(asylumExtractor.capture(), recordedOutOfTimeDecision.capture());

assertThat(asylumExtractor.getAllValues()).contains(SUBMISSION_OUT_OF_TIME);
assertThat(asylumExtractor.getValue()).isEqualTo(RECORDED_OUT_OF_TIME_DECISION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ void set_case_as_unrepresented_using_stop_representing_a_client_event() {
assertNotNull(callbackResponse);
assertEquals(asylumCase, callbackResponse.getData());

verify(asylumCase).clear(LEGAL_REP_COMPANY);
verify(asylumCase).clear(LEGAL_REP_COMPANY_ADDRESS);
verify(asylumCase).clear(LEGAL_REP_NAME);
verify(asylumCase).clear(LEGAL_REPRESENTATIVE_NAME);
verify(asylumCase).clear(LEGAL_REP_REFERENCE_NUMBER);
}

@Test
Expand All @@ -72,11 +67,6 @@ void set_case_as_unrepresented_using_remove_legal_rep_event() {
assertNotNull(callbackResponse);
assertEquals(asylumCase, callbackResponse.getData());

verify(asylumCase).clear(LEGAL_REP_COMPANY);
verify(asylumCase).clear(LEGAL_REP_COMPANY_ADDRESS);
verify(asylumCase).clear(LEGAL_REP_NAME);
verify(asylumCase).clear(LEGAL_REPRESENTATIVE_NAME);
verify(asylumCase).clear(LEGAL_REP_REFERENCE_NUMBER);
}

@Test
Expand All @@ -92,11 +82,6 @@ void should_not_set_case_as_unrepresented_using_remove_legal_rep_event_out_of_co
assertEquals(asylumCase, callbackResponse.getData());

verify(asylumCase, times(0)).write(IS_ADMIN, YesOrNo.YES);
verify(asylumCase, times(0)).clear(LEGAL_REP_COMPANY);
verify(asylumCase, times(0)).clear(LEGAL_REP_COMPANY_ADDRESS);
verify(asylumCase, times(0)).clear(LEGAL_REP_NAME);
verify(asylumCase, times(0)).clear(LEGAL_REPRESENTATIVE_NAME);
verify(asylumCase, times(0)).clear(LEGAL_REP_REFERENCE_NUMBER);
verify(asylumCase).write(HAS_ADDED_LEGAL_REP_DETAILS, YesOrNo.NO);
}

Expand All @@ -114,11 +99,6 @@ void should_not_set_case_as_unrepresented_using_stop_representing_a_client_not_d
assertEquals(asylumCase, callbackResponse.getData());

verify(asylumCase, times(0)).write(IS_ADMIN, YesOrNo.YES);
verify(asylumCase, times(0)).clear(LEGAL_REP_COMPANY);
verify(asylumCase, times(0)).clear(LEGAL_REP_COMPANY_ADDRESS);
verify(asylumCase, times(0)).clear(LEGAL_REP_NAME);
verify(asylumCase, times(0)).clear(LEGAL_REPRESENTATIVE_NAME);
verify(asylumCase, times(0)).clear(LEGAL_REP_REFERENCE_NUMBER);
}

@Test
Expand Down