Skip to content

Commit

Permalink
include patch
Browse files Browse the repository at this point in the history
  • Loading branch information
cmagowan-hmcts committed May 29, 2024
1 parent e019ede commit 30265ae
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package uk.gov.hmcts.darts.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import org.apache.commons.text.StringEscapeUtils;

import java.io.IOException;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.equalToXml;
import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson;
import static com.github.tomakehurst.wiremock.client.WireMock.exactly;
import static com.github.tomakehurst.wiremock.client.WireMock.patch;
import static com.github.tomakehurst.wiremock.client.WireMock.patchRequestedFor;
Expand All @@ -19,7 +17,7 @@

public class DailyListApiStub extends DartsApiStub {

private static final String DAILY_LIST_API_PATH = "/dailylists";
private static final String DAILY_LIST_API_PATH = "/dailylists/v2";

public DailyListApiStub() {
super(DAILY_LIST_API_PATH);
Expand All @@ -38,48 +36,34 @@ public void willRespondSuccessfully() {

public void verifyPostRequest() throws IOException {
String dailyListXmlString = TestUtils.getContentsFromFile(
"payloads/events/dailyList-api-request.xml");
"payloads/events/dailyList-api-post-request.json");
verify(exactly(1), postRequestedFor(urlPathEqualTo(DAILY_LIST_API_PATH))
.withQueryParam("source_system", equalTo("XHB"))
.withQueryParam("courthouse", equalTo("SNARESBROOK"))
.withQueryParam("hearing_date", equalTo("2010-02-18"))
.withQueryParam("unique_id", equalTo("CSDDL000000000576147"))
.withQueryParam("published_ts", equalTo("2010-02-18T11:13:23.03Z"))
.withQueryParam("message_id", equalTo("18418"))
.withHeader("xml_document", equalTo(StringEscapeUtils.unescapeXml(dailyListXmlString.trim())))
.withRequestBody(equalToJson(dailyListXmlString))
);
}

public void verifyPostRequestWithoutLineBreaks() throws IOException {
String dailyListXmlString = TestUtils.getContentsFromFile(
"payloads/events/dailyList-api-request-with-lb-removed.xml");
"payloads/events/dailyList-api-request-with-lb-removed.json");
verify(exactly(1), postRequestedFor(urlPathEqualTo(DAILY_LIST_API_PATH))
.withQueryParam("source_system", equalTo("CPP"))
.withQueryParam("courthouse", equalTo("YORK"))
.withQueryParam("hearing_date", equalTo("2024-03-06"))
.withQueryParam("unique_id", equalTo("CSDDL1709741907143"))
.withQueryParam("published_ts", equalTo("2024-03-06T16:18:24.871Z"))
.withQueryParam("message_id", equalTo("18418"))
.withHeader("xml_document", equalToXml(StringEscapeUtils.unescapeXml(dailyListXmlString.trim())))
.withRequestBody(equalToJson(dailyListXmlString))
);
}

public void verifyPatchRequest() throws IOException {
String dailyListJsonString = TestUtils.getContentsFromFile(
"payloads/events/dailyList-api-request.json");
"payloads/events/dailyList-api-patch-request.json");

verify(exactly(1), patchRequestedFor(urlPathEqualTo(DAILY_LIST_API_PATH))
.withQueryParam("dal_id", equalTo("1"))
.withHeader("json_string", equalTo(dailyListJsonString.trim()))
.withRequestBody(equalToJson(dailyListJsonString))
);
}

