generated from ita-social-projects/DevTemplate
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #281 from ita-social-projects/create-achievements
Create achievements
- Loading branch information
Showing
18 changed files
with
27 additions
and
165 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
37 changes: 0 additions & 37 deletions
37
dao/src/main/java/greencity/entity/localization/AchievementTranslation.java
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
service-api/src/main/java/greencity/dto/achievement/AchievementTranslationVO.java
This file was deleted.
Oops, something went wrong.
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
6 changes: 0 additions & 6 deletions
6
service-api/src/main/java/greencity/enums/AchievementStatus.java
This file was deleted.
Oops, something went wrong.
23 changes: 5 additions & 18 deletions
23
service/src/main/java/greencity/mapping/AchievementVOMapper.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 |
---|---|---|
@@ -1,39 +1,26 @@ | ||
package greencity.mapping; | ||
|
||
import greencity.dto.achievement.AchievementTranslationVO; | ||
import greencity.dto.achievement.AchievementVO; | ||
import greencity.dto.achievementcategory.AchievementCategoryVO; | ||
import greencity.dto.language.LanguageVO; | ||
import greencity.entity.Achievement; | ||
import org.modelmapper.AbstractConverter; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Component | ||
public class AchievementVOMapper extends AbstractConverter<Achievement, AchievementVO> { | ||
@Override | ||
protected AchievementVO convert(Achievement achievement) { | ||
List<AchievementTranslationVO> list = new ArrayList<>(); | ||
achievement.getTranslations().forEach(achievementTranslation -> list.add(AchievementTranslationVO.builder() | ||
.id(achievementTranslation.getId()) | ||
.title(achievementTranslation.getTitle()) | ||
.description(achievementTranslation.getDescription()) | ||
.message(achievementTranslation.getMessage()) | ||
.language(LanguageVO.builder() | ||
.id(achievementTranslation.getLanguage().getId()) | ||
.code(achievementTranslation.getLanguage().getCode()) | ||
.build()) | ||
.build())); | ||
return AchievementVO.builder() | ||
.id(achievement.getId()) | ||
.translations(list) | ||
.condition(achievement.getCondition()) | ||
.title(achievement.getTitle()) | ||
.name(achievement.getName()) | ||
.nameEng(achievement.getNameEng()) | ||
.condition(achievement.getCondition()) | ||
.achievementCategory(AchievementCategoryVO.builder() | ||
.id(achievement.getAchievementCategory().getId()) | ||
.name(achievement.getAchievementCategory().getName()) | ||
.build()) | ||
.condition(achievement.getCondition()) | ||
.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
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
27 changes: 5 additions & 22 deletions
27
service/src/test/java/greencity/mapping/AchievementVOMapperTest.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 |
---|---|---|
@@ -1,53 +1,36 @@ | ||
package greencity.mapping; | ||
|
||
import greencity.ModelUtils; | ||
import greencity.dto.achievement.AchievementTranslationVO; | ||
import greencity.dto.achievement.AchievementVO; | ||
import greencity.dto.achievementcategory.AchievementCategoryVO; | ||
import greencity.dto.language.LanguageVO; | ||
import greencity.entity.Achievement; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class AchievementVOMapperTest { | ||
|
||
@InjectMocks | ||
AchievementVOMapper mapper; | ||
private AchievementVOMapper achievementVOMapper; | ||
|
||
@Test | ||
void convert() { | ||
List<AchievementTranslationVO> list = new ArrayList<>(); | ||
Achievement achievement = ModelUtils.getAchievement(); | ||
|
||
achievement.getTranslations().forEach(achievementTranslation -> list.add(AchievementTranslationVO.builder() | ||
.id(achievementTranslation.getId()) | ||
.title(achievementTranslation.getTitle()) | ||
.description(achievementTranslation.getDescription()) | ||
.message(achievementTranslation.getMessage()) | ||
.language(LanguageVO.builder() | ||
.id(achievementTranslation.getLanguage().getId()) | ||
.code(achievementTranslation.getLanguage().getCode()) | ||
.build()) | ||
.build())); | ||
|
||
AchievementVO expected = AchievementVO.builder() | ||
.id(achievement.getId()) | ||
.translations(list) | ||
.title(achievement.getTitle()) | ||
.name(achievement.getName()) | ||
.nameEng(achievement.getNameEng()) | ||
.achievementCategory(AchievementCategoryVO.builder() | ||
.id(achievement.getAchievementCategory().getId()) | ||
.name(achievement.getAchievementCategory().getName()) | ||
.build()) | ||
.condition(achievement.getCondition()) | ||
.build(); | ||
|
||
assertEquals(expected, mapper.convert(achievement)); | ||
assertEquals(expected, achievementVOMapper.convert(achievement)); | ||
} | ||
} |
Oops, something went wrong.