Skip to content

Commit

Permalink
story(ccls-1814) linked cases
Browse files Browse the repository at this point in the history
Includes CCLS-1815
  • Loading branch information
PhilDigitalJustice committed Jan 8, 2024
1 parent 6a040d0 commit f304616
Show file tree
Hide file tree
Showing 10 changed files with 863 additions and 55 deletions.
147 changes: 146 additions & 1 deletion caab-api/open-api-specification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ paths:
type: 'integer'
format: 'int64'
example: '1234567890'
- name: 'Caab-user-Login-Id'
- name: 'Caab-User-Login-Id'
in: header
required: true
schema:
Expand Down Expand Up @@ -257,6 +257,149 @@ paths:
description: 'Not found'
'500':
description: 'Internal server error'
/applications/{id}/linked-cases:
get:
tags:
- applications
summary: 'Get an application''s linked cases'
operationId: 'getApplicationLinkedCases'
parameters:
- name: 'id'
in: 'path'
required: true
schema:
type: 'integer'
format: 'int64'
example: '1234567890'
responses:
'200':
description: 'Successful operation'
content:
application/json:
schema:
type: 'array'
items:
$ref: "#/components/schemas/linkedCase"
'400':
description: 'Bad request'
'401':
description: 'Unauthorized'
'404':
description: 'Not found'
'500':
description: 'Internal server error'
post:
tags:
- applications
summary: 'Add a linked case to an application'
operationId: 'addApplicationLinkedCase'
parameters:
- name: 'id'
in: 'path'
required: true
schema:
type: 'integer'
format: 'int64'
- name: 'Caab-User-Login-Id'
in: header
required: true
schema:
type: 'string'
example: '[email protected]'
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/linkedCase"
responses:
'201':
description: 'Case added successfully'
'400':
description: 'Bad request'
'401':
description: 'Unauthorized'
'404':
description: 'Not found'
'500':
description: 'Internal server error'
/applications/{id}/linked-cases/{linked-case-id}:
delete:
tags:
- applications
summary: 'Remove a linked case from an application'
operationId: 'removeApplicationLinkedCase'
parameters:
- name: 'id'
in: 'path'
required: true
schema:
type: 'integer'
format: 'int64'
- name: 'linked-case-id'
in: 'path'
required: true
schema:
type: 'integer'
format: 'int64'
- name: 'Caab-User-Login-Id'
in: header
required: true
schema:
type: 'string'
example: '[email protected]'
responses:
'204':
description: 'No Content'
'400':
description: 'Bad request'
'401':
description: 'Unauthorized'
'404':
description: 'Not found'
'500':
description: 'Internal server error'
patch:
tags:
- applications
summary: 'Update a linked case of an application'
operationId: 'updateApplicationLinkedCase'
parameters:
- name: 'id'
in: 'path'
required: true
schema:
type: 'integer'
format: 'int64'
- name: 'linked-case-id'
in: 'path'
required: true
schema:
type: 'integer'
format: 'int64'
- name: 'Caab-User-Login-Id'
in: header
required: true
schema:
type: 'string'
example: '[email protected]'
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/linkedCase"
responses:
'200':
description: 'Case updated successfully'
'400':
description: 'Bad request'
'401':
description: 'Unauthorized'
'404':
description: 'Not found'
'500':
description: 'Internal server error'
components:
schemas:
intDisplayValue:
Expand Down Expand Up @@ -501,6 +644,8 @@ components:
linkedCase:
type: 'object'
properties:
id:
type: 'integer'
lsc_case_reference:
type: 'string'
relation_to_case:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import uk.gov.laa.ccms.caab.api.entity.AuditTrail;
import uk.gov.laa.ccms.caab.api.service.ApplicationService;
import uk.gov.laa.ccms.caab.model.ApplicationDetail;
import uk.gov.laa.ccms.caab.model.LinkedCase;
import uk.gov.laa.ccms.data.api.AbstractIntegrationTest;

@SpringBootTest(classes = CaabApiApplication.class)
Expand Down Expand Up @@ -161,6 +162,15 @@ public void testCreateApplication(String fileInput, String auditTrailMethod, Lis

assertAuditTrail(savedApplicationDetails, auditTrailMethod, auditUser);
setAuditPropertiesToNull(savedApplicationDetails, auditTrailsToNull);

//null out the id's as they are generated by the database
//theses will always be different
if (savedApplicationDetails.getLinkedCases() != null){
for (LinkedCase linkedCase : savedApplicationDetails.getLinkedCases()){
linkedCase.setId(null);
}
}

assertEquals(applicationDetail, savedApplicationDetails);
}

Expand Down Expand Up @@ -258,4 +268,5 @@ private static void nullifyFieldRecursive(Object object, String[] fields, int in
}
}
}

}
Loading

0 comments on commit f304616

Please sign in to comment.