Responses up[dated

This commit is contained in:
Filip Izydorczyk
2020-10-13 17:07:04 +02:00
parent bdd0278880
commit 148d7a31c6
12 changed files with 161 additions and 49 deletions

View File

@ -5,20 +5,24 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import java.util.List;
import com.plannaplan.entities.Assignment;
import com.plannaplan.entities.Commision;
import com.plannaplan.entities.Groups;
import com.plannaplan.responses.models.AssignmentResponse;
import com.plannaplan.responses.models.GetCurrentAssignmentsResponse;
import org.junit.Test;
public class AssignmentResponseMappersTest {
@Test
public void shouldReturnNewList() {
final List<Groups> groups = Arrays.asList(new Groups(), new Groups());
final List<AssignmentResponse> response = AssignmentResponseMappers
.mapGroupsListToAssignmentResponseList(groups);
final Commision com = new Commision();
final List<Assignment> groups = Arrays.asList(new Assignment(new Groups(), com),
new Assignment(new Groups(), com));
final List<GetCurrentAssignmentsResponse> response = AssignmentResponseMappers
.mapAssignmentsListToAssignmentResponseList(groups);
assertTrue(response.size() == 2);
assertTrue(response instanceof List);
assertTrue(response.get(0) instanceof AssignmentResponse);
assertTrue(response.get(0) instanceof GetCurrentAssignmentsResponse);
}
}

View File

@ -7,6 +7,7 @@ import java.util.List;
import com.plannaplan.entities.Course;
import com.plannaplan.responses.models.GetCoursesResponse;
import com.plannaplan.responses.models.GetCoursesWithGroupsResponse;
import org.junit.Test;
@ -20,4 +21,15 @@ public class CoursesResponseMappersTest {
assertTrue(response.get(0) instanceof GetCoursesResponse);
}
@Test
public void shouldMapListCoursesToResponseWithGroupsList() {
final List<Course> courses = Arrays.asList(new Course(), new Course());
final List<GetCoursesWithGroupsResponse> response = CoursesResponseMappers
.mapCoursesWithGrtoupsListToCoursesResponseList(courses);
assertTrue(response.size() == 2);
assertTrue(response.get(0) instanceof GetCoursesWithGroupsResponse);
}
}

View File

@ -10,14 +10,13 @@ import com.plannaplan.types.WeekDay;
import org.junit.Test;
public class AssignmentResponseTest {
public class DefaultGroupResponseTest {
@Test
public void shouldMapAssignmentClassToResponse() {
final Assignment assignment = new Assignment(
new Groups(42, "A4-1", null, 520, WeekDay.MONDAY, new Lecturer("krul.", "Wladyslaw", "Potocki")), null);
final AssignmentResponse response = new AssignmentResponse(assignment);
final DefaultGroupResponse response = new DefaultGroupResponse(assignment);
assertTrue(response.getCapacity() == 42);
assertTrue(response.getDay() == 0);
assertTrue(response.getLecturer().equals("krul. Wladyslaw Potocki"));
@ -31,7 +30,7 @@ public class AssignmentResponseTest {
final Groups group = new Groups(42, "A4-1", null, 520, WeekDay.MONDAY,
new Lecturer("krul.", "Wladyslaw", "Potocki"));
final AssignmentResponse response = new AssignmentResponse(group);
final DefaultGroupResponse response = new DefaultGroupResponse(group);
assertTrue(response.getCapacity() == 42);
assertTrue(response.getDay() == 0);
assertTrue(response.getLecturer().equals("krul. Wladyslaw Potocki"));
@ -44,7 +43,7 @@ public class AssignmentResponseTest {
public void shouldMapEmptyGroupClassToResponse() {
final Groups group = new Groups();
final AssignmentResponse response = new AssignmentResponse(group);
final DefaultGroupResponse response = new DefaultGroupResponse(group);
assertTrue(response.getCapacity() == 0);
assertTrue(response.getDay() == -1);
assertTrue(response.getLecturer().equals(""));

View File

@ -0,0 +1,20 @@
package com.plannaplan.responses.models;
import static org.junit.jupiter.api.Assertions.assertTrue;
import com.plannaplan.entities.Course;
import org.junit.Test;
public class GetCoursesWithGroupsResponseTest {
@Test
public void shouldMapCourseToResponseWithGroupsIncluded() {
final GetCoursesWithGroupsResponse response = new GetCoursesWithGroupsResponse(
new Course("Programowanie funkcyjne", "xd"));
assertTrue(response.getName() == "Programowanie funkcyjne");
assertTrue(response.getClasses().size() == 0);
assertTrue(response.getLectures().size() == 0);
}
}

View File

@ -0,0 +1,29 @@
package com.plannaplan.responses.models;
import static org.junit.jupiter.api.Assertions.assertTrue;
import com.plannaplan.entities.Assignment;
import com.plannaplan.entities.Groups;
import com.plannaplan.entities.Lecturer;
import com.plannaplan.types.GroupType;
import com.plannaplan.types.WeekDay;
import org.junit.Test;
public class GetCurrentAssignmentsResponseTest {
@Test
public void shouldMapAssignmentClassToResponse() {
final Assignment assignment = new Assignment(
new Groups(42, "A4-1", null, 520, WeekDay.MONDAY, new Lecturer("krul.", "Wladyslaw", "Potocki")), null);
final GetCurrentAssignmentsResponse response = new GetCurrentAssignmentsResponse(assignment);
assertTrue(response.getCapacity() == 42);
assertTrue(response.getDay() == 0);
assertTrue(response.getLecturer().equals("krul. Wladyslaw Potocki"));
assertTrue(response.getRoom().equals("A4-1"));
assertTrue(response.getTime().equals("8.40"));
assertTrue(response.getType() == GroupType.CLASS);
}
}