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

DTSRD-4052 . Adding extra column to court venue table #893

Merged
merged 19 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8dc814c
DTSRD-4052 . Adding extra column to court venue table
SabinaHMCTS Jan 10, 2025
abbe62e
DTSRD-4052 . Adding extra column to court venue table
SabinaHMCTS Jan 14, 2025
39d577d
DTSRD-4052 . Adding extra column to court venue table
SabinaHMCTS Jan 15, 2025
05b7c1e
DTSRD-4052 . Adding extra column to court venue table
SabinaHMCTS Jan 15, 2025
9d40b11
DTSRD-4052 . Adding extra column to court venue table
SabinaHMCTS Jan 15, 2025
5985546
DTSRD-4052 . Adding extra column to court venue table
SabinaHMCTS Jan 15, 2025
516ba28
DTSRD-4052 . Adding extra column to court venue table
SabinaHMCTS Jan 16, 2025
d22d388
DTSRD-4052 . Adding extra column to court venue table
SabinaHMCTS Jan 16, 2025
b0473c0
DTSRD-4052 . Adding extra column to court venue table
SabinaHMCTS Jan 16, 2025
9018d42
DTSRD-4052 . Adding extra column to court venue table
SabinaHMCTS Jan 20, 2025
c456f81
DTSRD-4052 . Adding extra column to court venue table
SabinaHMCTS Jan 20, 2025
5663d56
DTSRD-4052 . Adding extra column to court venue table
SabinaHMCTS Jan 20, 2025
2ccf385
DTSRD-4052 . Adding extra column to court venue table
SabinaHMCTS Jan 20, 2025
3a69d5e
DTSRD-4052 . Adding extra column to court venue table
SabinaHMCTS Jan 20, 2025
de7b932
DTSRD-4052 . Adding extra column to court venue table
SabinaHMCTS Jan 20, 2025
aca35d4
DTSRD-4052 . Adding extra column to court venue table
SabinaHMCTS Jan 20, 2025
f5f7a28
DTSRD-4052 . Adding extra column to court venue table
SabinaHMCTS Jan 20, 2025
503b22a
DTSRD-4052 . Adding extra column to court venue table
SabinaHMCTS Jan 20, 2025
cc14ba0
DTSRD-4052 . Adding extra column to court venue table
SabinaHMCTS Jan 20, 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
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ private void responseVerification(List<LrdBuildingLocationResponse> response, St
} else if (TWO_STR.equalsIgnoreCase(responseType)) {
assertThat(response).hasSize(2).containsAnyElementsOf(getTwoLocationResponse());
} else if (ALL.equalsIgnoreCase(responseType)) {
assertThat(response).hasSize(14).containsAnyElementsOf(getAllLocationResponse());
assertThat(response).hasSize(16).containsAnyElementsOf(getAllLocationResponse());
} else {
assertThat(response).hasSize(4).hasSameElementsAs(getAllOpenLocationResponse());
}
Expand Down Expand Up @@ -402,6 +402,7 @@ private List<LrdBuildingLocationResponse> getAllLocationResponse() {
.courtAddress("AB7, 54 HUNTLY STREET, ABERDEEN")
.courtVenueId("13")
.externalShortName("Aberdeen Tribunal External")
.welshExternalShortName("Welsh Aberdeen Tribunal External")
.build();

LrdBuildingLocationResponse locationResponses5 = LrdBuildingLocationResponse.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import com.fasterxml.jackson.core.JsonProcessingException;
import io.opentelemetry.api.internal.StringUtils;
import net.thucydides.core.annotations.WithTag;
import net.thucydides.core.annotations.WithTags;
import org.junit.jupiter.api.Test;
Expand All @@ -28,6 +29,22 @@ class RetrieveCourtVenueDetailsIntegrationTest extends LrdAuthorizationEnabledIn
private static final String HTTP_STATUS_STR = "http_status";
private static final String path = "/court-venues";

@ParameterizedTest
@ValueSource(strings = {"123462"})
@SuppressWarnings("unchecked")
void retrieveCourtVenues_WithEpimmsIdGiven_ShouldReturnValidResponseAndStatusCodeWithWelshExternalShortName200(
String id) throws JsonProcessingException {

final var response = (List<LrdCourtVenueResponse>)
lrdApiClient.retrieveCourtVenueResponseForGivenRequest("?epimms_id=" + id,
LrdCourtVenueResponse[].class, path);

assertThat(response).isNotEmpty().hasSize(1);
assertTrue(response.stream().allMatch(venue -> venue.getEpimmsId().equals("123462")));
assertTrue(response.stream().allMatch(venue -> venue.getWelshExternalShortName().equalsIgnoreCase(
"Welsh External Short Name")));
}

@ParameterizedTest
@ValueSource(strings = {"123456789", " 123456789 ", "123456789, *"})
@SuppressWarnings("unchecked")
Expand All @@ -39,7 +56,8 @@ void retrieveCourtVenues_WithEpimmsIdGiven_ShouldReturnValidResponseAndStatusCod
LrdCourtVenueResponse[].class, path);

