Checkpoint: ExchangeServiceTest

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
2021-01-13 14:13:26 +01:00
parent d1641277ac
commit 11469e9314
2 changed files with 17 additions and 9 deletions

View File

@ -78,7 +78,7 @@ public class ExchangeService {
}
public void performExchange() {
final Set<MatchData> matchData = this.getMatches();
final List<MatchData> matchData = this.getMatches();
final List<Long> performedAssignmentExchanges = new ArrayList<>();
matchData.forEach( m -> {
final Assignment assignmentOne = m.getAssignmentOne();
@ -114,16 +114,17 @@ public class ExchangeService {
});
}
public Set<MatchData> getMatches(){
public List<MatchData> getMatches(){
final List<MatchData> matches = this.repo.getMatches().stream().map(m -> {
final Exchange exchangeOne = (Exchange) m[0];
final Exchange exchangeTwo = (Exchange) m[1];
return new MatchData(exchangeOne, exchangeTwo);
}).collect(Collectors.toList());
Set<MatchData> filterMatches = new TreeSet<>((m1, m2) -> m1.compare(m2));
filterMatches.addAll(matches);
return filterMatches;
final Set<MatchData> uniqData = new HashSet<>(matches);
final List<MatchData> matchDataListSorted = uniqData.stream().sorted((m1, m2) -> -1 * m1.compare(m2))
.collect(Collectors.toList());
return matchDataListSorted;
}
}