-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
made some update and added some test
- Loading branch information
1 parent
7983d21
commit 7a6a06b
Showing
12 changed files
with
200 additions
and
45 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 |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
import it.gov.pagopa.atmlayer.service.model.entity.UserProfilesPK; | ||
import it.gov.pagopa.atmlayer.service.model.mapper.UserMapper; | ||
import it.gov.pagopa.atmlayer.service.model.model.ProfileDTO; | ||
import it.gov.pagopa.atmlayer.service.model.repository.UserRepository; | ||
import it.gov.pagopa.atmlayer.service.model.service.UserService; | ||
import jakarta.ws.rs.core.MediaType; | ||
import org.junit.jupiter.api.Test; | ||
|
@@ -28,7 +29,8 @@ class UserResourceTest { | |
|
||
@InjectMock | ||
UserMapper userMapper; | ||
|
||
@InjectMock | ||
UserRepository userRepository; | ||
@InjectMock | ||
UserService userService; | ||
|
||
|
@@ -118,6 +120,9 @@ void testInsertWithProfiles() { | |
List<UserProfiles> userProfilesList = new ArrayList<>(); | ||
userProfilesList.add(userProfiles); | ||
|
||
List<Integer> profileIds = new ArrayList<>(); | ||
profileIds.add(1); | ||
|
||
user.setUserId("[email protected]"); | ||
user.setName("prova"); | ||
user.setSurname("test"); | ||
|
@@ -127,12 +132,12 @@ void testInsertWithProfiles() { | |
userInsertionWithProfilesDTO.setUserId("[email protected]"); | ||
userInsertionWithProfilesDTO.setName("prova"); | ||
userInsertionWithProfilesDTO.setSurname("test"); | ||
userInsertionWithProfilesDTO.setProfileIds(List.of(1)); | ||
userInsertionWithProfilesDTO.setProfileIds(profileIds); | ||
|
||
UserWithProfilesDTO userWithProfilesDTO = new UserWithProfilesDTO(); | ||
|
||
when(userMapper.toEntityInsertionWithProfiles(userInsertionWithProfilesDTO)).thenReturn(user); | ||
when(userService.findUser(userInsertionWithProfilesDTO.getUserId())).thenReturn(Uni.createFrom().item(user)); | ||
when(userService.insertUserWithProfiles(userInsertionWithProfilesDTO)).thenReturn(Uni.createFrom().item(user)); | ||
when(userRepository.findByIdCustom(userInsertionWithProfilesDTO.getUserId())).thenReturn(Uni.createFrom().item(user)); | ||
when(userMapper.toProfilesDTO(user)).thenReturn(userWithProfilesDTO); | ||
|
||
UserWithProfilesDTO result = given() | ||
|
@@ -213,7 +218,7 @@ void testGetByIdWithProfiles() { | |
User user = new User(); | ||
UserWithProfilesDTO userWithProfilesDTO = new UserWithProfilesDTO(); | ||
|
||
when(userService.findById(any(String.class))).thenReturn(Uni.createFrom().item(user)); | ||
when(userService.getById(any(String.class))).thenReturn(Uni.createFrom().item(user)); | ||
when(userMapper.toProfilesDTO(any(User.class))).thenReturn(userWithProfilesDTO); | ||
|
||
UserWithProfilesDTO result = given() | ||
|
@@ -226,7 +231,7 @@ void testGetByIdWithProfiles() { | |
.as(UserWithProfilesDTO.class); | ||
|
||
assertEquals(userWithProfilesDTO, result); | ||
verify(userService, times(1)).findById(any(String.class)); | ||
verify(userService, times(1)).getById(any(String.class)); | ||
verify(userMapper, times(1)).toProfilesDTO(user); | ||
} | ||
|
||
|
Oops, something went wrong.