From a550d5cb1d8cdee45dd045dcf04502c0582a5982 Mon Sep 17 00:00:00 2001 From: Nevio Di Gennaro Date: Thu, 19 Dec 2024 16:01:46 +0100 Subject: [PATCH] change naming of ValidationServiceTests so that all test names start with should --- .../ActionValidationServiceTest.java | 34 +++++++++---------- .../AlignmentValidationServiceTest.java | 17 ++++------ .../CheckInValidationServiceTest.java | 30 ++++++++-------- .../CompletedValidationServiceTest.java | 12 +++---- .../KeyResultValidationServiceTest.java | 32 ++++++++--------- 5 files changed, 61 insertions(+), 64 deletions(-) diff --git a/backend/src/test/java/ch/puzzle/okr/service/validation/ActionValidationServiceTest.java b/backend/src/test/java/ch/puzzle/okr/service/validation/ActionValidationServiceTest.java index dd03d8e9df..0894729931 100644 --- a/backend/src/test/java/ch/puzzle/okr/service/validation/ActionValidationServiceTest.java +++ b/backend/src/test/java/ch/puzzle/okr/service/validation/ActionValidationServiceTest.java @@ -110,7 +110,7 @@ void setUp() { @DisplayName("Should be successful on validateOnCreate() when action is valid") @Test - void validateOnCreateShouldBeSuccessfulWhenActionIsValid() { + void shouldBeSuccessfulOnValidateOnCreateWhenActionIsValid() { validator.validateOnCreate(action1); verify(validator, times(1)).throwExceptionWhenModelIsNull(action1); @@ -119,7 +119,7 @@ void validateOnCreateShouldBeSuccessfulWhenActionIsValid() { @DisplayName("Should throw exception on validateOnCreate() when model is null") @Test - void validateOnCreateShouldThrowExceptionWhenModelIsNull() { + void shouldThrowExceptionOnValidateOnCreateWhenModelIsNull() { // arrange OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnCreate(null)); @@ -132,7 +132,7 @@ void validateOnCreateShouldThrowExceptionWhenModelIsNull() { @DisplayName("Should be successful on validateOnCreate() when id is not null") @Test - void validateOnCreateShouldThrowExceptionWhenIdIsNotNull() { + void shouldThrowExceptionOnValidateOnCreateWhenIdIsNotNull() { // arrange OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnCreate(action2)); @@ -145,7 +145,7 @@ void validateOnCreateShouldThrowExceptionWhenIdIsNotNull() { @ParameterizedTest(name = "should throw exception on validateOnCreate() when model has invalid text {0}") @MethodSource("actionValidationArguments") - void validateOnCreateShouldThrowExceptionWhenActionIsInvalid(String actionText, List errors) { + void shouldThrowExceptionOnValidateOnCreateWhenActionIsInvalid(String actionText, List errors) { // arrange Action action = Action.Builder.builder().withId(null).withAction(actionText).isChecked(false).withPriority(1) .withKeyResult(keyResult).build(); @@ -159,7 +159,7 @@ void validateOnCreateShouldThrowExceptionWhenActionIsInvalid(String actionText, @DisplayName("Should throw exception on validateOnCreate() when attributes are missing") @Test - void validateOnCreateShouldThrowExceptionWhenAttrsAreMissing() { + void shouldThrowExceptionOnValidateOnCreateWhenAttrsAreMissing() { // arrange Action actionInvalid = Action.Builder.builder().isChecked(true).build(); @@ -175,7 +175,7 @@ void validateOnCreateShouldThrowExceptionWhenAttrsAreMissing() { @DisplayName("Should be successful on validateOnUpdate() when action is valid") @Test - void validateOnUpdateShouldBeSuccessfulWhenActionIsValid() { + void shouldBeSuccessfulOnValidateOnUpdateWhenActionIsValid() { // arrange when(actionPersistenceService.findById(anyLong())).thenReturn(action2); @@ -193,7 +193,7 @@ void validateOnUpdateShouldBeSuccessfulWhenActionIsValid() { @DisplayName("Should throw exception on validateOnUpdate() when model is null") @Test - void validateOnUpdateShouldThrowExceptionWhenModelIsNull() { + void shouldThrowExceptionOnValidateOnUpdateWhenModelIsNull() { // arrange OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnUpdate(1L, null)); @@ -206,7 +206,7 @@ void validateOnUpdateShouldThrowExceptionWhenModelIsNull() { @DisplayName("Should throw exception on validateOnUpdate() when id is null") @Test - void validateOnUpdateShouldThrowExceptionWhenIdIsNull() { + void shouldThrowExceptionOnValidateOnUpdateWhenIdIsNull() { // act + assert OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnUpdate(null, action1)); @@ -221,7 +221,7 @@ void validateOnUpdateShouldThrowExceptionWhenIdIsNull() { @DisplayName("Should throw exception on validateOnUpdate() when id has changed") @Test - void validateOnUpdateShouldThrowExceptionWhenIdHasChanged() { + void shouldThrowExceptionOnValidateOnUpdateWhenIdHasChanged() { // act + assert OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnUpdate(1L, action2)); @@ -237,7 +237,7 @@ void validateOnUpdateShouldThrowExceptionWhenIdHasChanged() { @DisplayName("Should throw exception on validateOnUpdate() when no entity can be found") @Test - void validateOnUpdateShouldThrowExceptionWhenEntityDoesNotExist() { + void shouldThrowExceptionOnValidateOnUpdateWhenEntityDoesNotExist() { // arrange String reason = "MODEL_WITH_ID_NOT_FOUND"; when(actionPersistenceService.findById(anyLong())) @@ -258,7 +258,7 @@ void validateOnUpdateShouldThrowExceptionWhenEntityDoesNotExist() { @DisplayName("Should throw exception on validateOnUpdate() when KeyResult is not set") @ParameterizedTest @MethodSource("actionPairArgument") - void validateOnUpdateShouldThrowExceptionWhenKeyResultNotSet(ActionPair actionPair) { + void shouldThrowExceptionOnValidateOnUpdateWhenKeyResultNotSet(ActionPair actionPair) { // arrange Action action = actionPair.action(); Action saveAction = actionPair.saveAction(); @@ -281,7 +281,7 @@ void validateOnUpdateShouldThrowExceptionWhenKeyResultNotSet(ActionPair actionPa @DisplayName("should throw exception on validateOnUpdate() when key result id has changed") @Test - void validateOnUpdateShouldThrowExceptionWhenKeyResultIdHasChanged() { + void shouldThrowExceptionOnValidateOnUpdateWhenKeyResultIdHasChanged() { // arrange Action action = Action.Builder.builder().withId(action2.getId()).withAction("Action").isChecked(false) .withPriority(1) @@ -303,7 +303,7 @@ void validateOnUpdateShouldThrowExceptionWhenKeyResultIdHasChanged() { @ParameterizedTest(name = "should throw exception on validateOnUpdate() when model has invalid text {0}") @MethodSource("actionValidationArguments") - void validateOnUpdateShouldThrowExceptionWhenTitleIsInvalid(String actionText, List errors) { + void shouldThrowExceptionOnValidateOnUpdateWhenTitleIsInvalid(String actionText, List errors) { // arrange Action action = Action.Builder.builder().withId(3L).withAction(actionText).isChecked(false).withPriority(1) .withKeyResult(keyResult).build(); @@ -317,7 +317,7 @@ void validateOnUpdateShouldThrowExceptionWhenTitleIsInvalid(String actionText, L @DisplayName("should throw exception on validateOnUpdate() when key result is missing in model") @Test - void validateOnUpdateShouldThrowExceptionWhenKeyResultIsMissing() { + void shouldThrowExceptionOnValidateOnUpdateWhenKeyResultIsMissing() { // arrange Action actionInvalid = Action.Builder.builder().withId(11L).isChecked(true).build(); when(actionPersistenceService.findById(anyLong())).thenReturn(actionInvalid); @@ -333,7 +333,7 @@ void validateOnUpdateShouldThrowExceptionWhenKeyResultIsMissing() { @DisplayName("should throw exception on validateOnUpdate() when attributes are missing") @Test - void validateOnUpdateShouldThrowExceptionWhenAttrsAreMissing() { + void shouldThrowExceptionOnValidateOnUpdateWhenAttrsAreMissing() { // arrange Action actionInvalid = Action.Builder.builder().withId(11L).isChecked(true).withKeyResult(keyResult).build(); when(actionPersistenceService.findById(anyLong())).thenReturn(actionInvalid); @@ -349,7 +349,7 @@ void validateOnUpdateShouldThrowExceptionWhenAttrsAreMissing() { @DisplayName("should be successful on validateOnGetByKeyResultId() when id is not null") @Test - void validateOnGetByKeyResultIdShouldBeSuccessfulWhenIdIsNotNull() { + void shouldBeSuccessfulInValidateOnGetByKeyResultIdWhenIdIsNotNull() { // arrange Long id = 1L; doNothing().when(keyResultValidationService).validateOnGet(id); @@ -361,7 +361,7 @@ void validateOnGetByKeyResultIdShouldBeSuccessfulWhenIdIsNotNull() { @DisplayName("should throw exception on validateOnGetByKeyResultId() when id is null") @Test - void validateOnGetByKeyResultIdShouldThrowExceptionWhenIdIsNull() { + void shouldThrowExceptionOnValidateOnGetByKeyResultIdWhenIdIsNull() { // arrange Long id = null; doThrow(OkrResponseStatusException.class).when(keyResultValidationService).validateOnGet(id); diff --git a/backend/src/test/java/ch/puzzle/okr/service/validation/AlignmentValidationServiceTest.java b/backend/src/test/java/ch/puzzle/okr/service/validation/AlignmentValidationServiceTest.java index 4e0cdfe766..4e8344722d 100644 --- a/backend/src/test/java/ch/puzzle/okr/service/validation/AlignmentValidationServiceTest.java +++ b/backend/src/test/java/ch/puzzle/okr/service/validation/AlignmentValidationServiceTest.java @@ -20,29 +20,26 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) class AlignmentValidationServiceTest { + private final Alignment keyResultAlignment = new KeyResultAlignment(); @MockitoBean AlignmentPersistenceService alignmentPersistenceService = Mockito.mock(AlignmentPersistenceService.class); - private final Alignment keyResultAlignment = new KeyResultAlignment(); - @Spy @InjectMocks private AlignmentValidationService validator; @DisplayName("Should throw exception on validateOnCreate()") @Test - void validateOnCreateShouldThrowException() { + void shouldThrowExceptionOnValidateOnCreate() { assertThrows(UnsupportedOperationException.class, () -> validator.validateOnCreate(keyResultAlignment)); } @DisplayName("Should throw exception on validateOnUpdate() when id is null") @Test - void validateOnUpdateShouldThrowExceptionWhenIdIsNull() { + void shouldThrowExceptionOnValidateOnUpdateWhenIdIsNull() { when(alignmentPersistenceService.getModelName()).thenReturn("Alignment"); OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, @@ -56,7 +53,7 @@ void validateOnUpdateShouldThrowExceptionWhenIdIsNull() { @DisplayName("Should throw exception on validateOnUpdate() when id of alignment is null") @Test - void validateOnUpdateShouldThrowExceptionWhenIdOfAlignmentIsNull() { + void shouldThrowExceptionOnValidateOnValidateOnUpdateWhenIdOfAlignmentIsNull() { when(alignmentPersistenceService.getModelName()).thenReturn("Alignment"); Alignment alignment = KeyResultAlignment.Builder.builder().withId(null).build(); @@ -72,7 +69,7 @@ void validateOnUpdateShouldThrowExceptionWhenIdOfAlignmentIsNull() { @DisplayName("Should throw exception on validateOnUpdate() when id has changed") @Test - void validateOnUpdateShouldThrowExceptionWhenIdHasChanged() { + void shouldThrowExceptionOnValidateOnUpdateWhenIdHasChanged() { Alignment alignment = KeyResultAlignment.Builder.builder().withId(3L).build(); OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, @@ -86,7 +83,7 @@ void validateOnUpdateShouldThrowExceptionWhenIdHasChanged() { @DisplayName("Should throw exception on validateOnUpdate() when model is invalid") @Test - void validateOnUpdateShouldValidateDto() { + void shouldThrowExceptionOnValidateOnUpdateWhenModelIsInvalid() { when(alignmentPersistenceService.getModelName()).thenReturn("Alignment"); Alignment alignment = KeyResultAlignment.Builder.builder().withId(2L).withAlignedObjective(null).withVersion(1) .build(); diff --git a/backend/src/test/java/ch/puzzle/okr/service/validation/CheckInValidationServiceTest.java b/backend/src/test/java/ch/puzzle/okr/service/validation/CheckInValidationServiceTest.java index cb785929cb..4a94b961d6 100644 --- a/backend/src/test/java/ch/puzzle/okr/service/validation/CheckInValidationServiceTest.java +++ b/backend/src/test/java/ch/puzzle/okr/service/validation/CheckInValidationServiceTest.java @@ -81,14 +81,14 @@ void setUp() { @DisplayName("Should be successful on validateOnGet() when id is valid") @Test - void validateOnGetShouldBeSuccessfulWhenValidCheckInId() { + void shouldBeSuccessfulOnValidateOnGetWhenValidCheckInId() { validator.validateOnGet(1L); verify(validator, times(1)).throwExceptionWhenIdIsNull(1L); } @DisplayName("Should throw exception on validateOnGet() when id is null") @Test - void validateOnGetShouldThrowExceptionIfCheckInIdIsNull() { + void shouldThrowExceptionOnValidateOnGetIfCheckInIdIsNull() { // act + assert OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnGet(null)); @@ -101,7 +101,7 @@ void validateOnGetShouldThrowExceptionIfCheckInIdIsNull() { @DisplayName("Should be successful on validateOnCreate() when check in is valid") @Test - void validateOnCreateShouldBeSuccessfulWhenCheckInIsValid() { + void shouldBeSuccessfulOnValidateOnCreateWhenCheckInIsValid() { when(checkInPersistenceService.findById(checkInMetric.getId())).thenReturn(checkInMetric); validator.validateOnCreate(checkInMetric); @@ -113,7 +113,7 @@ void validateOnCreateShouldBeSuccessfulWhenCheckInIsValid() { @DisplayName("Should throw exception on validateOnCreate() when model is null") @Test - void validateOnCreateShouldThrowExceptionWhenModelIsNull() { + void shouldThrowExceptionOnValidateOnCreateWhenModelIsNull() { // act + assert OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnCreate(null)); @@ -124,7 +124,7 @@ void validateOnCreateShouldThrowExceptionWhenModelIsNull() { @DisplayName("Should throw exception on validateOnCreate() when id is not null") @Test - void validateOnCreateShouldThrowExceptionWhenIdIsNotNull() { + void shouldThrowExceptionOnValidateOnCreateWhenIdIsNotNull() { // act + assert OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnCreate(fullCheckIn)); @@ -135,7 +135,7 @@ void validateOnCreateShouldThrowExceptionWhenIdIsNotNull() { @ParameterizedTest(name = "should throw exception on validateOnCreate() when confidence has invalid value {0}") @MethodSource("confidenceValidationArguments") - void validateOnCreateShouldThrowExceptionWhenConfidenceIsInvalid(Integer confidence, + void shouldThrowExceptionOnValidateOnCreateWhenConfidenceIsInvalid(Integer confidence, List expectedErrors) { // arrange @@ -158,7 +158,7 @@ void validateOnCreateShouldThrowExceptionWhenConfidenceIsInvalid(Integer confide @DisplayName("Should throw exception on validateOnCreate() when attributes are missing") @Test - void validateOnCreateShouldThrowExceptionWhenAttrsAreMissing() { + void shouldThrowExceptionOnValidateOnCreateWhenAttrsAreMissing() { // arrange CheckIn checkInInvalid = CheckInMetric.Builder.builder() // .withId(null) // @@ -192,7 +192,7 @@ void validateOnUpdateShouldBeSuccessfulWhenCheckInIsValid() { @DisplayName("Should throw exception on validateOnUpdate() when model is null") @Test - void validateOnUpdateShouldThrowExceptionWhenModelIsNull() { + void shouldThrowExceptionOnValidateOnUpdateWhenModelIsNull() { // act + assert OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnUpdate(1L, null)); @@ -203,7 +203,7 @@ void validateOnUpdateShouldThrowExceptionWhenModelIsNull() { @DisplayName("Should throw exception on validateOnUpdate() when id is null") @Test - void validateOnUpdateShouldThrowExceptionWhenIdIsNull() { + void shouldThrowExceptionOnValidateOnUpdateWhenIdIsNull() { // act + assert OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnUpdate(null, checkInOrdinal)); @@ -217,7 +217,7 @@ void validateOnUpdateShouldThrowExceptionWhenIdIsNull() { @DisplayName("Should throw exception on validateOnUpdate() when id has changed") @Test - void validateOnUpdateShouldThrowExceptionWhenIdIsHasChanged() { + void shouldThrowExceptionOnValidateOnUpdateWhenIdIsHasChanged() { // act + assert OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnUpdate(2L, checkInOrdinal)); @@ -232,7 +232,7 @@ void validateOnUpdateShouldThrowExceptionWhenIdIsHasChanged() { @ParameterizedTest(name = "should throw exception on validateOnUpdate() when confidence has invalid value {0}") @MethodSource("confidenceValidationArguments") - void validateOnUpdateShouldThrowExceptionWhenConfidenceIsInvalid(Integer confidence, + void shouldThrowExceptionOnValidateOnUpdateWhenConfidenceIsInvalid(Integer confidence, List expectedErrors) { // arrange @@ -251,7 +251,7 @@ void validateOnUpdateShouldThrowExceptionWhenConfidenceIsInvalid(Integer confide @DisplayName("Should throw exception on validateOnUpdate() when check ins are empty") @Test - void validateOnUpdateShouldThrowExceptionWhenCheckInsOfKeyResultIsEmpty() { + void shouldThrowExceptionOnValidateOnUpdateWhenCheckInsOfKeyResultIsEmpty() { // arrange Long id = 2L; CheckIn checkIn = CheckInMetric.Builder.builder().withValue(40.9).withId(id).withChangeInfo("ChangeInfo") @@ -277,7 +277,7 @@ void validateOnUpdateShouldThrowExceptionWhenCheckInsOfKeyResultIsEmpty() { @DisplayName("Should throw exception on validateOnUpdate() when attributes are missing") @Test - void validateOnUpdateShouldThrowExceptionWhenAttrsAreMissing() { + void shouldThrowExceptionOnValidateOnUpdateWhenAttrsAreMissing() { // arrange Long id = 11L; CheckIn checkInInvalid = CheckInMetric.Builder.builder() // @@ -301,7 +301,7 @@ void validateOnUpdateShouldThrowExceptionWhenAttrsAreMissing() { @DisplayName("Should be successful on validateOnDelete() when id is valid") @Test - void validateOnDeleteShouldBeSuccessfulWhenValidKeyResultId() { + void shouldBeSuccessfulOnValidateOnDeleteWhenValidKeyResultId() { validator.validateOnDelete(1L); verify(validator, times(1)).throwExceptionWhenIdIsNull(1L); verify(validator, times(1)).doesEntityExist(1L); @@ -309,7 +309,7 @@ void validateOnDeleteShouldBeSuccessfulWhenValidKeyResultId() { @DisplayName("Should throw exception on validateOnDelete() when id is null") @Test - void validateOnDeleteShouldThrowExceptionIfKeyResultIdIsNull() { + void shouldThrowExceptionOnValidateOnDeleteWhenKeyResultIdIsNull() { // act + assert OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnDelete(null)); diff --git a/backend/src/test/java/ch/puzzle/okr/service/validation/CompletedValidationServiceTest.java b/backend/src/test/java/ch/puzzle/okr/service/validation/CompletedValidationServiceTest.java index 2162b8c15f..5288667473 100644 --- a/backend/src/test/java/ch/puzzle/okr/service/validation/CompletedValidationServiceTest.java +++ b/backend/src/test/java/ch/puzzle/okr/service/validation/CompletedValidationServiceTest.java @@ -74,7 +74,7 @@ private static Stream nameValidationArguments() { @DisplayName("Should be successful on validateOnCreate() when model is valid") @Test - void validateOnCreateShouldBeSuccessfulWhenCompletedIsValid() { + void shouldBeSuccessfulOnValidateOnCreateWhenCompletedIsValid() { validator.validateOnCreate(this.validCompleted); verify(validator, times(1)).throwExceptionWhenModelIsNull(this.validCompleted); @@ -83,7 +83,7 @@ void validateOnCreateShouldBeSuccessfulWhenCompletedIsValid() { @DisplayName("Should throw exception on validateOnCreate() when model is null") @Test - void validateOnCreateShouldThrowExceptionWhenModelIsNull() { + void shouldThrowExceptionOnValidateOnCreateWhenModelIsNull() { // act + assert OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnCreate(null)); @@ -94,7 +94,7 @@ void validateOnCreateShouldThrowExceptionWhenModelIsNull() { @DisplayName("Should throw exception on validateOnCreate() when id is not null") @Test - void validateOnCreateShouldThrowExceptionWhenIdIsNotNull() { + void shouldThrowExceptionOnValidateOnCreateWhenIdIsNotNull() { // arrange Completed completed = Completed.Builder.builder() // .withId(300L) // @@ -112,7 +112,7 @@ void validateOnCreateShouldThrowExceptionWhenIdIsNotNull() { @ParameterizedTest(name = "should throw exception on validateOnCreate() when model has invalid comment {0}") @MethodSource("nameValidationArguments") - void validateOnCreateShouldThrowExceptionWhenCommentIsInvalid(String comment, List expectedErrors) { + void shouldThrowExceptionOnValidateOnCreateWhenCommentIsInvalid(String comment, List expectedErrors) { // arrange Completed completed = Completed.Builder.builder() // .withObjective(this.objective) // @@ -128,7 +128,7 @@ void validateOnCreateShouldThrowExceptionWhenCommentIsInvalid(String comment, Li @DisplayName("Should throw exception on validateOnCreate() when attributes are missing") @Test - void validateOnCreateShouldThrowExceptionWhenAttrsAreMissing() { + void shouldThrowExceptionOnValidateOnCreateWhenAttrsAreMissing() { // arrange Completed completedInvalid = Completed.Builder.builder() // .withId(null) // @@ -146,7 +146,7 @@ void validateOnCreateShouldThrowExceptionWhenAttrsAreMissing() { @DisplayName("Should throw exception on validateOnUpdate()") @Test - void validateOnUpdateShouldThrowException() { + void shouldThrowOnValidateOnUpdateException() { // arrange Long id = 1L; Completed completed = Completed.Builder.builder().build(); diff --git a/backend/src/test/java/ch/puzzle/okr/service/validation/KeyResultValidationServiceTest.java b/backend/src/test/java/ch/puzzle/okr/service/validation/KeyResultValidationServiceTest.java index 0563d2e0b4..7126664670 100644 --- a/backend/src/test/java/ch/puzzle/okr/service/validation/KeyResultValidationServiceTest.java +++ b/backend/src/test/java/ch/puzzle/okr/service/validation/KeyResultValidationServiceTest.java @@ -90,7 +90,7 @@ private static Stream nameValidationArguments() { @DisplayName("Should be successful on validateOnGet() when id is valid") @Test - void validateOnGetShouldBeSuccessfulWhenValidKeyResultId() { + void shouldBeSuccessfulOnValidateOnGetWhenValidKeyResultId() { validator.validateOnGet(1L); verify(validator, times(1)).validateOnGet(1L); @@ -99,7 +99,7 @@ void validateOnGetShouldBeSuccessfulWhenValidKeyResultId() { @DisplayName("Should throw exception on validateOnGet() when id is null") @Test - void validateOnGetShouldThrowExceptionIfKeyResultIdIsNull() { + void shouldThrowExceptionOnValidateOnGetIfKeyResultIdIsNull() { // act + assert OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnGet(null)); @@ -112,7 +112,7 @@ void validateOnGetShouldThrowExceptionIfKeyResultIdIsNull() { @DisplayName("Should be successful on validateOnCreate() when key result is valid") @Test - void validateOnCreateShouldBeSuccessfulWhenKeyResultIsValid() { + void shouldBeSuccessfulOnValidateOnCreateWhenKeyResultIsValid() { validator.validateOnCreate(fullKeyResult); verify(validator, times(1)).throwExceptionWhenModelIsNull(fullKeyResult); @@ -121,7 +121,7 @@ void validateOnCreateShouldBeSuccessfulWhenKeyResultIsValid() { @DisplayName("Should throw exception on validateOnCreate() when key result is null") @Test - void validateOnCreateShouldThrowExceptionWhenModelIsNull() { + void shouldThrowExceptionOnValidateOnCreateWhenModelIsNull() { // act + assert OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnCreate(null)); @@ -132,7 +132,7 @@ void validateOnCreateShouldThrowExceptionWhenModelIsNull() { @DisplayName("Should throw exception on validateOnCreate() when id is not null") @Test - void validateOnCreateShouldThrowExceptionWhenIdIsNotNull() { + void shouldThrowExceptionOnValidateOnCreateWhenIdIsNotNull() { // act + assert OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnCreate(keyResultMetric)); @@ -143,7 +143,7 @@ void validateOnCreateShouldThrowExceptionWhenIdIsNotNull() { @ParameterizedTest(name = "should throw exception on validateOnCreate() when model has invalid name {0}") @MethodSource("nameValidationArguments") - void validateOnCreateShouldThrowExceptionWhenTitleIsInvalid(String title, List errors) { + void shouldThrowExceptionOnValidateOnCreateWhenTitleIsInvalid(String title, List errors) { // arrange KeyResult keyResult = KeyResultMetric.Builder.builder() // .withBaseline(3.0) // @@ -165,7 +165,7 @@ void validateOnCreateShouldThrowExceptionWhenTitleIsInvalid(String title, List validator.validateOnUpdate(1L, null)); @@ -221,7 +221,7 @@ void validateOnUpdateShouldThrowExceptionWhenModelIsNull() { @DisplayName("should throw exception on validateOnUpdate() when id is null") @Test - void validateOnUpdateShouldThrowExceptionWhenIdIsNull() { + void shouldThrowExceptionOnValidateOnUpdateWhenIdIsNull() { // act + assert OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnUpdate(null, keyResultOrdinal)); @@ -235,7 +235,7 @@ void validateOnUpdateShouldThrowExceptionWhenIdIsNull() { @DisplayName("should throw exception on validateOnUpdate() when id has changed") @Test - void validateOnUpdateShouldThrowExceptionWhenIdHasChanged() { + void shouldThrowExceptionOnValidateOnUpdateWhenIdHasChanged() { // act + assert OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnUpdate(1L, keyResultMetric)); @@ -250,7 +250,7 @@ void validateOnUpdateShouldThrowExceptionWhenIdHasChanged() { @ParameterizedTest(name = "should throw exception on validateOnUpdate() when model has invalid name {0}") @MethodSource("nameValidationArguments") - void validateOnUpdateShouldThrowExceptionWhenTitleIsInvalid(String title, List errors) { + void shouldThrowExceptionOnValidateOnUpdateWhenTitleIsInvalid(String title, List errors) { // arrange Long id = 3L; KeyResult keyResult = KeyResultMetric.Builder.builder() // @@ -275,7 +275,7 @@ void validateOnUpdateShouldThrowExceptionWhenTitleIsInvalid(String title, List validator.validateOnDelete(null)); @@ -323,7 +323,7 @@ void validateOnDeleteShouldThrowExceptionIfKeyResultIdIsNull() { @DisplayName("should throw exception on validateOnUpdate() when objective id (of input and saved KeyResult) has changed") @Test - void validateOnUpdateShouldThrowExceptionWhenObjectiveIdOfKeyResultHasChanged() { + void shouldThrowExceptionOnValidateOnUpdateWhenObjectiveIdOfKeyResultHasChanged() { // arrange Long keyResultId = 1L; Long objectiveId = 2L;