Skip to content

Commit

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

import com.iteratec.teamdojo.domain.Skill;
import com.iteratec.teamdojo.repository.SkillRepository;
import com.iteratec.teamdojo.service.TeamSkillQueryService;
import com.iteratec.teamdojo.service.criteria.TeamSkillCriteria;
import com.iteratec.teamdojo.service.custom.CustomTeamScoreService;
Expand All @@ -21,14 +23,17 @@
public class CustomTeamScoreServiceImpl implements CustomTeamScoreService {

private final TeamSkillQueryService teamSkillQueryService;
private final SkillRepository skillRepository;

public CustomTeamScoreServiceImpl(TeamSkillQueryService teamSkillQueryService) {
public CustomTeamScoreServiceImpl(TeamSkillQueryService teamSkillQueryService, SkillRepository skillRepository) {
this.teamSkillQueryService = teamSkillQueryService;
this.skillRepository = skillRepository;
}

@Override
public TeamScoreDTO calculateTeamScore(@NonNull final TeamDTO t) {
final var teamSkills = this.retrieveTeamSkills(t.getId());
final var allSkills = this.retrieveAllSkills();

final var achieved = calculateAchieved();
final var required = calculateRequired();
Expand Down Expand Up @@ -65,4 +70,8 @@ private Collection<TeamSkillDTO> retrieveTeamSkills(final long teamId) {
teamSkillCriteria.setTeamId(longFilter);
return this.teamSkillQueryService.findByCriteria(teamSkillCriteria);
}

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

import com.iteratec.teamdojo.repository.SkillRepository;
import com.iteratec.teamdojo.repository.TeamSkillRepository;
import com.iteratec.teamdojo.service.TeamSkillQueryService;
import org.junit.jupiter.api.Test;
Expand All @@ -16,7 +17,10 @@ class CustomTeamScoreServiceImplTest {
@Mock
private TeamSkillQueryService teamSkillQueryService;

private final CustomTeamScoreServiceImpl sut = new CustomTeamScoreServiceImpl(teamSkillQueryService);
@Mock
private SkillRepository skillRepository;

private final CustomTeamScoreServiceImpl sut = new CustomTeamScoreServiceImpl(teamSkillQueryService, skillRepository);

@Test
void calculateProgress() {}
Expand Down

0 comments on commit 82b860b

Please sign in to comment.