Skip to content

Commit

Permalink
Issue #151: Retrieve all LevelSkills in TeamScoreCalc Service
Browse files Browse the repository at this point in the history
  • Loading branch information
Amar-Bolkan committed Nov 29, 2022
1 parent a124a52 commit fd4074b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@
*/
package com.iteratec.teamdojo.service.impl.custom;

import com.iteratec.teamdojo.domain.Badge;
import com.iteratec.teamdojo.domain.BadgeSkill;
import com.iteratec.teamdojo.domain.Level;
import com.iteratec.teamdojo.domain.Skill;
import com.iteratec.teamdojo.repository.BadgeRepository;
import com.iteratec.teamdojo.repository.BadgeSkillRepository;
import com.iteratec.teamdojo.repository.LevelRepository;
import com.iteratec.teamdojo.repository.SkillRepository;
import com.iteratec.teamdojo.domain.*;
import com.iteratec.teamdojo.repository.*;
import com.iteratec.teamdojo.service.TeamSkillQueryService;
import com.iteratec.teamdojo.service.criteria.TeamSkillCriteria;
import com.iteratec.teamdojo.service.custom.CustomTeamScoreService;
Expand All @@ -33,19 +27,22 @@ public class CustomTeamScoreServiceImpl implements CustomTeamScoreService {
private final BadgeRepository badgeRepository;
private final LevelRepository levelRepository;
private final BadgeSkillRepository badgeSkillRepository;
private final LevelSkillRepository levelSkillRepository;

public CustomTeamScoreServiceImpl(
TeamSkillQueryService teamSkillQueryService,
SkillRepository skillRepository,
BadgeRepository badgeRepository,
LevelRepository levelRepository,
BadgeSkillRepository badgeSkillRepository
BadgeSkillRepository badgeSkillRepository,
LevelSkillRepository levelSkillRepository
) {
this.teamSkillQueryService = teamSkillQueryService;
this.skillRepository = skillRepository;
this.badgeRepository = badgeRepository;
this.levelRepository = levelRepository;
this.badgeSkillRepository = badgeSkillRepository;
this.levelSkillRepository = levelSkillRepository;
}

@Override
Expand All @@ -55,6 +52,7 @@ public TeamScoreDTO calculateTeamScore(@NonNull final TeamDTO t) {
final var allBadges = this.retrieveAllBadges();
final var allLevels = this.retrieveAllLevels();
final var allBadgeSkills = this.retrieveAllBadgeSkills();
final var allLevelSkills = this.retrieveAllLevelSkills();

final var achieved = calculateAchieved();
final var required = calculateRequired();
Expand All @@ -64,6 +62,10 @@ public TeamScoreDTO calculateTeamScore(@NonNull final TeamDTO t) {
return new TeamScoreDTO(achieved, required, totalScore, progressInPercent, completed);
}

private Collection<LevelSkill> retrieveAllLevelSkills() {
return this.levelSkillRepository.findAll();
}

private Collection<BadgeSkill> retrieveAllBadgeSkills() {
return this.badgeSkillRepository.findAll();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;

import com.iteratec.teamdojo.domain.BadgeSkill;
import com.iteratec.teamdojo.repository.BadgeRepository;
import com.iteratec.teamdojo.repository.BadgeSkillRepository;
import com.iteratec.teamdojo.repository.LevelRepository;
import com.iteratec.teamdojo.repository.SkillRepository;
import com.iteratec.teamdojo.repository.*;
import com.iteratec.teamdojo.service.TeamSkillQueryService;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
Expand All @@ -32,12 +28,16 @@ class CustomTeamScoreServiceImplTest {
@Mock
private BadgeSkillRepository badgeSkillRepository;

@Mock
private LevelSkillRepository levelSkillRepository;

private final CustomTeamScoreServiceImpl sut = new CustomTeamScoreServiceImpl(
teamSkillQueryService,
skillRepository,
badgeRepository,
levelRepository,
badgeSkillRepository
badgeSkillRepository,
levelSkillRepository
);

@Test
Expand Down

0 comments on commit fd4074b

Please sign in to comment.