public void verifyCppPatchRequest() throws IOException {
String dailyListJsonString = TestUtils.getContentsFromFile("payloads/events/dailyList-CPP-api-request.json");
String dailyListJsonString = TestUtils.getContentsFromFile("payloads/events/dailyList-CPP-api-patch-request.json");

verify(exactly(1), patchRequestedFor(urlPathEqualTo(DAILY_LIST_API_PATH))
.withQueryParam("dal_id", equalTo("1"))
.withHeader("json_string", equalTo(dailyListJsonString.trim()))
.withRequestBody(equalToJson(dailyListJsonString))
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"dal_id": 1,
"json_string": "{\"document_id\":{\"document_name\":\"DailyList_467_20240306161825.xml\",\"unique_id\":\"CSDDL1709741907143\",\"document_type\":\"DL\",\"time_stamp\":\"2024-03-06T16:18:24.871Z\"},\"list_header\":{\"list_category\":\"Criminal\",\"start_date\":\"2024-03-06\",\"end_date\":\"2024-03-06\",\"version\":\"NOT VERSIONED\",\"published_time\":\"2024-03-06T16:18:25.108Z\"},\"crown_court\":{\"court_house_type\":\"CROWN_COURT\",\"court_house_code\":{\"court_house_short_name\":\"YORK\",\"code\":467},\"court_house_name\":\"YORK\"},\"court_lists\":[{\"court_house\":{\"court_house_type\":\"CROWN_COURT\",\"court_house_code\":{\"code\":467},\"court_house_name\":\"YORK\"},\"sittings\":[{\"court_room_number\":\"1\",\"sitting_sequence_no\":1,\"sitting_at\":\"10:30:00\",\"sitting_priority\":\"T\",\"judiciary\":[{\"citizen_name_forename\":\"NONE\",\"citizen_name_surname\":\"NONE\",\"citizen_name_requested_name\":\"NONE\"}],\"hearings\":[{\"hearing_sequence_number\":1,\"hearing_details\":{\"hearing_type\":\"PLE\",\"hearing_description\":\"For Plea\",\"hearing_date\":\"2024-03-06\"},\"time_marking_note\":\"10:30 AM\",\"case_number\":\"T20107001\",\"prosecution\":{\"prosecuting_authority\":\"Other Prosecutor\",\"prosecuting_reference\":\"Other Prosecutor\",\"prosecuting_organisation\":{\"organisation_name\":\"Other Prosecutor\"},\"advocates\":[]},\"defendants\":[{\"personal_details\":{\"name\":{\"citizen_name_forename\":\"Casper\",\"citizen_name_surname\":\"Daugherty\",\"citizen_name_requested_name\":\"Casper Daugherty\"},\"is_masked\":false},\"counsel\":[],\"urn\":\"50MD1811194\",\"charges\":[{\"indictment_count_number\":0,\"offence_statement\":\"Sex offences - abuse position of trust - engage in sexual activity\"}]}]}]}]}]}"
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"dal_id": 1,
"json_string": "{\"document_id\":{\"document_name\":\"DL 18/02/10 FINAL v1\",\"unique_id\":\"CSDDL000000000576147\",\"document_type\":\"DL\",\"time_stamp\":\"2010-02-18T11:13:23.03Z\"},\"list_header\":{\"list_category\":\"Criminal\",\"start_date\":\"2010-02-18\",\"end_date\":\"2010-02-18\",\"version\":\"FINAL v1\",\"published_time\":\"2010-02-17T16:16:50Z\"},\"crown_court\":{\"court_house_type\":\"CROWN_COURT\",\"court_house_code\":{\"court_house_short_name\":\"SNARE\",\"code\":453},\"court_house_name\":\"SNARESBROOK\"},\"court_lists\":[{\"court_house\":{\"court_house_type\":\"CROWN_COURT\",\"court_house_code\":{\"code\":453},\"court_house_name\":\"SNARESBROOK\"},\"sittings\":[{\"court_room_number\":\"1A\",\"sitting_sequence_no\":1,\"sitting_at\":\"10:00:00\",\"sitting_priority\":\"T\",\"judiciary\":[{\"citizen_name_forename\":\"\",\"citizen_name_surname\":\"N/A\",\"citizen_name_requested_name\":\"N/A\"}],\"hearings\":[{\"hearing_sequence_number\":1,\"hearing_details\":{\"hearing_type\":\"TRL\",\"hearing_description\":\"For Trial\",\"hearing_date\":\"2010-02-18\"},\"time_marking_note\":\"10:00 AM\",\"case_number\":\"T20107001\",\"prosecution\":{\"prosecuting_authority\":\"Crown Prosecution Service\",\"prosecuting_reference\":\"CPS\",\"prosecuting_organisation\":{\"organisation_name\":\"Crown Prosecution Service\"},\"advocates\":[]},\"defendants\":[{\"personal_details\":{\"name\":{\"citizen_name_forename\":\"Franz\",\"citizen_name_surname\":\"KAFKA\"},\"is_masked\":false},\"counsel\":[],\"urn\":\"62AA1010646\"}]}]}]}]}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"source_system": "XHB",
"courthouse": "SNARESBROOK",
"hearing_date": "2010-02-18",
"unique_id": "CSDDL000000000576147",
"published_ts": "2010-02-18T11:13:23.03Z",
"message_id": "18418",
"xml_document": "<cs:DailyList xmlns:cs=\"http://www.courtservice.gov.uk/schemas/courtservice\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.courtservice.gov.uk/schemas/courtservice DailyList-v5-2.xsd\" xmlns:apd=\"http://www.govtalk.gov.uk/people/AddressAndPersonalDetails\"><cs:DocumentID><cs:DocumentName>DL 18/02/10 FINAL v1</cs:DocumentName><cs:UniqueID>CSDDL000000000576147</cs:UniqueID><cs:DocumentType>DL</cs:DocumentType><cs:TimeStamp>2010-02-18T11:13:23.030</cs:TimeStamp><cs:Version>1.0</cs:Version><cs:SecurityClassification>NPM</cs:SecurityClassification><cs:SellByDate>2010-12-15</cs:SellByDate><cs:XSLstylesheetURL>http://www.courtservice.gov.uk/transforms/courtservice/dailyListHtml.xsl</cs:XSLstylesheetURL></cs:DocumentID><cs:ListHeader><cs:ListCategory>Criminal</cs:ListCategory><cs:StartDate>2010-02-18</cs:StartDate><cs:EndDate>2010-02-18</cs:EndDate><cs:Version>FINAL v1</cs:Version><cs:CRESTprintRef>MCD/112585</cs:CRESTprintRef><cs:PublishedTime>2010-02-17T16:16:50</cs:PublishedTime><cs:CRESTlistID>12298</cs:CRESTlistID></cs:ListHeader><cs:CrownCourt><cs:CourtHouseType>Crown Court</cs:CourtHouseType><cs:CourtHouseCode CourtHouseShortName=\"SNARE\">453</cs:CourtHouseCode><cs:CourtHouseName>SNARESBROOK</cs:CourtHouseName><cs:CourtHouseAddress><apd:Line>THE CROWN COURT AT SNARESBROOK</apd:Line><apd:Line>75 HOLLYBUSH HILL</apd:Line><apd:Line>SNARESBROOK, LONDON</apd:Line><apd:PostCode>E11 1QW</apd:PostCode></cs:CourtHouseAddress><cs:CourtHouseDX>DX 98240 WANSTEAD 2</cs:CourtHouseDX><cs:CourtHouseTelephone>02085300000</cs:CourtHouseTelephone><cs:CourtHouseFax>02085300072</cs:CourtHouseFax></cs:CrownCourt><cs:CourtLists><cs:CourtList><cs:CourtHouse><cs:CourtHouseType>Crown Court</cs:CourtHouseType><cs:CourtHouseCode>453</cs:CourtHouseCode><cs:CourtHouseName>SNARESBROOK</cs:CourtHouseName></cs:CourtHouse><cs:Sittings><cs:Sitting><cs:CourtRoomNumber>1A</cs:CourtRoomNumber><cs:SittingSequenceNo>1</cs:SittingSequenceNo><cs:SittingAt>10:00:00</cs:SittingAt><cs:SittingPriority>T</cs:SittingPriority><cs:Judiciary><cs:Judge><apd:CitizenNameSurname>N&#47;A</apd:CitizenNameSurname><apd:CitizenNameRequestedName>N&#47;A</apd:CitizenNameRequestedName><cs:CRESTjudgeID>0</cs:CRESTjudgeID></cs:Judge></cs:Judiciary><cs:Hearings><cs:Hearing><cs:HearingSequenceNumber>1</cs:HearingSequenceNumber><cs:HearingDetails HearingType=\"TRL\"><cs:HearingDescription>For Trial</cs:HearingDescription><cs:HearingDate>2010-02-18</cs:HearingDate></cs:HearingDetails><cs:CRESThearingID>1</cs:CRESThearingID><cs:TimeMarkingNote>10:00 AM</cs:TimeMarkingNote><cs:CaseNumber>T20107001</cs:CaseNumber><cs:Prosecution ProsecutingAuthority=\"Crown Prosecution Service\"><cs:ProsecutingReference>CPS</cs:ProsecutingReference><cs:ProsecutingOrganisation><cs:OrganisationName>Crown Prosecution Service</cs:OrganisationName></cs:ProsecutingOrganisation></cs:Prosecution><cs:CommittingCourt><cs:CourtHouseType>Magistrates Court</cs:CourtHouseType><cs:CourtHouseCode CourtHouseShortName=\"BAM\">2725</cs:CourtHouseCode><cs:CourtHouseName>BARNET MAGISTRATES COURT</cs:CourtHouseName><cs:CourtHouseAddress><apd:Line>7C HIGH STREET</apd:Line><apd:Line>-</apd:Line><apd:Line>BARNET</apd:Line><apd:PostCode>EN5 5UE</apd:PostCode></cs:CourtHouseAddress><cs:CourtHouseDX>DX 8626 BARNET</cs:CourtHouseDX><cs:CourtHouseTelephone>02084419042</cs:CourtHouseTelephone></cs:CommittingCourt><cs:Defendants><cs:Defendant><cs:PersonalDetails><cs:Name><apd:CitizenNameForename>Franz</apd:CitizenNameForename><apd:CitizenNameSurname>KAFKA</apd:CitizenNameSurname></cs:Name><cs:IsMasked>no</cs:IsMasked><cs:DateOfBirth><apd:BirthDate>1962-06-12</apd:BirthDate><apd:VerifiedBy>not verified</apd:VerifiedBy></cs:DateOfBirth><cs:Sex>male</cs:Sex><cs:Address><apd:Line>ADDRESS LINE 1</apd:Line><apd:Line>ADDRESS LINE 2</apd:Line><apd:Line>ADDRESS LINE 3</apd:Line><apd:Line>ADDRESS LINE 4</apd:Line><apd:Line>SOMETOWN, SOMECOUNTY</apd:Line><apd:PostCode>GU12 7RT</apd:PostCode></cs:Address></cs:PersonalDetails><cs:ASNs><cs:ASN>0723XH1000000262665K</cs:ASN></cs:ASNs><cs:CRESTdefendantID>29161</cs:CRESTdefendantID><cs:PNCnumber>20123456789L</cs:PNCnumber><cs:URN>62AA1010646</cs:URN><cs:CustodyStatus>In custody</cs:CustodyStatus></cs:Defendant></cs:Defendants></cs:Hearing></cs:Hearings></cs:Sitting></cs:Sittings></cs:CourtList></cs:CourtLists></cs:DailyList>"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"source_system": "CPP",
"courthouse": "YORK",
"hearing_date": "2024-03-06",
"unique_id": "CSDDL1709741907143",
"published_ts": "2024-03-06T16:18:24.871Z",
"message_id": "18418",
"xml_document": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?> <cs:DailyList xmlns:cs=\"http://www.courtservice.gov.uk/schemas/courtservice\" xmlns:p2=\"http://www.govtalk.gov.uk/people/bs7666\" xmlns:apd=\"http://www.govtalk.gov.uk/people/AddressAndPersonalDetails\"> <cs:DocumentID> <cs:DocumentName>DailyList_467_20240306161825.xml</cs:DocumentName> <cs:UniqueID>CSDDL1709741907143</cs:UniqueID> <cs:DocumentType>DL</cs:DocumentType> <cs:TimeStamp>2024-03-06T16:18:24.871</cs:TimeStamp> </cs:DocumentID> <cs:ListHeader> <cs:ListCategory>Criminal</cs:ListCategory> <cs:StartDate>2024-03-06</cs:StartDate> <cs:EndDate>2024-03-06</cs:EndDate> <cs:Version>NOT VERSIONED</cs:Version> <cs:PublishedTime>2024-03-06T16:18:25.108Z</cs:PublishedTime> </cs:ListHeader> <cs:CrownCourt> <cs:CourtHouseType>Crown Court</cs:CourtHouseType> <cs:CourtHouseCode CourtHouseShortName=\"YORK\">467</cs:CourtHouseCode> <cs:CourtHouseName>YORK</cs:CourtHouseName> </cs:CrownCourt> <cs:CourtLists> <cs:CourtList> <cs:CourtHouse> <cs:CourtHouseType>Crown Court</cs:CourtHouseType> <cs:CourtHouseCode>467</cs:CourtHouseCode> <cs:CourtHouseName>YORK</cs:CourtHouseName> </cs:CourtHouse> <cs:Sittings> <cs:Sitting> <cs:CourtRoomNumber>1</cs:CourtRoomNumber> <cs:SittingSequenceNo>1</cs:SittingSequenceNo> <cs:SittingAt>10:30:00</cs:SittingAt> <cs:SittingPriority>T</cs:SittingPriority> <cs:Judiciary> <cs:Judge> <apd:CitizenNameForename>NONE</apd:CitizenNameForename> <apd:CitizenNameSurname>NONE</apd:CitizenNameSurname> <apd:CitizenNameRequestedName>NONE</apd:CitizenNameRequestedName> </cs:Judge> </cs:Judiciary> <cs:Hearings> <cs:Hearing> <cs:HearingSequenceNumber>1</cs:HearingSequenceNumber> <cs:HearingDetails HearingType=\"PLE\"> <cs:HearingDescription>For Plea</cs:HearingDescription> <cs:HearingDate>2024-03-06</cs:HearingDate> </cs:HearingDetails> <cs:TimeMarkingNote>10:30 AM</cs:TimeMarkingNote> <cs:CaseNumber>T20107001</cs:CaseNumber> <cs:Prosecution ProsecutingAuthority=\"Other Prosecutor\"> <cs:ProsecutingReference>Other Prosecutor</cs:ProsecutingReference> <cs:ProsecutingOrganisation> <cs:OrganisationName>Other Prosecutor</cs:OrganisationName> </cs:ProsecutingOrganisation> </cs:Prosecution> <cs:Defendants> <cs:Defendant> <cs:PersonalDetails> <cs:Name> <apd:CitizenNameForename>Casper</apd:CitizenNameForename> <apd:CitizenNameSurname>Daugherty</apd:CitizenNameSurname> <apd:CitizenNameRequestedName>Casper Daugherty</apd:CitizenNameRequestedName> </cs:Name> <cs:IsMasked>no</cs:IsMasked> </cs:PersonalDetails> <cs:URN>50MD1811194</cs:URN> <cs:Charges> <cs:Charge IndictmentCountNumber=\"0\" CJSoffenceCode=\"SA00002\"> <cs:OffenceStatement>Sex offences - abuse position of trust - engage in sexual activity</cs:OffenceStatement> </cs:Charge> </cs:Charges> </cs:Defendant> </cs:Defendants> </cs:Hearing> </cs:Hearings> </cs:Sitting> </cs:Sittings> </cs:CourtList> </cs:CourtLists> </cs:DailyList> "
}
Loading

0 comments on commit 30265ae

Please sign in to comment.