Made ASsignm,ents Conmtroller more readable
This commit is contained in:
@ -0,0 +1,24 @@
|
||||
package com.plannaplan.responses.mappers;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.plannaplan.entities.Groups;
|
||||
import com.plannaplan.responses.models.AssignmentResponse;
|
||||
|
||||
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);
|
||||
|
||||
assertTrue(response.size() == 2);
|
||||
assertTrue(response instanceof List);
|
||||
assertTrue(response.get(0) instanceof AssignmentResponse);
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ 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;
|
||||
@ -11,6 +12,20 @@ import org.junit.Test;
|
||||
|
||||
public class AssignmentResponseTest {
|
||||
|
||||
@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);
|
||||
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,
|
||||
@ -25,4 +40,17 @@ public class AssignmentResponseTest {
|
||||
assertTrue(response.getType() == GroupType.CLASS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldMapEmptyGroupClassToResponse() {
|
||||
final Groups group = new Groups();
|
||||
|
||||
final AssignmentResponse response = new AssignmentResponse(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