Improve the UX when creating groups as a supervisor #123
65
test-data/src/main/java/se/su/dsv/scipro/testdata/populators/GroupCreationUXImprovement.java
vendored
Normal file
65
test-data/src/main/java/se/su/dsv/scipro/testdata/populators/GroupCreationUXImprovement.java
vendored
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
package se.su.dsv.scipro.testdata.populators;
|
||||||
|
|
||||||
|
import jakarta.inject.Inject;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
import se.su.dsv.scipro.project.ProjectService;
|
||||||
|
import se.su.dsv.scipro.system.ProjectType;
|
||||||
|
import se.su.dsv.scipro.system.User;
|
||||||
|
import se.su.dsv.scipro.testdata.BaseData;
|
||||||
|
import se.su.dsv.scipro.testdata.Factory;
|
||||||
|
import se.su.dsv.scipro.testdata.TestDataPopulator;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GroupCreationUXImprovement implements TestDataPopulator {
|
||||||
|
|
||||||
|
private static final String[] STUDENT_NAMES = { "Alice", "Bob", "Charlie", "David", "Emma" };
|
||||||
|
|
||||||
|
private final ProjectService projectService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public GroupCreationUXImprovement(ProjectService projectService) {
|
||||||
|
this.projectService = projectService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void populate(BaseData baseData, Factory factory) {
|
||||||
|
User supervisor = factory.createSupervisor("Evan");
|
||||||
|
List<User> students = createStudents(factory);
|
||||||
|
for (int i = 1; i <= 20; i++) {
|
||||||
|
projectService.save(createProject(baseData, i, supervisor, students));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<User> createStudents(Factory factory) {
|
||||||
|
return Arrays.stream(STUDENT_NAMES).map(factory::createAuthor).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Project createProject(BaseData baseData, int i, User supervisor, List<User> students) {
|
||||||
|
User author1 = students.get(i % students.size());
|
||||||
|
User author2 = students.get((i + 1) % students.size());
|
||||||
|
|
||||||
|
String title = "Test project " + i;
|
||||||
|
if (i % 6 == 0) {
|
||||||
|
title = title + " with a very long title that makes the project special";
|
||||||
|
}
|
||||||
|
|
||||||
|
ProjectType projectType =
|
||||||
|
switch (i % 3) {
|
||||||
|
case 1 -> baseData.magister();
|
||||||
|
case 2 -> baseData.master();
|
||||||
|
default -> baseData.bachelor();
|
||||||
|
};
|
||||||
|
return Project.builder()
|
||||||
|
.title(title)
|
||||||
|
.projectType(projectType)
|
||||||
|
.startDate(LocalDate.now())
|
||||||
|
.headSupervisor(supervisor)
|
||||||
|
.projectParticipants(Set.of(author1, author2))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user