assertThat(response).isNotEmpty().hasSize(1);
assertTrue(response.stream().allMatch(venue -> venue.getEpimmsId().equals("123456789")));
assertTrue(response.stream().allMatch(venue -> venue.getEpimmsId().equals("123456789")
&& StringUtils.isNullOrEmpty(venue.getExternalShortName())));
}

@ParameterizedTest
Expand All @@ -53,8 +71,9 @@ void retrieveCourtVenues_AllepimmsIdGiven_ShouldReturnValidResponseAndStatusCode
LrdCourtVenueResponse[].class, path
);

assertThat(response).isNotEmpty().hasSize(13);
assertThat(response).isNotEmpty().hasSize(15);
assertEquals("Aberdeen Tribunal External", response.get(12).getExternalShortName());
assertEquals("Welsh External Short Name", response.get(13).getWelshExternalShortName());
}

@Test
Expand All @@ -67,9 +86,10 @@ void retrieveCourtVenues_NoEpimmsIdGiven_ShouldReturnValidResponseAndStatusCode2
LrdCourtVenueResponse[].class, path
);

assertThat(response).isNotEmpty().hasSize(13);
assertThat(response).isNotEmpty().hasSize(15);
assertTrue(response.stream().allMatch(venue -> venue.getCourtStatus().equalsIgnoreCase("Open")));
assertEquals("Aberdeen Tribunal External", response.get(12).getExternalShortName());
assertEquals("Welsh External Short Name", response.get(13).getWelshExternalShortName());
}


Expand Down Expand Up @@ -107,6 +127,22 @@ void retrieveCourtVenues_WithEpimmsIdAndCourtType_ShouldReturnStatusCode200(Stri
assertTrue(response.stream().allMatch(venue -> venue.getCourtTypeId().equals("17")));
}

@ParameterizedTest
@CsvSource({ "123462,17" })
void retrieveCourtVenues_WithEpimmsIdAndCourtType_WithWelshShortName_ShouldReturnStatusCode200(
String id, String courtType) throws
JsonProcessingException {

final var response = (List<LrdCourtVenueResponse>)
lrdApiClient.retrieveCourtVenueResponseForGivenRequest("?epimms_id=" + id
+ "&court_type_id=" + courtType,LrdCourtVenueResponse[].class, path);

assertThat(response).isNotEmpty().hasSize(1);
assertTrue(response.stream().allMatch(venue -> venue.getEpimmsId().equals("123462")));
assertTrue(response.stream().allMatch(venue -> venue.getCourtTypeId().equals("17")));
assertTrue(response.stream().allMatch(venue -> venue.getWelshExternalShortName()
.equals("Welsh External Short Name")));
}

