Skip to content

Commit

Permalink
Add displayname annotation to each test in the service.persistence pa…
Browse files Browse the repository at this point in the history
…ckage
  • Loading branch information
MasterEvarior committed Dec 19, 2024
1 parent eeed326 commit 4a8d07f
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import ch.puzzle.okr.test.SpringIntegrationTest;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.server.ResponseStatusException;
Expand Down Expand Up @@ -60,6 +61,7 @@ void tearDown() {
TenantContext.setCurrentTenant(null);
}

@DisplayName("should create new entity on save()")
@Test
void saveActionShouldSaveNewAction() {
Action action = createAction(null);
Expand All @@ -73,6 +75,7 @@ void saveActionShouldSaveNewAction() {
assertEquals(action.isChecked(), createdAction.isChecked());
}

@DisplayName("should update action on save() when the action has been modified")
@Test
void updateActionShouldUpdateAction() {
Action action = createAction(null);
Expand All @@ -87,6 +90,7 @@ void updateActionShouldUpdateAction() {
assertEquals(4, updateAction.getPriority());
}

@DisplayName("should throw exception on save() when the action has already been updated")
@Test
void updateActionShouldThrowExceptionWhenAlreadyUpdated() {
createdAction = actionPersistenceService.save(createAction(null));
Expand All @@ -102,13 +106,15 @@ void updateActionShouldThrowExceptionWhenAlreadyUpdated() {
assertTrue(TestHelper.getAllErrorKeys(expectedErrors).contains(exception.getReason()));
}

@DisplayName("should return list of all actions on findAll()")
@Test
void getAllActionsShouldReturnListOfAllActions() {
List<Action> actions = actionPersistenceService.findAll();

assertEquals(11, actions.size());
}

@DisplayName("should return list of actions from a key result ordered by ascending priority on getActionsByKeyResultIdOrderByPriorityAsc()")
@Test
void getAllActionsByKeyResultIdShouldReturnListOfAllActionsFromThisKeyResultOrderASC() {
List<Action> actions = actionPersistenceService.getActionsByKeyResultIdOrderByPriorityAsc(6L);
Expand All @@ -119,6 +125,7 @@ void getAllActionsByKeyResultIdShouldReturnListOfAllActionsFromThisKeyResultOrde
assertEquals(3, actions.get(2).getPriority());
}

@DisplayName("should return correct action on findById()")
@Test
void getActionByIdShouldReturnActionProperly() {
Action action = actionPersistenceService.findById(1L);
Expand All @@ -130,6 +137,7 @@ void getActionByIdShouldReturnActionProperly() {
assertEquals(8L, action.getKeyResult().getId());
}

@DisplayName("should delete action on delete()")
@Test
void shouldDeleteActionById() {
Action action = createAction(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import ch.puzzle.okr.test.SpringIntegrationTest;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.server.ResponseStatusException;
Expand Down Expand Up @@ -64,6 +65,7 @@ void tearDown() {
TenantContext.setCurrentTenant(null);
}

@DisplayName("should save new objective alignment entity on save()")
@Test
void saveAlignmentShouldSaveNewObjectiveAlignment() {
Alignment alignment = createObjectiveAlignment(null);
Expand All @@ -75,6 +77,7 @@ void saveAlignmentShouldSaveNewObjectiveAlignment() {
assertEquals(4L, ((ObjectiveAlignment) createdAlignment).getAlignmentTarget().getId());
}

@DisplayName("should save new key result alignment entity on save()")
@Test
void saveAlignmentShouldSaveNewKeyResultAlignment() {
Alignment alignment = createKeyResultAlignment(null);
Expand All @@ -86,6 +89,7 @@ void saveAlignmentShouldSaveNewKeyResultAlignment() {
assertEquals(8L, ((KeyResultAlignment) createdAlignment).getAlignmentTarget().getId());
}

@DisplayName("should update key result alignment entity on save()")
@Test
void updateAlignmentShouldSaveKeyResultAlignment() {
createdAlignment = alignmentPersistenceService.save(createKeyResultAlignment(null));
Expand All @@ -98,6 +102,7 @@ void updateAlignmentShouldSaveKeyResultAlignment() {
assertEquals(createdAlignment.getVersion() + 1, updatedAlignment.getVersion());
}

@DisplayName("should throw exception on save() when entity was already updated in the mean time")
@Test
void updateAlignmentShouldThrowExceptionWhenAlreadyUpdated() {
createdAlignment = alignmentPersistenceService.save(createKeyResultAlignment(null));
Expand All @@ -114,6 +119,7 @@ void updateAlignmentShouldThrowExceptionWhenAlreadyUpdated() {
assertTrue(TestHelper.getAllErrorKeys(expectedErrors).contains(exception.getReason()));
}

@DisplayName("should return correct list of alignments on findByAlignedObjectiveId()")
@Test
void findByAlignedObjectiveIdShouldReturnListOfAlignments() {
List<Alignment> alignments = alignmentPersistenceService.findByAlignedObjectiveId(4L);
Expand All @@ -122,6 +128,7 @@ void findByAlignedObjectiveIdShouldReturnListOfAlignments() {
alignments.forEach(this::assertAlignment);
}

@DisplayName("should return correct list of key result alignments on findByKeyResultAlignmentId()")
@Test
void findByKeyResultAlignmentIdShouldReturnListOfAlignments() {
List<KeyResultAlignment> alignments = alignmentPersistenceService.findByKeyResultAlignmentId(8L);
Expand All @@ -130,6 +137,7 @@ void findByKeyResultAlignmentIdShouldReturnListOfAlignments() {
assertAlignment(alignments.get(0));
}

@DisplayName("should return correct list of objective alignments on findByObjectiveAlignmentId()")
@Test
void findByObjectiveAlignmentIdShouldReturnListOfAlignments() {
List<ObjectiveAlignment> alignments = alignmentPersistenceService.findByObjectiveAlignmentId(3L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import ch.puzzle.okr.test.SpringIntegrationTest;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

Expand All @@ -31,6 +32,7 @@ void tearDown() {
TenantContext.setCurrentTenant(null);
}

@DisplayName("should return correct alignment selections on getAlignmentSelectionByQuarterIdAndTeamIdNot()")
@Test
void getAlignmentSelectionByQuarterIdAndTeamIdNotShouldReturnAlignmentSelections() {
List<AlignmentSelection> alignmentSelections = alignmentSelectionPersistenceService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import ch.puzzle.okr.test.SpringIntegrationTest;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

Expand All @@ -34,6 +35,7 @@ void tearDown() {
TenantContext.setCurrentTenant(null);
}

@DisplayName("should return objective on findObjectiveById() when user is has first level role")
@Test
void appendObjectiveShouldReturnObjectiveWhenFirstLevelRole() {
Long objectiveId = 5L;
Expand All @@ -43,6 +45,7 @@ void appendObjectiveShouldReturnObjectiveWhenFirstLevelRole() {
assertEquals(objectiveId, objective.getId());
}

@DisplayName("should return objective on findObjectiveById() when user is has second level role")
@Test
void appendObjectiveShouldReturnObjectiveWhenSecondLevelRole() {
Long objectiveId = 6L;
Expand All @@ -52,6 +55,7 @@ void appendObjectiveShouldReturnObjectiveWhenSecondLevelRole() {
assertEquals(objectiveId, objective.getId());
}

@DisplayName("should return objective on findObjectiveById() when user is has member level role")
@Test
void appendObjectiveShouldReturnObjectiveWhenMemberRole() {
Long objectiveId = 6L;
Expand All @@ -61,6 +65,7 @@ void appendObjectiveShouldReturnObjectiveWhenMemberRole() {
assertEquals(objectiveId, objective.getId());
}

@DisplayName("should return correct overview on getFilteredOverview() when user has first level role and no team ids are supplied")
@Test
void appendOverviewShouldReturnObjectiveWhenFirstLevelRoleAndTeamIdsEmpty() {
Long quarterId = 2L;
Expand All @@ -71,6 +76,7 @@ void appendOverviewShouldReturnObjectiveWhenFirstLevelRoleAndTeamIdsEmpty() {
assertEquals(18L, overviews.size());
}

@DisplayName("should return correct overview on getFilteredOverview() when user has second level role")
@Test
void appendOverviewShouldReturnObjectiveWhenSecondLevelRole() {
Long quarterId = 2L;
Expand All @@ -81,6 +87,7 @@ void appendOverviewShouldReturnObjectiveWhenSecondLevelRole() {
assertEquals(6L, overviews.size());
}

@DisplayName("should return correct overview on getFilteredOverview() when user has member level role")
@Test
void appendOverviewShouldReturnObjectiveWhenMemberRole() {
Long quarterId = 2L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public class AuthorizationCriteriaParametersTest {

@DisplayName("setParameters() should be successful with default authorization user")
@DisplayName("should be successful on setParameters() with default authorization user")
@Test
void setParametersShouldBeSuccessfulWithDefaultAuthorizationUser() {
// arrange
Expand All @@ -39,7 +39,7 @@ void setParametersShouldBeSuccessfulWithDefaultAuthorizationUser() {
assertEquals(expected, typedQueryMock.getLog());
}

@DisplayName("setParameters() should be successful when user is okr champion")
@DisplayName("should be successful on setParameters() when user is okr champion")
@Test
void setParametersShouldBeSuccessfulWhenUserIsOkrChampion() {
// arrange
Expand All @@ -65,7 +65,7 @@ void setParametersShouldBeSuccessfulWhenUserIsOkrChampion() {
assertEquals(expected, typedQueryMock.getLog());
}

@DisplayName("setParameters() should be successful when team ids or objective query are empty")
@DisplayName("should be successful on setParameters() when team ids or objective query are empty")
@ParameterizedTest
@MethodSource("provideListAndString")
void setParametersShouldBeSuccessfulWhenTeamIdsOrObjectiveQueryAreEmpty(List<Long> teamIds, String objectiveQuery) {
Expand Down Expand Up @@ -94,7 +94,7 @@ private static Stream<Arguments> provideListAndString() {
Arguments.of(null, ""));
}

@DisplayName("setParameters() should be successful when team ids and objective query are not empty")
@DisplayName("should be successful on setParameters() when team ids and objective query are not empty")
@Test
void setParametersShouldBeSuccessfulWhenTeamIdsAndObjectiveQueryAreNotEmpty() {
// arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

public class AuthorizationCriteriaTest {

@DisplayName("appendObjective() should be successful with default authorization user")
@DisplayName("should be successful on appendObjective() with default authorization user")
@Test
void appendObjectiveShouldBeSuccessfulWithDefaultAuthorizationUser() {
// arrange
Expand All @@ -32,7 +32,7 @@ void appendObjectiveShouldBeSuccessfulWithDefaultAuthorizationUser() {
assertEquals(expected, current);
}

@DisplayName("appendObjective() should be successful when user is okrChampion")
@DisplayName("should be successful on appendObjective() when user is okrChampion")
@Test
void appendObjectiveShouldBeSuccessfulWhenUserIsOkrChampion() {
// arrange
Expand All @@ -53,8 +53,7 @@ void appendObjectiveShouldBeSuccessfulWhenUserIsOkrChampion() {
assertEquals(expected, current);
}

@DisplayName("appendOverview() should be successful when team ids or objective query are empty")
@ParameterizedTest
@ParameterizedTest(name = "should be successful on appendOverview() when team ids ({0}) or objectives query ({0}) are empty")
@MethodSource("provideListAndString")
void appendOverviewShouldBeSuccessfulWhenTeamIdsOrObjectiveQueryAreEmpty(List<Long> teamIds,
String objectiveQuery) {
Expand All @@ -77,7 +76,7 @@ private static Stream<Arguments> provideListAndString() {
Arguments.of(null, ""));
}

@DisplayName("appendOverview() should be successful when team ids and objective query are not empty")
@DisplayName("should be successful on appendOverview() when team ids and objective query are not empty")
@Test
void appendOverviewShouldBeSuccessfulWhenTeamIdsAndObjectiveQueryAreNotEmpty() {
// arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void tearDown() {
}

// uses data from V100_0_0__TestData.sql
@DisplayName("getCheckInsByKeyResultIdOrderByCheckInDate() should get checkIns by keyResultId and order them by date desc")
@DisplayName("should get checkIns by keyResultId and order them by date desc on getCheckInsByKeyResultIdOrderByCheckInDate() ")
@Test
void getCheckInsByKeyResultIdOrderByCheckInDateShouldGetCheckInsByKeyResultIdAndOrderThemByDateDesc() {
// act
Expand All @@ -57,7 +57,7 @@ private void assertFirstIsCreatedAfterSecond(CheckIn first, CheckIn second) {
}

// uses data from V100_0_0__TestData.sql
@DisplayName("getLastCheckInOfKeyResult() should get last checkIn of keyResult")
@DisplayName("should get last checkIn of keyResult on getLastCheckInOfKeyResult()")
@Test
void getLastCheckInOfKeyResultShouldGetLastCheckInOfKeyResult() {
// act
Expand All @@ -76,7 +76,7 @@ private void assertLastIsCreatedAfterAllOtherCheckIns(CheckIn last, List<CheckIn
}
}

@DisplayName("getModelName() should return checkIn")
@DisplayName("should return checkIn on getModelName()")
@Test
void getModelNameShouldReturnCheckIn() {
assertEquals(CHECK_IN, checkInPersistenceService.getModelName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import ch.puzzle.okr.test.SpringIntegrationTest;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.server.ResponseStatusException;
Expand Down Expand Up @@ -61,6 +62,7 @@ void tearDown() {
TenantContext.setCurrentTenant(null);
}

@DisplayName("should save entity on save()")
@Test
void saveCompletedShouldSaveCompleted() {
createdCompleted = completedPersistenceService.save(createCompleted(null));
Expand All @@ -71,6 +73,7 @@ void saveCompletedShouldSaveCompleted() {
assertEquals(OBJECTIVE_TITLE, createdCompleted.getObjective().getTitle());
}

@DisplayName("should update entity on save() when the entity already exists")
@Test
void updateCompletedShouldSaveCompleted() {
createdCompleted = completedPersistenceService.save(createCompleted(null));
Expand All @@ -84,6 +87,7 @@ void updateCompletedShouldSaveCompleted() {
assertEquals(updateCompleted.getComment(), updatedCompleted.getComment());
}

@DisplayName("should throw exception on save() when entity was already updated in the mean time")
@Test
void updateCompletedShouldThrowExceptionWhenAlreadyUpdated() {
createdCompleted = completedPersistenceService.save(createCompleted(null));
Expand All @@ -100,6 +104,7 @@ void updateCompletedShouldThrowExceptionWhenAlreadyUpdated() {
assertTrue(TestHelper.getAllErrorKeys(expectedErrors).contains(exception.getReason()));
}

@DisplayName("should return correct entity on getCompletedByObjectiveId()")
@Test
void getCompletedShouldGetCompletedByObjectiveId() {
Completed savedCompleted = completedPersistenceService.getCompletedByObjectiveId(6L);
Expand All @@ -110,6 +115,7 @@ void getCompletedShouldGetCompletedByObjectiveId() {
savedCompleted.getObjective().getTitle());
}

@DisplayName("should delete entity on deleteById()")
@Test
void deleteByIdShouldDeleteExistingCompletedByObjectiveId() {

Expand All @@ -125,6 +131,7 @@ void deleteByIdShouldDeleteExistingCompletedByObjectiveId() {
assertTrue(TestHelper.getAllErrorKeys(expectedErrors).contains(exception.getReason()));
}

@DisplayName("should throw exception on findById() when id does not exist")
@Test
void deleteCompletedShouldThrowExceptionWhenCompletedNotFound() {
long noExistentId = getNonExistentId();
Expand Down
Loading

0 comments on commit 4a8d07f

Please sign in to comment.