Checkpoint: Added ExchangeServiceTest

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
2021-01-12 13:04:57 +01:00
parent 3583d30b26
commit 1c12a778af
5 changed files with 94 additions and 20 deletions

View File

@ -1,7 +1,10 @@
package com.plannaplan.services;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import com.plannaplan.entities.Assignment;
import com.plannaplan.entities.Exchange;
@ -62,9 +65,14 @@ public class ExchangeService {
}
// public void getMatches(){
// final List<MatchData> matches = this.repo.getMatches().stream().map(m -> {
// return (MatchData) m;
// });
// }
public Set<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.getOwnedAssignment(), exchangeTwo.getOwnedAssignment());
}).collect(Collectors.toList());
final Set<MatchData> filterMatches = new HashSet<>(matches);
return filterMatches;
}
}