Made ASsignm,ents Conmtroller more readable

This commit is contained in:
Filip Izydorczyk
2020-10-08 16:41:13 +02:00
parent 9d97306e5c
commit f97e22fa5f
5 changed files with 90 additions and 31 deletions

View File

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

View File

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