Added GetCourseGroupsResponse(-Test)

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
Marcin Woźniak 2020-10-16 16:13:40 +02:00
parent 9c02a0b596
commit a20bc89fc6
2 changed files with 56 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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);
}
}