generated from ita-social-projects/DevTemplate
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update develop.md * Update master.md * Add dokazovi.info into allowed_origin * Merge 634 user story and delete logic (#618) * Implement user account activation logic without tests, they will be in next commits * Return port 5432 to docker compose file * Made changes regarding comments * Made changes regarding comments * Delete rewrite (#616) * Refactored deleteById method * Fixed style errors * Tests are ready to go * Refactored deleteById method * Fixed style errors * Tests are ready to go * Added eventPublisher for deleteById method * Added method to change status * Change user methods to work with authorId (#617) * Change everywhere we use userId to AuthorId and then add logic to get userEntity from authorEntity, change some dtos * Change tests to new version of code * Change tests to new version of code * Change tests to new version of code * test * test * test * Delete rewrite (#616) * Refactored deleteById method * Fixed style errors * Tests are ready to go * Refactored deleteById method * Fixed style errors * Tests are ready to go * Added eventPublisher for deleteById method * Added method to change status * Change everywhere we use userId to AuthorId and then add logic to get userEntity from authorEntity, change some dtos * Change tests to new version of code * Change tests to new version of code * Change tests to new version of code * test * test * test * Add join author id to all queries that returns user information --------- Co-authored-by: VadimasikKPI <[email protected]> Co-authored-by: Voloshkevych <[email protected]> --------- Co-authored-by: VadimasikKPI <[email protected]> Co-authored-by: Voloshkevych <[email protected]> * bug fixes * make changes according to coments * make changes according to coments --------- Co-authored-by: Vitalii Kulinskyi <[email protected]> Co-authored-by: AxelNordov <[email protected]> Co-authored-by: Stanislav Kucher <[email protected]> Co-authored-by: Ihor Zakharko <[email protected]> Co-authored-by: Vlad Kaidash <[email protected]> Co-authored-by: Anton Sidliar <[email protected]> Co-authored-by: Artem Kurovskyi <[email protected]> Co-authored-by: vasilpetrus <[email protected]> Co-authored-by: VadimasikKPI <[email protected]> Co-authored-by: Voloshkevych <[email protected]>
- Loading branch information
1 parent
a7c367a
commit 4583169
Showing
12 changed files
with
80 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,10 +90,12 @@ void init() { | |
.email("[email protected]") | ||
.phone("380990099009") | ||
.avatar("Some avatar url") | ||
.enabled(true) | ||
.socialNetworks(Set.of("Facebook", "Twitter")) | ||
.build(); | ||
|
||
authorEntity = AuthorEntity.builder() | ||
.id(1) | ||
.qualification("qualification 1") | ||
.bio("bio 1") | ||
.mainInstitution(mainInstitution) | ||
|
@@ -247,6 +249,7 @@ void tooUserDtoEmptyOrNullCases() { | |
assertNull(userDTO.getMainInstitution().getCity()); | ||
|
||
UserEntity userEntity1 = new UserEntity(); | ||
userEntity1.setEnabled(false); | ||
userDTO = mapper.toUserDTO(userEntity1); | ||
assertNull(userDTO.getId()); | ||
assertNull(userDTO.getBio()); | ||
|
@@ -258,6 +261,7 @@ void tooUserDtoEmptyOrNullCases() { | |
|
||
userEntity.setAuthor(new AuthorEntity()); | ||
userDTO = mapper.toUserDTO(userEntity); | ||
userDTO.setId(userEntity.getId()); | ||
assertEquals(userDTO.getId(), userEntity.getId()); | ||
assertNull(userDTO.getBio()); | ||
assertNull(userDTO.getQualification()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,9 +99,6 @@ void init() { | |
.enabled(true) | ||
.build(); | ||
|
||
institutionEntity = InstitutionEntity.builder() | ||
.build(); | ||
|
||
userEntity = UserEntity.builder() | ||
.id(2) | ||
.email("[email protected]") | ||
|
@@ -118,6 +115,7 @@ void init() { | |
.build(); | ||
|
||
authorRequestDTO = AuthorRequestDTO.builder() | ||
.authorId(1) | ||
.firstName("firstName") | ||
.lastName("lastName") | ||
.cityId(190) | ||
|
@@ -127,15 +125,21 @@ void init() { | |
.socialNetworks(new HashSet<>()) | ||
.build(); | ||
|
||
cityEntity = CityEntity.builder() | ||
.id(190) | ||
.build(); | ||
|
||
institutionEntity = InstitutionEntity.builder() | ||
.id(1) | ||
.city(cityEntity) | ||
.name("Hospital") | ||
.build(); | ||
|
||
authorEntity = AuthorEntity.builder() | ||
.id(1) | ||
.profile(userEntity) | ||
.mainInstitution(institutionEntity) | ||
.build(); | ||
|
||
cityEntity = CityEntity.builder() | ||
.id(190) | ||
.build(); | ||
} | ||
|
||
@Test | ||
|
@@ -145,7 +149,7 @@ void updateWithoutPermission() { | |
.role(adminRole) | ||
.build(); | ||
|
||
assertThatThrownBy(() -> authorService.update(1, authorRequestDTO, userPrincipal)) | ||
assertThatThrownBy(() -> authorService.update(authorRequestDTO, userPrincipal)) | ||
.isInstanceOf(ForbiddenPermissionsException.class); | ||
} | ||
|
||
|
@@ -159,7 +163,7 @@ void update() { | |
.role(adminRole) | ||
.build(); | ||
|
||
authorService.update(1, authorRequestDTO, userPrincipal); | ||
authorService.update(authorRequestDTO, userPrincipal); | ||
|
||
verify(authorRepository).save(authorEntityArgumentCaptor.capture()); | ||
Assertions.assertEquals(authorEntityArgumentCaptor.getValue().getId(), authorEntity.getId()); | ||
|
@@ -179,6 +183,7 @@ void saveWithoutPermission() { | |
@Test | ||
void save() { | ||
when(cityRepository.findById(anyInt())).thenReturn(Optional.of(cityEntity)); | ||
|
||
UserPrincipal userPrincipal = UserPrincipal.builder() | ||
.role(adminRole) | ||
.build(); | ||
|
@@ -199,12 +204,13 @@ void save() { | |
.promotionScale(1.0) | ||
.mainWorkingPlace(authorRequestDTO.getMainWorkingPlace()) | ||
.city(cityEntity) | ||
.mainInstitution(institutionEntity) | ||
.profile(user) | ||
.bio(authorRequestDTO.getBio()) | ||
.build(); | ||
verify(userRepository).save(userEntityArgumentCaptor.capture()); | ||
verify(authorRepository).save(authorEntityArgumentCaptor.capture()); | ||
Assertions.assertEquals(authorEntityArgumentCaptor.getValue(), author); | ||
Assertions.assertEquals(authorEntityArgumentCaptor.getValue().getId(), author.getId()); | ||
Assertions.assertEquals(userEntityArgumentCaptor.getValue().getId(), user.getId()); | ||
} | ||
|
||
|
Oops, something went wrong.