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

DMP 4161 Darts API should only accept uppercase courthouse and courtroom from Portal #2351

Merged
merged 13 commits into from
Dec 11, 2024
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,9 @@ created by these tests. To this end the following conventions should be used:

- If a courthouse needs to pre-exist for a functional test it can be created from within the tests
using `/functional-tests/courthouse/{courthouse_name}/courtroom/{courtroom_name}`. The courthouse_name must be
prefixed with `func-`. This data will be cleaned after the test has executed.
prefixed with `FUNC-`. This data will be cleaned after the test has executed.
- If a case needs to pre-exist for a functional test then however it is created the case_number should also pre-fixed
with `func-`. There is a random case_number generator that will provide case_numbers with this prefix. These cases and
with `FUNC-`. There is a random case_number generator that will provide case_numbers with this prefix. These cases and
their associated hearings and events will be cleaned up automatically after the test has executed.

## Caching
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
@SuppressWarnings("PMD.TestClassWithoutTestCases")
public class FunctionalTest {

protected static final String COURTHOUSE_SWANSEA = "func-swansea";
protected static final String COURTHOUSE_SWANSEA = "FUNC-SWANSEA";

@Autowired
private AccessTokenClient externalAccessTokenClient;
Expand Down Expand Up @@ -113,7 +113,7 @@ public String getContentsFromFile(String filelocation) throws IOException {
}

protected static String randomCaseNumber() {
return "func-case-" + randomAlphanumeric(7);
return "FUNC-CASE-" + randomAlphanumeric(7);
}

protected void createCourtroomAndCourthouse(String courthouseName, String courtroomName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
class CasesFunctionalTest extends FunctionalTest {
private static final String CASES_PATH = "/cases";
private static final String EVENTS_PATH = "/events";
private static final String CASE_NUMBER = "func-case-" + randomAlphanumeric(7);
private static final String COURTHOUSE = "Swansea";
private static final String COURTROOM = "func-case-1";
private static final String CASE_NUMBER = "FUNC-CASE-" + randomAlphanumeric(7);
private static final String COURTHOUSE = "SWANSEA";
private static final String COURTROOM = "FUNC-CASE-1";
private static int caseId;

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private Response executeCourthousesPost() {
.baseUri(getUri(ADMIN_COURTHOUSES_URI))
.body("""
{
"courthouse_name": "func-swansea",
"courthouse_name": "FUNC-SWANSEA",
"display_name": "Swansea Functional Test Courthouse"
}
""")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ void cleanData() {
@ParameterizedTest
@EnumSource(names = {"CPP", "XHB"})
void postDailyList(SourceType sourceType) throws IOException {
String courthouseName = "func-swansea-house-" + randomAlphanumeric(7);
String courtroomName = "func-swansea-room-" + randomAlphanumeric(7);
String courthouseName = "FUNC-SWANSEA-HOUSE-" + randomAlphanumeric(7);
String courtroomName = "FUNC-SWANSEA-ROOM-" + randomAlphanumeric(7);

createCourtroomAndCourthouse(courthouseName, courtroomName);

String xmlDocument = getContentsFromFile("DailyList-Document.xml");

String uniqueId = "func-unique-id-" + randomAlphanumeric(7);
String messageId = "func-unique-id-" + randomAlphanumeric(7);
String uniqueId = "FUNC-UNIQUE-ID-" + randomAlphanumeric(7);
String messageId = "FUNC-UNIQUE-ID-" + randomAlphanumeric(7);

PostDailyListRequest request = new PostDailyListRequest();
request.setSourceSystem(sourceType.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class CourtlogsFunctionalTest extends FunctionalTest {

public static final String ENDPOINT_URL = "/courtlogs";
public final String courthouseName = "func-swansea-house-" + randomAlphanumeric(7);
public final String courthouseName = "FUNC-SWANSEA-HOUSE-" + randomAlphanumeric(7);


@AfterAll
Expand All @@ -33,7 +33,7 @@ void cleanData() {
@Order(1)
void postSuccess() {

String courtroomName = "func-swansea-room-" + randomAlphanumeric(7);
String courtroomName = "FUNC-SWANSEA-ROOM-" + randomAlphanumeric(7);

createCourtroomAndCourthouse(courthouseName, courtroomName);

Expand All @@ -43,7 +43,7 @@ void postSuccess() {
"courthouse": "<<courtHouseName>>",
"courtroom": "<<courtroomName>>",
"case_numbers": [
"func-CASE1001"
"FUNC-CASE1001"
],
"text": "System : Start Recording : Record: Case Code:0008, New Case"
}""";
Expand Down Expand Up @@ -74,7 +74,7 @@ void postFail() {
"courthouse": "",
"courtroom": "1",
"case_numbers": [
"func-CASE1001"
"FUNC-CASE1001"
],
"text": "System : Start Recording : Record: Case Code:0008, New Case"
}""")
Expand All @@ -94,7 +94,7 @@ void getSuccess() {
Response response = buildRequestWithExternalGlobalAccessAuth()
.contentType(ContentType.JSON)
.param("courthouse", courthouseName)
.param("case_number", "func-CASE1001")
.param("case_number", "FUNC-CASE1001")
.param("start_date_time", "1999-05-23T09:15:25Z")
.param("end_date_time", "1999-05-23T09:15:25Z")
.when()
Expand All @@ -108,7 +108,7 @@ void getSuccess() {
[
{
"courthouse": "<<courtHouseName>>",
"caseNumber": "func-CASE1001",
"caseNumber": "FUNC-CASE1001",
"timestamp": "1999-05-23T09:15:25Z",
"eventText": "System : Start Recording : Record: Case Code:0008, New Case"
}
Expand All @@ -122,8 +122,8 @@ void getSuccess() {
void getFail() {
Response response = buildRequestWithExternalGlobalAccessAuth()
.contentType(ContentType.JSON)
.param("courthouse", "func-liverpool")
.param("case_number", "func-CASE1001")
.param("courthouse", "FUNC-liverpool")
.param("case_number", "FUNC-CASE1001")
.param("start_date_time1", "2023-05-24T09:15:25Z")
.param("end_date_time", "2023-05-23T09:15:25Z")
.when()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ void cleanData() {

@Test
void success() {
String courthouseName = "func-swansea-house-" + randomAlphanumeric(7);
String courtroomName = "func-swansea-room-" + randomAlphanumeric(7);
String courthouseName = "FUNC-SWANSEA-HOUSE-" + randomAlphanumeric(7);
String courtroomName = "FUNC-SWANSEA-ROOM-" + randomAlphanumeric(7);

createCourtroomAndCourthouse(courthouseName,courtroomName);

Expand All @@ -38,7 +38,7 @@ void success() {
"courthouse": "<<courtHouseName>>",
"courtroom": "<<courtroomName>>",
"case_numbers": [
"func-Swansea_case_1"
"FUNC-Swansea_case_1"
],
"event_text": "A temporary event created by functional test",
"date_time": "2023-08-08T14:01:06Z"
Expand Down Expand Up @@ -72,7 +72,7 @@ void fail() {
"courthouse": "",
"courtroom": "1",
"case_numbers": [
"func-Swansea_case_1"
"FUNC-Swansea_case_1"
],
"event_text": "A temporary event created by functional test",
"date_time": "2023-08-08T14:01:06Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void cleanData() {

@Test
void success() {
String courtroomName = "func-swansea-room-" + randomAlphanumeric(7);
String courtroomName = "FUNC-SWANSEA-ROOM-" + randomAlphanumeric(7);

createCourtroomAndCourthouse(COURTHOUSE, courtroomName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class NodeRegistrationFunctionalTest extends FunctionalTest {

@Test
void testRegisterDevice() {
String courthouseName = "func-swansea-house-" + randomAlphanumeric(7);
String courtroomName = "func-swansea-room-" + randomAlphanumeric(7);
String courthouseName = "FUNC-SWANSEA-HOUSE-" + randomAlphanumeric(7);
String courtroomName = "FUNC-SWANSEA-ROOM-" + randomAlphanumeric(7);

createCourtroomAndCourthouse(courthouseName, courtroomName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void createNewRetentionPolicy() {
"id": "",
"name": "Func test policy",
"display_name": "Func test policy",
"description": "func-policy",
"description": "FUNC-policy",
"fixed_policy_key": "999",
"duration": "1Y0M0D",
"policy_start_at": "2124-01-01T00:00:00Z"
Expand Down Expand Up @@ -121,7 +121,7 @@ void editRetentionPolicy() {
"id": "",
"name": "Updated func test policy name",
"display_name": "Func test policy",
"description": "func-policy",
"description": "FUNC-policy",
"fixed_policy_key": "999",
"duration": "1Y0M0D",
"policy_start_at": "2124-01-01T00:00:00Z"
Expand All @@ -144,7 +144,7 @@ private Response createRetentionPolicyType() {
{
"name": "Func test policy",
"display_name": "Func test policy",
"description": "func-policy",
"description": "FUNC-policy",
"fixed_policy_key": "999",
"duration": "1Y0M0D",
"policy_start_at": "2124-01-01T00:00:00Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.UUID;

import static org.hamcrest.CoreMatchers.equalTo;
Expand Down Expand Up @@ -193,8 +194,8 @@ void shouldPatchSecurityGroups() throws JsonProcessingException {
patchContent = patchContent.replace("<func-a-security-group-new-name>", newName);
String newDisplayName = "A security group new name " + UUID.randomUUID();
patchContent = patchContent.replace("<A security group new name>", newDisplayName);
Integer id1 = createCourthouse("func-a-courthouse " + UUID.randomUUID(), "func-a-courthouse" + UUID.randomUUID());
Integer id2 = createCourthouse("func-a-courthouse " + UUID.randomUUID(), "func-a-courthouse" + UUID.randomUUID());
Integer id1 = createCourthouse(("FUNC-A-COURTHOUSE " + UUID.randomUUID()).toUpperCase(Locale.ENGLISH), "func-a-courthouse" + UUID.randomUUID());
Integer id2 = createCourthouse(("FUNC-A-COURTHOUSE " + UUID.randomUUID()).toUpperCase(Locale.ENGLISH), "func-a-courthouse" + UUID.randomUUID());
patchContent = patchContent.replace("<id1>", id1.toString());
patchContent = patchContent.replace("<id2>", id2.toString());
Response createUserResponse = createUser("user1@email.com");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,30 +75,30 @@ void rejectsCourthousesNotPrefixedCorrectly() throws Exception {

@Test
void createsCourthouseAndCourtroom() throws Exception {
mockMvc.perform(post(ENDPOINT_URL + "/courthouse/func-swansea/courtroom/cr1"))
mockMvc.perform(post(ENDPOINT_URL + "/courthouse/FUNC-SWANSEA/courtroom/cr1"))
.andExpect(status().isCreated());

assertThat(dartsDatabase.findCourtroomBy("func-swansea", "cr1")).isNotNull();
assertThat(dartsDatabase.findCourtroomBy("FUNC-SWANSEA", "cr1")).isNotNull();
}

@Test
void createsCourtroomForExistingCourthouse() throws Exception {
mockMvc.perform(post(ENDPOINT_URL + "/courthouse/func-swansea/courtroom/cr1"))
mockMvc.perform(post(ENDPOINT_URL + "/courthouse/FUNC-SWANSEA/courtroom/cr1"))
.andExpect(status().isCreated());
mockMvc.perform(post(ENDPOINT_URL + "/courthouse/func-swansea/courtroom/cr2"))
mockMvc.perform(post(ENDPOINT_URL + "/courthouse/FUNC-SWANSEA/courtroom/cr2"))
.andExpect(status().isCreated());

assertThat(dartsDatabase.findCourtroomBy("func-swansea", "cr1")).isNotNull();
assertThat(dartsDatabase.findCourtroomBy("func-swansea", "cr2")).isNotNull();
assertThat(dartsDatabase.findCourtroomBy("FUNC-SWANSEA", "cr1")).isNotNull();
assertThat(dartsDatabase.findCourtroomBy("FUNC-SWANSEA", "cr2")).isNotNull();
}


@Test
void createsAudit() throws Exception {
mockMvc.perform(post(ENDPOINT_URL + "/courthouse/func-swansea/courtroom/cr1"))
mockMvc.perform(post(ENDPOINT_URL + "/courthouse/FUNC-SWANSEA/courtroom/cr1"))
.andExpect(status().isCreated());

mockMvc.perform(post(ENDPOINT_URL + "/audit/REQUEST_AUDIO/courthouse/func-swansea"))
mockMvc.perform(post(ENDPOINT_URL + "/audit/REQUEST_AUDIO/courthouse/FUNC-SWANSEA"))
.andExpect(status().isCreated());

assertEquals(1, dartsDatabase.getAuditRepository().findAll().size());
Expand All @@ -109,10 +109,10 @@ void createsAudit() throws Exception {
void createsNoAuditAndNoCourtCaseOnBadRequest() throws Exception {
when(auditActivityRepository.getReferenceById(anyInt())).thenThrow(DataIntegrityViolationException.class);

mockMvc.perform(post(ENDPOINT_URL + "/courthouse/func-swansea/courtroom/cr1"))
mockMvc.perform(post(ENDPOINT_URL + "/courthouse/FUNC-SWANSEA/courtroom/cr1"))
.andExpect(status().isCreated());

mockMvc.perform(post(ENDPOINT_URL + "/audit/REQUEST_AUDIO/courthouse/func-swansea"))
mockMvc.perform(post(ENDPOINT_URL + "/audit/REQUEST_AUDIO/courthouse/FUNC-SWANSEA"))
.andExpect(status().isBadRequest());

assertEquals(0, dartsDatabase.getCaseRepository().findAll().size());
Expand All @@ -138,7 +138,7 @@ void getsBankHolidays() throws Exception {

@Test
void createRetention() throws Exception {
MvcResult response = mockMvc.perform(post(ENDPOINT_URL + "/case-retentions/caseNumber/func-case-a"))
MvcResult response = mockMvc.perform(post(ENDPOINT_URL + "/case-retentions/caseNumber/FUNC-CASE-A"))
.andExpect(status().isOk())
.andReturn();

Expand All @@ -147,12 +147,12 @@ void createRetention() throws Exception {

@Test
void cleansData() throws Exception {
mockMvc.perform(post(ENDPOINT_URL + "/courthouse/func-swansea/courtroom/func-cr1"))
mockMvc.perform(post(ENDPOINT_URL + "/courthouse/FUNC-SWANSEA/courtroom/FUNC-CR1"))
.andExpect(status().isCreated());

mockMvc.perform(delete(ENDPOINT_URL + "/clean"))
.andExpect(status().is2xxSuccessful());

assertThat(dartsDatabase.findCourtroomBy("func-swansea", "cr1")).isNull();
assertThat(dartsDatabase.findCourtroomBy("FUNC-SWANSEA", "CR1")).isNull();
}
}
Loading
Loading