@ParameterizedTest
@CsvSource({
Expand Down Expand Up @@ -139,10 +175,10 @@ void retrieveCourtVenues_WithCourtTypeIdGiven_ShouldReturnValidResponseAndStatus
lrdApiClient.retrieveCourtVenueResponseForGivenRequest("?court_type_id=" + id,
LrdCourtVenueResponse[].class, path);

assertThat(response).isNotEmpty().hasSize(10);
assertThat(response).isNotEmpty().hasSize(12);
assertTrue(response.stream().allMatch(venue -> venue.getCourtTypeId().equals(id.trim())));
assertEquals("Aberdeen Tribunal External", response.get(9).getExternalShortName());

assertEquals("Welsh External Short Name", response.get(10).getWelshExternalShortName());
}

@ParameterizedTest
Expand All @@ -156,7 +192,23 @@ void retrieveCourtVenues_WithRegionIdGiven_ShouldReturnValidResponseAndStatusCod
LrdCourtVenueResponse[].class, path);

assertThat(response).isNotEmpty().hasSize(8);
assertTrue(response.stream().allMatch(venue -> venue.getRegionId().equals(id.trim())));
assertTrue(response.stream().allMatch(venue -> venue.getRegionId().equals(id.trim())
&& StringUtils.isNullOrEmpty(venue.getWelshExternalShortName())));
}

@ParameterizedTest
@ValueSource(strings = {"3"})
@SuppressWarnings("unchecked")
void retrieveCourtVenues_WithRegionIdGiven_WithWelshNameShouldReturnValidResponseAndStatusCode200(String id) throws
JsonProcessingException {

final var response = (List<LrdCourtVenueResponse>)
lrdApiClient.retrieveCourtVenueResponseForGivenRequest("?region_id=" + id,
LrdCourtVenueResponse[].class, path);

assertThat(response).isNotEmpty().hasSize(1);
assertTrue(response.stream().allMatch(venue -> venue.getRegionId().equals(id.trim())
&& venue.getWelshExternalShortName().equalsIgnoreCase("Welsh External Short Name")));
}

@ParameterizedTest
Expand All @@ -172,6 +224,23 @@ void retrieveCourtVenues_WithClusterIdGiven_ShouldReturnValidResponseAndStatusCo
assertThat(response).isNotEmpty().hasSize(6);
assertTrue(response.stream().allMatch(venue -> venue.getClusterId().equals(id.trim())));
assertEquals("Aberdeen Tribunal External", response.get(5).getExternalShortName());

}

@ParameterizedTest
@ValueSource(strings = {"1"})
@SuppressWarnings("unchecked")
void retrieveCourtVenues_WithClusterIdGiven_WithWelshShortName_ShouldReturnValidResponseAndStatusCode200(
String id) throws JsonProcessingException {

final var response = (List<LrdCourtVenueResponse>)
lrdApiClient.retrieveCourtVenueResponseForGivenRequest("?cluster_id=" + id,
LrdCourtVenueResponse[].class, path);

assertThat(response).isNotEmpty().hasSize(5);
assertTrue(response.stream().allMatch(venue -> venue.getClusterId().equals(id.trim())));
assertEquals("Aberdeen Tribunal External", response.get(3).getExternalShortName());
assertEquals("Welsh External Short Name",response.get(3).getWelshExternalShortName());
}

@Test
Expand All @@ -185,7 +254,24 @@ void retrieveCourtVenues_WithCourtVenueNameGiven_ShouldReturnValidResponseAndSta

assertThat(response).isNotEmpty().hasSize(1);
assertTrue(response.stream().allMatch(venue -> venue.getCourtName()
.equals("ABERDEEN TRIBUNAL HEARING CENTRE 1")));
.equals("ABERDEEN TRIBUNAL HEARING CENTRE 1")
&& StringUtils.isNullOrEmpty(venue.getWelshExternalShortName())));
}

@Test
@SuppressWarnings("unchecked")
void retrieveCourtVenues_WithCourtVenueNameGiven_WithWelshShortName_ShouldReturnValidResponseAndStatusCode200()
throws JsonProcessingException {

final var response = (List<LrdCourtVenueResponse>)
lrdApiClient.retrieveCourtVenueResponseForGivenRequest(
"?court_venue_name=ABERDEEN TRIBUNAL HEARING CENTRE 22",
LrdCourtVenueResponse[].class, path);

assertThat(response).isNotEmpty().hasSize(1);
assertTrue(response.stream().allMatch(venue -> venue.getCourtName()
.equals("ABERDEEN TRIBUNAL HEARING CENTRE 22")
&& venue.getWelshExternalShortName().equalsIgnoreCase("Welsh External Short Name")));
}

