Checkpoint - added many to many user group relations and test cerating users and groups to accept test
This commit is contained in:
@ -18,8 +18,10 @@ import javax.management.relation.Role;
|
||||
|
||||
import com.plannaplan.entities.Assignment;
|
||||
import com.plannaplan.entities.Commision;
|
||||
import com.plannaplan.entities.Groups;
|
||||
import com.plannaplan.entities.User;
|
||||
import com.plannaplan.types.UserRoles;
|
||||
import com.plannaplan.types.WeekDay;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@ -36,6 +38,8 @@ public class AssignmentServiceTest {
|
||||
private CommisionService comServie;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private GroupService groupService;
|
||||
|
||||
@Test
|
||||
public void shouldSaveAssignment() {
|
||||
@ -67,11 +71,37 @@ public class AssignmentServiceTest {
|
||||
@DirtiesContext(methodMode = MethodMode.BEFORE_METHOD)
|
||||
public void shouldPerformAcceptAlgorythm() {
|
||||
final Random generator = new Random();
|
||||
final User user1 = this.userService.save(new User(null, null,
|
||||
"shouldPerformAcceptAlgorythm-" + UUID.randomUUID().toString() + "@AssignmentService.test", null,
|
||||
UserRoles.STUDENT, generator.nextInt(400) + 100));
|
||||
|
||||
final User user2 = this.userService.save(new User(null, null,
|
||||
"shouldPerformAcceptAlgorythm-" + UUID.randomUUID().toString() + "@AssignmentService.test", null,
|
||||
UserRoles.STUDENT, generator.nextInt(400) + 100));
|
||||
|
||||
IntStream.range(0, 1700).forEach(i -> {
|
||||
this.userService.save(new User(null, null,
|
||||
"shouldPerformAcceptAlgorythm-" + UUID.randomUUID().toString() + "@AssignmentService.test", null,
|
||||
UserRoles.STUDENT, generator.nextInt(400) + 100));
|
||||
});
|
||||
|
||||
IntStream.range(0, 418).forEach(i -> {
|
||||
this.groupService.save(new Groups(generator.nextInt(80) + 20, null, null,
|
||||
generator.nextInt(9) * 30 + 9 * 30, WeekDay.getDay(generator.nextInt(5)), null));
|
||||
});
|
||||
|
||||
IntStream.range(0, 12).forEach(i -> {
|
||||
user1.claimGroup(this.groupService.save(new Groups(generator.nextInt(80) + 20, null, null,
|
||||
generator.nextInt(9) * 30 + 9 * 30, WeekDay.getDay(generator.nextInt(5)), null)));
|
||||
});
|
||||
this.userService.save(user1);
|
||||
|
||||
IntStream.range(0, 12).forEach(i -> {
|
||||
user2.claimGroup(this.groupService.save(new Groups(generator.nextInt(80) + 20, null, null,
|
||||
generator.nextInt(9) * 30 + 9 * 30, WeekDay.getDay(generator.nextInt(5)), null)));
|
||||
});
|
||||
this.userService.save(user2);
|
||||
|
||||
this.service.callAcceptAlgorythm();
|
||||
System.out.println("-X_-x-x-x-_X-x-x-x-X_-x-x-x-");
|
||||
}
|
||||
|
Reference in New Issue
Block a user