Group default response places overload
This commit is contained in:
@ -2,7 +2,9 @@ package com.plannaplan.responses.mappers;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.plannaplan.entities.Groups;
|
||||
@ -37,16 +39,43 @@ public class GroupsMappersTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldMapToGetCourseGroupsResponse(){
|
||||
public void shouldMapToGetCourseGroupsResponse() {
|
||||
final List<Groups> groups = Arrays.asList(
|
||||
new Groups(150, "A4-1", null, 520, WeekDay.MONDAY, new Lecturer("krul.", "Wladyslaw", "Potocki")), new Groups(24, "A4-1", null, 520, WeekDay.MONDAY, new Lecturer("krul.", "Wladyslaw", "Potocki")));
|
||||
|
||||
final CourseWithGroupsResponse<GroupDefaultResponse> response = GroupsMappers.mapToGetCourseGroupsDefaultResponse(groups);
|
||||
new Groups(150, "A4-1", null, 520, WeekDay.MONDAY, new Lecturer("krul.", "Wladyslaw", "Potocki")),
|
||||
new Groups(24, "A4-1", null, 520, WeekDay.MONDAY, new Lecturer("krul.", "Wladyslaw", "Potocki")));
|
||||
|
||||
final CourseWithGroupsResponse<GroupDefaultResponse> response = GroupsMappers
|
||||
.mapToGetCourseGroupsDefaultResponse(groups);
|
||||
|
||||
assertTrue(response.getClasses().size() == 1);
|
||||
assertTrue(response.getLectures().size() == 1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldMapToDefaultResponseWithTakenPlace()
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
final Field reader = Groups.class.getDeclaredField("id");
|
||||
reader.setAccessible(true);
|
||||
|
||||
final Groups group1 = new Groups(150, "A4-1", null, 520, WeekDay.MONDAY,
|
||||
new Lecturer("krul.", "Wladyslaw", "Potocki"));
|
||||
final Groups group2 = new Groups(24, "A4-1", null, 520, WeekDay.MONDAY,
|
||||
new Lecturer("krul.", "Wladyslaw", "Potocki"));
|
||||
|
||||
reader.set(group1, Long.valueOf(0));
|
||||
reader.set(group2, Long.valueOf(1));
|
||||
|
||||
final HashMap<Long, Integer> placeMap = new HashMap<>();
|
||||
placeMap.put(Long.valueOf(0), 5);
|
||||
placeMap.put(Long.valueOf(1), 56);
|
||||
|
||||
final List<GroupDefaultResponse> response = GroupsMappers.mapToDefaultResponse(List.of(group1, group2),
|
||||
placeMap);
|
||||
|
||||
assertTrue(response.size() == 2);
|
||||
assertTrue(response.get(0).getTakenPlaces() == 5);
|
||||
assertTrue(response.get(1).getTakenPlaces() == 56);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user