Skip to content

Commit

Permalink
Issue #151: Retrieve teamSkills inside TeamScoreService
Browse files Browse the repository at this point in the history
  • Loading branch information
Amar-Bolkan committed Nov 28, 2022
1 parent 059f8b2 commit 4d09446
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,32 @@
*/
package com.iteratec.teamdojo.service.impl.custom;

import com.iteratec.teamdojo.service.TeamSkillQueryService;
import com.iteratec.teamdojo.service.criteria.TeamSkillCriteria;
import com.iteratec.teamdojo.service.custom.CustomTeamScoreService;
import com.iteratec.teamdojo.service.dto.TeamDTO;
import com.iteratec.teamdojo.service.dto.TeamSkillDTO;
import com.iteratec.teamdojo.service.dto.custom.TeamScoreDTO;
import java.util.Collection;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import tech.jhipster.service.filter.LongFilter;

@Service
@Slf4j
public class CustomTeamScoreServiceImpl implements CustomTeamScoreService {

private final TeamSkillQueryService teamSkillQueryService;

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

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

final var achieved = calculateAchieved();
final var required = calculateRequired();
final var totalScore = calculateTotalScore();
Expand Down Expand Up @@ -44,4 +57,12 @@ float calculateProgressInPercent() {
boolean calculateCompleted(final int achieved, final int required) {
return achieved >= required;
}

private Collection<TeamSkillDTO> retrieveTeamSkills(final long teamId) {
final var teamSkillCriteria = new TeamSkillCriteria();
final var longFilter = new LongFilter();
longFilter.setEquals(teamId);
teamSkillCriteria.setTeamId(longFilter);
return this.teamSkillQueryService.findByCriteria(teamSkillCriteria);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;

import com.iteratec.teamdojo.repository.TeamSkillRepository;
import com.iteratec.teamdojo.service.TeamSkillQueryService;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;

/**
*
*/
class CustomTeamScoreServiceImplTest {

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

private final CustomTeamScoreServiceImpl sut = new CustomTeamScoreServiceImpl(teamSkillQueryService);

@Test
void calculateProgress() {}
Expand Down

0 comments on commit 4d09446

Please sign in to comment.