Added new test for new columns and update groups

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
2020-12-26 14:18:47 +01:00
parent f51979484f
commit c3d78505c8
5 changed files with 79 additions and 2 deletions

View File

@ -92,8 +92,12 @@ public class FileToDatabaseMigrator {
.orElseGet(() -> this.lecturerService
.save(new Lecturer(lecturerTitle, lecturerName, lecturerSurname)));
this.groupService.find(zajCykId, grNr).orElseGet(
() -> this.groupService.save(new Groups(capacity, room, course, time, groupDay, lecturer, zajCykId, grNr)));
Groups group = this.groupService.find(zajCykId, grNr).orElseGet(
() -> new Groups(capacity, room, course, time, groupDay, lecturer, zajCykId, grNr));
group.update(capacity, room, course, time, null, groupDay, lecturer);
this.groupService.save(group);
}

View File

@ -130,6 +130,47 @@ public class Groups {
this(capacity, room, course, time, time + DEFAULT_CLASS_TIME, day, lecturer);
}
/**
* Updates given values other that are not null
*
* @param capacity capacity given to the groups
* @param room room given to the groups
* @param course course given to the groups
* @param time time given to the groups
* @param endTime end time of class in minutes
* @param day day given to the groups
* @param lecturer lecturer given to the groups
*/
public void update(Integer capacity, String room, Course course, Integer time, Integer endTime, WeekDay day, Lecturer lecturer){
if (capacity != null){
this.capacity = capacity;
}
if (room != null){
this.room = room;
}
if (course != null){
this.course = course;
}
if (time != null){
this.time = time;
}
if (endTime != null){
this.endTime = endTime;
}
if (day != null){
this.day = day;
}
if (lecturer != null){
this.lecturer = lecturer;
}
}
/**
* get time of class end
*