Method for removing application periods wrongly implemented.
This commit is contained in:
parent
c81b8bf207
commit
28f158cc26
src
main/java/se/su/dsv/scipro/match/facade
test/java/se/su/dsv/scipro/match/dao
@ -24,7 +24,7 @@ public class ApplicationPeriodFacade {
|
||||
|
||||
/**
|
||||
* Returns true when the application period has been removed successfully,
|
||||
* it should only be possible to remove/edit a period if the end date is after the present date,
|
||||
* it should only be possible to remove/edit a period only if the start date NOT IS BEFORE present date,
|
||||
* That is because the history should be kept.
|
||||
* @param appPeriod the period that should be removed
|
||||
* @return boolean the value is true when success false when failure
|
||||
@ -32,7 +32,7 @@ public class ApplicationPeriodFacade {
|
||||
@Transactional
|
||||
public boolean removeApplicationPeriod(ApplicationPeriod appPeriod){
|
||||
appPeriod = applicationPeriodDao.reLoad(appPeriod);
|
||||
if(appPeriod.getEndDate().after(Calendar.getInstance().getTime())) {
|
||||
if(!appPeriod.getStartDate().before(Calendar.getInstance().getTime())) {
|
||||
applicationPeriodDao.delete(appPeriod);
|
||||
return true;
|
||||
} else {
|
||||
|
@ -189,7 +189,8 @@ public class TestApplicationPeriodDao {
|
||||
}
|
||||
|
||||
|
||||
/* create an application period with the end date before the date of TODAY, then it should NOT be possible to remove the application period */
|
||||
/* create an application period with the end date before the date of TODAY, then it should NOT be possible to remove the application period,
|
||||
* this is because old application periods must be kept in the history */
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
@ -207,7 +208,26 @@ public class TestApplicationPeriodDao {
|
||||
Assert.assertFalse(periodRemoved); // should be false
|
||||
}
|
||||
|
||||
/* create an application period with the end date before after the date of "TODAY", then it should be possible to remove */
|
||||
|
||||
/* create an application period with the start date before the date of TODAY but the end date after the date of TODAY, then it should NOT be possible to remove the application period, */
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
public void notAbleToRemovePeriod_v2() {
|
||||
Set<ProjectClass> myBachelorSet = new HashSet<ProjectClass>();
|
||||
myBachelorSet.add(bachelor);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.MONTH, -1);
|
||||
final Date startDate1 = cal.getTime();
|
||||
cal.add(Calendar.MONDAY, 3);
|
||||
final Date endDate1 = cal.getTime();
|
||||
ApplicationPeriod applicationPeriod = applicationPeriodDao.save(ApplicationPeriodFacade.createApplicationPeriod(myBachelorSet, startDate1, endDate1));
|
||||
boolean periodRemoved = applicationPeriodFacade.removeApplicationPeriod(applicationPeriod);
|
||||
Assert.assertFalse(periodRemoved); // should be false
|
||||
}
|
||||
|
||||
|
||||
/* create an application period with the both the start-date and the end-date after the date of "TODAY", then it should be possible to remove the period */
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
@ -215,10 +235,9 @@ public class TestApplicationPeriodDao {
|
||||
Set<ProjectClass> myBachelorSet = new HashSet<ProjectClass>();
|
||||
myBachelorSet.add(bachelor);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(2011, Calendar.DECEMBER, 2);
|
||||
cal.add(Calendar.MONTH, 2);
|
||||
final Date startDate1 = cal.getTime();
|
||||
cal.set(2051, Calendar.DECEMBER, 7);
|
||||
cal.set(Calendar.HOUR_OF_DAY, 13);
|
||||
cal.add(Calendar.MONTH, 3);
|
||||
final Date endDate1 = cal.getTime();
|
||||
ApplicationPeriod applicationPeriod = applicationPeriodDao.save(ApplicationPeriodFacade.createApplicationPeriod(myBachelorSet, startDate1, endDate1));
|
||||
boolean periodRemoved = applicationPeriodFacade.removeApplicationPeriod(applicationPeriod);
|
||||
|
Loading…
x
Reference in New Issue
Block a user