From d142b671bf96c46406c6741d7b4a94617eb4be18 Mon Sep 17 00:00:00 2001 From: Jannik Pulfer Date: Tue, 17 Dec 2024 13:22:18 +0100 Subject: [PATCH] Rename all occurences of firstname and lastname to firstName and lastName --- .../java/ch/puzzle/okr/dto/NewUserDto.java | 2 +- .../main/java/ch/puzzle/okr/dto/UserDto.java | 2 +- .../okr/dto/keyresult/KeyResultUserDto.java | 2 +- .../java/ch/puzzle/okr/mapper/UserMapper.java | 6 +- .../keyresult/KeyResultMetricMapper.java | 4 +- .../keyresult/KeyResultOrdinalMapper.java | 4 +- .../main/java/ch/puzzle/okr/models/User.java | 44 +++++------ .../ch/puzzle/okr/security/JwtHelper.java | 16 ++-- .../AuthorizationRegistrationService.java | 4 +- .../src/main/resources/application.properties | 4 +- .../h2-db/data-test-h2/V100_0_0__TestData.sql | 2 +- .../V1_0_0__current-db-schema-for-testing.sql | 4 +- .../V3_2_0__renameFirstAndLastNameColumns.sql | 4 + .../puzzle/okr/SpringCachingConfigTest.java | 4 +- .../okr/controller/KeyResultControllerIT.java | 16 ++-- .../okr/controller/ObjectiveControllerIT.java | 3 +- .../okr/controller/TeamControllerIT.java | 2 +- .../okr/controller/UserControllerIT.java | 40 +++++----- .../KeyResultDeserializerTest.java | 12 +-- .../ch/puzzle/okr/mapper/UserMapperTest.java | 20 ++--- .../mapper/keyresult/helper/AssertHelper.java | 8 +- .../keyresult/helper/TestDataConstants.java | 4 +- .../keyresult/helper/TestDataDtoHelper.java | 4 +- .../keyresult/helper/TestDataHelper.java | 4 +- .../ch/puzzle/okr/security/JwtHelperTest.java | 16 ++-- .../AuthorizationRegistrationServiceIT.java | 24 +++--- .../authorization/UserUpdateHelperTest.java | 12 +-- .../business/CheckInBusinessServiceTest.java | 2 +- .../ObjectiveBusinessServiceTest.java | 2 +- .../business/TeamBusinessServiceTest.java | 2 +- .../business/UserBusinessServiceTest.java | 36 ++++----- .../AuthorizationCriteriaParametersTest.java | 4 +- .../AuthorizationCriteriaTest.java | 4 +- .../persistence/PersistenceBaseTestIT.java | 14 ++-- .../persistence/UserPersistenceServiceIT.java | 34 ++++----- .../CheckInValidationServiceTest.java | 2 +- .../CompletedValidationServiceTest.java | 2 +- .../KeyResultValidationServiceTest.java | 2 +- .../ObjectiveValidationServiceTest.java | 4 +- .../validation/UserValidationServiceTest.java | 74 +++++++++---------- .../puzzle/okr/test/CheckInTestHelpers.java | 4 +- .../puzzle/okr/test/KeyResultTestHelpers.java | 10 +-- .../java/ch/puzzle/okr/test/TestHelper.java | 26 +++---- 43 files changed, 246 insertions(+), 243 deletions(-) create mode 100644 backend/src/main/resources/db/migration/V3_2_0__renameFirstAndLastNameColumns.sql diff --git a/backend/src/main/java/ch/puzzle/okr/dto/NewUserDto.java b/backend/src/main/java/ch/puzzle/okr/dto/NewUserDto.java index 5874453023..872eb00e63 100644 --- a/backend/src/main/java/ch/puzzle/okr/dto/NewUserDto.java +++ b/backend/src/main/java/ch/puzzle/okr/dto/NewUserDto.java @@ -1,4 +1,4 @@ package ch.puzzle.okr.dto; -public record NewUserDto(String firstname, String lastname, String email) { +public record NewUserDto(String firstName, String lastName, String email) { } diff --git a/backend/src/main/java/ch/puzzle/okr/dto/UserDto.java b/backend/src/main/java/ch/puzzle/okr/dto/UserDto.java index 119a7554cd..a6fe5f96e4 100644 --- a/backend/src/main/java/ch/puzzle/okr/dto/UserDto.java +++ b/backend/src/main/java/ch/puzzle/okr/dto/UserDto.java @@ -2,6 +2,6 @@ import java.util.List; -public record UserDto(Long id, int version, String firstname, String lastname, String email, +public record UserDto(Long id, int version, String firstName, String lastName, String email, List userTeamList, boolean isOkrChampion) { } diff --git a/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultUserDto.java b/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultUserDto.java index b10f27becf..135a06aaa3 100644 --- a/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultUserDto.java +++ b/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultUserDto.java @@ -1,4 +1,4 @@ package ch.puzzle.okr.dto.keyresult; -public record KeyResultUserDto(Long id, String firstname, String lastname) { +public record KeyResultUserDto(Long id, String firstName, String lastName) { } diff --git a/backend/src/main/java/ch/puzzle/okr/mapper/UserMapper.java b/backend/src/main/java/ch/puzzle/okr/mapper/UserMapper.java index 6b2d2c2d14..92359a4ec8 100644 --- a/backend/src/main/java/ch/puzzle/okr/mapper/UserMapper.java +++ b/backend/src/main/java/ch/puzzle/okr/mapper/UserMapper.java @@ -27,7 +27,7 @@ public UserDto toDto(User user) { ut -> new UserTeamDto(ut.getId(), user.getVersion(), teamMapper.toDto(ut.getTeam()), ut.isTeamAdmin())) .collect(Collectors.toList()); - return new UserDto(user.getId(), user.getVersion(), user.getFirstname(), user.getLastname(), user.getEmail(), + return new UserDto(user.getId(), user.getVersion(), user.getFirstName(), user.getLastName(), user.getEmail(), userTeams, user.isOkrChampion()); } @@ -37,8 +37,8 @@ public List toUserList(List newUserList) { public User toUser(NewUserDto newUserDto) { User user = new User(); - user.setFirstname(newUserDto.firstname()); - user.setLastname(newUserDto.lastname()); + user.setFirstName(newUserDto.firstName()); + user.setLastName(newUserDto.lastName()); user.setEmail(newUserDto.email()); return user; } diff --git a/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultMetricMapper.java b/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultMetricMapper.java index e285304f06..5496ccc28b 100644 --- a/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultMetricMapper.java +++ b/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultMetricMapper.java @@ -34,8 +34,8 @@ public KeyResultMetricMapper(UserBusinessService userBusinessService, public KeyResultDto toDto(KeyResultMetric keyResult, List actionList) { KeyResultUserDto ownerDto = new KeyResultUserDto( // keyResult.getOwner().getId(), // - keyResult.getOwner().getFirstname(), // - keyResult.getOwner().getLastname()); + keyResult.getOwner().getFirstName(), // + keyResult.getOwner().getLastName()); KeyResultQuarterDto quarterDto = new KeyResultQuarterDto( // keyResult.getObjective().getQuarter().getId(), // diff --git a/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultOrdinalMapper.java b/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultOrdinalMapper.java index e62c93b482..843c2c46b4 100644 --- a/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultOrdinalMapper.java +++ b/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultOrdinalMapper.java @@ -34,8 +34,8 @@ public KeyResultOrdinalMapper(UserBusinessService userBusinessService, public KeyResultDto toDto(KeyResultOrdinal keyResult, List actionList) { KeyResultUserDto ownerDto = new KeyResultUserDto( // keyResult.getOwner().getId(), // - keyResult.getOwner().getFirstname(), // - keyResult.getOwner().getLastname()); + keyResult.getOwner().getFirstName(), // + keyResult.getOwner().getLastName()); KeyResultQuarterDto quarterDto = new KeyResultQuarterDto( // keyResult.getObjective().getQuarter().getId(), // diff --git a/backend/src/main/java/ch/puzzle/okr/models/User.java b/backend/src/main/java/ch/puzzle/okr/models/User.java index e05b9cd266..e30ba15e28 100644 --- a/backend/src/main/java/ch/puzzle/okr/models/User.java +++ b/backend/src/main/java/ch/puzzle/okr/models/User.java @@ -25,12 +25,12 @@ public class User { @NotBlank(message = MessageKey.ATTRIBUTE_NOT_BLANK) @NotNull(message = MessageKey.ATTRIBUTE_NOT_NULL) @Size(min = 2, max = 50, message = MessageKey.ATTRIBUTE_SIZE_BETWEEN) - private String firstname; + private String firstName; @NotBlank(message = MessageKey.ATTRIBUTE_NOT_BLANK) @NotNull(message = MessageKey.ATTRIBUTE_NOT_NULL) @Size(min = 2, max = 50, message = MessageKey.ATTRIBUTE_SIZE_BETWEEN) - private String lastname; + private String lastName; @Column(unique = true, nullable = false) @Email(message = MessageKey.ATTRIBUTE_NOT_VALID) @@ -51,8 +51,8 @@ public User() { private User(Builder builder) { id = builder.id; version = builder.version; - setFirstname(builder.firstname); - setLastname(builder.lastname); + setFirstName(builder.firstName); + setLastName(builder.lastName); setEmail(builder.email); setUserTeamList(builder.userTeamList); setOkrChampion(builder.okrChampion); @@ -66,20 +66,20 @@ public int getVersion() { return version; } - public String getFirstname() { - return firstname; + public String getFirstName() { + return firstName; } - public void setFirstname(String firstname) { - this.firstname = firstname; + public void setFirstName(String firstName) { + this.firstName = firstName; } - public String getLastname() { - return lastname; + public String getLastName() { + return lastName; } - public void setLastname(String lastname) { - this.lastname = lastname; + public void setLastName(String lastName) { + this.lastName = lastName; } public String getEmail() { @@ -108,8 +108,8 @@ public void setOkrChampion(boolean okrChampion) { @Override public String toString() { - return "User{" + "id=" + id + ", version=" + version + ", firstname='" + firstname + '\'' + ", lastname='" - + lastname + '\'' + ", email='" + email + '\'' + ", okrChampion='" + okrChampion + '\'' + '}'; + return "User{" + "id=" + id + ", version=" + version + ", firstName='" + firstName + '\'' + ", lastName='" + + lastName + '\'' + ", email='" + email + '\'' + ", okrChampion='" + okrChampion + '\'' + '}'; } @Override @@ -120,20 +120,20 @@ public boolean equals(Object o) { return false; User user = (User) o; return Objects.equals(id, user.id) && Objects.equals(version, user.version) - && Objects.equals(firstname, user.firstname) && Objects.equals(lastname, user.lastname) + && Objects.equals(firstName, user.firstName) && Objects.equals(lastName, user.lastName) && Objects.equals(email, user.email) && Objects.equals(okrChampion, user.okrChampion); } @Override public int hashCode() { - return Objects.hash(id, version, firstname, lastname, email, okrChampion); + return Objects.hash(id, version, firstName, lastName, email, okrChampion); } public static final class Builder { private Long id; private int version; - private String firstname; - private String lastname; + private String firstName; + private String lastName; private String email; private List userTeamList; private boolean okrChampion; @@ -155,13 +155,13 @@ public Builder withVersion(int version) { return this; } - public Builder withFirstname(String firstname) { - this.firstname = firstname; + public Builder withFirstName(String firstName) { + this.firstName = firstName; return this; } - public Builder withLastname(String lastname) { - this.lastname = lastname; + public Builder withLastName(String lastName) { + this.lastName = lastName; return this; } diff --git a/backend/src/main/java/ch/puzzle/okr/security/JwtHelper.java b/backend/src/main/java/ch/puzzle/okr/security/JwtHelper.java index fe15d284f1..420f79d34f 100644 --- a/backend/src/main/java/ch/puzzle/okr/security/JwtHelper.java +++ b/backend/src/main/java/ch/puzzle/okr/security/JwtHelper.java @@ -34,17 +34,17 @@ public class JwtHelper { private static final Logger logger = LoggerFactory.getLogger(JwtHelper.class); private final TenantConfigProvider tenantConfigProvider; - private final String firstname; - private final String lastname; + private final String firstName; + private final String lastName; private final String email; public JwtHelper(TenantConfigProvider tenantConfigProvider, - @Value("${okr.jwt.claim.firstname}") final String tokenClaimsKeyFirstname, - @Value("${okr.jwt.claim.lastname}") final String tokenClaimsKeyLastname, + @Value("${okr.jwt.claim.first-name}") final String tokenClaimsKeyFirstname, + @Value("${okr.jwt.claim.last-name}") final String tokenClaimsKeyLastname, @Value("${okr.jwt.claim.email}") final String tokenClaimsKeyEmail) { this.tenantConfigProvider = tenantConfigProvider; - this.firstname = tokenClaimsKeyFirstname; - this.lastname = tokenClaimsKeyLastname; + this.firstName = tokenClaimsKeyFirstname; + this.lastName = tokenClaimsKeyLastname; this.email = tokenClaimsKeyEmail; } @@ -54,8 +54,8 @@ public User getUserFromJwt(Jwt token) { try { return User.Builder.builder() // - .withFirstname(claims.get(firstname).toString()) // - .withLastname(claims.get(lastname).toString()) // + .withFirstName(claims.get(firstName).toString()) // + .withLastName(claims.get(lastName).toString()) // .withEmail(claims.get(email).toString()) // .build(); } catch (Exception e) { diff --git a/backend/src/main/java/ch/puzzle/okr/service/authorization/AuthorizationRegistrationService.java b/backend/src/main/java/ch/puzzle/okr/service/authorization/AuthorizationRegistrationService.java index 0ce7d9ed68..f4bf2308cb 100644 --- a/backend/src/main/java/ch/puzzle/okr/service/authorization/AuthorizationRegistrationService.java +++ b/backend/src/main/java/ch/puzzle/okr/service/authorization/AuthorizationRegistrationService.java @@ -60,8 +60,8 @@ public User setOkrChampionFromProperties(User user, TenantConfigProvider.TenantC } public User setFirstLastNameFromToken(User userFromDb, User userFromToken) { - userFromDb.setFirstname(userFromToken.getFirstname()); - userFromDb.setLastname(userFromToken.getLastname()); + userFromDb.setFirstName(userFromToken.getFirstName()); + userFromDb.setLastName(userFromToken.getLastName()); return userFromDb; } } diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 6fccf1781a..e9d6ff7ec1 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -38,8 +38,8 @@ okr.jwt.claim.realm=pitc okr.jwt.claim.organisations=roles okr.jwt.claim.organisation.name.prefix=org_ okr.jwt.claim.username=preferred_username -okr.jwt.claim.firstname=given_name -okr.jwt.claim.lastname=family_name +okr.jwt.claim.first-name=given_name +okr.jwt.claim.last-name=family_name okr.jwt.claim.email=email spring.jpa.properties.hibernate.multi-tenancy=SCHEMA diff --git a/backend/src/main/resources/db/h2-db/data-test-h2/V100_0_0__TestData.sql b/backend/src/main/resources/db/h2-db/data-test-h2/V100_0_0__TestData.sql index 19ef9ba302..8df25c4cf5 100644 --- a/backend/src/main/resources/db/h2-db/data-test-h2/V100_0_0__TestData.sql +++ b/backend/src/main/resources/db/h2-db/data-test-h2/V100_0_0__TestData.sql @@ -24,7 +24,7 @@ ALTER SEQUENCE sequence_quarter RESTART WITH 200; ALTER SEQUENCE sequence_team RESTART WITH 200; ALTER SEQUENCE sequence_person_team RESTART WITH 200; -INSERT INTO person (id, version, email, firstname, lastname, okr_champion) +INSERT INTO person (id, version, email, first_name, last_name, okr_champion) VALUES (1, 1, 'peggimann@puzzle.ch', 'Paco', 'Eggimann', FALSE), (11, 1, 'wunderland@puzzle.ch', 'Alice', 'Wunderland', FALSE), (21, 1, 'baumeister@puzzle.ch', 'Bob', 'Baumeister', FALSE), diff --git a/backend/src/main/resources/db/h2-db/database-h2-schema/V1_0_0__current-db-schema-for-testing.sql b/backend/src/main/resources/db/h2-db/database-h2-schema/V1_0_0__current-db-schema-for-testing.sql index 504e1fae46..689cab97d7 100644 --- a/backend/src/main/resources/db/h2-db/database-h2-schema/V1_0_0__current-db-schema-for-testing.sql +++ b/backend/src/main/resources/db/h2-db/database-h2-schema/V1_0_0__current-db-schema-for-testing.sql @@ -14,8 +14,8 @@ create table if not exists person id bigint not null, version int not null, email varchar(250) not null, - firstname varchar(50) not null, - lastname varchar(50) not null, + first_name varchar(50) not null, + last_name varchar(50) not null, okr_champion BOOLEAN DEFAULT FALSE, primary key (id), constraint uk_person_email diff --git a/backend/src/main/resources/db/migration/V3_2_0__renameFirstAndLastNameColumns.sql b/backend/src/main/resources/db/migration/V3_2_0__renameFirstAndLastNameColumns.sql new file mode 100644 index 0000000000..4fe77bde02 --- /dev/null +++ b/backend/src/main/resources/db/migration/V3_2_0__renameFirstAndLastNameColumns.sql @@ -0,0 +1,4 @@ +ALTER TABLE person + RENAME COLUMN firstname to first_name; +ALTER TABLE person + RENAME COLUMN lastname to last_name; \ No newline at end of file diff --git a/backend/src/test/java/ch/puzzle/okr/SpringCachingConfigTest.java b/backend/src/test/java/ch/puzzle/okr/SpringCachingConfigTest.java index f083c8ed4d..52b078427f 100644 --- a/backend/src/test/java/ch/puzzle/okr/SpringCachingConfigTest.java +++ b/backend/src/test/java/ch/puzzle/okr/SpringCachingConfigTest.java @@ -68,8 +68,8 @@ private void assertEqualUsers(AuthorizationUser expectedAuthorizationUser, User expectedUser = expectedAuthorizationUser.user(); User actualUser = actualAuthorizationUser.user(); - assertTrue(expectedUser.getFirstname().equals(actualUser.getFirstname()) - && expectedUser.getLastname().equals(actualUser.getLastname()) + assertTrue(expectedUser.getFirstName().equals(actualUser.getFirstName()) + && expectedUser.getLastName().equals(actualUser.getLastName()) && expectedUser.getEmail().equals(actualUser.getEmail())); } } \ No newline at end of file diff --git a/backend/src/test/java/ch/puzzle/okr/controller/KeyResultControllerIT.java b/backend/src/test/java/ch/puzzle/okr/controller/KeyResultControllerIT.java index 90ce8446ab..4ecaf8bab6 100644 --- a/backend/src/test/java/ch/puzzle/okr/controller/KeyResultControllerIT.java +++ b/backend/src/test/java/ch/puzzle/okr/controller/KeyResultControllerIT.java @@ -83,7 +83,7 @@ void shouldGetMetricKeyResultById() throws Exception { .andExpect(jsonPath(JSON_PATH_BASELINE, Is.is(BASELINE_VALUE))) .andExpect(jsonPath(JSON_PATH_STRETCH_GOAL, Is.is(STRETCH_GOAL_VALUE))) .andExpect(jsonPath(JSON_PATH_UNIT, Is.is(KEY_RESULT_UNIT.toString()))) - .andExpect(jsonPath(JSON_PATH_OWNER_FIRSTNAME, Is.is(FIRSTNAME))) + .andExpect(jsonPath(JSON_PATH_OWNER_FIRST_NAME, Is.is(FIRST_NAME))) .andExpect(jsonPath(JSON_PATH_OBJECTIVE_STATE, Is.is(OBJECTIVE_STATE_ONGOING))) .andExpect(jsonPath(JSON_PATH_ID_LAST_CHECK_IN_VALUE, Is.is(4.0))) .andExpect(jsonPath(JSON_PATH_LAST_CHECK_IN_CONFIDENCE, Is.is(CONFIDENCE))) @@ -99,7 +99,7 @@ void shouldGetOrdinalKeyResultById() throws Exception { .andExpect(MockMvcResultMatchers.status().isOk()).andExpect(jsonPath(JSON_PATH_ID, Is.is(5))) .andExpect(jsonPath(JSON_PATH_DESCRIPTION, Is.is(DESCRIPTION))) .andExpect(jsonPath(JSON_PATH_KEY_RESULT_TYPE, Is.is(KEY_RESULT_TYPE_ORDINAL))) - .andExpect(jsonPath(JSON_PATH_OWNER_FIRSTNAME, Is.is(FIRSTNAME))) + .andExpect(jsonPath(JSON_PATH_OWNER_FIRST_NAME, Is.is(FIRST_NAME))) .andExpect(jsonPath(JSON_PATH_OBJECTIVE_ID, Is.is(OBJECTIVE_ID))) .andExpect(jsonPath(JSON_PATH_OBJECTIVE_STATE, Is.is(OBJECTIVE_STATE_ONGOING))) .andExpect(jsonPath(JSON_PATH_QUARTER_LABEL, Is.is(QUARTER_LABEL))) @@ -170,7 +170,7 @@ void shouldBeAbleToCreateMetricKeyResult() throws Exception { .andExpect(jsonPath(JSON_PATH_KEY_RESULT_TYPE, Is.is(KEY_RESULT_TYPE_METRIC))) .andExpect(jsonPath(JSON_PATH_BASELINE, Is.is(BASELINE_VALUE))) .andExpect(jsonPath(JSON_PATH_STRETCH_GOAL, Is.is(STRETCH_GOAL_VALUE))) - .andExpect(jsonPath(JSON_PATH_OWNER_FIRSTNAME, Is.is(FIRSTNAME))) + .andExpect(jsonPath(JSON_PATH_OWNER_FIRST_NAME, Is.is(FIRST_NAME))) .andExpect(jsonPath(JSON_PATH_OBJECTIVE_ID, Is.is(OBJECTIVE_ID))) .andExpect(jsonPath(JSON_PATH_OBJECTIVE_STATE, Is.is(OBJECTIVE_STATE_ONGOING))) .andExpect(jsonPath(JSON_PATH_QUARTER_START_DATE, Is.is(START_DATE))) @@ -195,7 +195,7 @@ void shouldBeAbleToCreateOrdinalKeyResult() throws Exception { .andExpect(jsonPath(JSON_PATH_KEY_RESULT_TYPE, Is.is(KEY_RESULT_TYPE_ORDINAL))) .andExpect(jsonPath(JSON_PATH_TARGET_ZONE, Is.is(TARGET_ZONE))) .andExpect(jsonPath(JSON_PATH_STRETCH_ZONE, Is.is(STRETCH_ZONE))) - .andExpect(jsonPath(JSON_PATH_OWNER_FIRSTNAME, Is.is(FIRSTNAME))) + .andExpect(jsonPath(JSON_PATH_OWNER_FIRST_NAME, Is.is(FIRST_NAME))) .andExpect(jsonPath(JSON_PATH_OBJECTIVE_ID, Is.is(OBJECTIVE_ID))) .andExpect(jsonPath(JSON_PATH_OBJECTIVE_STATE, Is.is(OBJECTIVE_STATE_ONGOING))) .andExpect(jsonPath(JSON_PATH_QUARTER_START_DATE, Is.is(START_DATE))) @@ -228,7 +228,7 @@ void shouldCreateActionsWhenCreatingKeyResult() throws Exception { .andExpect(jsonPath(JSON_PATH_KEY_RESULT_TYPE, Is.is(KEY_RESULT_TYPE_ORDINAL))) .andExpect(jsonPath(JSON_PATH_TARGET_ZONE, Is.is(TARGET_ZONE))) .andExpect(jsonPath(JSON_PATH_STRETCH_ZONE, Is.is(STRETCH_ZONE))) - .andExpect(jsonPath(JSON_PATH_OWNER_FIRSTNAME, Is.is(FIRSTNAME))) + .andExpect(jsonPath(JSON_PATH_OWNER_FIRST_NAME, Is.is(FIRST_NAME))) .andExpect(jsonPath(JSON_PATH_OBJECTIVE_ID, Is.is(OBJECTIVE_ID))) .andExpect(jsonPath(JSON_PATH_OBJECTIVE_STATE, Is.is(OBJECTIVE_STATE_ONGOING))) .andExpect(jsonPath(JSON_PATH_QUARTER_START_DATE, Is.is(START_DATE))) @@ -264,7 +264,7 @@ void shouldCreateEntityWithEnumKeys() throws Exception { .andExpect(jsonPath(JSON_PATH_OBJECTIVE_ID, Is.is(OBJECTIVE_ID))) .andExpect(jsonPath(JSON_PATH_DESCRIPTION, Is.is(DESCRIPTION))) .andExpect(jsonPath(JSON_PATH_KEY_RESULT_TYPE, Is.is(KEY_RESULT_TYPE_ORDINAL))) - .andExpect(jsonPath(JSON_PATH_OWNER_FIRSTNAME, Is.is(FIRSTNAME))) + .andExpect(jsonPath(JSON_PATH_OWNER_FIRST_NAME, Is.is(FIRST_NAME))) .andExpect(jsonPath(JSON_PATH_OBJECTIVE_STATE, Is.is(OBJECTIVE_STATE_ONGOING))) .andExpect(jsonPath(JSON_PATH_LAST_CHECK_IN_ZONE, Is.is(LAST_CHECK_IN_ZONE.toString()))) .andExpect(jsonPath(JSON_PATH_LAST_CHECK_IN_CONFIDENCE, Is.is(CONFIDENCE))) @@ -297,7 +297,7 @@ void shouldReturnUpdatedKeyResultWhenUpdatingKeyResult() throws Exception { mvc.perform(put(URL_TO_KEY_RESULT_1).contentType(MediaType.APPLICATION_JSON) .with(SecurityMockMvcRequestPostProcessors.csrf()).content(JSON)) .andExpect(MockMvcResultMatchers.status().isOk()).andExpect(jsonPath(JSON_PATH_TITLE, Is.is(TITLE))) - .andExpect(jsonPath(JSON_PATH_OWNER_FIRSTNAME, Is.is(FIRSTNAME))) + .andExpect(jsonPath(JSON_PATH_OWNER_FIRST_NAME, Is.is(FIRST_NAME))) .andExpect(jsonPath(JSON_PATH_KEY_RESULT_TYPE, Is.is(KEY_RESULT_TYPE_METRIC))) .andExpect(jsonPath(JSON_PATH_BASELINE, Is.is(BASELINE_VALUE))) .andExpect(jsonPath(JSON_PATH_STRETCH_GOAL, Is.is(STRETCH_GOAL_VALUE))) @@ -321,7 +321,7 @@ void shouldReturnUpdatedKeyResultWithImUsed() throws Exception { mvc.perform(put(URL_TO_KEY_RESULT_1).contentType(MediaType.APPLICATION_JSON) .with(SecurityMockMvcRequestPostProcessors.csrf()).content(JSON)) .andExpect(MockMvcResultMatchers.status().isImUsed()).andExpect(jsonPath(JSON_PATH_TITLE, Is.is(TITLE))) - .andExpect(jsonPath(JSON_PATH_OWNER_FIRSTNAME, Is.is(FIRSTNAME))) + .andExpect(jsonPath(JSON_PATH_OWNER_FIRST_NAME, Is.is(FIRST_NAME))) .andExpect(jsonPath(JSON_PATH_KEY_RESULT_TYPE, Is.is(KEY_RESULT_TYPE_METRIC))) .andExpect(jsonPath(JSON_PATH_BASELINE, Is.is(BASELINE_VALUE))) .andExpect(jsonPath(JSON_PATH_STRETCH_GOAL, Is.is(STRETCH_GOAL_VALUE))) diff --git a/backend/src/test/java/ch/puzzle/okr/controller/ObjectiveControllerIT.java b/backend/src/test/java/ch/puzzle/okr/controller/ObjectiveControllerIT.java index 5a6a3270f2..e0c4dabf2a 100644 --- a/backend/src/test/java/ch/puzzle/okr/controller/ObjectiveControllerIT.java +++ b/backend/src/test/java/ch/puzzle/okr/controller/ObjectiveControllerIT.java @@ -23,7 +23,6 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.web.server.ResponseStatusException; -import java.time.LocalDate; import java.time.LocalDateTime; import static org.mockito.ArgumentMatchers.any; @@ -71,7 +70,7 @@ class ObjectiveControllerIT { .build(); private static final Objective objective2 = Objective.Builder.builder().withId(7L).withTitle(OBJECTIVE_TITLE_2) .build(); - private static final User user = User.Builder.builder().withId(1L).withFirstname("Bob").withLastname("Kaufmann") + private static final User user = User.Builder.builder().withId(1L).withFirstName("Bob").withLastName("Kaufmann") .withEmail("kaufmann@puzzle.ch").build(); private static final Team team = Team.Builder.builder().withId(1L).withName("Team1").build(); private static final Quarter quarter = Quarter.Builder.builder().withId(1L).withLabel("GJ 22/23-Q2").build(); diff --git a/backend/src/test/java/ch/puzzle/okr/controller/TeamControllerIT.java b/backend/src/test/java/ch/puzzle/okr/controller/TeamControllerIT.java index ba29df382e..162ae1142f 100644 --- a/backend/src/test/java/ch/puzzle/okr/controller/TeamControllerIT.java +++ b/backend/src/test/java/ch/puzzle/okr/controller/TeamControllerIT.java @@ -67,7 +67,7 @@ class TeamControllerIT { """; private static final String ADD_USERS = """ - [{"id":31,"version":1,"firstname":"Findus","lastname":"Peterson","email":"peterson@puzzle.ch","userTeamList":[{"id":31,"version":1,"team":{"id":8,"version":1,"name":"we are cube.³","isWriteable":false},"isTeamAdmin":true}],"isOkrChampion":false},{"id":41,"version":1,"firstname":"Paco","lastname":"Egiman","email":"egiman@puzzle.ch","userTeamList":[{"id":41,"version":1,"team":{"id":4,"version":1,"name":"/BBT","isWriteable":false},"isTeamAdmin":false}],"isOkrChampion":false}] + [{"id":31,"version":1,"firstName":"Findus","lastName":"Peterson","email":"peterson@puzzle.ch","userTeamList":[{"id":31,"version":1,"team":{"id":8,"version":1,"name":"we are cube.³","isWriteable":false},"isTeamAdmin":true}],"isOkrChampion":false},{"id":41,"version":1,"firstName":"Paco","lastName":"Egiman","email":"egiman@puzzle.ch","userTeamList":[{"id":41,"version":1,"team":{"id":4,"version":1,"name":"/BBT","isWriteable":false},"isTeamAdmin":false}],"isOkrChampion":false}] """; @Autowired diff --git a/backend/src/test/java/ch/puzzle/okr/controller/UserControllerIT.java b/backend/src/test/java/ch/puzzle/okr/controller/UserControllerIT.java index 23244c9782..0c4ef65d6e 100644 --- a/backend/src/test/java/ch/puzzle/okr/controller/UserControllerIT.java +++ b/backend/src/test/java/ch/puzzle/okr/controller/UserControllerIT.java @@ -40,19 +40,19 @@ @ExtendWith(MockitoExtension.class) @WebMvcTest(UserController.class) class UserControllerIT { - private static final String FIRSTNAME_1 = "Alice"; - private static final String LASTNAME_1 = "Wunderland"; + private static final String FIRST_NAME_1 = "Alice"; + private static final String LAST_NAME_1 = "Wunderland"; private static final String EMAIL_1 = "wunderland@puzzle.ch"; - private static final String FIRSTNAME_2 = "Bob"; - private static final String LASTNAME_2 = "Baumeister"; + private static final String FIRST_NAME_2 = "Bob"; + private static final String LAST_NAME_2 = "Baumeister"; private static final String EMAIL_2 = "baumeister@puzzle.ch"; - static User userAlice = User.Builder.builder().withId(2L).withFirstname(FIRSTNAME_1).withLastname(LASTNAME_1) + static User userAlice = User.Builder.builder().withId(2L).withFirstName(FIRST_NAME_1).withLastName(LAST_NAME_1) .withEmail(EMAIL_1).build(); - static User userBob = User.Builder.builder().withId(9L).withFirstname(FIRSTNAME_2).withLastname(LASTNAME_2) + static User userBob = User.Builder.builder().withId(9L).withFirstName(FIRST_NAME_2).withLastName(LAST_NAME_2) .withEmail(EMAIL_2).build(); static List userList = Arrays.asList(userAlice, userBob); - static UserDto userAliceDto = new UserDto(2L, 3, FIRSTNAME_1, LASTNAME_1, EMAIL_1, new ArrayList<>(), false); - static UserDto userBobDto = new UserDto(9L, 4, FIRSTNAME_2, LASTNAME_2, EMAIL_2, new ArrayList<>(), false); + static UserDto userAliceDto = new UserDto(2L, 3, FIRST_NAME_1, LAST_NAME_1, EMAIL_1, new ArrayList<>(), false); + static UserDto userBobDto = new UserDto(9L, 4, FIRST_NAME_2, LAST_NAME_2, EMAIL_2, new ArrayList<>(), false); @Autowired private MockMvc mvc; @MockBean @@ -74,11 +74,11 @@ void shouldGetAllUsers() throws Exception { mvc.perform(get("/api/v1/users").contentType(MediaType.APPLICATION_JSON)) .andExpect(MockMvcResultMatchers.status().isOk()).andExpect(jsonPath("$", Matchers.hasSize(2))) - .andExpect(jsonPath("$[0].id", Is.is(2))).andExpect(jsonPath("$[0].firstname", Is.is(FIRSTNAME_1))) - .andExpect(jsonPath("$[0].lastname", Is.is(LASTNAME_1))) + .andExpect(jsonPath("$[0].id", Is.is(2))).andExpect(jsonPath("$[0].firstName", Is.is(FIRST_NAME_1))) + .andExpect(jsonPath("$[0].lastName", Is.is(LAST_NAME_1))) .andExpect(jsonPath("$[0].email", Is.is(EMAIL_1))).andExpect(jsonPath("$[1].id", Is.is(9))) - .andExpect(jsonPath("$[1].firstname", Is.is(FIRSTNAME_2))) - .andExpect(jsonPath("$[1].lastname", Is.is(LASTNAME_2))) + .andExpect(jsonPath("$[1].firstName", Is.is(FIRST_NAME_2))) + .andExpect(jsonPath("$[1].lastName", Is.is(LAST_NAME_2))) .andExpect(jsonPath("$[1].email", Is.is(EMAIL_2))); } @@ -101,8 +101,8 @@ void shouldReturnCurrentUser() throws Exception { .andExpect(jsonPath("$", Matchers.aMapWithSize(7))) // .andExpect(jsonPath("$.id", Is.is(2))) // .andExpect(jsonPath("$.version", Is.is(3))) // - .andExpect(jsonPath("$.firstname", Is.is(FIRSTNAME_1))) // - .andExpect(jsonPath("$.lastname", Is.is(LASTNAME_1))) // + .andExpect(jsonPath("$.firstName", Is.is(FIRST_NAME_1))) // + .andExpect(jsonPath("$.lastName", Is.is(LAST_NAME_1))) // .andExpect(jsonPath("$.email", Is.is(EMAIL_1))) // .andExpect(jsonPath("$.userTeamList", Matchers.empty())) // .andExpect(jsonPath("$.isOkrChampion", Is.is(false))); @@ -118,8 +118,8 @@ void shouldReturnUserById() throws Exception { .andExpect(jsonPath("$", Matchers.aMapWithSize(7))) // .andExpect(jsonPath("$.id", Is.is(2))) // .andExpect(jsonPath("$.version", Is.is(3))) // - .andExpect(jsonPath("$.firstname", Is.is(FIRSTNAME_1))) // - .andExpect(jsonPath("$.lastname", Is.is(LASTNAME_1))) // + .andExpect(jsonPath("$.firstName", Is.is(FIRST_NAME_1))) // + .andExpect(jsonPath("$.lastName", Is.is(LAST_NAME_1))) // .andExpect(jsonPath("$.email", Is.is(EMAIL_1))) // .andExpect(jsonPath("$.userTeamList", Matchers.empty())) // .andExpect(jsonPath("$.isOkrChampion", Is.is(false))); @@ -139,8 +139,8 @@ void shouldSetOkrChampion() throws Exception { .andExpect(jsonPath("$", Matchers.aMapWithSize(7))) // .andExpect(jsonPath("$.id", Is.is(2))) // .andExpect(jsonPath("$.version", Is.is(3))) // - .andExpect(jsonPath("$.firstname", Is.is(FIRSTNAME_1))) // - .andExpect(jsonPath("$.lastname", Is.is(LASTNAME_1))) // + .andExpect(jsonPath("$.firstName", Is.is(FIRST_NAME_1))) // + .andExpect(jsonPath("$.lastName", Is.is(LAST_NAME_1))) // .andExpect(jsonPath("$.email", Is.is(EMAIL_1))) // .andExpect(jsonPath("$.userTeamList", Matchers.empty())) // .andExpect(jsonPath("$.isOkrChampion", Is.is(false))); @@ -160,8 +160,8 @@ void shouldSuccessfullyCreateUsers() throws Exception { .andExpect(jsonPath("$", Matchers.hasSize(1))) // .andExpect(jsonPath("$[0].id", Is.is(2))) // .andExpect(jsonPath("$[0].version", Is.is(3))) // - .andExpect(jsonPath("$[0].firstname", Is.is(FIRSTNAME_1))) // - .andExpect(jsonPath("$[0].lastname", Is.is(LASTNAME_1))) // + .andExpect(jsonPath("$[0].firstName", Is.is(FIRST_NAME_1))) // + .andExpect(jsonPath("$[0].lastName", Is.is(LAST_NAME_1))) // .andExpect(jsonPath("$[0].email", Is.is(EMAIL_1))) // .andExpect(jsonPath("$[0].userTeamList", Matchers.empty())) // .andExpect(jsonPath("$[0].isOkrChampion", Is.is(false))); diff --git a/backend/src/test/java/ch/puzzle/okr/deserializer/KeyResultDeserializerTest.java b/backend/src/test/java/ch/puzzle/okr/deserializer/KeyResultDeserializerTest.java index 1fc4e9ba5f..59ece3d1bb 100644 --- a/backend/src/test/java/ch/puzzle/okr/deserializer/KeyResultDeserializerTest.java +++ b/backend/src/test/java/ch/puzzle/okr/deserializer/KeyResultDeserializerTest.java @@ -46,8 +46,8 @@ void deserializeShouldReturnKeyResultMetricDtoForMetricJson() throws Exception { "unit": "NUMBER", "owner": { "id": 1000, - "firstname": "Jaya", - "lastname": "Norris" + "firstName": "Jaya", + "lastName": "Norris" }, "objective": { "id": 1000, @@ -95,8 +95,8 @@ private void assertKeyResultMetricDto(KeyResultMetricDto keyResultMetricDto) { private static void assertOwner(KeyResultUserDto owner) { assertNotNull(owner); assertEquals(1000, owner.id()); - assertEquals("Jaya", owner.firstname()); - assertEquals("Norris", owner.lastname()); + assertEquals("Jaya", owner.firstName()); + assertEquals("Norris", owner.lastName()); } private static void assertObjective(KeyResultObjectiveDto objective) { @@ -120,8 +120,8 @@ void deserializeShouldReturnKeyResultOrdinalDtoForOrdinalJson() throws Exception "stretchZone": "5", "owner": { "id": 1000, - "firstname": "Jaya", - "lastname": "Norris" + "firstName": "Jaya", + "lastName": "Norris" }, "objective": { "id": 1000, diff --git a/backend/src/test/java/ch/puzzle/okr/mapper/UserMapperTest.java b/backend/src/test/java/ch/puzzle/okr/mapper/UserMapperTest.java index 97239eb44d..4d6eb855ae 100644 --- a/backend/src/test/java/ch/puzzle/okr/mapper/UserMapperTest.java +++ b/backend/src/test/java/ch/puzzle/okr/mapper/UserMapperTest.java @@ -22,8 +22,8 @@ public class UserMapperTest { private static final long USER_TEAM_ID = 100L; private static final long ID = 0L; private static final int VERSION = 1; - private static final String FIRSTNAME = "firstname"; - private static final String LASTNAME = "lastname"; + private static final String FIRST_NAME = "firstname"; + private static final String LAST_NAME = "lastname"; private static final String EMAIL = "a@b.ch"; private static final boolean IS_OKR_CHAMPION = true; @@ -35,8 +35,8 @@ public class UserMapperTest { private final User user = User.Builder.builder() // .withId(ID) // .withVersion(VERSION) // - .withFirstname(FIRSTNAME) // - .withLastname(LASTNAME) // + .withFirstName(FIRST_NAME) // + .withLastName(LAST_NAME) // .withEmail(EMAIL) // .withUserTeamList(List.of(UserTeam.Builder.builder() // .withId(USER_TEAM_ID) // @@ -45,7 +45,7 @@ public class UserMapperTest { .isOkrChampion(IS_OKR_CHAMPION) // .build(); - private final NewUserDto userDto = new NewUserDto(FIRSTNAME, LASTNAME, EMAIL); + private final NewUserDto userDto = new NewUserDto(FIRST_NAME, LAST_NAME, EMAIL); @BeforeEach void setup() { @@ -59,8 +59,8 @@ void toDtoWithoutTeamListThrowsException() { User user = User.Builder.builder() // .withId(ID) // .withVersion(VERSION) // - .withFirstname(FIRSTNAME) // - .withLastname(LASTNAME) // + .withFirstName(FIRST_NAME) // + .withLastName(LAST_NAME) // .withEmail(EMAIL) // .isOkrChampion(IS_OKR_CHAMPION) // .build(); @@ -94,7 +94,7 @@ void toDtosShouldMapListOfUsersToDtos() { private void assertUserDto(User expected, UserDto actual) { assertEquals(expected.getId(), actual.id()); assertEquals(expected.getVersion(), actual.version()); - assertEquals(expected.getFirstname(), actual.firstname()); + assertEquals(expected.getFirstName(), actual.firstName()); assertEquals(expected.isOkrChampion(), actual.isOkrChampion()); assertEquals(expected.getEmail(), actual.email()); @@ -125,8 +125,8 @@ void toUserListShouldMapUserDtoListToUserList() { } private void assertUser(NewUserDto expected, User actual) { - assertEquals(expected.firstname(), actual.getFirstname()); - assertEquals(expected.lastname(), actual.getLastname()); + assertEquals(expected.firstName(), actual.getFirstName()); + assertEquals(expected.lastName(), actual.getLastName()); assertEquals(expected.email(), actual.getEmail()); } diff --git a/backend/src/test/java/ch/puzzle/okr/mapper/keyresult/helper/AssertHelper.java b/backend/src/test/java/ch/puzzle/okr/mapper/keyresult/helper/AssertHelper.java index fe66213e59..04c76373fe 100644 --- a/backend/src/test/java/ch/puzzle/okr/mapper/keyresult/helper/AssertHelper.java +++ b/backend/src/test/java/ch/puzzle/okr/mapper/keyresult/helper/AssertHelper.java @@ -159,14 +159,14 @@ private static void assertQuarter(KeyResultQuarterDto expected, Quarter actual) private static void assertOwnerDto(User expected, KeyResultUserDto actual) { assertEquals(expected.getId(), actual.id()); - assertEquals(expected.getFirstname(), actual.firstname()); - assertEquals(expected.getLastname(), actual.lastname()); + assertEquals(expected.getFirstName(), actual.firstName()); + assertEquals(expected.getLastName(), actual.lastName()); } private static void assertOwner(KeyResultUserDto expected, User actual) { assertEquals(expected.id(), actual.getId()); - assertEquals(expected.firstname(), actual.getFirstname()); - assertEquals(expected.lastname(), actual.getLastname()); + assertEquals(expected.firstName(), actual.getFirstName()); + assertEquals(expected.lastName(), actual.getLastName()); } private static void assertCheckInMetricDto(KeyResultLastCheckInMetricDto expected, diff --git a/backend/src/test/java/ch/puzzle/okr/mapper/keyresult/helper/TestDataConstants.java b/backend/src/test/java/ch/puzzle/okr/mapper/keyresult/helper/TestDataConstants.java index eff5381a5a..c80cc36c93 100644 --- a/backend/src/test/java/ch/puzzle/okr/mapper/keyresult/helper/TestDataConstants.java +++ b/backend/src/test/java/ch/puzzle/okr/mapper/keyresult/helper/TestDataConstants.java @@ -22,8 +22,8 @@ public class TestDataConstants { public static final boolean CHECK_IN_IS_WRITABLE = true; public static final long USER_ID = 101L; - public static final String USER_FIRSTNAME = "owner firstname"; - public static final String USER_LASTNAME = "owner lastname"; + public static final String USER_FIRST_NAME = "owner firstname"; + public static final String USER_LAST_NAME = "owner lastname"; public static final long QUARTER_ID = 102L; public static final String QUARTER_LABEL = "GJ 2024 Q1"; diff --git a/backend/src/test/java/ch/puzzle/okr/mapper/keyresult/helper/TestDataDtoHelper.java b/backend/src/test/java/ch/puzzle/okr/mapper/keyresult/helper/TestDataDtoHelper.java index ed836d442b..4ed2563d6c 100644 --- a/backend/src/test/java/ch/puzzle/okr/mapper/keyresult/helper/TestDataDtoHelper.java +++ b/backend/src/test/java/ch/puzzle/okr/mapper/keyresult/helper/TestDataDtoHelper.java @@ -25,8 +25,8 @@ public static KeyResultLastCheckInOrdinalDto lastCheckInOrdinalDto() { private static final KeyResultUserDto ownerDto = new KeyResultUserDto( // USER_ID, // - USER_FIRSTNAME, // - USER_LASTNAME // + USER_FIRST_NAME, // + USER_LAST_NAME // ); private static final KeyResultQuarterDto quarterDto = new KeyResultQuarterDto( // diff --git a/backend/src/test/java/ch/puzzle/okr/mapper/keyresult/helper/TestDataHelper.java b/backend/src/test/java/ch/puzzle/okr/mapper/keyresult/helper/TestDataHelper.java index 2aee112241..2569a354cd 100644 --- a/backend/src/test/java/ch/puzzle/okr/mapper/keyresult/helper/TestDataHelper.java +++ b/backend/src/test/java/ch/puzzle/okr/mapper/keyresult/helper/TestDataHelper.java @@ -73,8 +73,8 @@ public static Objective objective() { private static final User owner = User.Builder.builder() // .withId(USER_ID) // - .withFirstname(USER_FIRSTNAME) // - .withLastname(USER_LASTNAME) // + .withFirstName(USER_FIRST_NAME) // + .withLastName(USER_LAST_NAME) // .build(); private static final Quarter quarter = Quarter.Builder.builder() // diff --git a/backend/src/test/java/ch/puzzle/okr/security/JwtHelperTest.java b/backend/src/test/java/ch/puzzle/okr/security/JwtHelperTest.java index 6833a68f1a..30c88960b9 100644 --- a/backend/src/test/java/ch/puzzle/okr/security/JwtHelperTest.java +++ b/backend/src/test/java/ch/puzzle/okr/security/JwtHelperTest.java @@ -21,8 +21,8 @@ public class JwtHelperTest { - private static final String TOKEN_CLAIMS_KEY_FIRSTNAME = "given_name"; - private static final String TOKEN_CLAIMS_KEY_LASTNAME = "family_name"; + private static final String TOKEN_CLAIMS_KEY_FIRST_NAME = "given_name"; + private static final String TOKEN_CLAIMS_KEY_LAST_NAME = "family_name"; private static final String TOKEN_CLAIMS_KEY_EMAIL = "email"; private static final String HANS = "Hans"; private static final String MUSTER = "Muster"; @@ -38,20 +38,20 @@ void getUserFromJwtExtractsUserDataFromToken() { // arrange Jwt tokenWithUserDataMock = mock(Jwt.class); when(tokenWithUserDataMock.getClaims()).thenReturn(Map.of( // - TOKEN_CLAIMS_KEY_FIRSTNAME, HANS, // - TOKEN_CLAIMS_KEY_LASTNAME, MUSTER, // + TOKEN_CLAIMS_KEY_FIRST_NAME, HANS, // + TOKEN_CLAIMS_KEY_LAST_NAME, MUSTER, // TOKEN_CLAIMS_KEY_EMAIL, EMAIL // )); JwtHelper jwtHelper = new JwtHelper(null, // - TOKEN_CLAIMS_KEY_FIRSTNAME, TOKEN_CLAIMS_KEY_LASTNAME, TOKEN_CLAIMS_KEY_EMAIL); + TOKEN_CLAIMS_KEY_FIRST_NAME, TOKEN_CLAIMS_KEY_LAST_NAME, TOKEN_CLAIMS_KEY_EMAIL); // act User userFromToken = jwtHelper.getUserFromJwt(tokenWithUserDataMock); // assert - assertEquals(HANS, userFromToken.getFirstname()); - assertEquals(MUSTER, userFromToken.getLastname()); + assertEquals(HANS, userFromToken.getFirstName()); + assertEquals(MUSTER, userFromToken.getLastName()); assertEquals(EMAIL, userFromToken.getEmail()); } @@ -63,7 +63,7 @@ void getUserFromJwtThrowsExceptionIfTokenNotContainsUserData() { Jwt tokenWithNoUserDataMock = mock(Jwt.class); JwtHelper jwtHelper = new JwtHelper(null, // - TOKEN_CLAIMS_KEY_FIRSTNAME, TOKEN_CLAIMS_KEY_LASTNAME, TOKEN_CLAIMS_KEY_EMAIL); + TOKEN_CLAIMS_KEY_FIRST_NAME, TOKEN_CLAIMS_KEY_LAST_NAME, TOKEN_CLAIMS_KEY_EMAIL); // act + assert OkrResponseStatusException okrResponseStatusException = // diff --git a/backend/src/test/java/ch/puzzle/okr/service/authorization/AuthorizationRegistrationServiceIT.java b/backend/src/test/java/ch/puzzle/okr/service/authorization/AuthorizationRegistrationServiceIT.java index dc650ee4b5..9549c67c6d 100644 --- a/backend/src/test/java/ch/puzzle/okr/service/authorization/AuthorizationRegistrationServiceIT.java +++ b/backend/src/test/java/ch/puzzle/okr/service/authorization/AuthorizationRegistrationServiceIT.java @@ -87,8 +87,8 @@ void updateOrAddAuthorizationUserShouldAddAuthorizationUserToCache() { void updateOrAddAuthorizationUserShouldSetIsOkrChampionToFalse() { // arrange User user = User.Builder.builder() // - .withFirstname("Richard") // - .withLastname("Eberhard") // + .withFirstName("Richard") // + .withLastName("Eberhard") // .withEmail("richard.eberhard@puzzle.ch") // email not found in application-integration-test.properties .build(); @@ -126,8 +126,8 @@ void updateOrAddAuthorizationUserShouldSetIsOkrChampionToTrue() { // "okr.tenants.pitc.user.champion.emails" from application-integration-test.properties file AuthorizationUser processedUser = authorizationRegistrationService .updateOrAddAuthorizationUser(User.Builder.builder() // - .withFirstname("Alice") // - .withLastname("Wunderland") // + .withFirstName("Alice") // + .withLastName("Wunderland") // .withEmail(EMAIL_WUNDERLAND) // user.champion.emails from // application-integration-test.properties .build()); @@ -141,17 +141,17 @@ void updateOrAddAuthorizationUserShouldSetIsOkrChampionToTrue() { void updateOrAddAuthorizationUserShouldSetFirstnameAndLastnameFromToken() { // arrange User user = User.Builder.builder() // - .withFirstname("Richard") // - .withLastname("Eberhard") // + .withFirstName("Richard") // + .withLastName("Eberhard") // .withEmail("richard.eberhard@puzzle.ch") // .build(); userPersistenceService.save(user); - String firstnameFromToken = "Richu"; - String lastnameFromToken = "von Gunten"; + String firstNameFromToken = "Richu"; + String lastNameFromToken = "von Gunten"; User userFromToken = User.Builder.builder() // - .withFirstname(firstnameFromToken) // - .withLastname(lastnameFromToken) // + .withFirstName(firstNameFromToken) // + .withLastName(lastNameFromToken) // .withEmail("richard.eberhard@puzzle.ch") // .build(); @@ -161,8 +161,8 @@ void updateOrAddAuthorizationUserShouldSetFirstnameAndLastnameFromToken() { // assert Optional userFromDB = userPersistenceService.findByEmail(user.getEmail()); assertTrue(userFromDB.isPresent()); - assertEquals(userFromDB.get().getFirstname(), firstnameFromToken); - assertEquals(userFromDB.get().getLastname(), lastnameFromToken); + assertEquals(userFromDB.get().getFirstName(), firstNameFromToken); + assertEquals(userFromDB.get().getLastName(), lastNameFromToken); // cleanup userPersistenceService.deleteById(userFromDB.get().getId()); diff --git a/backend/src/test/java/ch/puzzle/okr/service/authorization/UserUpdateHelperTest.java b/backend/src/test/java/ch/puzzle/okr/service/authorization/UserUpdateHelperTest.java index 958eaac311..86a3d01135 100644 --- a/backend/src/test/java/ch/puzzle/okr/service/authorization/UserUpdateHelperTest.java +++ b/backend/src/test/java/ch/puzzle/okr/service/authorization/UserUpdateHelperTest.java @@ -22,14 +22,14 @@ void updateUserFromWithTokenData() { // arrange User userFromDB = User.Builder.builder() // .withId(23L) // - .withFirstname("firstname_from_db") // - .withLastname("lastname_from_db") // + .withFirstName("firstname_from_db") // + .withLastName("lastname_from_db") // .withEmail("a@b.ch") // .build(); User userFromToken = User.Builder.builder() // - .withFirstname("firstname_from_token") // - .withLastname("lastname_from_token") // + .withFirstName("firstname_from_token") // + .withLastName("lastname_from_token") // .build(); // act @@ -38,8 +38,8 @@ void updateUserFromWithTokenData() { // assert assertEquals(23L, updatedUser.getId()); assertEquals("a@b.ch", updatedUser.getEmail()); - assertEquals("firstname_from_token", updatedUser.getFirstname()); - assertEquals("lastname_from_token", updatedUser.getLastname()); + assertEquals("firstname_from_token", updatedUser.getFirstName()); + assertEquals("lastname_from_token", updatedUser.getLastName()); } @Test diff --git a/backend/src/test/java/ch/puzzle/okr/service/business/CheckInBusinessServiceTest.java b/backend/src/test/java/ch/puzzle/okr/service/business/CheckInBusinessServiceTest.java index 9a6d397863..366962fca1 100644 --- a/backend/src/test/java/ch/puzzle/okr/service/business/CheckInBusinessServiceTest.java +++ b/backend/src/test/java/ch/puzzle/okr/service/business/CheckInBusinessServiceTest.java @@ -36,7 +36,7 @@ class CheckInBusinessServiceTest { @InjectMocks private CheckInBusinessService checkInBusinessService; - private User user = User.Builder.builder().withEmail("Email").withFirstname("Firstname").withLastname("Lastname") + private User user = User.Builder.builder().withEmail("Email").withFirstName("Firstname").withLastName("Lastname") .build(); private KeyResult ordinalKeyResult = KeyResultOrdinal.Builder.builder().withCommitZone("Baum") .withStretchZone("Wald").withId(7L).withTitle("Keyresult Ordinal").build(); diff --git a/backend/src/test/java/ch/puzzle/okr/service/business/ObjectiveBusinessServiceTest.java b/backend/src/test/java/ch/puzzle/okr/service/business/ObjectiveBusinessServiceTest.java index 8901b1b7a5..70c0d52d2a 100644 --- a/backend/src/test/java/ch/puzzle/okr/service/business/ObjectiveBusinessServiceTest.java +++ b/backend/src/test/java/ch/puzzle/okr/service/business/ObjectiveBusinessServiceTest.java @@ -46,7 +46,7 @@ class ObjectiveBusinessServiceTest { private final Team team1 = Team.Builder.builder().withId(1L).withName("Team1").build(); private final Quarter quarter = Quarter.Builder.builder().withId(1L).withLabel("GJ 22/23-Q2").build(); - private final User user = User.Builder.builder().withId(1L).withFirstname("Bob").withLastname("Kaufmann") + private final User user = User.Builder.builder().withId(1L).withFirstName("Bob").withLastName("Kaufmann") .withEmail("kaufmann@puzzle.ch").build(); private final Objective objective = Objective.Builder.builder().withId(5L).withTitle("Objective 1").build(); private final Objective fullObjective = Objective.Builder.builder().withTitle("FullObjective1").withCreatedBy(user) diff --git a/backend/src/test/java/ch/puzzle/okr/service/business/TeamBusinessServiceTest.java b/backend/src/test/java/ch/puzzle/okr/service/business/TeamBusinessServiceTest.java index ee8cd88810..d6f3ec4be7 100644 --- a/backend/src/test/java/ch/puzzle/okr/service/business/TeamBusinessServiceTest.java +++ b/backend/src/test/java/ch/puzzle/okr/service/business/TeamBusinessServiceTest.java @@ -110,7 +110,7 @@ void getAllTeamsSortedShouldReturnSortedListUserTeamsFirst() { List userTeamList = List .of(UserTeam.Builder.builder().withUser(user).withTeam(userTeam).withId(1L).build()); AuthorizationUser authUser = new AuthorizationUser(User.Builder.builder().withId(user.getId()) - .withFirstname(user.getFirstname()).withLastname(user.getLastname()).withEmail(user.getEmail()) + .withFirstName(user.getFirstName()).withLastName(user.getLastName()).withEmail(user.getEmail()) .withUserTeamList(userTeamList).build()); when(teamPersistenceService.findAll()).thenReturn(teams); diff --git a/backend/src/test/java/ch/puzzle/okr/service/business/UserBusinessServiceTest.java b/backend/src/test/java/ch/puzzle/okr/service/business/UserBusinessServiceTest.java index 1fc4839cc9..68850445d6 100644 --- a/backend/src/test/java/ch/puzzle/okr/service/business/UserBusinessServiceTest.java +++ b/backend/src/test/java/ch/puzzle/okr/service/business/UserBusinessServiceTest.java @@ -40,15 +40,15 @@ class UserBusinessServiceTest { void setUp() { User userAlice = User.Builder.builder() // .withId(2L) // - .withFirstname("Alice") // - .withLastname("Wunderland") // + .withFirstName("Alice") // + .withLastName("Wunderland") // .withEmail("wunderland@puzzle.ch") // .build(); User userBob = User.Builder.builder() // .withId(9L) // - .withFirstname("Bob") // - .withLastname("Baumeister") // + .withFirstName("Bob") // + .withLastName("Baumeister") // .withEmail("baumeister@puzzle.ch") // .build(); @@ -63,12 +63,12 @@ void shouldReturnAllUsersCorrectly() throws ResponseStatusException { Assertions.assertThat(userList.size()).isEqualTo(2); Assertions.assertThat(userList.getFirst().getId()).isEqualTo(2); - Assertions.assertThat(userList.getFirst().getFirstname()).isEqualTo("Alice"); - Assertions.assertThat(userList.get(0).getLastname()).isEqualTo("Wunderland"); + Assertions.assertThat(userList.getFirst().getFirstName()).isEqualTo("Alice"); + Assertions.assertThat(userList.get(0).getLastName()).isEqualTo("Wunderland"); Assertions.assertThat(userList.get(0).getEmail()).isEqualTo("wunderland@puzzle.ch"); Assertions.assertThat(userList.get(1).getId()).isEqualTo(9); - Assertions.assertThat(userList.get(1).getFirstname()).isEqualTo("Bob"); - Assertions.assertThat(userList.get(1).getLastname()).isEqualTo("Baumeister"); + Assertions.assertThat(userList.get(1).getFirstName()).isEqualTo("Bob"); + Assertions.assertThat(userList.get(1).getLastName()).isEqualTo("Baumeister"); Assertions.assertThat(userList.get(1).getEmail()).isEqualTo("baumeister@puzzle.ch"); } @@ -81,49 +81,49 @@ void shouldReturnEmptyListOfUsers() throws ResponseStatusException { @Test void getUserByIdShouldReturnSingleUserWhenUserFound() { - User owner = User.Builder.builder().withId(1L).withFirstname("Bob").withLastname("Kaufmann") + User owner = User.Builder.builder().withId(1L).withFirstName("Bob").withLastName("Kaufmann") .withEmail("kaufmann@puzzle.ch").build(); Mockito.when(userPersistenceService.findById(any())).thenReturn(owner); User returnedUser = userBusinessService.getUserById(1L); assertEquals(1L, returnedUser.getId()); - assertEquals("Bob", returnedUser.getFirstname()); - assertEquals("Kaufmann", returnedUser.getLastname()); + assertEquals("Bob", returnedUser.getFirstName()); + assertEquals("Kaufmann", returnedUser.getLastName()); assertEquals("kaufmann@puzzle.ch", returnedUser.getEmail()); } @Test void getOrCreateUserShouldReturnSingleUserWhenUserFound() { - User newUser = User.Builder.builder().withId(1L).withFirstname("Bob").withLastname("Kaufmann") + User newUser = User.Builder.builder().withId(1L).withFirstName("Bob").withLastName("Kaufmann") .withEmail("kaufmann@puzzle.ch").build(); Mockito.when(userPersistenceService.getOrCreateUser(any())).thenReturn(newUser); User returnedUser = userBusinessService.getOrCreateUser(newUser); assertEquals(1L, returnedUser.getId()); - assertEquals("Bob", returnedUser.getFirstname()); - assertEquals("Kaufmann", returnedUser.getLastname()); + assertEquals("Bob", returnedUser.getFirstName()); + assertEquals("Kaufmann", returnedUser.getLastName()); assertEquals("kaufmann@puzzle.ch", returnedUser.getEmail()); } @Test void getOrCreateUserShouldReturnSavedUserWhenUserNotFound() { - User newUser = User.Builder.builder().withId(1L).withFirstname("Bob").withLastname("Kaufmann") + User newUser = User.Builder.builder().withId(1L).withFirstName("Bob").withLastName("Kaufmann") .withEmail("kaufmann@puzzle.ch").build(); Mockito.when(userPersistenceService.getOrCreateUser(newUser)).thenReturn(newUser); User returnedUser = userBusinessService.getOrCreateUser(newUser); assertEquals(1L, returnedUser.getId()); - assertEquals("Bob", returnedUser.getFirstname()); - assertEquals("Kaufmann", returnedUser.getLastname()); + assertEquals("Bob", returnedUser.getFirstName()); + assertEquals("Kaufmann", returnedUser.getLastName()); assertEquals("kaufmann@puzzle.ch", returnedUser.getEmail()); } @Test void getOrCreateUserShouldThrowResponseStatusExceptionWhenInvalidUser() { - User newUser = User.Builder.builder().withId(1L).withFirstname("Bob").withLastname("Kaufmann") + User newUser = User.Builder.builder().withId(1L).withFirstName("Bob").withLastName("Kaufmann") .withEmail("kaufmann@puzzle.ch").build(); Mockito.doThrow(new ResponseStatusException(HttpStatus.BAD_REQUEST, "Not allowed to give an id")) .when(validationService).validateOnGetOrCreate(newUser); diff --git a/backend/src/test/java/ch/puzzle/okr/service/persistence/AuthorizationCriteriaParametersTest.java b/backend/src/test/java/ch/puzzle/okr/service/persistence/AuthorizationCriteriaParametersTest.java index a67a67340f..ba2dee98bf 100644 --- a/backend/src/test/java/ch/puzzle/okr/service/persistence/AuthorizationCriteriaParametersTest.java +++ b/backend/src/test/java/ch/puzzle/okr/service/persistence/AuthorizationCriteriaParametersTest.java @@ -45,8 +45,8 @@ void setParametersShouldBeSuccessfulWhenUserIsOkrChampion() { // arrange var user = User.Builder.builder() // .withId(23L) // - .withFirstname("Hanna") // - .withLastname("muster") // + .withFirstName("Hanna") // + .withLastName("muster") // .withEmail("hanna.muster@example.com") // .isOkrChampion(true) // .build(); diff --git a/backend/src/test/java/ch/puzzle/okr/service/persistence/AuthorizationCriteriaTest.java b/backend/src/test/java/ch/puzzle/okr/service/persistence/AuthorizationCriteriaTest.java index 0ca3bcec41..c8b88ea426 100644 --- a/backend/src/test/java/ch/puzzle/okr/service/persistence/AuthorizationCriteriaTest.java +++ b/backend/src/test/java/ch/puzzle/okr/service/persistence/AuthorizationCriteriaTest.java @@ -38,8 +38,8 @@ void appendObjectiveShouldBeSuccessfulWhenUserIsOkrChampion() { // arrange var user = User.Builder.builder() // .withId(23L) // - .withFirstname("Hanna") // - .withLastname("muster") // + .withFirstName("Hanna") // + .withLastName("muster") // .withEmail("hanna.muster@example.com") // .isOkrChampion(true) // .build(); diff --git a/backend/src/test/java/ch/puzzle/okr/service/persistence/PersistenceBaseTestIT.java b/backend/src/test/java/ch/puzzle/okr/service/persistence/PersistenceBaseTestIT.java index 7f5a60a5e5..25ccb923bf 100644 --- a/backend/src/test/java/ch/puzzle/okr/service/persistence/PersistenceBaseTestIT.java +++ b/backend/src/test/java/ch/puzzle/okr/service/persistence/PersistenceBaseTestIT.java @@ -37,8 +37,8 @@ public class PersistenceBaseTestIT { private static final long NON_EXISTING_USER_ID = 321L; private static final long USER_PACO_ID = 1L; private static final User USER_WITHOUT_CONSTRAINTS = User.Builder.builder() // - .withFirstname("Hans") // - .withLastname("Muster") // + .withFirstName("Hans") // + .withLastName("Muster") // .withEmail("hans.muster@puzzle.ch") // .build(); @@ -135,16 +135,16 @@ void saveExistingEntityWithDifferentDataShouldUpdateExistingEntity() throws Resp var foundUser = persistenceBase.findById(createdUserId); // pro-condition - assertEquals("Hans", createdUser.getFirstname()); + assertEquals("Hans", createdUser.getFirstName()); // act - foundUser.setFirstname("Pekka"); + foundUser.setFirstName("Pekka"); persistenceBase.save(foundUser); foundUser = persistenceBase.findById(createdUserId); // assert assertEquals(createdUserId, foundUser.getId()); - assertEquals("Pekka", foundUser.getFirstname()); + assertEquals("Pekka", foundUser.getFirstName()); } @DisplayName("deleteById() should delete entity") @@ -164,8 +164,8 @@ void deleteByIdShouldDeleteEntity() throws ResponseStatusException { private static void assertUser(String expectedFirstName, String expectedLastName, String expectedEmail, User currentUser) { - assertEquals(expectedFirstName, currentUser.getFirstname()); - assertEquals(expectedLastName, currentUser.getLastname()); + assertEquals(expectedFirstName, currentUser.getFirstName()); + assertEquals(expectedLastName, currentUser.getLastName()); assertEquals(expectedEmail, currentUser.getEmail()); } diff --git a/backend/src/test/java/ch/puzzle/okr/service/persistence/UserPersistenceServiceIT.java b/backend/src/test/java/ch/puzzle/okr/service/persistence/UserPersistenceServiceIT.java index 38f02757c1..9f8b0ae232 100644 --- a/backend/src/test/java/ch/puzzle/okr/service/persistence/UserPersistenceServiceIT.java +++ b/backend/src/test/java/ch/puzzle/okr/service/persistence/UserPersistenceServiceIT.java @@ -46,8 +46,8 @@ void tearDown() { void saveShouldSaveUserWithEmptyUserTeamList() { // arrange var newUser = User.Builder.builder() // - .withFirstname("Hans") // - .withLastname("Muster") // + .withFirstName("Hans") // + .withLastName("Muster") // .withEmail("muster@puzzle.ch") // .withUserTeamList(List.of()).build(); @@ -64,8 +64,8 @@ void saveShouldSaveUserWithEmptyUserTeamList() { void saveShouldSaveUserWithNullUserTeamList() { // arrange var newUser = User.Builder.builder() // - .withFirstname("Hans") // - .withLastname("Muster") // + .withFirstName("Hans") // + .withLastName("Muster") // .withEmail("muster@puzzle.ch") // .withUserTeamList(null).build(); @@ -82,8 +82,8 @@ void saveShouldSaveUserWithNullUserTeamList() { void saveAllShouldSaveAllUsersInTheInputList() { // arrange var newUser = User.Builder.builder() // - .withFirstname("Hans") // - .withLastname("Muster") // + .withFirstName("Hans") // + .withLastName("Muster") // .withEmail("muster@puzzle.ch") // .build(); @@ -117,8 +117,8 @@ void getOrCreateUserShouldReturnSavedUserWhenUserNotFound() { // arrange var newUser = User.Builder.builder() // .withId(null) // - .withFirstname("firstname") // - .withLastname("lastname") // + .withFirstName("firstname") // + .withLastName("lastname") // .withEmail("lastname@puzzle.ch") // .build(); @@ -137,8 +137,8 @@ void findByEmailShouldReturnUserIfEmailIsFound() { Optional user = userPersistenceService.findByEmail("gl@gl.com"); assertTrue(user.isPresent()); - assertEquals("Jaya", user.get().getFirstname()); - assertEquals("Norris", user.get().getLastname()); + assertEquals("Jaya", user.get().getFirstName()); + assertEquals("Norris", user.get().getLastName()); } @DisplayName("findByEmail() should return empty optional if email is not found") @@ -171,14 +171,14 @@ void getModelNameShouldReturnUser() { assertEquals(USER, userPersistenceService.getModelName()); } - private void assertUser(Long id, String firstname, String lastname, String email, User currentUser) { + private void assertUser(Long id, String firstName, String lastName, String email, User currentUser) { assertEquals(id, currentUser.getId()); - assertUser(firstname, lastname, email, currentUser); + assertUser(firstName, lastName, email, currentUser); } - private void assertUser(String firstname, String lastname, String email, User currentUser) { - assertEquals(firstname, currentUser.getFirstname()); - assertEquals(lastname, currentUser.getLastname()); + private void assertUser(String firstName, String lastName, String email, User currentUser) { + assertEquals(firstName, currentUser.getFirstName()); + assertEquals(lastName, currentUser.getLastName()); assertEquals(email, currentUser.getEmail()); } @@ -201,8 +201,8 @@ void deleteByIdShouldDeleteUserWhenUserExists() { private User createUser() { User newUser = User.Builder.builder() // .withId(null) // - .withFirstname("firstname") // - .withLastname("lastname") // + .withFirstName("firstname") // + .withLastName("lastname") // .withEmail("lastname@puzzle.ch") // .build(); createdUser = userPersistenceService.getOrCreateUser(newUser); 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 b4a1801da5..482680d122 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 @@ -37,7 +37,7 @@ class CheckInValidationServiceTest { @MockBean CheckInPersistenceService checkInPersistenceService = Mockito.mock(CheckInPersistenceService.class); - private final User user = User.Builder.builder().withId(1L).withFirstname("Ruedi").withLastname("Grochde") + private final User user = User.Builder.builder().withId(1L).withFirstName("Ruedi").withLastName("Grochde") .withEmail("grochde@puzzle.ch").build(); private final Team team = Team.Builder.builder().withId(1L).withName("Team4").build(); private final Quarter quarter = Quarter.Builder.builder().withId(1L).withLabel("GJ 22/23-Q2").build(); 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 3fbe650e14..8dc1bdee2e 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 @@ -43,7 +43,7 @@ class CompletedValidationServiceTest { @BeforeEach void setUp() { - this.user = User.Builder.builder().withId(1L).withFirstname("Bob").withLastname("Kaufmann") + this.user = User.Builder.builder().withId(1L).withFirstName("Bob").withLastName("Kaufmann") .withEmail("kaufmann@puzzle.ch").build(); this.team = Team.Builder.builder().withId(1L).withName("Team1").build(); this.quarter = Quarter.Builder.builder().withId(1L).withLabel("GJ 22/23-Q2").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 518a7cbc2f..e848738acc 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 @@ -39,7 +39,7 @@ class KeyResultValidationServiceTest { @MockBean KeyResultPersistenceService keyResultPersistenceService = Mockito.mock(KeyResultPersistenceService.class); - private final User user = User.Builder.builder().withId(1L).withFirstname("Bob").withLastname("Kaufmann") + private final User user = User.Builder.builder().withId(1L).withFirstName("Bob").withLastName("Kaufmann") .withEmail("kaufmann@puzzle.ch").build(); private final Quarter quarter = Quarter.Builder.builder().withId(1L).withLabel("GJ 22/23-Q2").build(); private final Team team = Team.Builder.builder().withId(1L).withName("Team1").build(); 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 a2544d1975..6fdc1e04fb 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 @@ -70,7 +70,7 @@ private static Stream nameValidationArguments() { @BeforeEach void setUp() { - this.user = User.Builder.builder().withId(1L).withFirstname("Bob").withLastname("Kaufmann") + this.user = User.Builder.builder().withId(1L).withFirstName("Bob").withLastName("Kaufmann") .withEmail("kaufmann@puzzle.ch").build(); this.team = Team.Builder.builder().withId(1L).withName("Team1").build(); this.quarter = Quarter.Builder.builder().withId(1L).withLabel("GJ 22/23-Q2") @@ -185,7 +185,7 @@ void validateOnCreateShouldThrowExceptionWhenAttrModifiedByIsSet() { OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnCreate(objectiveInvalid)); List expectedErrors = List.of(new ErrorDto("ATTRIBUTE_SET_FORBIDDEN", List.of("ModifiedBy", - "User{id=1, version=0, firstname='Bob', lastname='Kaufmann', email='kaufmann@puzzle.ch', okrChampion='false'}"))); + "User{id=1, version=0, firstName='Bob', lastName='Kaufmann', email='kaufmann@puzzle.ch', okrChampion='false'}"))); assertEquals(BAD_REQUEST, exception.getStatusCode()); assertThat(expectedErrors).hasSameElementsAs(exception.getErrors()); diff --git a/backend/src/test/java/ch/puzzle/okr/service/validation/UserValidationServiceTest.java b/backend/src/test/java/ch/puzzle/okr/service/validation/UserValidationServiceTest.java index db6f28dc23..c3d40c3444 100644 --- a/backend/src/test/java/ch/puzzle/okr/service/validation/UserValidationServiceTest.java +++ b/backend/src/test/java/ch/puzzle/okr/service/validation/UserValidationServiceTest.java @@ -42,10 +42,10 @@ class UserValidationServiceTest { @BeforeEach void setUp() { - user = User.Builder.builder().withId(1L).withFirstname("Bob").withLastname("Kaufmann") + user = User.Builder.builder().withId(1L).withFirstName("Bob").withLastName("Kaufmann") .withEmail("kaufmann@puzzle.ch").build(); - userMinimal = User.Builder.builder().withFirstname("Max").withLastname("Mustermann") + userMinimal = User.Builder.builder().withFirstName("Max").withLastName("Mustermann") .withEmail("max@mustermann.com").build(); when(userPersistenceService.findById(1L)).thenReturn(user); @@ -59,38 +59,38 @@ void setUp() { @InjectMocks private UserValidationService validator; - private static Stream firstnameValidationArguments() { + private static Stream firstNameValidationArguments() { return Stream.of( arguments(StringUtils.repeat('1', 51), - List.of(new ErrorDto("ATTRIBUTE_SIZE_BETWEEN", List.of("firstname", "User", "2", "50")))), + List.of(new ErrorDto("ATTRIBUTE_SIZE_BETWEEN", List.of("firstName", "User", "2", "50")))), arguments(StringUtils.repeat('1', 1), - List.of(new ErrorDto("ATTRIBUTE_SIZE_BETWEEN", List.of("firstname", "User", "2", "50")))), + List.of(new ErrorDto("ATTRIBUTE_SIZE_BETWEEN", List.of("firstName", "User", "2", "50")))), arguments("", - List.of(new ErrorDto("ATTRIBUTE_NOT_BLANK", List.of("firstname", "User")), - new ErrorDto("ATTRIBUTE_SIZE_BETWEEN", List.of("firstname", "User", "2", "50")))), + List.of(new ErrorDto("ATTRIBUTE_NOT_BLANK", List.of("firstName", "User")), + new ErrorDto("ATTRIBUTE_SIZE_BETWEEN", List.of("firstName", "User", "2", "50")))), arguments(" ", - List.of(new ErrorDto("ATTRIBUTE_NOT_BLANK", List.of("firstname", "User")), - new ErrorDto("ATTRIBUTE_SIZE_BETWEEN", List.of("firstname", "User", "2", "50")))), - arguments(" ", List.of(new ErrorDto("ATTRIBUTE_NOT_BLANK", List.of("firstname", "User")))), - arguments(null, List.of(new ErrorDto("ATTRIBUTE_NOT_BLANK", List.of("firstname", "User")), - new ErrorDto("ATTRIBUTE_NOT_NULL", List.of("firstname", "User"))))); + List.of(new ErrorDto("ATTRIBUTE_NOT_BLANK", List.of("firstName", "User")), + new ErrorDto("ATTRIBUTE_SIZE_BETWEEN", List.of("firstName", "User", "2", "50")))), + arguments(" ", List.of(new ErrorDto("ATTRIBUTE_NOT_BLANK", List.of("firstName", "User")))), + arguments(null, List.of(new ErrorDto("ATTRIBUTE_NOT_BLANK", List.of("firstName", "User")), + new ErrorDto("ATTRIBUTE_NOT_NULL", List.of("firstName", "User"))))); } - private static Stream lastnameValidationArguments() { + private static Stream lastNameValidationArguments() { return Stream.of( arguments(StringUtils.repeat('1', 51), - List.of(new ErrorDto("ATTRIBUTE_SIZE_BETWEEN", List.of("lastname", "User", "2", "50")))), + List.of(new ErrorDto("ATTRIBUTE_SIZE_BETWEEN", List.of("lastName", "User", "2", "50")))), arguments(StringUtils.repeat('1', 1), - List.of(new ErrorDto("ATTRIBUTE_SIZE_BETWEEN", List.of("lastname", "User", "2", "50")))), + List.of(new ErrorDto("ATTRIBUTE_SIZE_BETWEEN", List.of("lastName", "User", "2", "50")))), arguments("", - List.of(new ErrorDto("ATTRIBUTE_NOT_BLANK", List.of("lastname", "User")), - new ErrorDto("ATTRIBUTE_SIZE_BETWEEN", List.of("lastname", "User", "2", "50")))), + List.of(new ErrorDto("ATTRIBUTE_NOT_BLANK", List.of("lastName", "User")), + new ErrorDto("ATTRIBUTE_SIZE_BETWEEN", List.of("lastName", "User", "2", "50")))), arguments(" ", - List.of(new ErrorDto("ATTRIBUTE_NOT_BLANK", List.of("lastname", "User")), - new ErrorDto("ATTRIBUTE_SIZE_BETWEEN", List.of("lastname", "User", "2", "50")))), - arguments(" ", List.of(new ErrorDto("ATTRIBUTE_NOT_BLANK", List.of("lastname", "User")))), - arguments(null, List.of(new ErrorDto("ATTRIBUTE_NOT_BLANK", List.of("lastname", "User")), - new ErrorDto("ATTRIBUTE_NOT_NULL", List.of("lastname", "User"))))); + List.of(new ErrorDto("ATTRIBUTE_NOT_BLANK", List.of("lastName", "User")), + new ErrorDto("ATTRIBUTE_SIZE_BETWEEN", List.of("lastName", "User", "2", "50")))), + arguments(" ", List.of(new ErrorDto("ATTRIBUTE_NOT_BLANK", List.of("lastName", "User")))), + arguments(null, List.of(new ErrorDto("ATTRIBUTE_NOT_BLANK", List.of("lastName", "User")), + new ErrorDto("ATTRIBUTE_NOT_NULL", List.of("lastName", "User"))))); } private static Stream emailValidationArguments() { @@ -189,9 +189,9 @@ void validateOnCreateShouldThrowExceptionWhenIdIsNotNull() { } @ParameterizedTest - @MethodSource("firstnameValidationArguments") + @MethodSource("firstNameValidationArguments") void validateOnCreateShouldThrowExceptionWhenFirstnameIsInvalid(String name, List errors) { - User user = User.Builder.builder().withEmail("max@mail.com").withFirstname(name).withLastname("lastname") + User user = User.Builder.builder().withEmail("max@mail.com").withFirstName(name).withLastName("lastname") .build(); OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, @@ -203,9 +203,9 @@ void validateOnCreateShouldThrowExceptionWhenFirstnameIsInvalid(String name, Lis } @ParameterizedTest - @MethodSource("lastnameValidationArguments") + @MethodSource("lastNameValidationArguments") void validateOnCreateShouldThrowExceptionWhenLastnameIsInvalid(String name, List errors) { - User user = User.Builder.builder().withEmail("max@mail.com").withFirstname("firstname").withLastname(name) + User user = User.Builder.builder().withEmail("max@mail.com").withFirstName("firstname").withLastName(name) .build(); OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, @@ -219,7 +219,7 @@ void validateOnCreateShouldThrowExceptionWhenLastnameIsInvalid(String name, List @ParameterizedTest @MethodSource("emailValidationArguments") void validateOnCreateShouldThrowExceptionWhenEmailIsInvalid(String email, List errors) { - User user = User.Builder.builder().withEmail(email).withFirstname("firstname").withLastname("lastname").build(); + User user = User.Builder.builder().withEmail(email).withFirstName("firstname").withLastName("lastname").build(); OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnCreate(user)); @@ -231,7 +231,7 @@ void validateOnCreateShouldThrowExceptionWhenEmailIsInvalid(String email, List validator.validateOnCreate(userInvalid)); @@ -297,10 +297,10 @@ void validateOnUpdateShouldThrowExceptionWhenIdHasChanged() { } @ParameterizedTest - @MethodSource("firstnameValidationArguments") + @MethodSource("firstNameValidationArguments") void validateOnUpdateShouldThrowExceptionWhenFirstnameIsInvalid(String name, List errors) { - User user = User.Builder.builder().withId(3L).withEmail("max@mail.com").withFirstname(name) - .withLastname("lastname").build(); + User user = User.Builder.builder().withId(3L).withEmail("max@mail.com").withFirstName(name) + .withLastName("lastname").build(); OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnUpdate(3L, user)); @@ -311,10 +311,10 @@ void validateOnUpdateShouldThrowExceptionWhenFirstnameIsInvalid(String name, Lis } @ParameterizedTest - @MethodSource("lastnameValidationArguments") + @MethodSource("lastNameValidationArguments") void validateOnUpdateShouldThrowExceptionWhenLastnameIsInvalid(String name, List errors) { - User user = User.Builder.builder().withId(3L).withEmail("max@mail.com").withFirstname("firstname") - .withLastname(name).build(); + User user = User.Builder.builder().withId(3L).withEmail("max@mail.com").withFirstName("firstname") + .withLastName(name).build(); OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnUpdate(3L, user)); @@ -327,8 +327,8 @@ void validateOnUpdateShouldThrowExceptionWhenLastnameIsInvalid(String name, List @ParameterizedTest @MethodSource("emailValidationArguments") void validateOnUpdateShouldThrowExceptionWhenEmailIsInvalid(String email, List errors) { - User user = User.Builder.builder().withId(3L).withEmail(email).withFirstname("firstname") - .withLastname("lastname").build(); + User user = User.Builder.builder().withId(3L).withEmail(email).withFirstName("firstname") + .withLastName("lastname").build(); OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class, () -> validator.validateOnUpdate(3L, user)); @@ -340,7 +340,7 @@ void validateOnUpdateShouldThrowExceptionWhenEmailIsInvalid(String email, List validator.validateOnUpdate(3L, userInvalid)); diff --git a/backend/src/test/java/ch/puzzle/okr/test/CheckInTestHelpers.java b/backend/src/test/java/ch/puzzle/okr/test/CheckInTestHelpers.java index 303e1c8beb..7fc2c83bf4 100644 --- a/backend/src/test/java/ch/puzzle/okr/test/CheckInTestHelpers.java +++ b/backend/src/test/java/ch/puzzle/okr/test/CheckInTestHelpers.java @@ -48,12 +48,12 @@ public class CheckInTestHelpers { static final Objective objective = Objective.Builder.builder().withId(1L).build(); public static final CheckIn checkInMetric = CheckInMetric.Builder.builder().withValue(30D).withConfidence(5) .withChangeInfo(CHANGE_INFO).withInitiatives(INITIATIVES) - .withCreatedBy(User.Builder.builder().withId(1L).withFirstname("Frank").build()) + .withCreatedBy(User.Builder.builder().withId(1L).withFirstName("Frank").build()) .withKeyResult(KeyResultMetric.Builder.builder().withBaseline(3.0).withStretchGoal(6.0).withId(8L) .withObjective(objective).build()) .build(); public static final CheckIn checkInOrdinal = CheckInOrdinal.Builder.builder().withZone(Zone.COMMIT).withId(4L) - .withCreatedBy(User.Builder.builder().withId(2L).withFirstname("Robert").build()) + .withCreatedBy(User.Builder.builder().withId(2L).withFirstName("Robert").build()) .withCreatedOn(LocalDateTime.MAX).withChangeInfo(CHANGE_INFO).withInitiatives(INITIATIVES) .withKeyResult( KeyResultOrdinal.Builder.builder().withCommitZone("Baum").withTargetZone("Wald").withId(9L).build()) diff --git a/backend/src/test/java/ch/puzzle/okr/test/KeyResultTestHelpers.java b/backend/src/test/java/ch/puzzle/okr/test/KeyResultTestHelpers.java index 27f175ccb1..e1a950f12e 100644 --- a/backend/src/test/java/ch/puzzle/okr/test/KeyResultTestHelpers.java +++ b/backend/src/test/java/ch/puzzle/okr/test/KeyResultTestHelpers.java @@ -34,8 +34,8 @@ public class KeyResultTestHelpers { public static final String STRETCH_ZONE = "Ein Wald"; public static final String QUARTER_LABEL = "GJ 22/23-Q4"; public static final Zone LAST_CHECK_IN_ZONE = Zone.COMMIT; - public static final String FIRSTNAME = "Johnny"; - public static final String LASTNAME = "Appleseed"; + public static final String FIRST_NAME = "Johnny"; + public static final String LAST_NAME = "Appleseed"; public static final String START_DATE = "-999999999-01-01"; public static final Unit KEY_RESULT_UNIT = Unit.FTE; public static final String KEY_RESULT_CREATED_ON = "-999999999-01-01T00:00:00"; @@ -48,7 +48,7 @@ public class KeyResultTestHelpers { public static final String JSON_PATH_DESCRIPTION = "$.description"; public static final String JSON_PATH_KEY_RESULT_TYPE = "$.keyResultType"; public static final String JSON_PATH_STRETCH_GOAL = "$.stretchGoal"; - public static final String JSON_PATH_OWNER_FIRSTNAME = "$.owner.firstname"; + public static final String JSON_PATH_OWNER_FIRST_NAME = "$.owner.firstName"; public static final String JSON_PATH_OBJECTIVE_STATE = "$.objective.state"; public static final String JSON_PATH_ID_LAST_CHECK_IN_VALUE = "$.lastCheckIn.value"; public static final String JSON_PATH_LAST_CHECK_IN_CONFIDENCE = "$.lastCheckIn.confidence"; @@ -78,7 +78,7 @@ public class KeyResultTestHelpers { static final String INITIATIVES_2 = "Initiatives2"; static final String CHANGE_INFO_1 = "Changeinfo1"; static final String CHANGE_INFO_2 = "Changeinfo2"; - public static final User user = User.Builder.builder().withId(1L).withFirstname("Bob").withLastname("Kaufmann") + public static final User user = User.Builder.builder().withId(1L).withFirstName("Bob").withLastName("Kaufmann") .withEmail("kaufmann@puzzle.ch").build(); public static final KeyResult metricKeyResult = KeyResultMetric.Builder.builder().withId(5L).withTitle(TITLE) .build(); @@ -93,7 +93,7 @@ public class KeyResultTestHelpers { public static final CheckInDto checkInDto2 = new CheckInMetricDto(4L, 1, CHANGE_INFO_2, INITIATIVES_2, 5, metricKeyResult.getId(), LocalDateTime.MAX, LocalDateTime.MAX, 12D, true); - public static final KeyResultUserDto keyResultUserDto = new KeyResultUserDto(1L, FIRSTNAME, LASTNAME); + public static final KeyResultUserDto keyResultUserDto = new KeyResultUserDto(1L, FIRST_NAME, LAST_NAME); public static final KeyResultQuarterDto keyResultQuarterDto = new KeyResultQuarterDto(1L, QUARTER_LABEL, LocalDate.MIN, LocalDate.MAX); public static final KeyResultLastCheckInMetricDto keyResultLastCheckInDto = new KeyResultLastCheckInMetricDto(1L, 1, diff --git a/backend/src/test/java/ch/puzzle/okr/test/TestHelper.java b/backend/src/test/java/ch/puzzle/okr/test/TestHelper.java index 4033066578..d190875a47 100644 --- a/backend/src/test/java/ch/puzzle/okr/test/TestHelper.java +++ b/backend/src/test/java/ch/puzzle/okr/test/TestHelper.java @@ -21,12 +21,12 @@ private TestHelper() { public static final String SCHEMA_PITC = "pitc"; - private static final String FIRSTNAME = "Bob"; - private static final String LASTNAME = "Kaufmann"; + private static final String FIRST_NAME = "Bob"; + private static final String LAST_NAME = "Kaufmann"; private static final String EMAIL = "kaufmann@puzzle.ch"; public static User defaultUser(Long id) { - return User.Builder.builder().withId(id).withFirstname(FIRSTNAME).withLastname(LASTNAME).withEmail(EMAIL) + return User.Builder.builder().withId(id).withFirstName(FIRST_NAME).withLastName(LAST_NAME).withEmail(EMAIL) .build(); } @@ -56,20 +56,20 @@ public static UserTeam defaultUserTeam(Long id, User user) { } public static AuthorizationUser defaultAuthorizationUser() { - return mockAuthorizationUser(1L, FIRSTNAME, LASTNAME, EMAIL, false); + return mockAuthorizationUser(1L, FIRST_NAME, LAST_NAME, EMAIL, false); } public static AuthorizationUser mockAuthorizationUser(User user) { - return mockAuthorizationUser(user.getId(), user.getFirstname(), user.getLastname(), user.getEmail(), + return mockAuthorizationUser(user.getId(), user.getFirstName(), user.getLastName(), user.getEmail(), user.isOkrChampion()); } - public static AuthorizationUser mockAuthorizationUser(Long id, String firstname, String lastname, String email, + public static AuthorizationUser mockAuthorizationUser(Long id, String firstName, String lastName, String email, boolean isOkrChampion) { User user = User.Builder.builder() // .withId(id) // - .withFirstname(firstname) // - .withLastname(lastname) // + .withFirstName(firstName) // + .withLastName(lastName) // .withEmail(email) // .isOkrChampion(isOkrChampion) // .build(); @@ -78,14 +78,14 @@ public static AuthorizationUser mockAuthorizationUser(Long id, String firstname, } public static Jwt defaultJwtToken() { - return mockJwtToken(FIRSTNAME, LASTNAME, EMAIL); + return mockJwtToken(FIRST_NAME, LAST_NAME, EMAIL); } public static Jwt mockJwtToken(User user) { - return mockJwtToken(user.getFirstname(), user.getLastname(), user.getEmail()); + return mockJwtToken(user.getFirstName(), user.getLastName(), user.getEmail()); } - public static Jwt mockJwtToken(String firstname, String lastname, String email) { + public static Jwt mockJwtToken(String firstName, String lastName, String email) { String exampleToken = "MockToken"; Map headers = new HashMap<>(); @@ -93,8 +93,8 @@ public static Jwt mockJwtToken(String firstname, String lastname, String email) headers.put("typ", "JWT"); Map claims = new HashMap<>(); - claims.put("given_name", firstname); - claims.put("family_name", lastname); + claims.put("given_name", firstName); + claims.put("family_name", lastName); claims.put("email", email); claims.put("exp", Instant.now().plusSeconds(3600).getEpochSecond()); // Expires in 1 hour