Added GetCourseGroupsResponse(-Test)
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
parent
9c02a0b596
commit
a20bc89fc6
@ -0,0 +1,32 @@
|
|||||||
|
package com.plannaplan.responses.models;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Groups;
|
||||||
|
import com.plannaplan.types.GroupType;
|
||||||
|
|
||||||
|
public class GetCourseGroupsResponse {
|
||||||
|
|
||||||
|
private List<DefaultGroupResponse> lectures = new ArrayList<>();
|
||||||
|
private List<DefaultGroupResponse> classes = new ArrayList<>();
|
||||||
|
|
||||||
|
public GetCourseGroupsResponse(List<Groups> groups ){
|
||||||
|
groups.stream().forEach(group -> {
|
||||||
|
if (group.getType() == GroupType.CLASS) {
|
||||||
|
this.classes.add(new DefaultGroupResponse(group));
|
||||||
|
} else {
|
||||||
|
this.lectures.add(new DefaultGroupResponse(group));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DefaultGroupResponse> getClasses() {
|
||||||
|
return this.classes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DefaultGroupResponse> getLectures() {
|
||||||
|
return this.lectures;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.plannaplan.responses.models;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Groups;
|
||||||
|
import com.plannaplan.types.WeekDay;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class GetCourseGroupResponseTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldMapListGroupsToResponse() {
|
||||||
|
final List<Groups> groups = Arrays.asList(new Groups(32,"A1-1", null, 480, WeekDay.MONDAY, null), new Groups(150,"A1-2", null, 500, WeekDay.THURSDAY, null));
|
||||||
|
|
||||||
|
final GetCourseGroupsResponse response = new GetCourseGroupsResponse(groups);
|
||||||
|
assertTrue(response.getClasses().size() == 1);
|
||||||
|
assertTrue(response.getLectures().size() == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user