From 276e394dade2a69bcdafd384d81f707932c5b12d Mon Sep 17 00:00:00 2001 From: fortamt Date: Wed, 13 Jul 2022 10:10:47 +0300 Subject: [PATCH 01/10] - added fields following #544 task --- .../softserveinc/dokazovi/dto/user/UserDTO.java | 8 +++++++- .../dokazovi/entity/DoctorEntity.java | 3 --- .../softserveinc/dokazovi/entity/UserEntity.java | 16 ++++++++++++++++ .../dokazovi/repositories/UserRepository.java | 3 ++- .../dokazovi/service/impl/UserServiceImpl.java | 4 ++++ .../V24__add_column_editedAt_for_users.sql | 2 ++ ...emoved_social_network_column_from_doctors.sql | 12 ++++++++++++ ...e_table_social_networks_and_rename_column.sql | 2 ++ .../V27__rename_column_social_network.sql | 1 + .../V28__add_column_region_for_users.sql | 2 ++ .../service/impl/UserServiceImplTest.java | 4 ++++ 11 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/db/migration/V24__add_column_editedAt_for_users.sql create mode 100644 src/main/resources/db/migration/V25__add_social_network_table_and_removed_social_network_column_from_doctors.sql create mode 100644 src/main/resources/db/migration/V26__rename_table_social_networks_and_rename_column.sql create mode 100644 src/main/resources/db/migration/V27__rename_column_social_network.sql create mode 100644 src/main/resources/db/migration/V28__add_column_region_for_users.sql diff --git a/src/main/java/com/softserveinc/dokazovi/dto/user/UserDTO.java b/src/main/java/com/softserveinc/dokazovi/dto/user/UserDTO.java index aa78c52c..483cbf15 100644 --- a/src/main/java/com/softserveinc/dokazovi/dto/user/UserDTO.java +++ b/src/main/java/com/softserveinc/dokazovi/dto/user/UserDTO.java @@ -4,6 +4,7 @@ import lombok.Builder; import lombok.Data; +import java.sql.Timestamp; import java.util.Set; /** @@ -30,7 +31,9 @@ public class UserDTO { private String bio; - private String socialNetwork; + private String region; + + private Set socialNetworks; private Set directions; @@ -40,4 +43,7 @@ public class UserDTO { private LatestUserPostDTO lastAddedPost; + private Timestamp createdAt; + + private Timestamp editedAt; } diff --git a/src/main/java/com/softserveinc/dokazovi/entity/DoctorEntity.java b/src/main/java/com/softserveinc/dokazovi/entity/DoctorEntity.java index 91f116bc..3d536bd9 100644 --- a/src/main/java/com/softserveinc/dokazovi/entity/DoctorEntity.java +++ b/src/main/java/com/softserveinc/dokazovi/entity/DoctorEntity.java @@ -51,9 +51,6 @@ public class DoctorEntity { @Column(columnDefinition = "TEXT") private String bio; - @Column(columnDefinition = "TEXT") - private String socialNetwork; - @ColumnDefault("1.0") private Double promotionScale; diff --git a/src/main/java/com/softserveinc/dokazovi/entity/UserEntity.java b/src/main/java/com/softserveinc/dokazovi/entity/UserEntity.java index 47322d42..ac8365f9 100644 --- a/src/main/java/com/softserveinc/dokazovi/entity/UserEntity.java +++ b/src/main/java/com/softserveinc/dokazovi/entity/UserEntity.java @@ -11,7 +11,9 @@ import org.hibernate.annotations.CreationTimestamp; import javax.persistence.CascadeType; +import javax.persistence.CollectionTable; import javax.persistence.Column; +import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; @@ -70,6 +72,20 @@ public class UserEntity { @CreationTimestamp private Timestamp createdAt; + @EqualsAndHashCode.Exclude + private Timestamp editedAt; + + private String region; + + @ElementCollection + @CollectionTable( + name = "users_social_networks", + joinColumns = @JoinColumn(name = "user_id")) + @Column(name = "link") + @EqualsAndHashCode.Exclude + @ToString.Exclude + private Set socialNetworks; + @OneToMany(fetch = FetchType.EAGER, mappedBy = "user", cascade = CascadeType.ALL) @EqualsAndHashCode.Exclude @ToString.Exclude diff --git a/src/main/java/com/softserveinc/dokazovi/repositories/UserRepository.java b/src/main/java/com/softserveinc/dokazovi/repositories/UserRepository.java index 2f48a1b3..a66fc329 100644 --- a/src/main/java/com/softserveinc/dokazovi/repositories/UserRepository.java +++ b/src/main/java/com/softserveinc/dokazovi/repositories/UserRepository.java @@ -80,8 +80,9 @@ public interface UserRepository extends JpaRepository { * @return the resulting user entity page */ @Query(nativeQuery = true, - value = " SELECT U.* FROM DOCTORS D " + value = " SELECT U.*, SN.LINK FROM DOCTORS D " + " JOIN USERS U ON U.USER_ID = D.USER_ID " + + " JOIN USERS_SOCIAL_NETWORKS SN ON D.USER_ID = SN.USER_ID" + " ORDER BY D.PROMOTION_LEVEL DESC, D.RATING DESC, " + " U.LAST_NAME, U.FIRST_NAME ") Page findDoctorsProfiles(Pageable pageable); diff --git a/src/main/java/com/softserveinc/dokazovi/service/impl/UserServiceImpl.java b/src/main/java/com/softserveinc/dokazovi/service/impl/UserServiceImpl.java index f964efd1..f7481aec 100644 --- a/src/main/java/com/softserveinc/dokazovi/service/impl/UserServiceImpl.java +++ b/src/main/java/com/softserveinc/dokazovi/service/impl/UserServiceImpl.java @@ -21,6 +21,9 @@ import org.springframework.util.CollectionUtils; import javax.transaction.Transactional; +import java.sql.Date; +import java.sql.Timestamp; +import java.time.LocalDateTime; import java.util.Set; import java.util.UUID; @@ -232,6 +235,7 @@ public UserEntity update(UserEntity user) { if (user != null) { UserEntity oldUser = getById(user.getId()); if (oldUser != null) { + user.setEditedAt(new Timestamp(System.currentTimeMillis())); return userRepository.save(user); } } diff --git a/src/main/resources/db/migration/V24__add_column_editedAt_for_users.sql b/src/main/resources/db/migration/V24__add_column_editedAt_for_users.sql new file mode 100644 index 00000000..b4cedfab --- /dev/null +++ b/src/main/resources/db/migration/V24__add_column_editedAt_for_users.sql @@ -0,0 +1,2 @@ +alter table public.users + add column EDITED_AT timestamp; \ No newline at end of file diff --git a/src/main/resources/db/migration/V25__add_social_network_table_and_removed_social_network_column_from_doctors.sql b/src/main/resources/db/migration/V25__add_social_network_table_and_removed_social_network_column_from_doctors.sql new file mode 100644 index 00000000..dcaf2613 --- /dev/null +++ b/src/main/resources/db/migration/V25__add_social_network_table_and_removed_social_network_column_from_doctors.sql @@ -0,0 +1,12 @@ +create table if not exists SOCIAL_NETWORKS( + user_id integer not null + constraint social_networks_user_id_fkey + references users, + link varchar +); + +insert into SOCIAL_NETWORKS (user_id, link) +select user_id, social_network from DOCTORS; + +alter table public.doctors +drop column social_network; \ No newline at end of file diff --git a/src/main/resources/db/migration/V26__rename_table_social_networks_and_rename_column.sql b/src/main/resources/db/migration/V26__rename_table_social_networks_and_rename_column.sql new file mode 100644 index 00000000..8fee07a3 --- /dev/null +++ b/src/main/resources/db/migration/V26__rename_table_social_networks_and_rename_column.sql @@ -0,0 +1,2 @@ +alter table social_networks rename column link to social_networks; +alter table social_networks rename to users_social_networks; \ No newline at end of file diff --git a/src/main/resources/db/migration/V27__rename_column_social_network.sql b/src/main/resources/db/migration/V27__rename_column_social_network.sql new file mode 100644 index 00000000..90bc2e67 --- /dev/null +++ b/src/main/resources/db/migration/V27__rename_column_social_network.sql @@ -0,0 +1 @@ +alter table users_social_networks rename column social_networks to link; \ No newline at end of file diff --git a/src/main/resources/db/migration/V28__add_column_region_for_users.sql b/src/main/resources/db/migration/V28__add_column_region_for_users.sql new file mode 100644 index 00000000..8e0e578c --- /dev/null +++ b/src/main/resources/db/migration/V28__add_column_region_for_users.sql @@ -0,0 +1,2 @@ +alter table public.users + add column REGION varchar; \ No newline at end of file diff --git a/src/test/java/com/softserveinc/dokazovi/service/impl/UserServiceImplTest.java b/src/test/java/com/softserveinc/dokazovi/service/impl/UserServiceImplTest.java index db972ef3..f4792c77 100644 --- a/src/test/java/com/softserveinc/dokazovi/service/impl/UserServiceImplTest.java +++ b/src/test/java/com/softserveinc/dokazovi/service/impl/UserServiceImplTest.java @@ -22,6 +22,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.security.crypto.password.PasswordEncoder; +import java.sql.Timestamp; import java.time.LocalDateTime; import java.util.HashSet; import java.util.List; @@ -440,8 +441,11 @@ void updateUserEntityTest() { UserEntity userEntity = userService.getById(1); userEntity.setEmail(expectedEmail); when(userRepository.save(any(UserEntity.class))).thenReturn(expected); + Assertions.assertNull(expected.getEditedAt()); UserEntity actual = userService.update(userEntity); Assertions.assertEquals(expectedEmail, actual.getEmail()); + Assertions.assertNotNull(actual.getEditedAt()); + } @Test From 045770db77d0037163361a7565480e27d26521e1 Mon Sep 17 00:00:00 2001 From: fortamt Date: Wed, 13 Jul 2022 10:20:54 +0300 Subject: [PATCH 02/10] - removed import --- .../com/softserveinc/dokazovi/service/impl/UserServiceImpl.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/softserveinc/dokazovi/service/impl/UserServiceImpl.java b/src/main/java/com/softserveinc/dokazovi/service/impl/UserServiceImpl.java index f7481aec..25884ac7 100644 --- a/src/main/java/com/softserveinc/dokazovi/service/impl/UserServiceImpl.java +++ b/src/main/java/com/softserveinc/dokazovi/service/impl/UserServiceImpl.java @@ -21,9 +21,7 @@ import org.springframework.util.CollectionUtils; import javax.transaction.Transactional; -import java.sql.Date; import java.sql.Timestamp; -import java.time.LocalDateTime; import java.util.Set; import java.util.UUID; From bdb0e1655c9a88c5111fc324021f4c84586ef0ef Mon Sep 17 00:00:00 2001 From: fortamt Date: Wed, 13 Jul 2022 10:26:12 +0300 Subject: [PATCH 03/10] - removed unused import --- .../softserveinc/dokazovi/service/impl/UserServiceImplTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/com/softserveinc/dokazovi/service/impl/UserServiceImplTest.java b/src/test/java/com/softserveinc/dokazovi/service/impl/UserServiceImplTest.java index f4792c77..2a5da4f5 100644 --- a/src/test/java/com/softserveinc/dokazovi/service/impl/UserServiceImplTest.java +++ b/src/test/java/com/softserveinc/dokazovi/service/impl/UserServiceImplTest.java @@ -22,7 +22,6 @@ import org.springframework.data.domain.Pageable; import org.springframework.security.crypto.password.PasswordEncoder; -import java.sql.Timestamp; import java.time.LocalDateTime; import java.util.HashSet; import java.util.List; From 4a1f0eb141c5d72b79700ac87534f2601f0cb1af Mon Sep 17 00:00:00 2001 From: fortamt Date: Sun, 17 Jul 2022 13:09:32 +0300 Subject: [PATCH 04/10] - refactor database migration (collect to one file) --- .../V24__add_column_editedAt_for_users.sql | 2 -- ...etworks_and_move_data_add_region_column.sql | 18 ++++++++++++++++++ ...oved_social_network_column_from_doctors.sql | 12 ------------ ...table_social_networks_and_rename_column.sql | 2 -- .../V27__rename_column_social_network.sql | 1 - .../V28__add_column_region_for_users.sql | 2 -- 6 files changed, 18 insertions(+), 19 deletions(-) delete mode 100644 src/main/resources/db/migration/V24__add_column_editedAt_for_users.sql create mode 100644 src/main/resources/db/migration/V24__add_column_editedAt_for_users_and_table_for_social_networks_and_move_data_add_region_column.sql delete mode 100644 src/main/resources/db/migration/V25__add_social_network_table_and_removed_social_network_column_from_doctors.sql delete mode 100644 src/main/resources/db/migration/V26__rename_table_social_networks_and_rename_column.sql delete mode 100644 src/main/resources/db/migration/V27__rename_column_social_network.sql delete mode 100644 src/main/resources/db/migration/V28__add_column_region_for_users.sql diff --git a/src/main/resources/db/migration/V24__add_column_editedAt_for_users.sql b/src/main/resources/db/migration/V24__add_column_editedAt_for_users.sql deleted file mode 100644 index b4cedfab..00000000 --- a/src/main/resources/db/migration/V24__add_column_editedAt_for_users.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table public.users - add column EDITED_AT timestamp; \ No newline at end of file diff --git a/src/main/resources/db/migration/V24__add_column_editedAt_for_users_and_table_for_social_networks_and_move_data_add_region_column.sql b/src/main/resources/db/migration/V24__add_column_editedAt_for_users_and_table_for_social_networks_and_move_data_add_region_column.sql new file mode 100644 index 00000000..36088ff4 --- /dev/null +++ b/src/main/resources/db/migration/V24__add_column_editedAt_for_users_and_table_for_social_networks_and_move_data_add_region_column.sql @@ -0,0 +1,18 @@ +alter table public.users + add column EDITED_AT timestamp; + +create table if not exists USERS_SOCIAL_NETWORKS( + user_id integer not null + constraint social_networks_user_id_fkey + references users, + link varchar +); + +insert into USERS_SOCIAL_NETWORKS (user_id, link) +select user_id, social_network from DOCTORS; + +alter table public.doctors + drop column social_network; + +alter table public.users + add column REGION varchar; \ No newline at end of file diff --git a/src/main/resources/db/migration/V25__add_social_network_table_and_removed_social_network_column_from_doctors.sql b/src/main/resources/db/migration/V25__add_social_network_table_and_removed_social_network_column_from_doctors.sql deleted file mode 100644 index dcaf2613..00000000 --- a/src/main/resources/db/migration/V25__add_social_network_table_and_removed_social_network_column_from_doctors.sql +++ /dev/null @@ -1,12 +0,0 @@ -create table if not exists SOCIAL_NETWORKS( - user_id integer not null - constraint social_networks_user_id_fkey - references users, - link varchar -); - -insert into SOCIAL_NETWORKS (user_id, link) -select user_id, social_network from DOCTORS; - -alter table public.doctors -drop column social_network; \ No newline at end of file diff --git a/src/main/resources/db/migration/V26__rename_table_social_networks_and_rename_column.sql b/src/main/resources/db/migration/V26__rename_table_social_networks_and_rename_column.sql deleted file mode 100644 index 8fee07a3..00000000 --- a/src/main/resources/db/migration/V26__rename_table_social_networks_and_rename_column.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table social_networks rename column link to social_networks; -alter table social_networks rename to users_social_networks; \ No newline at end of file diff --git a/src/main/resources/db/migration/V27__rename_column_social_network.sql b/src/main/resources/db/migration/V27__rename_column_social_network.sql deleted file mode 100644 index 90bc2e67..00000000 --- a/src/main/resources/db/migration/V27__rename_column_social_network.sql +++ /dev/null @@ -1 +0,0 @@ -alter table users_social_networks rename column social_networks to link; \ No newline at end of file diff --git a/src/main/resources/db/migration/V28__add_column_region_for_users.sql b/src/main/resources/db/migration/V28__add_column_region_for_users.sql deleted file mode 100644 index 8e0e578c..00000000 --- a/src/main/resources/db/migration/V28__add_column_region_for_users.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table public.users - add column REGION varchar; \ No newline at end of file From a9c424d44f801172413c2c4f74bc6a03d0b9c80b Mon Sep 17 00:00:00 2001 From: Ilya Kosarenko Date: Tue, 19 Jul 2022 20:02:16 +0300 Subject: [PATCH 05/10] Added to PostDTO new json format of date time: --- src/main/java/com/softserveinc/dokazovi/dto/post/PostDTO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/softserveinc/dokazovi/dto/post/PostDTO.java b/src/main/java/com/softserveinc/dokazovi/dto/post/PostDTO.java index b97603f1..a44c4cdc 100644 --- a/src/main/java/com/softserveinc/dokazovi/dto/post/PostDTO.java +++ b/src/main/java/com/softserveinc/dokazovi/dto/post/PostDTO.java @@ -31,7 +31,7 @@ public class PostDTO { private PostTypeDTO type; private String status; private Set origins; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd.MM.yyyy") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm dd.MM.yyyy") private Timestamp createdAt; @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd.MM.yyyy") private Timestamp modifiedAt; From ccc8b23a7afc676d719fec4eba6e89e89dfe7a5f Mon Sep 17 00:00:00 2001 From: fortamt Date: Thu, 11 Aug 2022 15:39:26 +0300 Subject: [PATCH 06/10] - minor fix --- src/main/java/com/softserveinc/dokazovi/entity/UserEntity.java | 1 - .../softserveinc/dokazovi/service/impl/UserServiceImplTest.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/main/java/com/softserveinc/dokazovi/entity/UserEntity.java b/src/main/java/com/softserveinc/dokazovi/entity/UserEntity.java index ac8365f9..c7888b81 100644 --- a/src/main/java/com/softserveinc/dokazovi/entity/UserEntity.java +++ b/src/main/java/com/softserveinc/dokazovi/entity/UserEntity.java @@ -72,7 +72,6 @@ public class UserEntity { @CreationTimestamp private Timestamp createdAt; - @EqualsAndHashCode.Exclude private Timestamp editedAt; private String region; diff --git a/src/test/java/com/softserveinc/dokazovi/service/impl/UserServiceImplTest.java b/src/test/java/com/softserveinc/dokazovi/service/impl/UserServiceImplTest.java index 2a5da4f5..85aad5e2 100644 --- a/src/test/java/com/softserveinc/dokazovi/service/impl/UserServiceImplTest.java +++ b/src/test/java/com/softserveinc/dokazovi/service/impl/UserServiceImplTest.java @@ -444,7 +444,6 @@ void updateUserEntityTest() { UserEntity actual = userService.update(userEntity); Assertions.assertEquals(expectedEmail, actual.getEmail()); Assertions.assertNotNull(actual.getEditedAt()); - } @Test From b86ff6aab8b62bdb3c709627052487f0ecad79ca Mon Sep 17 00:00:00 2001 From: fortamt Date: Thu, 11 Aug 2022 16:33:37 +0300 Subject: [PATCH 07/10] - added city field to user entity --- .../java/com/softserveinc/dokazovi/dto/user/UserDTO.java | 2 ++ .../java/com/softserveinc/dokazovi/entity/UserEntity.java | 2 ++ ..._for_social_networks_and_move_data_add_region_column.sql} | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) rename src/main/resources/db/migration/{V24__add_column_editedAt_for_users_and_table_for_social_networks_and_move_data_add_region_column.sql => V25__add_column_editedAt_for_users_and_table_for_social_networks_and_move_data_add_region_column.sql} (82%) diff --git a/src/main/java/com/softserveinc/dokazovi/dto/user/UserDTO.java b/src/main/java/com/softserveinc/dokazovi/dto/user/UserDTO.java index 483cbf15..6de06999 100644 --- a/src/main/java/com/softserveinc/dokazovi/dto/user/UserDTO.java +++ b/src/main/java/com/softserveinc/dokazovi/dto/user/UserDTO.java @@ -33,6 +33,8 @@ public class UserDTO { private String region; + private String city; + private Set socialNetworks; private Set directions; diff --git a/src/main/java/com/softserveinc/dokazovi/entity/UserEntity.java b/src/main/java/com/softserveinc/dokazovi/entity/UserEntity.java index c7888b81..3a98295b 100644 --- a/src/main/java/com/softserveinc/dokazovi/entity/UserEntity.java +++ b/src/main/java/com/softserveinc/dokazovi/entity/UserEntity.java @@ -76,6 +76,8 @@ public class UserEntity { private String region; + private String city; + @ElementCollection @CollectionTable( name = "users_social_networks", diff --git a/src/main/resources/db/migration/V24__add_column_editedAt_for_users_and_table_for_social_networks_and_move_data_add_region_column.sql b/src/main/resources/db/migration/V25__add_column_editedAt_for_users_and_table_for_social_networks_and_move_data_add_region_column.sql similarity index 82% rename from src/main/resources/db/migration/V24__add_column_editedAt_for_users_and_table_for_social_networks_and_move_data_add_region_column.sql rename to src/main/resources/db/migration/V25__add_column_editedAt_for_users_and_table_for_social_networks_and_move_data_add_region_column.sql index 36088ff4..07fb7e73 100644 --- a/src/main/resources/db/migration/V24__add_column_editedAt_for_users_and_table_for_social_networks_and_move_data_add_region_column.sql +++ b/src/main/resources/db/migration/V25__add_column_editedAt_for_users_and_table_for_social_networks_and_move_data_add_region_column.sql @@ -15,4 +15,7 @@ alter table public.doctors drop column social_network; alter table public.users - add column REGION varchar; \ No newline at end of file + add column REGION varchar; + +alter table public.users + add column CITY varchar; \ No newline at end of file From fc01d2b53ed55a36ba5a17a66b887121cf2b6dae Mon Sep 17 00:00:00 2001 From: fortamt Date: Thu, 11 Aug 2022 17:55:41 +0300 Subject: [PATCH 08/10] - changed response statuses --- .../softserveinc/dokazovi/controller/UserController.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/softserveinc/dokazovi/controller/UserController.java b/src/main/java/com/softserveinc/dokazovi/controller/UserController.java index 1f4ee37b..dc32584b 100644 --- a/src/main/java/com/softserveinc/dokazovi/controller/UserController.java +++ b/src/main/java/com/softserveinc/dokazovi/controller/UserController.java @@ -35,6 +35,7 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; @@ -148,6 +149,9 @@ public ResponseEntity getExpertById(@PathVariable("userId") Integer use @ApiOperation(value = "Get current user", authorizations = {@Authorization(value = "Authorization")}) public ResponseEntity getCurrentUser(@AuthenticationPrincipal UserPrincipal userPrincipal) { + if (userPrincipal == null) { + return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); + } UserDTO userDTO = userService.findExpertById(userPrincipal.getId()); return ResponseEntity .status((userDTO != null) ? HttpStatus.OK : HttpStatus.NOT_FOUND) @@ -247,6 +251,6 @@ public ResponseEntity> getAuthorities( authorities = userPrincipal.getAuthorities(); } return ResponseEntity.status(authorities != null - ? HttpStatus.OK : HttpStatus.NOT_FOUND).body(authorities); + ? HttpStatus.OK : HttpStatus.FORBIDDEN).body(authorities); } } From fcc64171b2e4ec72835f223f83b35b420fb00c51 Mon Sep 17 00:00:00 2001 From: fortamt Date: Thu, 11 Aug 2022 17:56:31 +0300 Subject: [PATCH 09/10] - changed response statuses --- .../com/softserveinc/dokazovi/controller/UserController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/softserveinc/dokazovi/controller/UserController.java b/src/main/java/com/softserveinc/dokazovi/controller/UserController.java index dc32584b..3f6362c9 100644 --- a/src/main/java/com/softserveinc/dokazovi/controller/UserController.java +++ b/src/main/java/com/softserveinc/dokazovi/controller/UserController.java @@ -35,7 +35,6 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; From e5998a8e2e2a75c686537a036ae938e4159056c9 Mon Sep 17 00:00:00 2001 From: fortamt Date: Thu, 11 Aug 2022 18:10:35 +0300 Subject: [PATCH 10/10] - test fixed --- .../softserveinc/dokazovi/controller/UserControllerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/softserveinc/dokazovi/controller/UserControllerTest.java b/src/test/java/com/softserveinc/dokazovi/controller/UserControllerTest.java index c926c683..6544889f 100644 --- a/src/test/java/com/softserveinc/dokazovi/controller/UserControllerTest.java +++ b/src/test/java/com/softserveinc/dokazovi/controller/UserControllerTest.java @@ -330,7 +330,7 @@ void checkTokenTest() throws Exception { void getAuthoritiesTestNotFound() throws Exception { String uri = USER + USER_GET_AUTHORITIES; when(userPrincipal.getAuthorities()).thenReturn(null); - mockMvc.perform(get(uri)).andExpect(status().isNotFound()); + mockMvc.perform(get(uri)).andExpect(status().isForbidden()); Collection actual = userPrincipal.getAuthorities(); Assertions.assertNull(actual); }