Checkpoint - group controller needs to be fixed
This commit is contained in:
@ -0,0 +1,35 @@
|
||||
package com.plannaplan.responses.mappers;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.plannaplan.entities.Groups;
|
||||
import com.plannaplan.entities.Lecturer;
|
||||
import com.plannaplan.responses.models.DefaultGroupResponse;
|
||||
import com.plannaplan.responses.models.WithCapacityGroupResponse;
|
||||
import com.plannaplan.types.WeekDay;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class GroupsMappersTest {
|
||||
@Test
|
||||
public void shouldMapToResponseIncludingCapacity() {
|
||||
final List<Groups> gropus = Arrays.asList(
|
||||
new Groups(42, "A4-1", null, 520, WeekDay.MONDAY, new Lecturer("krul.", "Wladyslaw", "Potocki")));
|
||||
final List<WithCapacityGroupResponse> response = GroupsMappers.mapToCapacityResponse(gropus);
|
||||
|
||||
assert (response.get(0).getCapacity() == 42);
|
||||
assert (response.get(0) instanceof WithCapacityGroupResponse);
|
||||
assert (response.size() == 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldMapToResponseWiothoutCapacity() {
|
||||
final List<Groups> gropus = Arrays.asList(
|
||||
new Groups(42, "A4-1", null, 520, WeekDay.MONDAY, new Lecturer("krul.", "Wladyslaw", "Potocki")));
|
||||
final List<DefaultGroupResponse> response = GroupsMappers.mapToDefaultResponse(gropus);
|
||||
|
||||
assert (response.get(0) instanceof DefaultGroupResponse);
|
||||
assert (response.size() == 1);
|
||||
}
|
||||
}
|
@ -17,7 +17,6 @@ public class DefaultGroupResponseTest {
|
||||
new Groups(42, "A4-1", null, 520, WeekDay.MONDAY, new Lecturer("krul.", "Wladyslaw", "Potocki")), null);
|
||||
|
||||
final DefaultGroupResponse response = new DefaultGroupResponse(assignment);
|
||||
assertTrue(response.getCapacity() == 42);
|
||||
assertTrue(response.getDay() == 0);
|
||||
assertTrue(response.getLecturer().equals("krul. Wladyslaw Potocki"));
|
||||
assertTrue(response.getRoom().equals("A4-1"));
|
||||
@ -31,7 +30,6 @@ public class DefaultGroupResponseTest {
|
||||
new Lecturer("krul.", "Wladyslaw", "Potocki"));
|
||||
|
||||
final DefaultGroupResponse response = new DefaultGroupResponse(group);
|
||||
assertTrue(response.getCapacity() == 42);
|
||||
assertTrue(response.getDay() == 0);
|
||||
assertTrue(response.getLecturer().equals("krul. Wladyslaw Potocki"));
|
||||
assertTrue(response.getRoom().equals("A4-1"));
|
||||
@ -44,12 +42,10 @@ public class DefaultGroupResponseTest {
|
||||
final Groups group = new Groups();
|
||||
|
||||
final DefaultGroupResponse response = new DefaultGroupResponse(group);
|
||||
assertTrue(response.getCapacity() == 0);
|
||||
assertTrue(response.getDay() == -1);
|
||||
assertTrue(response.getLecturer().equals(""));
|
||||
assertTrue(response.getRoom().equals(""));
|
||||
assertTrue(response.getTime().equals("0.00"));
|
||||
assertTrue(response.getType() == null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,55 @@
|
||||
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 WithCapacityGroupResponseTest {
|
||||
@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 WithCapacityGroupResponse response = new WithCapacityGroupResponse(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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldMapGroupClassToResponse() {
|
||||
final Groups group = new Groups(42, "A4-1", null, 520, WeekDay.MONDAY,
|
||||
new Lecturer("krul.", "Wladyslaw", "Potocki"));
|
||||
|
||||
final WithCapacityGroupResponse response = new WithCapacityGroupResponse(group);
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldMapEmptyGroupClassToResponse() {
|
||||
final Groups group = new Groups();
|
||||
|
||||
final WithCapacityGroupResponse response = new WithCapacityGroupResponse(group);
|
||||
assertTrue(response.getCapacity() == 0);
|
||||
assertTrue(response.getDay() == -1);
|
||||
assertTrue(response.getLecturer().equals(""));
|
||||
assertTrue(response.getRoom().equals(""));
|
||||
assertTrue(response.getTime().equals("0.00"));
|
||||
assertTrue(response.getType() == null);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user