-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
unknown error details and action message (#4271)
* unknown error details and action message
- Loading branch information
Showing
2 changed files
with
51 additions
and
49 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 |
---|---|---|
|
@@ -48,3 +48,5 @@ draftMetadata.validation.details.SCHEMA_REQUIRED=There was at least one missing | |
draftMetadata.validation.action.SCHEMA_REQUIRED=Add the following column headers to your metadata file and re-load. | ||
draftMetadata.validation.details.DUPLICATE_HEADER=There was at least one duplicate column in your metadata file. | ||
draftMetadata.validation.action.DUPLICATE_HEADER=Ensure there is only one of the following duplicated columns. | ||
draftMetadata.validation.details.UNKNOWN=An unknown error was identified. | ||
draftMetadata.validation.action.UNKNOWN=Please contact your Digital Transfer Advisor on <a href="mailto:[email protected]">[email protected]</a> quoting the Consignment Reference. |
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 |
---|---|---|
|
@@ -181,8 +181,8 @@ class DraftMetadataChecksResultsControllerSpec extends FrontEndTestHelper { | |
( | ||
FailedValue.value, | ||
FileError.UNKNOWN, | ||
"Require details message for draftMetadata.validation.details.", | ||
"Require action message for draftMetadata.validation.action.", | ||
"An unknown error was identified.", | ||
"Please contact your Digital Transfer Advisor on <a href=\"mailto:[email protected]\">[email protected]</a> quoting the Consignment Reference.", | ||
Set[String]() | ||
), | ||
( | ||
|
@@ -239,61 +239,61 @@ class DraftMetadataChecksResultsControllerSpec extends FrontEndTestHelper { | |
} | ||
} | ||
} | ||
} | ||
|
||
"downloadErrorReport" should { | ||
"download the excel file with error data" in { | ||
|
||
setConsignmentTypeResponse(wiremockServer, "standard") | ||
setConsignmentReferenceResponse(wiremockServer) | ||
val error = Error("BASE_SCHEMA", "FOI exemption code", "enum", "BASE_SCHEMA.foi_exmption_code.enum") | ||
val metadata = List(Metadata("FOI exemption code", "abcd"), Metadata("Filepath", "/aa/bb/faq")) | ||
val errorFileData = ErrorFileData(consignmentId, date = "2024-12-12", FileError.SCHEMA_VALIDATION, List(ValidationErrors("assetId", Set(error), metadata))) | ||
val response = instantiateController(errorFileData = Some(errorFileData)) | ||
.downloadErrorReport(consignmentId)(FakeRequest(GET, s"/consignment/$consignmentId/draft-metadata/download-report")) | ||
|
||
val responseByteArray: ByteString = contentAsBytes(response) | ||
val bufferedSource = new ByteArrayInputStream(responseByteArray.toArray) | ||
val wb: ReadableWorkbook = new ReadableWorkbook(bufferedSource) | ||
val ws: Sheet = wb.getFirstSheet | ||
val rows: List[Row] = ws.read.asScala.toList | ||
|
||
rows.length must equal(2) | ||
|
||
rows.head.getCell(0).asString must equal("Filepath") | ||
rows.head.getCell(1).asString must equal("Field") | ||
rows.head.getCell(2).asString must equal("Value") | ||
rows.head.getCell(3).asString must equal("Error Message") | ||
|
||
rows(1).getCell(0).asString must equal("/aa/bb/faq") | ||
rows(1).getCell(1).asString must equal("FOI exemption code") | ||
rows(1).getCell(2).asString must equal("abcd") | ||
rows(1).getCell(3).asString must equal("BASE_SCHEMA.foi_exmption_code.enum") | ||
} | ||
"downloadErrorReport" should { | ||
"download the excel file with error data" in { | ||
|
||
"download the excel file without error data when the error type is not SCHEMA_VALIDATION" in { | ||
setConsignmentTypeResponse(wiremockServer, "standard") | ||
setConsignmentReferenceResponse(wiremockServer) | ||
val error = Error("BASE_SCHEMA", "FOI exemption code", "enum", "BASE_SCHEMA.foi_exmption_code.enum") | ||
val metadata = List(Metadata("FOI exemption code", "abcd"), Metadata("Filepath", "/aa/bb/faq")) | ||
val errorFileData = ErrorFileData(consignmentId, date = "2024-12-12", FileError.SCHEMA_VALIDATION, List(ValidationErrors("assetId", Set(error), metadata))) | ||
val response = instantiateController(errorFileData = Some(errorFileData)) | ||
.downloadErrorReport(consignmentId)(FakeRequest(GET, s"/consignment/$consignmentId/draft-metadata/download-report")) | ||
|
||
val responseByteArray: ByteString = contentAsBytes(response) | ||
val bufferedSource = new ByteArrayInputStream(responseByteArray.toArray) | ||
val wb: ReadableWorkbook = new ReadableWorkbook(bufferedSource) | ||
val ws: Sheet = wb.getFirstSheet | ||
val rows: List[Row] = ws.read.asScala.toList | ||
|
||
rows.length must equal(2) | ||
|
||
rows.head.getCell(0).asString must equal("Filepath") | ||
rows.head.getCell(1).asString must equal("Field") | ||
rows.head.getCell(2).asString must equal("Value") | ||
rows.head.getCell(3).asString must equal("Error Message") | ||
|
||
rows(1).getCell(0).asString must equal("/aa/bb/faq") | ||
rows(1).getCell(1).asString must equal("FOI exemption code") | ||
rows(1).getCell(2).asString must equal("abcd") | ||
rows(1).getCell(3).asString must equal("BASE_SCHEMA.foi_exmption_code.enum") | ||
} | ||
|
||
setConsignmentTypeResponse(wiremockServer, "standard") | ||
setConsignmentReferenceResponse(wiremockServer) | ||
val error = Error("FILE_VALIDATION", "draftmetadata.csv", "INVALID_CSV", "") | ||
val errorFileData = ErrorFileData(consignmentId, date = "2024-12-12", FileError.INVALID_CSV, List(ValidationErrors("assetId", Set(error), Nil))) | ||
"download the excel file without error data when the error type is not SCHEMA_VALIDATION" in { | ||
|
||
when(draftMetaDataService.getErrorReport(any[UUID])).thenReturn(Future.successful(errorFileData)) | ||
setConsignmentTypeResponse(wiremockServer, "standard") | ||
setConsignmentReferenceResponse(wiremockServer) | ||
val error = Error("FILE_VALIDATION", "draftmetadata.csv", "INVALID_CSV", "") | ||
val errorFileData = ErrorFileData(consignmentId, date = "2024-12-12", FileError.INVALID_CSV, List(ValidationErrors("assetId", Set(error), Nil))) | ||
|
||
val response = instantiateController().downloadErrorReport(consignmentId)(FakeRequest(GET, s"/consignment/$consignmentId/draft-metadata/download-report")) | ||
when(draftMetaDataService.getErrorReport(any[UUID])).thenReturn(Future.successful(errorFileData)) | ||
|
||
val responseByteArray: ByteString = contentAsBytes(response) | ||
val bufferedSource = new ByteArrayInputStream(responseByteArray.toArray) | ||
val wb: ReadableWorkbook = new ReadableWorkbook(bufferedSource) | ||
val ws: Sheet = wb.getFirstSheet | ||
val rows: List[Row] = ws.read.asScala.toList | ||
val response = instantiateController().downloadErrorReport(consignmentId)(FakeRequest(GET, s"/consignment/$consignmentId/draft-metadata/download-report")) | ||
|
||
rows.length must equal(1) | ||
val responseByteArray: ByteString = contentAsBytes(response) | ||
val bufferedSource = new ByteArrayInputStream(responseByteArray.toArray) | ||
val wb: ReadableWorkbook = new ReadableWorkbook(bufferedSource) | ||
val ws: Sheet = wb.getFirstSheet | ||
val rows: List[Row] = ws.read.asScala.toList | ||
|
||
rows.head.getCell(0).asString must equal("Filepath") | ||
rows.head.getCell(1).asString must equal("Field") | ||
rows.head.getCell(2).asString must equal("Value") | ||
rows.head.getCell(3).asString must equal("Error Message") | ||
} | ||
rows.length must equal(1) | ||
|
||
rows.head.getCell(0).asString must equal("Filepath") | ||
rows.head.getCell(1).asString must equal("Field") | ||
rows.head.getCell(2).asString must equal("Value") | ||
rows.head.getCell(3).asString must equal("Error Message") | ||
} | ||
} | ||
|
||
|