Refactored the test code, instance variables should be local variables if possible, unused code are removed etc..
This commit is contained in:
parent
9ebe83fdd0
commit
20b1d10219
@ -54,34 +54,34 @@ public class TestFinalSeminarDaoJPA {
|
||||
|
||||
@Autowired
|
||||
private FinalSeminarActiveParticipationDao finalSeminarActiveParticipationDao;
|
||||
|
||||
Project opponentProject;
|
||||
Project presenterProject;
|
||||
ProjectClass projectClass;
|
||||
|
||||
User presenter;
|
||||
Student presenterRole;
|
||||
|
||||
User opponent1;
|
||||
Student opponent1Role;
|
||||
FinalSeminarOpposition opposition1;
|
||||
|
||||
User opponent2;
|
||||
Student opponent2Role;
|
||||
FinalSeminarOpposition opposition2;
|
||||
|
||||
User opponentProjectSupervisor;
|
||||
Employee opponentProjectSupervisorRole;
|
||||
|
||||
User presenterProjectSupervisor;
|
||||
Employee presenterProjectSupervisorRole;
|
||||
|
||||
FinalSeminar seminar;
|
||||
|
||||
User activeParticipantUser;
|
||||
Student activeParticipantRole;
|
||||
FinalSeminarActiveParticipation activeParticipation;
|
||||
Project activeParticipantProject;
|
||||
|
||||
private Project opponentProject;
|
||||
private Project presenterProject;
|
||||
private ProjectClass projectClass;
|
||||
|
||||
private User presenter;
|
||||
private Student presenterRole;
|
||||
|
||||
private User opponent1;
|
||||
private Student opponent1Role;
|
||||
private FinalSeminarOpposition opposition1;
|
||||
|
||||
private User opponent2;
|
||||
private Student opponent2Role;
|
||||
private FinalSeminarOpposition opposition2;
|
||||
|
||||
private User opponentProjectSupervisor;
|
||||
private Employee opponentProjectSupervisorRole;
|
||||
|
||||
private User presenterProjectSupervisor;
|
||||
private Employee presenterProjectSupervisorRole;
|
||||
|
||||
private FinalSeminar seminar;
|
||||
|
||||
private User activeParticipantUser;
|
||||
private Student activeParticipantRole;
|
||||
private FinalSeminarActiveParticipation activeParticipation;
|
||||
private Project activeParticipantProject;
|
||||
|
||||
|
||||
@Before
|
||||
|
@ -53,16 +53,14 @@ public class TestMessageBoardDaoJPA {
|
||||
|
||||
@Autowired
|
||||
private ProjectDao projectDao;
|
||||
|
||||
private User user;
|
||||
|
||||
private MessageBoard messageBoard;
|
||||
private MessageBoard messageBoard;
|
||||
private Project presenterProject;
|
||||
|
||||
@Before
|
||||
public void startTransaction()
|
||||
{
|
||||
user = new User();
|
||||
User user = new User();
|
||||
user.setEmailAddress("test@dsv.su.se");
|
||||
user.setIdentifier(new Long(666));
|
||||
user.setFirstName("Test");
|
||||
|
@ -34,18 +34,16 @@ public class TestRatableDaoJPA {
|
||||
|
||||
@Autowired
|
||||
private RatingDao ratingDao;
|
||||
|
||||
private User user;
|
||||
|
||||
private Resource link;
|
||||
|
||||
private Resource link;
|
||||
|
||||
@Autowired
|
||||
private RatableDao ratableDao;
|
||||
|
||||
@Before
|
||||
public void startTransaction(){
|
||||
|
||||
user = new User();
|
||||
|
||||
User user = new User();
|
||||
user = userDao.save(user);
|
||||
Rating rating = new Rating();
|
||||
rating.setUser(user);
|
||||
|
@ -44,12 +44,8 @@ public class TestResourceDaoJPA {
|
||||
|
||||
@Autowired
|
||||
private CategoryDao categoryDao;
|
||||
|
||||
private User user;
|
||||
|
||||
private Resource resource;
|
||||
|
||||
private Tag tag;
|
||||
|
||||
private Tag tag;
|
||||
|
||||
private Category category;
|
||||
|
||||
@ -58,8 +54,8 @@ public class TestResourceDaoJPA {
|
||||
|
||||
@Before
|
||||
public void startTransaction(){
|
||||
|
||||
user = new User();
|
||||
|
||||
User user = new User();
|
||||
user = userDao.save(user);
|
||||
Rating rating = new Rating();
|
||||
rating.setUser(user);
|
||||
@ -77,8 +73,8 @@ public class TestResourceDaoJPA {
|
||||
category = new Category();
|
||||
category.setCategoryName("test");
|
||||
category = categoryDao.save(category);
|
||||
|
||||
resource = new Resource();
|
||||
|
||||
Resource resource = new Resource();
|
||||
resource.setCreator(user);
|
||||
List<Rating> ratingList = new ArrayList<Rating>();
|
||||
ratingList.add(rating);
|
||||
|
@ -43,14 +43,8 @@ public class TestScheduleTemplateDaoJPA {
|
||||
|
||||
@Autowired
|
||||
private ProjectClassDao projectClassDao;
|
||||
|
||||
private User supervisorUser;
|
||||
private Employee supervisorRole;
|
||||
|
||||
private User sysAdminUser;
|
||||
private SysAdmin sysAdminRole;
|
||||
|
||||
private ScheduleTemplate sysAdminTemplate;
|
||||
|
||||
private ScheduleTemplate sysAdminTemplate;
|
||||
private ScheduleTemplate employeeTemplate;
|
||||
private ScheduleTemplate masterTemplate;
|
||||
|
||||
@ -61,18 +55,18 @@ public class TestScheduleTemplateDaoJPA {
|
||||
|
||||
@Before
|
||||
public void startTransaction(){
|
||||
|
||||
supervisorUser = new User();
|
||||
|
||||
User supervisorUser = new User();
|
||||
supervisorUser = userDao.save(supervisorUser);
|
||||
|
||||
supervisorRole = new Employee();
|
||||
|
||||
Employee supervisorRole = new Employee();
|
||||
supervisorRole.setUser(supervisorUser);
|
||||
supervisorRole = (Employee) roleDao.save(supervisorRole);
|
||||
|
||||
sysAdminUser = new User();
|
||||
|
||||
User sysAdminUser = new User();
|
||||
sysAdminUser = userDao.save(sysAdminUser);
|
||||
|
||||
sysAdminRole = new SysAdmin();
|
||||
|
||||
SysAdmin sysAdminRole = new SysAdmin();
|
||||
sysAdminRole.setUser(sysAdminUser);
|
||||
sysAdminRole = (SysAdmin) roleDao.save(sysAdminRole);
|
||||
|
||||
|
@ -55,8 +55,6 @@ public class TestGreedyMatchingAlgorithm {
|
||||
@Autowired
|
||||
private KeywordDao keywordDao;
|
||||
|
||||
@Autowired
|
||||
private ApplicationPeriodDao applicationPeriodDao;
|
||||
|
||||
@Autowired
|
||||
private ApplicationPeriodFacade applicationPeriodFacade;
|
||||
|
@ -42,24 +42,14 @@ public class TestExemptionDao {
|
||||
|
||||
private ExemptionDao target;
|
||||
|
||||
private User student1;
|
||||
|
||||
private ProjectClass bachelor;
|
||||
|
||||
private Student student1Author;
|
||||
|
||||
private Exemption student1Exemption;
|
||||
|
||||
private User student2;
|
||||
|
||||
private Student student2Author;
|
||||
|
||||
private Exemption student2Exemption;
|
||||
|
||||
private ExemptionDaoParams exemptionDaoParams;
|
||||
|
||||
private User student3;
|
||||
|
||||
private Student student3Author;
|
||||
|
||||
private Exemption student3Exemption;
|
||||
@ -80,12 +70,12 @@ public class TestExemptionDao {
|
||||
admin.setFirstName("Admin 1");
|
||||
admin = userDao.save(admin);
|
||||
|
||||
|
||||
student1 = new User();
|
||||
|
||||
User student1 = new User();
|
||||
student1.setFirstName("User 1");
|
||||
student1.setLastName("Last 1");
|
||||
student1 = userDao.save(student1);
|
||||
student1Author = authorDao.getOrCreate(student1);
|
||||
Student student1Author = authorDao.getOrCreate(student1);
|
||||
|
||||
student1Exemption = new Exemption();
|
||||
student1Exemption.setProjectClass(bachelor);
|
||||
@ -93,22 +83,21 @@ public class TestExemptionDao {
|
||||
student1Exemption.setGrantedBy(admin);
|
||||
student1Exemption = exemptionDao.save(student1Exemption);
|
||||
|
||||
|
||||
|
||||
student2 = new User();
|
||||
|
||||
User student2 = new User();
|
||||
student2.setFirstName("User 2");
|
||||
student2.setLastName("Lst 1");
|
||||
student2 = userDao.save(student2);
|
||||
student2Author = authorDao.getOrCreate(student2);
|
||||
Student student2Author = authorDao.getOrCreate(student2);
|
||||
|
||||
student2Exemption = new Exemption();
|
||||
student2Exemption.setProjectClass(bachelor);
|
||||
student2Exemption.setAuthor(student2Author);
|
||||
student2Exemption.setGrantedBy(admin);
|
||||
student2Exemption = exemptionDao.save(student2Exemption);
|
||||
|
||||
|
||||
student3 = new User();
|
||||
|
||||
|
||||
User student3 = new User();
|
||||
student3.setFirstName("Usr 3");
|
||||
student3.setLastName("Last 3");
|
||||
student3 = userDao.save(student3);
|
||||
|
Loading…
x
Reference in New Issue
Block a user