@ParameterizedTest
Expand Down Expand Up @@ -219,7 +305,30 @@ void shouldReturn200WhenParameterEpmIdsValueAllWithYPassed() throws
venue.getIsHearingLocation().equalsIgnoreCase("Y")
&& venue.getIsCaseManagementLocation().equalsIgnoreCase("Y")
&& venue.getLocationType().equalsIgnoreCase("CTSC")
&& venue.getIsTemporaryLocation().equalsIgnoreCase("Y")));
&& venue.getIsTemporaryLocation().equalsIgnoreCase("Y")
&& StringUtils.isNullOrEmpty(venue.getWelshExternalShortName())));
}

@Test
void shouldReturn200WhenParameterEpmIdsValueAllWithYPassed_AndContainsWelshShortName() throws
JsonProcessingException {

List<LrdCourtVenueResponse> response = (List<LrdCourtVenueResponse>)
lrdApiClient.retrieveCourtVenueResponseForGivenRequest(
"?epimms_id=123463"
+ "&is_hearing_location=N&is_case_management_location=Y&location_type=CTSC"
+ "&is_temporary_location=Y",
LrdCourtVenueResponse[].class,
path
);

assertThat(response).isNotEmpty().hasSize(1);
assertTrue(response.stream().allMatch(venue ->
venue.getIsHearingLocation().equalsIgnoreCase("N")
&& venue.getIsCaseManagementLocation().equalsIgnoreCase("Y")
&& venue.getLocationType().equalsIgnoreCase("CTSC")
&& venue.getIsTemporaryLocation().equalsIgnoreCase("Y")
&& venue.getWelshExternalShortName().equalsIgnoreCase("Welsh External Short Name")));
}

@Test
Expand All @@ -240,7 +349,8 @@ void shouldReturn200WhenParameterEpmIdsValueAllWithLowerCaseValuesPassed() throw
venue.getIsHearingLocation().equalsIgnoreCase("Y")
&& venue.getIsCaseManagementLocation().equalsIgnoreCase("Y")
&& venue.getLocationType().equalsIgnoreCase("CTSC")
&& venue.getIsTemporaryLocation().equalsIgnoreCase("Y")));
&& venue.getIsTemporaryLocation().equalsIgnoreCase("Y")
&& StringUtils.isNullOrEmpty(venue.getWelshExternalShortName())));
}

@Test
Expand Down Expand Up @@ -278,7 +388,8 @@ void shouldReturn200WhenParameterEpmIdsValueAllWithHearingLocationYPassed() thro

assertThat(response).isNotEmpty().hasSize(2);
assertTrue(response.stream().allMatch(venue ->
venue.getIsHearingLocation().equalsIgnoreCase("Y")));
venue.getIsHearingLocation().equalsIgnoreCase("Y")
&& StringUtils.isNullOrEmpty(venue.getWelshExternalShortName())));
}

@Test
Expand All @@ -292,9 +403,10 @@ void shouldReturn200WhenParameterCourtTypeIdIsPassed() throws
path
);

assertThat(response).isNotEmpty().hasSize(10);
assertThat(response).isNotEmpty().hasSize(12);
assertTrue(response.stream().allMatch(venue -> venue.getCourtTypeId().equals("17")));
assertEquals("Aberdeen Tribunal External", response.get(9).getExternalShortName());
assertEquals("Welsh External Short Name", response.get(10).getWelshExternalShortName());
}

@Test
Expand All @@ -309,7 +421,8 @@ void shouldReturn200WhenParameterRegionIdIsPassed() throws
);

assertThat(response).isNotEmpty().hasSize(8);
assertTrue(response.stream().allMatch(venue -> venue.getRegionId().equals("1")));
assertTrue(response.stream().allMatch(venue -> venue.getRegionId().equals("1")
&& StringUtils.isNullOrEmpty(venue.getWelshExternalShortName())));
}

@Test
Expand All @@ -324,7 +437,8 @@ void shouldReturn200WhenParameterClusterIdIsPassed() throws
);

