Skip to content

Commit

Permalink
fix(ccls-2217): Add BaseEvidenceDocumentDetail for query response
Browse files Browse the repository at this point in the history
  • Loading branch information
porritta committed May 20, 2024
1 parent b848c79 commit 4329731
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 17 deletions.
29 changes: 17 additions & 12 deletions caab-api/open-api-specification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2429,8 +2429,8 @@ components:
type: 'array'
default: []
items:
$ref: '#/components/schemas/evidenceDocumentDetail'
evidenceDocumentDetail:
$ref: '#/components/schemas/baseEvidenceDocumentDetail'
baseEvidenceDocumentDetail:
type: 'object'
properties:
id:
Expand All @@ -2445,32 +2445,37 @@ components:
$ref: '#/components/schemas/stringDisplayValue'
description:
type: 'string'
registered_document_id:
file_name:
type: 'string'
document_sender:
file_extension:
type: 'string'
transfer_status:
evidence_descriptions:
type: 'string'
file_name:
audit_trail:
$ref: '#/components/schemas/auditDetail'
evidenceDocumentDetail:
type: 'object'
allOf:
- $ref: "#/components/schemas/baseEvidenceDocumentDetail"
properties:
registered_document_id:
type: 'string'
file_extension:
ccms_module:
type: 'string'
file_data:
type: 'string'
evidence_descriptions:
notification_reference:
type: 'string'
transfer_retry_count:
type: 'integer'
transfer_response_code:
type: 'string'
transfer_response_description:
type: 'string'
ccms_module:
transfer_status:
type: 'string'
notification_reference:
document_sender:
type: 'string'
audit_trail:
$ref: '#/components/schemas/auditDetail'

auditDetail:
type: 'object'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.net.URI;
import org.junit.jupiter.api.Test;
Expand All @@ -12,6 +13,7 @@
import org.springframework.test.context.jdbc.Sql;
import uk.gov.laa.ccms.caab.api.controller.EvidenceController;
import uk.gov.laa.ccms.caab.api.service.EvidenceService;
import uk.gov.laa.ccms.caab.model.BaseEvidenceDocumentDetail;
import uk.gov.laa.ccms.caab.model.EvidenceDocumentDetail;
import uk.gov.laa.ccms.caab.model.EvidenceDocumentDetails;

Expand Down Expand Up @@ -81,7 +83,7 @@ public void testGetEvidenceDocuments_byApplicationOrOutcomeId() {
EvidenceDocumentDetail retrievedEvidenceDocumentDetails =
evidenceService.getEvidenceDocument(3L);

assertEquals(retrievedEvidenceDocumentDetails, responseEntity.getBody().getContent().get(0));
compareData(retrievedEvidenceDocumentDetails, responseEntity.getBody().getContent().getFirst());
}

@Test
Expand Down Expand Up @@ -109,7 +111,7 @@ public void testGetEvidenceDocuments_usingAllFields() {
EvidenceDocumentDetail retrievedEvidenceDocumentDetails =
evidenceService.getEvidenceDocument(3L);

assertEquals(retrievedEvidenceDocumentDetails, responseEntity.getBody().getContent().get(0));
compareData(retrievedEvidenceDocumentDetails, responseEntity.getBody().getContent().getFirst());
}

@Test
Expand Down Expand Up @@ -137,7 +139,7 @@ public void testGetEvidenceDocuments_transferPending_filtersCorrectly() {
EvidenceDocumentDetail retrievedEvidenceDocumentDetails =
evidenceService.getEvidenceDocument(4L);

assertEquals(retrievedEvidenceDocumentDetails, responseEntity.getBody().getContent().get(0));
compareData(retrievedEvidenceDocumentDetails, responseEntity.getBody().getContent().getFirst());
}

@Test
Expand Down Expand Up @@ -176,7 +178,7 @@ public void testRemoveEvidenceDocument() {
Pageable.unpaged()
).getBody();

assertEquals(0, queriedDocuments.getContent().size());
assertTrue(queriedDocuments.getContent().isEmpty());
}

@Test
Expand Down Expand Up @@ -243,7 +245,7 @@ public void testRemoveEvidenceDocuments_byCaseRef() {
Pageable.unpaged()
).getBody();

assertEquals(0, queriedDocuments.getContent().size());
assertTrue(queriedDocuments.getContent().isEmpty());
}

@Test
Expand Down Expand Up @@ -278,4 +280,17 @@ public void testRemoveEvidenceDocuments_byCaseRef_transferPending_filtersCorrect

assertEquals(1, queriedDocuments.getContent().size());
}

private static void compareData(EvidenceDocumentDetail retrievedEvidenceDocumentDetails,
BaseEvidenceDocumentDetail baseEvidenceDocumentDetail) {
assertEquals(retrievedEvidenceDocumentDetails.getId(), baseEvidenceDocumentDetail.getId());
assertEquals(retrievedEvidenceDocumentDetails.getApplicationOrOutcomeId(), baseEvidenceDocumentDetail.getApplicationOrOutcomeId());
assertEquals(retrievedEvidenceDocumentDetails.getCaseReferenceNumber(), baseEvidenceDocumentDetail.getCaseReferenceNumber());
assertEquals(retrievedEvidenceDocumentDetails.getDescription(), baseEvidenceDocumentDetail.getDescription());
assertEquals(retrievedEvidenceDocumentDetails.getDocumentType(), baseEvidenceDocumentDetail.getDocumentType());
assertEquals(retrievedEvidenceDocumentDetails.getEvidenceDescriptions(), baseEvidenceDocumentDetail.getEvidenceDescriptions());
assertEquals(retrievedEvidenceDocumentDetails.getFileExtension(), baseEvidenceDocumentDetail.getFileExtension());
assertEquals(retrievedEvidenceDocumentDetails.getFileName(), baseEvidenceDocumentDetail.getFileName());
assertEquals(retrievedEvidenceDocumentDetails.getProviderId(), baseEvidenceDocumentDetail.getProviderId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.springframework.data.domain.Page;
import uk.gov.laa.ccms.caab.model.BaseEvidenceDocumentDetail;
import uk.gov.laa.ccms.caab.model.EvidenceDocumentDetail;
import uk.gov.laa.ccms.caab.model.EvidenceDocumentDetails;

Expand All @@ -22,6 +23,11 @@ public interface EvidenceMapper {
EvidenceDocumentDetails toEvidenceDocumentDetails(
final Page<uk.gov.laa.ccms.caab.api.entity.EvidenceDocument> evidenceDocuments);

@Mapping(target = "documentType.id", source = "documentType")
@Mapping(target = "documentType.displayValue", source = "documentTypeDisplayValue")
BaseEvidenceDocumentDetail toBaseEvidenceDocumentDetail(
final uk.gov.laa.ccms.caab.api.entity.EvidenceDocument evidenceDocument);

@Mapping(target = "documentType.id", source = "documentType")
@Mapping(target = "documentType.displayValue", source = "documentTypeDisplayValue")
@Mapping(target = "fileData", source = "fileBytes")
Expand Down

0 comments on commit 4329731

Please sign in to comment.