Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add further directions to order flow (FPLA-1105) #760

Merged
merged 32 commits into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6974848
feat: add directions to order generation flow (FPLA-1105)
Dec 30, 2019
12cee1a
added assertion for removing orderFurtherDirections
Dec 30, 2019
497f7e1
merge with master branch
Jan 3, 2020
c9954c0
judiciary permissions for furtherDirections
Jan 3, 2020
d88ee8a
Merge branch 'master' into FPLA-1105-add-further-directions-to-order-…
swalker125 Jan 3, 2020
cd869f0
Initial pass of show hide logic
lewisbirks Jan 6, 2020
3830790
Logic to only generate document once
lewisbirks Jan 6, 2020
9286c17
Reset callback-request.json
lewisbirks Jan 6, 2020
bb47ea6
Updated template, moved furtherDirections output to be within the con…
lewisbirks Jan 6, 2020
c1a515c
Update integration tests to fully test the mid event
lewisbirks Jan 6, 2020
20c36ef
Fix NPE when caseData.getOrderFurtherDirections is null
lewisbirks Jan 6, 2020
cf7415d
Updated e2e tests to reflect show conditions based on orders
lewisbirks Jan 6, 2020
f2e76e8
Test clean up
lewisbirks Jan 6, 2020
00141fa
Merge branch 'master' of github.com:hmcts/fpl-ccd-configuration into …
lewisbirks Jan 6, 2020
ef27d73
Removed exception that isn't thrown
lewisbirks Jan 6, 2020
5059b07
Merge branch 'master' into FPLA-1105-add-further-directions-to-order-…
lewisbirks Jan 6, 2020
758d184
Updated template to ensure that warning block always appears at the b…
lewisbirks Jan 7, 2020
07e62a2
Merge branch 'FPLA-1105-add-further-directions-to-order-flow' of gith…
lewisbirks Jan 7, 2020
78e453f
Merge branch 'master' of github.com:hmcts/fpl-ccd-configuration into …
lewisbirks Jan 7, 2020
6762b3f
Moved GeneratedOrderService.getFurtherDirections to CaseData.getFurth…
lewisbirks Jan 7, 2020
2bdb314
Merge branch 'master' of github.com:hmcts/fpl-ccd-configuration into …
lewisbirks Jan 7, 2020
86e1c2f
Merge branch 'master' into FPLA-1105-add-further-directions-to-order-…
lewisbirks Jan 7, 2020
e3ce857
Merge branch 'master' into FPLA-1105-add-further-directions-to-order-…
lewisbirks Jan 7, 2020
a62bed4
Code review comments
lewisbirks Jan 7, 2020
fad8225
Merge remote-tracking branch 'origin/FPLA-1105-add-further-directions…
lewisbirks Jan 7, 2020
309f322
Made further directions mandatory
lewisbirks Jan 8, 2020
c2e5595
Merge branch 'master' into FPLA-1105-add-further-directions-to-order-…
lewisbirks Jan 9, 2020
f30d635
Merge branch 'master' of github.com:hmcts/fpl-ccd-configuration into …
lewisbirks Jan 9, 2020
e51bb9a
Merge branch 'master' into FPLA-1105-add-further-directions-to-order-…
lewisbirks Jan 10, 2020
125742d
Merge branch 'master' into FPLA-1105-add-further-directions-to-order-…
lewisbirks Jan 10, 2020
256715c
Merge branch 'master' into FPLA-1105-add-further-directions-to-order-…
lewisbirks Jan 13, 2020
d593576
Merge branch 'master' into FPLA-1105-add-further-directions-to-order-…
lewisbirks Jan 13, 2020
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
7 changes: 7 additions & 0 deletions ccd-definition/AuthorisationCaseField/court-admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,13 @@
"UserRole": "caseworker-publiclaw-courtadmin",
"CRUD": "CRUD"
},
{
"LiveFrom": "01/01/2017",
"CaseTypeID": "CARE_SUPERVISION_EPO",
"CaseFieldID": "orderFurtherDirections",
"UserRole": "caseworker-publiclaw-courtadmin",
joez-f marked this conversation as resolved.
Show resolved Hide resolved
"CRUD": "CRUD"
},
{
"LiveFrom": "01/01/2017",
"CaseTypeID": "CARE_SUPERVISION_EPO",
Expand Down
7 changes: 7 additions & 0 deletions ccd-definition/AuthorisationCaseField/judiciary.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,12 @@
"CaseFieldID": "cmoEventId",
"UserRole": "caseworker-publiclaw-judiciary",
"CRUD": "CRU"
},
{
"LiveFrom": "01/01/2017",
"CaseTypeID": "CARE_SUPERVISION_EPO",
"CaseFieldID": "orderFurtherDirections",
"UserRole": "caseworker-publiclaw-judiciary",
"CRUD": "CRUD"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,20 @@
"PageColumnNumber": 1,
"ShowSummaryChangeOption": "Y",
"CallBackURLMidEvent": "${CCD_DEF_CASE_SERVICE_BASE_URL}/callback/create-order/mid-event"
},
{
"LiveFrom": "01/01/2017",
"CaseTypeID": "CARE_SUPERVISION_EPO",
"CaseEventID": "createOrder-PREPARE_FOR_HEARING",
joez-f marked this conversation as resolved.
Show resolved Hide resolved
"CaseFieldID": "orderFurtherDirections",
"PageFieldDisplayOrder": 1,
"DisplayContext": "OPTIONAL",
"PageID": "FurtherDirections",
"PageLabel": " ",
"PageDisplayOrder": 4,
"PageColumnNumber": 1,
"ShowSummaryChangeOption": "Y",
"PageShowCondition": "orderTypeAndDocument.type!=\"BLANK_ORDER\"",
"CallBackURLMidEvent": "${CCD_DEF_CASE_SERVICE_BASE_URL}/callback/create-order/mid-event"
}
]
15 changes: 15 additions & 0 deletions ccd-definition/CaseEventToFields/createOrder.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,20 @@
"PageColumnNumber": 1,
"ShowSummaryChangeOption": "Y",
"CallBackURLMidEvent": "${CCD_DEF_CASE_SERVICE_BASE_URL}/callback/create-order/mid-event"
},
{
"LiveFrom": "01/01/2017",
"CaseTypeID": "CARE_SUPERVISION_EPO",
"CaseEventID": "createOrder",
"CaseFieldID": "orderFurtherDirections",
"PageFieldDisplayOrder": 1,
"DisplayContext": "MANDATORY",
"PageID": "FurtherDirections",
"PageLabel": " ",
"PageDisplayOrder": 4,
"PageColumnNumber": 1,
joez-f marked this conversation as resolved.
Show resolved Hide resolved
"ShowSummaryChangeOption": "Y",
"PageShowCondition": "orderTypeAndDocument.type!=\"BLANK_ORDER\"",
"CallBackURLMidEvent": "${CCD_DEF_CASE_SERVICE_BASE_URL}/callback/create-order/mid-event"
}
]
15 changes: 15 additions & 0 deletions ccd-definition/CaseEventToFields/createOrderGatekeeping.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,20 @@
"PageColumnNumber": 1,
"ShowSummaryChangeOption": "Y",
"CallBackURLMidEvent": "${CCD_DEF_CASE_SERVICE_BASE_URL}/callback/create-order/mid-event"
},
{
"LiveFrom": "01/01/2017",
"CaseTypeID": "CARE_SUPERVISION_EPO",
"CaseEventID": "createOrderGatekeeping",
"CaseFieldID": "orderFurtherDirections",
"PageFieldDisplayOrder": 1,
"DisplayContext": "OPTIONAL",
"PageID": "FurtherDirections",
"PageLabel": " ",
"PageDisplayOrder": 4,
"PageColumnNumber": 1,
"ShowSummaryChangeOption": "Y",
"PageShowCondition": "orderTypeAndDocument.type!=\"BLANK_ORDER\"",
"CallBackURLMidEvent": "${CCD_DEF_CASE_SERVICE_BASE_URL}/callback/create-order/mid-event"
}
]
8 changes: 8 additions & 0 deletions ccd-definition/CaseField.json
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,14 @@
"FieldType": "OrderTypeAndDocument",
"SecurityClassification": "Public"
},
{
"LiveFrom": "01/01/2017",
"CaseTypeID": "CARE_SUPERVISION_EPO",
"ID": "orderFurtherDirections",
"Label": "Further directions",
"FieldType": "FurtherDirections",
"SecurityClassification": "Public"
},
{
"LiveFrom": "01/01/2017",
"CaseTypeID": "CARE_SUPERVISION_EPO",
Expand Down
19 changes: 19 additions & 0 deletions ccd-definition/ComplexTypes/1_furtherDirections.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{
"LiveFrom": "01/01/2017",
"ID": "FurtherDirections",
"ListElementCode": "directionsNeeded",
"FieldType": "YesOrNo",
"ElementLabel": "Do you want to add further directions to the order?",
"SecurityClassification": "Public"
},
{
"LiveFrom": "01/01/2017",
"ID": "FurtherDirections",
"ListElementCode": "directions",
"FieldType": "TextArea",
"ElementLabel": "Give details",
"SecurityClassification": "Public",
"FieldShowCondition": "directionsNeeded = \"Yes\""
}
]
8 changes: 8 additions & 0 deletions ccd-definition/ComplexTypes/GeneratedOrder.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,13 @@
"FieldType": "JudgeAndLegalAdvisor",
"ElementLabel": "Judge and legal advisor",
"SecurityClassification": "Public"
},
{
"LiveFrom": "01/01/2017",
"ID": "GeneratedOrder",
"ListElementCode": "furtherDirections",
"FieldType": "FurtherDirections",
"ElementLabel": "Directions",
"SecurityClassification": "Public"
}
]
Binary file modified docker/docmosis/templates/FL-PLW-GOR-ENG-00218.docx
Binary file not shown.
10 changes: 10 additions & 0 deletions e2e/pages/events/createOrderEvent.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ module.exports = {
title: '#order_title',
details: '#order_details',
orderTypeList: '#orderTypeAndDocument_type',
directionsNeeded: {
yes: '#orderFurtherDirections_directionsNeeded-Yes',
no: '#orderFurtherDirections_directionsNeeded-No',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have directionsNeeded.no if we don’t use it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of the page objects being a bit like an API for the page. i.e this is everything you can do... But sure it's not used. You think I should remove?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, maybe that is a good idea then actually. i think leave in :)

},
directions: '#orderFurtherDirections_directions',
},

