SortedSet<User> userSet = new TreeSet<User>();
userSet.add(user);
// create a new site
Site newSite = SiteService.get().newSite();
newSite.setName("Site_" + user.getUsername()); // make this unique
// create a new period
Period newPeriod = SiteService.get().newPeriod();
newPeriod.setSite(newSite);
newPeriod.setName("Class_" + user.getUsername()); // make this unique
// add the period to the user and the site
SortedSet<Period> periodSet = new TreeSet<Period>();
periodSet.add(newPeriod);
user.getPeriods().add(newPeriod);
newSite.getPeriods().add(newPeriod);
// a default student must be added to the new period
User studentUser = UserService.get().newUser();
studentUser.setRole(Role.STUDENT);
studentUser.setFirstName("Student");