-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Story(CCLS-2099) Post assessment endpoint
includes amendments to the PUT request to update existing assessments
- Loading branch information
1 parent
92c9b7e
commit a5700f3
Showing
15 changed files
with
251 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,21 +11,9 @@ paths: | |
operationId: 'getAssessments' | ||
parameters: | ||
- $ref: '#/components/parameters/assessmentType' | ||
- name: 'provider-id' | ||
in: 'query' | ||
schema: | ||
type: 'string' | ||
example: '1234567890' | ||
- name: 'case-reference-number' | ||
in: 'query' | ||
schema: | ||
type: 'string' | ||
example: '1234567890' | ||
- name: 'status' | ||
in: 'query' | ||
schema: | ||
type: 'string' | ||
example: 'INCOMPLETE' | ||
- $ref: '#/components/parameters/providerId' | ||
- $ref: '#/components/parameters/caseReferenceNumber' | ||
- $ref: '#/components/parameters/status' | ||
responses: | ||
'200': | ||
description: 'Successful operation' | ||
|
@@ -41,28 +29,6 @@ paths: | |
description: 'Not found' | ||
'500': | ||
description: 'Internal server error' | ||
put: | ||
tags: | ||
- assessments | ||
summary: 'update an existing assessment' | ||
operationId: 'updateAssessment' | ||
parameters: | ||
- $ref: '#/components/parameters/requiredUserLoginId' | ||
requestBody: | ||
description: update an existing assessment | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/assessmentDetail' | ||
responses: | ||
'204': | ||
description: 'Successful update' | ||
'400': | ||
description: 'Bad request' | ||
'401': | ||
description: 'Unauthorized' | ||
'500': | ||
description: 'Internal server error' | ||
delete: | ||
tags: | ||
- assessments | ||
|
@@ -83,11 +49,7 @@ paths: | |
schema: | ||
type: 'string' | ||
example: '1234567890' | ||
- name: 'status' | ||
in: 'query' | ||
schema: | ||
type: 'string' | ||
example: 'INCOMPLETE' | ||
- $ref: '#/components/parameters/status' | ||
responses: | ||
'204': | ||
description: 'Successful deletion' | ||
|
@@ -99,20 +61,36 @@ paths: | |
description: 'Not found' | ||
'500': | ||
description: 'Internal server error' | ||
post: | ||
tags: | ||
- assessments | ||
summary: 'create an assessment' | ||
operationId: 'createAssessment' | ||
parameters: | ||
- $ref: '#/components/parameters/requiredUserLoginId' | ||
requestBody: | ||
description: create an assessment | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/assessmentDetail' | ||
responses: | ||
'201': | ||
description: 'Successful create' | ||
'400': | ||
description: 'Bad request' | ||
'401': | ||
description: 'Unauthorized' | ||
'500': | ||
description: 'Internal server error' | ||
/assessments/{assessment-id}: | ||
get: | ||
tags: | ||
- assessments | ||
summary: 'get assessment by id ' | ||
operationId: 'getAssessment' | ||
parameters: | ||
- name: 'assessment-id' | ||
in: 'path' | ||
required: true | ||
schema: | ||
type: 'integer' | ||
format: 'int64' | ||
example: '1234567890' | ||
- $ref: '#/components/parameters/assessmentId' | ||
responses: | ||
'200': | ||
description: 'Successful operation' | ||
|
@@ -128,6 +106,29 @@ paths: | |
description: 'Not found' | ||
'500': | ||
description: 'Internal server error' | ||
put: | ||
tags: | ||
- assessments | ||
summary: 'update an existing assessment' | ||
operationId: 'updateAssessment' | ||
parameters: | ||
- $ref: '#/components/parameters/assessmentId' | ||
- $ref: '#/components/parameters/requiredUserLoginId' | ||
requestBody: | ||
description: update an existing assessment | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/assessmentDetail' | ||
responses: | ||
'204': | ||
description: 'Successful update' | ||
'400': | ||
description: 'Bad request' | ||
'401': | ||
description: 'Unauthorized' | ||
'500': | ||
description: 'Internal server error' | ||
patch: | ||
tags: | ||
- assessments | ||
|
@@ -140,13 +141,7 @@ paths: | |
schema: | ||
$ref: '#/components/schemas/patchAssessmentDetail' | ||
parameters: | ||
- name: 'assessment-id' | ||
in: 'path' | ||
required: true | ||
schema: | ||
type: 'integer' | ||
format: 'int64' | ||
example: '1234567890' | ||
- $ref: '#/components/parameters/assessmentId' | ||
- $ref: '#/components/parameters/requiredUserLoginId' | ||
responses: | ||
'204': | ||
|
@@ -166,13 +161,7 @@ paths: | |
summary: 'delete checkpoint from assessment' | ||
operationId: 'deleteAssessmentCheckpoint' | ||
parameters: | ||
- name: 'assessment-id' | ||
in: 'path' | ||
required: true | ||
schema: | ||
type: 'integer' | ||
format: 'int64' | ||
example: '1234567890' | ||
- $ref: '#/components/parameters/assessmentId' | ||
- $ref: '#/components/parameters/requiredUserLoginId' | ||
responses: | ||
'204': | ||
|
@@ -204,14 +193,39 @@ components: | |
- 'meansAssessment_PREPOP' | ||
- 'meritsAssessment' | ||
- 'meritsAssessment_PREPOP' | ||
|
||
assessmentId: | ||
name: 'assessment-id' | ||
in: 'path' | ||
required: true | ||
schema: | ||
type: 'integer' | ||
format: 'int64' | ||
example: '1234567890' | ||
requiredUserLoginId: | ||
name: 'Caab-User-Login-Id' | ||
in: header | ||
required: true | ||
schema: | ||
type: 'string' | ||
example: '[email protected]' | ||
providerId: | ||
name: 'provider-id' | ||
in: 'query' | ||
schema: | ||
type: 'string' | ||
example: '1234567890' | ||
caseReferenceNumber: | ||
name: 'case-reference-number' | ||
in: 'query' | ||
schema: | ||
type: 'string' | ||
example: '1234567890' | ||
status: | ||
name: 'status' | ||
in: 'query' | ||
schema: | ||
type: 'string' | ||
example: 'INCOMPLETE' | ||
|
||
schemas: | ||
assessmentDetails: | ||
|
@@ -289,7 +303,6 @@ components: | |
items: | ||
$ref: '#/components/schemas/assessmentEntityDetail' | ||
required: | ||
- id | ||
- entityType | ||
- entities | ||
assessmentEntityDetail: | ||
|
@@ -312,8 +325,9 @@ components: | |
$ref: '#/components/schemas/assessmentRelationshipDetail' | ||
prepopulated: | ||
type: boolean | ||
completed: | ||
type: boolean | ||
required: | ||
- id | ||
- entityId | ||
- prepopulated | ||
assessmentAttributeDetail: | ||
|
@@ -333,7 +347,6 @@ components: | |
asked: | ||
type: boolean | ||
required: | ||
- id | ||
- attributeId | ||
assessmentRelationshipDetail: | ||
type: object | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,12 @@ | |
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static uk.gov.laa.ccms.caab.assessment.audit.AuditorAwareImpl.currentUserHolder; | ||
|
||
import jakarta.transaction.Transactional; | ||
import java.util.List; | ||
import java.util.stream.Stream; | ||
import javax.management.relation.Relation; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
|
@@ -32,6 +33,26 @@ public abstract class BaseAssessmentControllerIntegrationTest { | |
@Autowired | ||
private AssessmentController assessmentController; | ||
|
||
protected final String caabUserLoginId = "[email protected]"; | ||
|
||
@Test | ||
@Transactional | ||
public void testCreateAssessment_expect201() { | ||
|
||
currentUserHolder.set(caabUserLoginId); | ||
|
||
AssessmentDetail assessment = new AssessmentDetail() | ||
.name("assessment1") | ||
.providerId("owner1") | ||
.caseReferenceNumber("1234567890") | ||
.status("status1"); | ||
|
||
ResponseEntity<Void> response = | ||
assessmentController.createAssessment(caabUserLoginId, assessment); | ||
|
||
assertEquals(HttpStatus.CREATED, response.getStatusCode()); | ||
} | ||
|
||
//get by id expect 200 | ||
@Test | ||
@Sql(scripts = "/sql/assessments_insert.sql") | ||
|
@@ -189,11 +210,12 @@ private static Stream<Arguments> updateAssessmentArguments_base() { | |
@Sql(scripts = "/sql/assessments_insert.sql") | ||
@Transactional | ||
public void testUpdateAssessment() { | ||
final String loginId = "testUser"; | ||
final Long assessmentId = 26L; | ||
currentUserHolder.set(caabUserLoginId); | ||
|
||
AssessmentDetail expected = buildAssessmentDetail(); | ||
|
||
ResponseEntity<Void> response = assessmentController.updateAssessment(loginId, expected); | ||
ResponseEntity<Void> response = assessmentController.updateAssessment(assessmentId, caabUserLoginId, expected); | ||
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode()); | ||
|
||
ResponseEntity<AssessmentDetail> updatedResponse = assessmentController.getAssessment(expected.getId()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.