-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GreenCity] Create endpoint for retrieving friends' (that are assign …
…to habit) profile photos. #5805 (#5839) * add getFriendsAssignedToHabitProfilePictures endpoint * fix code smell * refactor repo methods * fix code * fix code
- Loading branch information
1 parent
7608918
commit 939a36b
Showing
9 changed files
with
209 additions
and
1 deletion.
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
18 changes: 18 additions & 0 deletions
18
service/src/main/java/greencity/mapping/UserProfilePictureDtoMapper.java
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package greencity.mapping; | ||
|
||
import greencity.dto.user.UserProfilePictureDto; | ||
import greencity.entity.User; | ||
import org.modelmapper.AbstractConverter; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class UserProfilePictureDtoMapper extends AbstractConverter<User, UserProfilePictureDto> { | ||
@Override | ||
protected UserProfilePictureDto convert(User user) { | ||
return UserProfilePictureDto.builder() | ||
.id(user.getId()) | ||
.name(user.getName()) | ||
.profilePicturePath(user.getProfilePicturePath()) | ||
.build(); | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
service/src/test/java/greencity/mapping/UserProfilePictureDtoMapperTest.java
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package greencity.mapping; | ||
|
||
import greencity.ModelUtils; | ||
import greencity.dto.user.UserProfilePictureDto; | ||
import greencity.entity.User; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@ExtendWith(SpringExtension.class) | ||
class UserProfilePictureDtoMapperTest { | ||
@InjectMocks | ||
private UserProfilePictureDtoMapper mapper; | ||
|
||
@Test | ||
void convertTest() { | ||
User user = ModelUtils.getUser(); | ||
|
||
UserProfilePictureDto expected = UserProfilePictureDto.builder() | ||
.id(user.getId()) | ||
.name(user.getName()) | ||
.profilePicturePath(user.getProfilePicturePath()) | ||
.build(); | ||
|
||
assertEquals(expected, mapper.convert(user)); | ||
} | ||
} |
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