selectType(type) {
Expand All @@ -25,4 +30,9 @@ module.exports = {
judgeAndLegalAdvisor.enterJudgeLastName(judgeLastName);
judgeAndLegalAdvisor.enterLegalAdvisorName(legalAdvisorName);
},

enterDirections(directions) {
I.click(this.fields.directionsNeeded.yes);
I.fillField(this.fields.directions, directions);
},
};
3 changes: 3 additions & 0 deletions e2e/tests/hmctsAdministersCaseAfterSubmission_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,11 @@ Scenario('HMCTS admin creates multiple orders for the case', async (I, caseViewP
await createOrderEventPage.selectType(orders[1].type);
await I.retryUntilExists(() => I.click('Continue'), '#judgeAndLegalAdvisor_judgeTitle');
await createOrderEventPage.enterJudgeAndLegalAdvisor(orders[1].judgeAndLegalAdvisor.judgeLastName, orders[1].judgeAndLegalAdvisor.legalAdvisorName);
await I.retryUntilExists(() => I.click('Continue'), '#orderFurtherDirections_directionsNeeded');
await createOrderEventPage.enterDirections('example directions');
await I.completeEvent('Save and continue');
orderTime = new Date();

I.seeEventSubmissionConfirmation(config.administrationActions.createOrder);
caseViewPage.selectTab(caseViewPage.tabs.orders);
I.seeAnswerInTab(1, 'Order 2', 'Type of order', orders[1].type);
Expand Down
3 changes: 3 additions & 0 deletions e2e/tests/judiciaryAdministersCaseAfterSubmission_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,11 @@ Scenario('Judiciary creates multiple orders for the case', async (I, caseViewPag
await createOrderEventPage.selectType(orders[1].type);
await I.retryUntilExists(() => I.click('Continue'), '#judgeAndLegalAdvisor_judgeTitle');
await createOrderEventPage.enterJudgeAndLegalAdvisor(orders[1].judgeAndLegalAdvisor.judgeLastName, orders[1].judgeAndLegalAdvisor.legalAdvisorName);
await I.retryUntilExists(() => I.click('Continue'), '#orderFurtherDirections_directionsNeeded');
await createOrderEventPage.enterDirections('example directions');
await I.completeEvent('Save and continue');
orderTime = new Date();

I.seeEventSubmissionConfirmation(config.administrationActions.createOrder);
caseViewPage.selectTab(caseViewPage.tabs.orders);
I.seeAnswerInTab(1, 'Order 2', 'Type of order', orders[1].type);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package uk.gov.hmcts.reform.fpl.controllers;

import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.collect.ImmutableMap;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration;
Expand All @@ -12,7 +16,9 @@
import uk.gov.hmcts.reform.ccd.client.model.CaseDetails;
import uk.gov.hmcts.reform.document.domain.Document;
import uk.gov.hmcts.reform.fpl.model.CaseData;
import uk.gov.hmcts.reform.fpl.model.FurtherDirections;
import uk.gov.hmcts.reform.fpl.model.GeneratedOrder;
import uk.gov.hmcts.reform.fpl.model.OrderTypeAndDocument;
import uk.gov.hmcts.reform.fpl.model.common.DocmosisDocument;
import uk.gov.hmcts.reform.fpl.model.common.DocumentReference;
import uk.gov.hmcts.reform.fpl.model.common.Element;
Expand All @@ -32,6 +38,8 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static uk.gov.hmcts.reform.fpl.CaseDefinitionConstants.CASE_TYPE;
Expand Down Expand Up @@ -86,27 +94,6 @@ void aboutToStartShouldReturnErrorsWhenFamilymanNumberIsNotProvided() {
assertThat(callbackResponse.getErrors()).containsExactly("Enter Familyman case number");
}

@Test
void midEventShouldGenerateOrderDocument() throws Exception {
byte[] pdf = {1, 2, 3, 4, 5};
Document document = document();
DocmosisDocument docmosisDocument = new DocmosisDocument("order.pdf", pdf);

given(docmosisDocumentGeneratorService.generateDocmosisDocument(any(), any())).willReturn(docmosisDocument);
given(uploadDocumentService.uploadPDF(userId, userAuthToken, pdf, "blank_order_c21.pdf"))
.willReturn(document);

AboutToStartOrSubmitCallbackResponse callbackResponse = postMidEvent(callbackRequest());

CaseData caseData = mapper.convertValue(callbackResponse.getData(), CaseData.class);

assertThat(caseData.getOrderTypeAndDocument().getDocument()).isEqualTo(DocumentReference.builder()
.binaryUrl(document.links.binary.href)
.filename(document.originalDocumentName)
.url(document.links.self.href)
.build());
}

@Test
void aboutToSubmitShouldAddC21OrderToCaseDataAndRemoveTemporaryCaseDataOrderFields() throws Exception {
AboutToStartOrSubmitCallbackResponse callbackResponse = postAboutToSubmitEvent(callbackRequest());
Expand Down Expand Up @@ -174,11 +161,11 @@ private GeneratedOrder buildExpectedCareOrder() {
}

private void aboutToSubmitAssertions(CaseData caseData, GeneratedOrder expectedOrder) {

List<Element<GeneratedOrder>> orders = caseData.getOrderCollection();
assertThat(caseData.getOrderTypeAndDocument()).isEqualTo(null);
assertThat(caseData.getOrder()).isEqualTo(null);
assertThat(caseData.getJudgeAndLegalAdvisor()).isEqualTo(null);
assertThat(caseData.getOrderFurtherDirections()).isEqualTo(null);
assertThat(orders.get(0).getValue()).isEqualTo(expectedOrder);
}

Expand Down Expand Up @@ -216,4 +203,115 @@ private Map<String, Object> expectedOrderLocalAuthorityParameters() {
.put("localAuthorityOrCafcass", LOCAL_AUTHORITY_NAME)
.build();
}

@Nested
class MidEvent {
private final byte[] pdf = {1, 2, 3, 4, 5};
private Document document;

@BeforeEach
void setUp() {
document = document();
DocmosisDocument docmosisDocument = new DocmosisDocument("order.pdf", pdf);

given(docmosisDocumentGeneratorService.generateDocmosisDocument(any(), any())).willReturn(docmosisDocument);
given(uploadDocumentService.uploadPDF(any(), any(), any(), any())).willReturn(document);
}

@Test
void shouldGenerateOrderDocumentWhenOrderTypeIsBlankOrder() {
AboutToStartOrSubmitCallbackResponse callbackResponse = postMidEvent(generateBlankOrderCaseDetails());

CaseData caseData = mapper.convertValue(callbackResponse.getData(), CaseData.class);

verify(uploadDocumentService, times(1)).uploadPDF(userId, userAuthToken, pdf, "blank_order_c21.pdf");

assertThat(caseData.getOrderTypeAndDocument().getDocument()).isEqualTo(expectedDocument());
}

@Test
void shouldGenerateOrderDocumentWhenOrderTypeIsCareOrderWithFurtherDirections() {
final AboutToStartOrSubmitCallbackResponse callbackResponse = postMidEvent(
generateCareOrderCaseDetailsWithFurtherDirections());

verify(docmosisDocumentGeneratorService, times(1)).generateDocmosisDocument(any(), any());
verify(uploadDocumentService, times(1)).uploadPDF(userId, userAuthToken, pdf, "care_order.pdf");

final CaseData caseData = mapper.convertValue(callbackResponse.getData(), CaseData.class);

assertThat(caseData.getOrderTypeAndDocument().getDocument()).isEqualTo(expectedDocument());
}

@Test
void shouldNotGenerateOrderDocumentWhenOrderTypeIsCareOrderWithNoFurtherDirections() {
postMidEvent(generateCareOrderCaseDetailsWithoutFurtherDirections());

verify(docmosisDocumentGeneratorService, never()).generateDocmosisDocument(any(), any());
verify(uploadDocumentService, never()).uploadPDF(any(), any(), any(), any());
}

@AfterEach
void resetInvocations() {
reset(docmosisDocumentGeneratorService);
reset(uploadDocumentService);
}

private CaseDetails generateBlankOrderCaseDetails() {
final CaseData.CaseDataBuilder dataBuilder = CaseData.builder();

dataBuilder.order(GeneratedOrder.builder().details("").build());
dataBuilder.orderTypeAndDocument(OrderTypeAndDocument.builder().type(BLANK_ORDER).build());
generateDefaultValues(dataBuilder);

return CaseDetails.builder()
.data(mapper.convertValue(dataBuilder.build(), new TypeReference<>() {}))
.build();
}

private CaseDetails generateCareOrderCaseDetailsWithFurtherDirections() {
final CaseData.CaseDataBuilder dataBuilder = generateCommonCareOrderDetails();

dataBuilder.orderFurtherDirections(FurtherDirections.builder()
.directionsNeeded("Yes")
.directions("Some directions")
.build());

return CaseDetails.builder()
.data(mapper.convertValue(dataBuilder.build(), new TypeReference<>() {}))
.build();
}

private CaseDetails generateCareOrderCaseDetailsWithoutFurtherDirections() {
final CaseData.CaseDataBuilder dataBuilder = generateCommonCareOrderDetails();

return CaseDetails.builder()
.data(mapper.convertValue(dataBuilder.build(), new TypeReference<>() {}))
.build();
}

private CaseData.CaseDataBuilder generateCommonCareOrderDetails() {
final CaseData.CaseDataBuilder builder = CaseData.builder()
.orderTypeAndDocument(OrderTypeAndDocument.builder()
.type(CARE_ORDER)
.build());

generateDefaultValues(builder);

return builder;
}

private void generateDefaultValues(CaseData.CaseDataBuilder builder) {
builder.caseLocalAuthority(LOCAL_AUTHORITY_CODE);
builder.familyManCaseNumber(FAMILY_MAN_CASE_NUMBER);
builder.judgeAndLegalAdvisor(JudgeAndLegalAdvisor.builder().build());
}

private DocumentReference expectedDocument() {
return DocumentReference.builder()
.binaryUrl(document.links.binary.href)
.filename(document.originalDocumentName)
.url(document.links.self.href)
.build();
}
}
}
Loading