Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4bd4122
DMP-5271 [API Validation] GET/transcriptions/{transcription_id}/docum…
karen-hedges Oct 14, 2025
9cc0fcc
DMP-5271 [API Validation] GET/transcriptions/{transcription_id}/docum…
karen-hedges Oct 14, 2025
4a90844
DMP-5271 [API Validation] GET/transcriptions/{transcription_id}/docum…
karen-hedges Oct 14, 2025
b83dd2f
DMP-5271 [API Validation] GET/transcriptions/{transcription_id}/docum…
karen-hedges Oct 14, 2025
f748967
Add open api validation test
stephenokeefe Oct 15, 2025
91f7e50
Merge remote-tracking branch 'origin/DMP-5271-AddApiValidationGetTran…
stephenokeefe Oct 15, 2025
7e0ad0c
Integration tests and Open API validation
stephenokeefe Oct 17, 2025
67e897d
Merge branch 'master' into DMP-5271-AddApiValidationGetTranscriptions…
stephenokeefe Oct 17, 2025
71529c7
Refactor
stephenokeefe Oct 22, 2025
72bbe10
Merge remote-tracking branch 'origin/DMP-5271-AddApiValidationGetTran…
stephenokeefe Oct 22, 2025
287d18b
Merge branch 'master' into DMP-5271-AddApiValidationGetTranscriptions…
stephenokeefe Oct 22, 2025
b6f1b48
Add test coverage
stephenokeefe Oct 22, 2025
4267773
Merge remote-tracking branch 'origin/DMP-5271-AddApiValidationGetTran…
stephenokeefe Oct 22, 2025
e22961f
Add test coverage
stephenokeefe Oct 23, 2025
361ee2b
Add not found tests
stephenokeefe Oct 23, 2025
78a187f
Merge branch 'master' into DMP-5271-AddApiValidationGetTranscriptions…
stephenokeefe Oct 24, 2025
fbbde1a
Remove whitespace
stephenokeefe Oct 24, 2025
3cdf6b3
Merge remote-tracking branch 'origin/DMP-5271-AddApiValidationGetTran…
stephenokeefe Oct 24, 2025
778f0e3
DMP-5271 [API Validation] GET/transcriptions/{transcription_id}/docum…
karen-hedges Oct 14, 2025
c3679ae
DMP-5271 [API Validation] GET/transcriptions/{transcription_id}/docum…
karen-hedges Oct 14, 2025
c580d52
DMP-5271 [API Validation] GET/transcriptions/{transcription_id}/docum…
karen-hedges Oct 14, 2025
99b9bd7
Add open api validation test
stephenokeefe Oct 15, 2025
8c5e490
DMP-5271 [API Validation] GET/transcriptions/{transcription_id}/docum…
karen-hedges Oct 14, 2025
cd0eefd
Integration tests and Open API validation
stephenokeefe Oct 17, 2025
c4fcf8f
Refactor
stephenokeefe Oct 22, 2025
f8a3e78
Add test coverage
stephenokeefe Oct 22, 2025
b2bd3ab
Add test coverage
stephenokeefe Oct 23, 2025
e7d0e7b
Add not found tests
stephenokeefe Oct 23, 2025
8c408b7
Remove whitespace
stephenokeefe Oct 24, 2025
966451f
Merge remote-tracking branch 'origin/DMP-5271-AddApiValidationGetTran…
stephenokeefe Oct 31, 2025
5a697f7
Adjust tests from master to account for new validation
stephenokeefe Oct 31, 2025
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
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,8 @@ dependencies {

testImplementation group: 'org.jeasy', name: 'easy-random-core', version: '5.0.0'

integrationTestImplementation 'com.atlassian.oai:swagger-request-validator-core:2.46.0'

compileJava.dependsOn = openApiGenerateTaskList
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package uk.gov.hmcts.darts.transcriptions.api;

import com.atlassian.oai.validator.OpenApiInteractionValidator;
import com.atlassian.oai.validator.model.Request;
import com.atlassian.oai.validator.model.SimpleRequest;
import com.atlassian.oai.validator.report.ValidationReport;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;

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

@Slf4j
class TranscriptionOpenApiContractTest {

private static final OpenApiInteractionValidator VALIDATOR =
OpenApiInteractionValidator.createForSpecificationUrl(
TranscriptionOpenApiContractTest.class
.getResource("/openapi/transcriptions.yaml")
.toExternalForm()
).build();

@Test
void negativeTranscriptionId() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add to the method name the name of the method for controllers get transcription document which I think is attachTranscript

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test will not reach the controller but I have updated the naming to be clearer

Request request = SimpleRequest.Builder
.get("/transcriptions/-1/document")
.build();

ValidationReport report = VALIDATOR.validateRequest(request);

assertTrue(report.hasErrors());
report.getMessages().forEach(m -> log.info(m.getMessage()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void downloadTranscript_shouldReturn401Error_whenUserNotFound() throws Exception
}

@Test
void downloadTranscriptShouldReturnNotFoundError() throws Exception {
void downloadTranscript_ShouldReturnNotFoundError() throws Exception {
MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get(URL_TEMPLATE, transcriptionId)
.header(
"accept",
Expand All @@ -185,7 +185,7 @@ void downloadTranscriptShouldReturnNotFoundError() throws Exception {
}

@Test
void downloadTranscriptShouldReturnOkWithMicrosoftWordNew() throws Exception {
void downloadTranscript_ShouldReturnOk_WithMicrosoftWordNew() throws Exception {
final String fileName = "Test Document.docx";
final String fileType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
final int fileSize = 11_937;
Expand Down Expand Up @@ -257,7 +257,7 @@ void downloadTranscriptShouldReturnOkWithMicrosoftWordNew() throws Exception {

@Test
@SuppressWarnings("PMD.CloseResource")
void downloadTranscriptShouldReturnOkWithMicrosoftWordOld() throws Exception {
void downloadTranscript_ShouldReturnOk_WithMicrosoftWordOld() throws Exception {
final String fileName = "Test Document.doc";
final String fileType = "application/msword";
final int fileSize = 22_528;
Expand Down Expand Up @@ -319,4 +319,25 @@ void downloadTranscriptShouldReturnOkWithMicrosoftWordOld() throws Exception {
verifyNoMoreInteractions(mockAuditApi, mockDataManagementFacade, mockFileBasedDownloadResponseMetaData);
}

@Test
void downloadTranscript_ShouldReturnError_WhenNegativeTranscriptionIdUsed() throws Exception {
MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get("/transcriptions/-123/document")
.header(
"accept",
"application/msword",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
);
MvcResult mvcResult = mockMvc.perform(requestBuilder)
.andExpect(status().isNotFound())
.andReturn();

String actualResponse = mvcResult.getResponse().getContentAsString();

String expectedResponse = """
{"type":"TRANSCRIPTION_101","title":"The requested transcription cannot be found","status":404}
""";
JSONAssert.assertEquals(expectedResponse, actualResponse, JSONCompareMode.NON_EXTENSIBLE);

verifyNoInteractions(mockAuditApi);
}
}
8 changes: 4 additions & 4 deletions src/main/resources/openapi/annotations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ paths:
annotation:
$ref: '#/components/schemas/annotation'
responses:
201:
'201':
description: CREATED
content:
application/json:
Expand All @@ -43,7 +43,7 @@ paths:
content:
application/json+problem:
schema:
$ref: './problem.yaml'
$ref: './problem.yaml'
'400':
description: Bad Request Error
content:
Expand Down Expand Up @@ -78,7 +78,7 @@ paths:
content:
application/json+problem:
schema:
$ref: './problem.yaml'
$ref: './problem.yaml'
'400':
description: Bad Request Error
content:
Expand Down Expand Up @@ -132,7 +132,7 @@ paths:
content:
application/json+problem:
schema:
$ref: './problem.yaml'
$ref: './problem.yaml'
'400':
description: Bad Request Error
content:
Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/openapi/audio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ paths:
type: string
description: "Range header, required for streaming audio."
responses:
200:
'200':
description: OK
content:
audio/mpeg:
Expand Down Expand Up @@ -149,7 +149,7 @@ paths:
type: "AUDIO_102"
title: "The requested media cannot be found"
status: 404
500:
'500':
description: The requested data cannot be located
content:
application/json+problem:
Expand All @@ -172,15 +172,15 @@ paths:
schema:
$ref: '#/components/schemas/AddAudioMetadataRequestWithStorageGUID'
responses:
200:
'200':
description: Audio metadata accepted
400:
'400':
description: Bad request
content:
application/json+problem:
schema:
$ref: './problem.yaml'
500:
'500':
description: Internal server error
content:
application/json+problem:
Expand All @@ -201,7 +201,7 @@ paths:
type: integer
required: true
responses:
200:
'200':
description: OK
content:
application/json:
Expand Down
60 changes: 30 additions & 30 deletions src/main/resources/openapi/audiorequests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ paths:
content:
application/json+problem:
schema:
$ref: './problem.yaml'
$ref: './problem.yaml'
'400':
description: A required parameter is missing or an invalid.
content:
Expand Down Expand Up @@ -81,7 +81,7 @@ paths:
content:
application/json+problem:
schema:
$ref: './problem.yaml'
$ref: './problem.yaml'
'400':
description: A required parameter is missing or an invalid.
content:
Expand Down Expand Up @@ -206,7 +206,7 @@ paths:
content:
application/json+problem:
schema:
$ref: './problem.yaml'
$ref: './problem.yaml'
'400':
description: Bad Request Error
content:
Expand Down Expand Up @@ -327,7 +327,7 @@ paths:
content:
application/json+problem:
schema:
$ref: './problem.yaml'
$ref: './problem.yaml'
'400':
description: 'invalid input, object invalid'
'401':
Expand Down Expand Up @@ -371,7 +371,7 @@ paths:
content:
application/json+problem:
schema:
$ref: './problem.yaml'
$ref: './problem.yaml'
'400':
description: Bad Request Error
content:
Expand Down Expand Up @@ -438,7 +438,7 @@ paths:
content:
application/json+problem:
schema:
$ref: './problem.yaml'
$ref: './problem.yaml'
'400':
description: 'invalid input, object invalid'
'401':
Expand Down Expand Up @@ -499,7 +499,7 @@ paths:
schema:
$ref: '#/components/schemas/MediaPatchRequest'
responses:
200:
'200':
description: Media request details
content:
application/json:
Expand Down Expand Up @@ -529,7 +529,7 @@ paths:
content:
application/json+problem:
schema:
$ref: './problem.yaml'
$ref: './problem.yaml'
'400':
description: Bad request
content:
Expand Down Expand Up @@ -975,27 +975,27 @@ components:
x-enum-varnames: [ USER_NOT_AUTHORISED_FOR_COURTHOUSE, MEDIA_REQUEST_NOT_VALID_FOR_USER ]

AudioRequestsErrorCode:
type: string
enum:
- "AUDIO_REQUESTS_100"
- "AUDIO_REQUESTS_101"
- "AUDIO_REQUESTS_102"
- "AUDIO_REQUESTS_103"
- "AUDIO_REQUESTS_104"
- "AUDIO_REQUESTS_105"
- "AUDIO_REQUESTS_106"
- "AUDIO_REQUESTS_107"
x-enum-varnames: [ MEDIA_REQUEST_NOT_FOUND, MEDIA_REQUEST_NOT_VALID_FOR_USER, MEDIA_REQUEST_TYPE_IS_INVALID_FOR_ENDPOINT, TRANSFORMED_MEDIA_NOT_FOUND, DUPLICATE_MEDIA_REQUEST, USER_NOT_FOUND, INVALID_REQUEST, MAX_HANDHELD_AUDIO_FILES_EXCEEDED ]
type: string
enum:
- "AUDIO_REQUESTS_100"
- "AUDIO_REQUESTS_101"
- "AUDIO_REQUESTS_102"
- "AUDIO_REQUESTS_103"
- "AUDIO_REQUESTS_104"
- "AUDIO_REQUESTS_105"
- "AUDIO_REQUESTS_106"
- "AUDIO_REQUESTS_107"
x-enum-varnames: [ MEDIA_REQUEST_NOT_FOUND, MEDIA_REQUEST_NOT_VALID_FOR_USER, MEDIA_REQUEST_TYPE_IS_INVALID_FOR_ENDPOINT, TRANSFORMED_MEDIA_NOT_FOUND, DUPLICATE_MEDIA_REQUEST, USER_NOT_FOUND, INVALID_REQUEST, MAX_HANDHELD_AUDIO_FILES_EXCEEDED ]

AudioRequestsTitleErrors:
type: string
enum:
- "The requested audio request cannot be found"
- "The audio request is not valid for this user"
- "The audio request is not valid for this action"
- "The requested transformed media cannot be found"
- "An audio request already exists with these properties"
- "Patch media request with user not found"
- "Invalid request"
- "Max handheld audio files exceed"
x-enum-varnames: [ MEDIA_REQUEST_NOT_FOUND, MEDIA_REQUEST_NOT_VALID_FOR_USER, MEDIA_REQUEST_TYPE_IS_INVALID_FOR_ENDPOINT, TRANSFORMED_MEDIA_NOT_FOUND, DUPLICATE_MEDIA_REQUEST, USER_NOT_FOUND, INVALID_REQUEST, MAX_HANDHELD_AUDIO_FILES_EXCEEDED]
type: string
enum:
- "The requested audio request cannot be found"
- "The audio request is not valid for this user"
- "The audio request is not valid for this action"
- "The requested transformed media cannot be found"
- "An audio request already exists with these properties"
- "Patch media request with user not found"
- "Invalid request"
- "Max handheld audio files exceed"
x-enum-varnames: [ MEDIA_REQUEST_NOT_FOUND, MEDIA_REQUEST_NOT_VALID_FOR_USER, MEDIA_REQUEST_TYPE_IS_INVALID_FOR_ENDPOINT, TRANSFORMED_MEDIA_NOT_FOUND, DUPLICATE_MEDIA_REQUEST, USER_NOT_FOUND, INVALID_REQUEST, MAX_HANDHELD_AUDIO_FILES_EXCEEDED ]
8 changes: 4 additions & 4 deletions src/main/resources/openapi/retentions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ paths:
description: "Retention Policy Types"
parameters: [ ]
responses:
"200":
'200':
description: "OK"
content:
application/json:
Expand Down Expand Up @@ -251,7 +251,7 @@ paths:
content:
application/json+problem:
schema:
$ref: './problem.yaml'
$ref: './problem.yaml'
'400':
description: "Bad request"
content:
Expand Down Expand Up @@ -453,7 +453,7 @@ components:
NO_RETENTION_POLICIES_APPLIED, INTERNAL_SERVER_ERROR, RETENTION_DATE_TOO_LATE, RETENTION_POLICY_TYPE_ID_NOT_FOUND,
NON_UNIQUE_POLICY_NAME, NON_UNIQUE_POLICY_DISPLAY_NAME, DURATION_TOO_SHORT, POLICY_START_MUST_BE_FUTURE,
POLICY_START_DATE_MUST_BE_PAST, NON_UNIQUE_FIXED_POLICY_KEY, FIXED_POLICY_KEY_NOT_FOUND, LIVE_POLICIES_CANNOT_BE_EDITED,
TARGET_POLICY_HAS_PENDING_REVISION, CASE_RETENTION_PASSED]
TARGET_POLICY_HAS_PENDING_REVISION, CASE_RETENTION_PASSED ]

RetentionTitleErrors:
type: string
Expand Down Expand Up @@ -481,4 +481,4 @@ components:
NO_RETENTION_POLICIES_APPLIED, INTERNAL_SERVER_ERROR, RETENTION_DATE_TOO_LATE, RETENTION_POLICY_TYPE_ID_NOT_FOUND,
NON_UNIQUE_POLICY_NAME, NON_UNIQUE_POLICY_DISPLAY_NAME, DURATION_TOO_SHORT, POLICY_START_MUST_BE_FUTURE,
POLICY_START_DATE_MUST_BE_PAST, NON_UNIQUE_FIXED_POLICY_KEY, FIXED_POLICY_KEY_NOT_FOUND, LIVE_POLICIES_CANNOT_BE_EDITED,
TARGET_POLICY_HAS_PENDING_REVISION, CASE_RETENTION_PASSED]
TARGET_POLICY_HAS_PENDING_REVISION, CASE_RETENTION_PASSED ]
6 changes: 6 additions & 0 deletions src/main/resources/openapi/transcriptions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -358,25 +358,31 @@ paths:
operationId: downloadTranscript
parameters:
- name: transcription_id
description: Transcription ID
in: path
required: true
schema:
type: integer
format: int64
minimum: 1
maximum: 9223372036854775807
responses:
'200':
description: OK
content:
application/*:
schema:
description: Any non Microsoft Word file type
type: string
format: binary
application/msword:
schema:
description: Microsoft Word Document
type: string
format: binary
application/vnd.openxmlformats-officedocument.wordprocessingml.document:
schema:
description: Microsoft Word Open XML Document
type: string
format: binary
'422':
Expand Down