diff --git a/backend/src/test/java/ch/puzzle/okr/service/validation/ObjectiveValidationServiceTest.java b/backend/src/test/java/ch/puzzle/okr/service/validation/ObjectiveValidationServiceTest.java index 377a1fe17f..c44594d57a 100644 --- a/backend/src/test/java/ch/puzzle/okr/service/validation/ObjectiveValidationServiceTest.java +++ b/backend/src/test/java/ch/puzzle/okr/service/validation/ObjectiveValidationServiceTest.java @@ -94,30 +94,16 @@ void setUp() { @DisplayName("Should be successful on validateOnGet() when id is valid") @Test - void validateOnGetShouldBeSuccessfulWhenValidObjectiveId() { + void shouldBeSuccessfulOnValidateOnGetWhenValidObjectiveId() { validator.validateOnGet(1L); verify(validator, times(1)).validateOnGet(1L); verify(validator, times(1)).throwExceptionWhenIdIsNull(1L); } - @DisplayName("Should throw exception on validateOnGet() when id is null") - @Test - void validateOnGetShouldThrowExceptionIfObjectiveIdIsNull() { - OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, - () -> validator.validateOnGet(null)); - - verify(validator, times(1)).throwExceptionWhenIdIsNull(null); - List expectedErrors = List.of(new ErrorDto("ATTRIBUTE_NULL", List.of("ID", "Objective"))); - - assertEquals(BAD_REQUEST, exception.getStatusCode()); - assertThat(expectedErrors).hasSameElementsAs(exception.getErrors()); - assertTrue(TestHelper.getAllErrorKeys(expectedErrors).contains(exception.getReason())); - } - @DisplayName("Should be successful on validateOnCreate() when objective is valid") @Test - void validateOnCreateShouldBeSuccessfulWhenTeamIsValid() { + void shouldBeSuccessfulOnValidateOnGetWhenTeamIsValid() { validator.validateOnCreate(objectiveMinimal); verify(validator, times(1)).throwExceptionWhenModelIsNull(objectiveMinimal); @@ -126,7 +112,7 @@ void validateOnCreateShouldBeSuccessfulWhenTeamIsValid() { @DisplayName("Should throw exception on validateOnCreate() when objective is null") @Test - void validateOnCreateShouldThrowExceptionWhenModelIsNull() { + void shouldThrowExceptionOnValidateOnCreateWhenModelIsNull() { OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnCreate(null)); @@ -139,7 +125,7 @@ void validateOnCreateShouldThrowExceptionWhenModelIsNull() { @DisplayName("Should throw exception on validateOnCreate() when id is not null") @Test - void validateOnCreateShouldThrowExceptionWhenIdIsNotNull() { + void shouldThrowExceptionOnValidateOnCreateWhenIdIsNotNull() { OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnCreate(objective)); @@ -152,7 +138,7 @@ void validateOnCreateShouldThrowExceptionWhenIdIsNotNull() { @ParameterizedTest(name = "should throw exception on validateOnCreate() when model has invalid name {0}") @MethodSource("nameValidationArguments") - void validateOnCreateShouldThrowExceptionWhenTitleIsInvalid(String title, List expectedErrors) { + void shouldThrowExceptionOnValidateOnCreateWhenTitleIsInvalid(String title, List expectedErrors) { Objective objective = Objective.Builder.builder().withId(null).withTitle(title).withCreatedBy(this.user) .withTeam(this.team).withQuarter(this.quarter).withDescription("This is our description 2") .withModifiedOn(LocalDateTime.MAX).withState(State.DRAFT).withCreatedOn(LocalDateTime.MAX).build(); @@ -167,7 +153,7 @@ void validateOnCreateShouldThrowExceptionWhenTitleIsInvalid(String title, List validator.validateOnUpdate(1L, null)); @@ -262,7 +248,7 @@ void validateOnUpdateShouldThrowExceptionWhenModelIsNull() { @DisplayName("Should throw exception on validateOnUpdate() when id is null") @Test - void validateOnUpdateShouldThrowExceptionWhenIdIsNull() { + void shouldThrowExceptionOnValidateOnUpdateWhenIdIsNull() { OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnUpdate(null, objectiveMinimal)); @@ -277,7 +263,7 @@ void validateOnUpdateShouldThrowExceptionWhenIdIsNull() { @DisplayName("Should throw exception on validateOnUpdate() when id has changed") @Test - void validateOnUpdateShouldThrowExceptionWhenIdHasChanged() { + void shouldThrowExceptionOnValidateOnUpdateWhenIdHasChanged() { OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnUpdate(7L, objective)); @@ -293,7 +279,7 @@ void validateOnUpdateShouldThrowExceptionWhenIdHasChanged() { @ParameterizedTest(name = "should throw exception on validateOnUpdate() when model has invalid name {0}") @MethodSource("nameValidationArguments") - void validateOnUpdateShouldThrowExceptionWhenTitleIsInvalid(String title, List expectedErrors) { + void shouldThrowExceptionOnValidateOnUpdateWhenTitleIsInvalid(String title, List expectedErrors) { Objective objective = Objective.Builder.builder().withId(3L).withTitle(title).withCreatedBy(this.user) .withTeam(this.team).withQuarter(this.quarter).withDescription("This is our description 2") .withModifiedOn(LocalDateTime.MAX).withState(State.DRAFT).withModifiedBy(this.user) @@ -310,7 +296,7 @@ void validateOnUpdateShouldThrowExceptionWhenTitleIsInvalid(String title, List validator.validateOnUpdate(1L, validObjective)); } - @DisplayName("Should be successful on validateOnGet() when id is valid") - @Test - void validateOnDeleteShouldBeSuccessfulWhenValidObjectiveId() { - validator.validateOnGet(1L); - - verify(validator, times(1)).validateOnGet(1L); - verify(validator, times(1)).throwExceptionWhenIdIsNull(1L); - } - @DisplayName("Should throw exception on validateOnGet() when id is null") @Test - void validateOnDeleteShouldThrowExceptionIfObjectiveIdIsNull() { + void shouldThrowExceptionOnValidateOnGetWhenObjectiveIdIsNull() { OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnGet(null));