From 854f4fd59725f195a944196cb3f963ecce2ebfcc Mon Sep 17 00:00:00 2001 From: mariopaniccia Date: Mon, 4 Dec 2023 16:30:29 +0000 Subject: [PATCH] example naming of some tests to the proposed given when then style --- .../TranscriptionControllerGetTranscriptionTest.java | 4 ++-- ...onControllerUpdateTranscriptionApprovedIntTest.java | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/integrationTest/java/uk/gov/hmcts/darts/transcriptions/controller/TranscriptionControllerGetTranscriptionTest.java b/src/integrationTest/java/uk/gov/hmcts/darts/transcriptions/controller/TranscriptionControllerGetTranscriptionTest.java index c6b60a10f53..b0187e01d1f 100644 --- a/src/integrationTest/java/uk/gov/hmcts/darts/transcriptions/controller/TranscriptionControllerGetTranscriptionTest.java +++ b/src/integrationTest/java/uk/gov/hmcts/darts/transcriptions/controller/TranscriptionControllerGetTranscriptionTest.java @@ -63,7 +63,7 @@ void setUp() { } @Test - void getTranscription() throws Exception { + void givenExistingTranscription_whenGetTranscriptionIsRequested_thenTheDetailsAreReturned() throws Exception { HearingEntity hearingEntity = dartsDatabase.getHearingRepository().findAll().get(0); TranscriptionEntity transcription = dartsDatabase.getTranscriptionStub().createTranscription(hearingEntity); transcription.setCreatedDateTime(OffsetDateTime.of(2023, 6, 20, 10, 0, 0, 0, ZoneOffset.UTC)); @@ -117,7 +117,7 @@ private void addCommentToWorkflow(TranscriptionWorkflowEntity workflowEntity, St } @Test - void getTranscriptionNotFound() throws Exception { + void givenRequestedTranscriptionDoesNotExist_whenGetTranscriptionIsRequested_thenTranscriptionNotFoundErrorIsReturned() throws Exception { MockHttpServletRequestBuilder requestBuilder = get(ENDPOINT_URL_TRANSCRIPTION, -999); MvcResult response = mockMvc.perform(requestBuilder).andExpect(status().isNotFound()).andReturn(); String actualResponse = response.getResponse().getContentAsString(); diff --git a/src/integrationTest/java/uk/gov/hmcts/darts/transcriptions/controller/TranscriptionControllerUpdateTranscriptionApprovedIntTest.java b/src/integrationTest/java/uk/gov/hmcts/darts/transcriptions/controller/TranscriptionControllerUpdateTranscriptionApprovedIntTest.java index de196d09800..1888fb5e0cd 100644 --- a/src/integrationTest/java/uk/gov/hmcts/darts/transcriptions/controller/TranscriptionControllerUpdateTranscriptionApprovedIntTest.java +++ b/src/integrationTest/java/uk/gov/hmcts/darts/transcriptions/controller/TranscriptionControllerUpdateTranscriptionApprovedIntTest.java @@ -95,7 +95,7 @@ void beforeEach() { } @Test - void updateTranscriptionApprovedWithoutComment() throws Exception { + void givenAwaitingAuthorisationTranscription_whenApproveWithoutCommentIsRequested_thenNewStatusIsApprovedAndHasNoComment() throws Exception { TranscriptionEntity existingTranscription = dartsDatabase.getTranscriptionRepository().findById( transcriptionId).orElseThrow(); @@ -145,7 +145,7 @@ void updateTranscriptionApprovedWithoutComment() throws Exception { } @Test - void updateTranscriptionApprovedWithComment() throws Exception { + void givenAwaitingAuthorisationTranscription_whenApproveWithCommentIsRequested_thenNewStatusIsApprovedAndHasComment() throws Exception { UpdateTranscription updateTranscription = new UpdateTranscription(); updateTranscription.setTranscriptionStatusId(APPROVED.getId()); @@ -190,7 +190,9 @@ void updateTranscriptionApprovedWithComment() throws Exception { } @Test - void updateTranscriptionShouldReturnTranscriptionNotFoundError() throws Exception { +// alternative naming if we want to allow empty given +// void given_whenUpdateTranscriptionForNonExistingTranscriptionIsRequested_thenTranscriptionNotFoundErrorIsReturned() throws Exception { + void givenRequestedTranscriptionDoesNotExist_whenUpdateTranscriptionIsRequested_thenTranscriptionNotFoundErrorIsReturned() throws Exception { UpdateTranscription updateTranscription = new UpdateTranscription(); updateTranscription.setTranscriptionStatusId(APPROVED.getId()); updateTranscription.setWorkflowComment("APPROVED"); @@ -216,7 +218,7 @@ void updateTranscriptionShouldReturnTranscriptionNotFoundError() throws Exceptio } @Test - void updateTranscriptionShouldReturnTranscriptionWorkflowActionInvalidError() throws Exception { + void givenExistingTranscription_whenUpdateToInvalidStatusIsRequested_thenTranscriptionWorkflowActionInvalidErrorIsReturned() throws Exception { UpdateTranscription updateTranscription = new UpdateTranscription(); updateTranscription.setTranscriptionStatusId(WITH_TRANSCRIBER.getId()); updateTranscription.setWorkflowComment("APPROVED");