Added service method tests + javadocs

This commit is contained in:
BuildTools
2020-11-27 16:55:15 +01:00
parent 2545a0e682
commit 13eb8dae77
5 changed files with 56 additions and 12 deletions

View File

@ -54,12 +54,22 @@ public class GroupService {
}
public HashMap<Groups, Integer> getTakenPlaces(List<Groups> groups) {
HashMap<Groups, Integer> respoonse = new HashMap<>();
/**
*
* @param groups list of groups you want to get taken places ammount
* @return HashMap<Long, Integer> where Long is group id and Integer is how many
* places in gorup is already taken
*/
public HashMap<Long, Integer> getTakenPlaces(List<Groups> groups) {
HashMap<Long, Integer> response = new HashMap<>();
List<Object[]> respoonse2 = this.repo.getAssignedAmounts(
List<Object[]> respoonses = this.repo.getAssignedAmounts(
groups.stream().filter(Objects::nonNull).map(Groups::getId).collect(Collectors.toList()));
return respoonse;
for (Object[] element : respoonses) {
response.put(((Groups) element[0]).getId(), ((Long) element[1]).intValue());
}
return response;
}
}