01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.module.purap.service;
17:
18: import static org.kuali.test.fixtures.UserNameFixture.KHUNTLEY;
19:
20: import java.sql.Date;
21: import java.util.Calendar;
22:
23: import org.kuali.core.service.DateTimeService;
24: import org.kuali.kfs.context.KualiTestBase;
25: import org.kuali.kfs.context.SpringContext;
26: import org.kuali.test.ConfigureContext;
27:
28: @ConfigureContext(session=KHUNTLEY)
29: public class PurapServiceTest extends KualiTestBase {
30:
31: private Date currentDate;
32: private Date compareDate;
33: private int dayOffset = 60;
34:
35: @Override
36: protected void setUp() throws Exception {
37: super .setUp();
38: currentDate = SpringContext.getBean(DateTimeService.class)
39: .getCurrentSqlDate();
40: Calendar calendar = SpringContext
41: .getBean(DateTimeService.class).getCurrentCalendar();
42: calendar.add(Calendar.DATE, dayOffset);
43: compareDate = new Date(calendar.getTimeInMillis());
44: }
45:
46: @Override
47: protected void tearDown() throws Exception {
48: currentDate = null;
49: compareDate = null;
50: super .tearDown();
51: }
52:
53: public void testIsDateMoreThanANumberOfDaysAway_ManyFewerDays() {
54: int daysAway = dayOffset - 5;
55: assertTrue(SpringContext.getBean(PurapService.class)
56: .isDateMoreThanANumberOfDaysAway(compareDate, daysAway));
57: }
58:
59: public void testIsDateMoreThanANumberOfDaysAway_OneLessDays() {
60: int daysAway = dayOffset - 1;
61: assertTrue(SpringContext.getBean(PurapService.class)
62: .isDateMoreThanANumberOfDaysAway(compareDate, daysAway));
63: }
64:
65: public void testIsDateMoreThanANumberOfDaysAway_SameNumberOfDays() {
66: int daysAway = dayOffset;
67: assertFalse(SpringContext.getBean(PurapService.class)
68: .isDateMoreThanANumberOfDaysAway(compareDate, daysAway));
69: }
70:
71: public void testIsDateMoreThanANumberOfDaysAway_OneMoreDays() {
72: int daysAway = dayOffset + 1;
73: assertFalse(SpringContext.getBean(PurapService.class)
74: .isDateMoreThanANumberOfDaysAway(compareDate, daysAway));
75: }
76:
77: public void testIsDateMoreThanANumberOfDaysAway_ManyMoreDays() {
78: int daysAway = dayOffset + 5;
79: assertFalse(SpringContext.getBean(PurapService.class)
80: .isDateMoreThanANumberOfDaysAway(compareDate, daysAway));
81: }
82: }
|