assertThat(response).isNotEmpty().hasSize(6);
assertTrue(response.stream().allMatch(venue -> venue.getClusterId().equals("2")));
assertTrue(response.stream().allMatch(venue -> venue.getClusterId().equals("2")
&& StringUtils.isNullOrEmpty(venue.getWelshExternalShortName())));
}

@Test
Expand All @@ -341,7 +455,8 @@ void shouldReturn200WhenParameterCourtVenueNameIsPassed() throws

assertThat(response).isNotEmpty().hasSize(1);
assertTrue(response.stream().allMatch(venue -> venue.getCourtName()
.equals("ABERDEEN TRIBUNAL HEARING CENTRE 10")));
.equals("ABERDEEN TRIBUNAL HEARING CENTRE 10")
&& StringUtils.isNullOrEmpty(venue.getWelshExternalShortName())));
}

@Test
Expand Down Expand Up @@ -371,9 +486,8 @@ void shouldReturn200WhenNoQueryParameterIsPassed() throws
List<LrdCourtVenueResponse> response = (List<LrdCourtVenueResponse>)
lrdApiClient.retrieveCourtVenueResponseForGivenRequest(null, LrdCourtVenueResponse[].class, path);

assertThat(response).isNotEmpty().hasSize(13);
assertThat(response).isNotEmpty().hasSize(15);
assertEquals("Aberdeen Tribunal External", response.get(12).getExternalShortName());

}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ void shouldRetrieveCourtVenues_For_SearchString_WithStatusCode_200()
path
);

assertThat(response).isNotEmpty().hasSize(12);
assertThat(response).isNotEmpty().hasSize(14);
responseVerification(new ArrayList<>(Arrays.asList(response)));
assertEquals("Aberdeen Tribunal External", response[11].getExternalShortName());
assertEquals("Welsh External Short Name", response[12].getWelshExternalShortName());
}

@Test
Expand Down Expand Up @@ -87,9 +88,10 @@ void shouldRetrieveCourtVenues_For_SearchString_And_CourtTypeId_WithStatusCode_2
path
);

assertThat(response).isNotEmpty().hasSize(12);
assertThat(response).isNotEmpty().hasSize(14);
responseVerification(new ArrayList<>(Arrays.asList(response)));
assertEquals("Aberdeen Tribunal External", response[11].getExternalShortName());
assertEquals("Welsh External Short Name", response[12].getWelshExternalShortName());
}

@ParameterizedTest
Expand Down Expand Up @@ -213,7 +215,7 @@ void shouldReturn200_WhenIsCaseManagementLocationContainY() throws JsonProcessin
path
);

assertThat(response).isNotEmpty().hasSize(2);
assertThat(response).isNotEmpty().hasSize(3);
responseVerification(new ArrayList<>(Arrays.asList(response)));
}

Expand All @@ -227,7 +229,7 @@ void shouldReturn200_WhenIsCaseManagementLocationContainY_lowerCase() throws Jso
path
);

assertThat(response).isNotEmpty().hasSize(2);
assertThat(response).isNotEmpty().hasSize(3);
responseVerification(new ArrayList<>(Arrays.asList(response)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,57 @@ insert into
'EC2A 2YZ',
'3 Street, London',
now());

insert into
building_location(
building_location_id,
region_id,
building_location_status_id,
cluster_id,
epimms_id,
building_location_name,
area,
court_finder_url,
postcode,
address,
updated_time)
values(
'220420013',
'2',
'45678',
'01234',
'123462',
'Building Location C',
'Area C',
'Court Finder URL 3',
'EC2A 2YZ',
'3 Street London',
now());


insert into
building_location(
building_location_id,
region_id,
building_location_status_id,
cluster_id,
epimms_id,
building_location_name,
area,
court_finder_url,
postcode,
address,
updated_time)
values(
'220420012',
'2',
'45678',
'01234',
'123463',
'Building Location C',
'Area C',
'Court Finder URL 3',
'EC2A 2YZ',
'3 Street London',
now());

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE court_venue ADD COLUMN IF NOT EXISTS welsh_external_short_name VARCHAR(80);
Loading