Added Assignment Response Model
This commit is contained in:
parent
f9706e0e01
commit
9d97306e5c
@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
public class TokenController {
|
public class TokenController {
|
||||||
|
|
||||||
public static String SERVICE_URL = "http://localhost:3000";
|
private final static String SERVICE_URL = "http://localhost:3000";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
package com.plannaplan.responses.models;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Groups;
|
||||||
|
import com.plannaplan.types.GroupType;
|
||||||
|
|
||||||
|
public class AssignmentResponse {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private int day;
|
||||||
|
private String time;
|
||||||
|
private String lecturer;
|
||||||
|
private String room;
|
||||||
|
private int capacity;
|
||||||
|
private GroupType type;
|
||||||
|
|
||||||
|
public AssignmentResponse(Groups group) {
|
||||||
|
this.id = group.getId();
|
||||||
|
this.day = group.getDay().label;
|
||||||
|
this.time = group.getTimeString();
|
||||||
|
this.lecturer = group.getLecturer().toString();
|
||||||
|
this.room = group.getRoom();
|
||||||
|
this.capacity = group.getCapacity();
|
||||||
|
this.type = group.getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCapacity() {
|
||||||
|
return capacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoom() {
|
||||||
|
return room;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLecturer() {
|
||||||
|
return lecturer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDay() {
|
||||||
|
return day;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.plannaplan.responses.models;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
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 AssignmentResponseTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldMapGroupClassToResponse() {
|
||||||
|
final Groups group = new Groups(42, "A4-1", null, 520, WeekDay.MONDAY,
|
||||||
|
new Lecturer("krul.", "Wladyslaw", "Potocki"));
|
||||||
|
|
||||||
|
final AssignmentResponse response = new AssignmentResponse(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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user