Tested in big data set
This commit is contained in:
parent
95cc34c676
commit
44f8c610d9
@ -89,13 +89,13 @@ public class AssignmentService {
|
||||
final Groups group = a.getGroup();
|
||||
if (group.getCapacity() > group.getRegisteredStudents().size()) {
|
||||
e.claimGroup(group);
|
||||
this.userService.save(e);
|
||||
accepted.add(group);
|
||||
} else {
|
||||
removed.add(group);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.userService.save(e);
|
||||
this.emailService.sendAcceptationResult(e, new EmailAcceptedData(accepted, removed));
|
||||
});
|
||||
}
|
||||
|
@ -154,6 +154,10 @@ public class UserService {
|
||||
return this.repo.getAllByRole(UserRoles.ADMIN).size() > 0;
|
||||
}
|
||||
|
||||
public void saveAll(List<User> users) {
|
||||
this.repo.saveAll(users);
|
||||
}
|
||||
|
||||
/**
|
||||
* get students sorted by their ranking
|
||||
*
|
||||
|
@ -9,6 +9,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
@ -21,6 +22,7 @@ import com.plannaplan.entities.User;
|
||||
import com.plannaplan.types.UserRoles;
|
||||
import com.plannaplan.types.WeekDay;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
@ -66,23 +68,28 @@ public class AssignmentServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@DirtiesContext(methodMode = MethodMode.BEFORE_METHOD)
|
||||
public void shouldPerformAcceptAlgorythm() {
|
||||
final Random generator = new Random();
|
||||
|
||||
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));
|
||||
});
|
||||
final List<Groups> groups = new ArrayList<>();
|
||||
|
||||
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));
|
||||
groups.add(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, 1700).forEach(i -> {
|
||||
final User user = this.userService.save(new User(null, null,
|
||||
"shouldPerformAcceptAlgorythm-" + UUID.randomUUID().toString() + "@AssignmentService.test", null,
|
||||
UserRoles.STUDENT, generator.nextInt(400) + 100));
|
||||
final Commision com = this.comServie.save(new Commision(user));
|
||||
IntStream.range(0, 5).forEach(j -> {
|
||||
this.service.save(new Assignment(groups.get(generator.nextInt(groups.size())), com));
|
||||
});
|
||||
});
|
||||
this.service.callAcceptAlgorythm();
|
||||
System.out.println("-X_-x-x-x-_X-x-x-x-X_-x-x-x-");
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user