Issue #2636 - Changed subscription code to use gmt calendar.
Former-commit-id:6e01cdb78e
[formerly6e01cdb78e
[formerly 3e75bd3e55517bca7c85213307ed67973c2f145e]] Former-commit-id:1caacacfe3
Former-commit-id:f4da152d87
This commit is contained in:
parent
f7c3c8c83d
commit
1f4cc8681d
3 changed files with 205 additions and 54 deletions
|
@ -1,19 +1,19 @@
|
||||||
/**
|
/**
|
||||||
* This software was developed and / or modified by Raytheon Company,
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
*
|
*
|
||||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
* This software product contains export-restricted data whose
|
* This software product contains export-restricted data whose
|
||||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
* to non-U.S. persons whether in the United States or abroad requires
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
* an export license or other authorization.
|
* an export license or other authorization.
|
||||||
*
|
*
|
||||||
* Contractor Name: Raytheon Company
|
* Contractor Name: Raytheon Company
|
||||||
* Contractor Address: 6825 Pine Street, Suite 340
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
* Mail Stop B8
|
* Mail Stop B8
|
||||||
* Omaha, NE 68106
|
* Omaha, NE 68106
|
||||||
* 402.291.0100
|
* 402.291.0100
|
||||||
*
|
*
|
||||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
* further licensing information.
|
* further licensing information.
|
||||||
**/
|
**/
|
||||||
|
@ -65,9 +65,10 @@ import com.raytheon.uf.common.time.util.TimeUtil;
|
||||||
* Nov 14, 2013 2548 mpduff Add a subscription type slot.
|
* Nov 14, 2013 2548 mpduff Add a subscription type slot.
|
||||||
* Jan 08, 2014 2615 bgonzale Implement calculate start and calculate end methods.
|
* Jan 08, 2014 2615 bgonzale Implement calculate start and calculate end methods.
|
||||||
* Jan 14, 2014 2459 mpduff Add subscription state.
|
* Jan 14, 2014 2459 mpduff Add subscription state.
|
||||||
* Jan 20, 2013 2398 dhladky Fixed rescheduling beyond active period/expired window.
|
* Jan 20, 2014 2398 dhladky Fixed rescheduling beyond active period/expired window.
|
||||||
* Jan 24, 2013 2709 bgonzale Fix setting of active period end. Change active period checks
|
* Jan 24, 2014 2709 bgonzale Fix setting of active period end. Change active period checks
|
||||||
* to check day of year. removed now unused active period methods.
|
* to check day of year. removed now unused active period methods.
|
||||||
|
* Jan 28, 2014 2636 mpduff Changed to use GMT calendar.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -472,15 +473,15 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
||||||
|
|
||||||
private Integer getStartActivePeriodDayOfYear() {
|
private Integer getStartActivePeriodDayOfYear() {
|
||||||
if (startActivePeriodDayOfYear == null && activePeriodStart != null) {
|
if (startActivePeriodDayOfYear == null && activePeriodStart != null) {
|
||||||
startActivePeriodDayOfYear = TimeUtil
|
startActivePeriodDayOfYear = TimeUtil.newGmtCalendar(
|
||||||
.newCalendar(activePeriodStart).get(Calendar.DAY_OF_YEAR);
|
activePeriodStart).get(Calendar.DAY_OF_YEAR);
|
||||||
}
|
}
|
||||||
return startActivePeriodDayOfYear;
|
return startActivePeriodDayOfYear;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer getEndActivePeriodDayOfYear() {
|
private Integer getEndActivePeriodDayOfYear() {
|
||||||
if (endActivePeriodDayOfYear == null && activePeriodEnd != null) {
|
if (endActivePeriodDayOfYear == null && activePeriodEnd != null) {
|
||||||
endActivePeriodDayOfYear = TimeUtil.newCalendar(activePeriodEnd)
|
endActivePeriodDayOfYear = TimeUtil.newGmtCalendar(activePeriodEnd)
|
||||||
.get(Calendar.DAY_OF_YEAR);
|
.get(Calendar.DAY_OF_YEAR);
|
||||||
}
|
}
|
||||||
return endActivePeriodDayOfYear;
|
return endActivePeriodDayOfYear;
|
||||||
|
@ -488,14 +489,34 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Calendar calculateStart(Calendar startConstraint) {
|
public Calendar calculateStart(Calendar startConstraint) {
|
||||||
return TimeUtil.newCalendar(TimeUtil.max(subscriptionStart,
|
if (subscriptionStart == null) {
|
||||||
startConstraint));
|
return startConstraint;
|
||||||
|
}
|
||||||
|
|
||||||
|
long subStartMillis = subscriptionStart.getTime();
|
||||||
|
long constaintMillis = startConstraint.getTimeInMillis();
|
||||||
|
|
||||||
|
if (subStartMillis > constaintMillis) {
|
||||||
|
return TimeUtil.newGmtCalendar(subscriptionStart);
|
||||||
|
}
|
||||||
|
|
||||||
|
return startConstraint;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Calendar calculateEnd(Calendar endConstraint) {
|
public Calendar calculateEnd(Calendar endConstraint) {
|
||||||
return TimeUtil.newCalendar(TimeUtil
|
if (subscriptionEnd == null) {
|
||||||
.min(subscriptionEnd, endConstraint));
|
return endConstraint;
|
||||||
|
}
|
||||||
|
|
||||||
|
long subEndMillis = subscriptionEnd.getTime();
|
||||||
|
long constaintMillis = endConstraint.getTimeInMillis();
|
||||||
|
|
||||||
|
if (subEndMillis < constaintMillis) {
|
||||||
|
return TimeUtil.newGmtCalendar(subscriptionEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return endConstraint;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -891,9 +912,10 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
||||||
|
|
||||||
return expired;
|
return expired;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for expiration on date
|
* Check for expiration on date
|
||||||
|
*
|
||||||
* @param date
|
* @param date
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -941,9 +963,10 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
||||||
return subscriptionState == SubscriptionState.ON
|
return subscriptionState == SubscriptionState.ON
|
||||||
&& !checkAndSetExpiration();
|
&& !checkAndSetExpiration();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should this be scheduled for this time.
|
* Should this be scheduled for this time.
|
||||||
|
*
|
||||||
* @param checkDate
|
* @param checkDate
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -951,10 +974,11 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
||||||
if (!isExpired(checkCal.getTime()) && inActivePeriodWindow(checkCal)) {
|
if (!isExpired(checkCal.getTime()) && inActivePeriodWindow(checkCal)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean inActivePeriodWindow(Calendar checkDate) {
|
public boolean inActivePeriodWindow(Calendar checkDate) {
|
||||||
if (activePeriodStart == null && activePeriodEnd == null) {
|
if (activePeriodStart == null && activePeriodEnd == null) {
|
||||||
// no active period set
|
// no active period set
|
||||||
|
@ -967,7 +991,7 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
||||||
boolean isAfterPeriodStart = startDay <= checkDay;
|
boolean isAfterPeriodStart = startDay <= checkDay;
|
||||||
boolean isBeforePeriodEnd = checkDay < endDay;
|
boolean isBeforePeriodEnd = checkDay < endDay;
|
||||||
boolean periodCrossesYearBoundary = endDay < startDay;
|
boolean periodCrossesYearBoundary = endDay < startDay;
|
||||||
|
|
||||||
if (periodCrossesYearBoundary) {
|
if (periodCrossesYearBoundary) {
|
||||||
return isAfterPeriodStart || isBeforePeriodEnd;
|
return isAfterPeriodStart || isBeforePeriodEnd;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1084,4 +1108,4 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
||||||
public boolean shouldUpdate() {
|
public boolean shouldUpdate() {
|
||||||
return shouldUpdate;
|
return shouldUpdate;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -56,6 +56,7 @@ import com.raytheon.uf.common.time.domain.api.ITimePoint;
|
||||||
* Nov 05, 2013 2499 rjpeter Added prettyDuration.
|
* Nov 05, 2013 2499 rjpeter Added prettyDuration.
|
||||||
* Jan 08, 2014 2615 bgonzale Added Calendar min and max methods.
|
* Jan 08, 2014 2615 bgonzale Added Calendar min and max methods.
|
||||||
* Added newGmtCalendar from a date method.
|
* Added newGmtCalendar from a date method.
|
||||||
|
* Jan 28, 2014 2636 mpduff Removed unused methods.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author njensen
|
* @author njensen
|
||||||
|
@ -181,6 +182,13 @@ public final class TimeUtil {
|
||||||
*/
|
*/
|
||||||
static ITimeStrategy timeStrategy = SYSTEM_TIME_STRATEGY;
|
static ITimeStrategy timeStrategy = SYSTEM_TIME_STRATEGY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disabled constructor.
|
||||||
|
*/
|
||||||
|
private TimeUtil() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a Calendar in the local time zone to a GMT date
|
* Converts a Calendar in the local time zone to a GMT date
|
||||||
*
|
*
|
||||||
|
@ -327,30 +335,6 @@ public final class TimeUtil {
|
||||||
|| (laterCal.get(Calendar.YEAR) > earlierCal.get(Calendar.YEAR));
|
|| (laterCal.get(Calendar.YEAR) > earlierCal.get(Calendar.YEAR));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Min comparison of a Date and a Calendar; returns the lesser.
|
|
||||||
*
|
|
||||||
* @param lhs
|
|
||||||
* @param rhs
|
|
||||||
* @return the lesser of a Data and a Calendar; returns null if either is
|
|
||||||
* null.
|
|
||||||
*/
|
|
||||||
public static Calendar min(Date lhs, Calendar rhs) {
|
|
||||||
return min(TimeUtil.newCalendar(lhs), rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Max comparison of a Date and a Calendar; returns the greater.
|
|
||||||
*
|
|
||||||
* @param lhs
|
|
||||||
* @param rhs
|
|
||||||
* @return the greater of a Data and a Calendar; returns null if either is
|
|
||||||
* null.
|
|
||||||
*/
|
|
||||||
public static Calendar max(Date lhs, Calendar rhs) {
|
|
||||||
return max(TimeUtil.newCalendar(lhs), rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Max comparison of two Calendars; returns the greater.
|
* Max comparison of two Calendars; returns the greater.
|
||||||
*
|
*
|
||||||
|
@ -577,14 +561,9 @@ public final class TimeUtil {
|
||||||
return timeString.toString();
|
return timeString.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Disabled constructor.
|
|
||||||
*/
|
|
||||||
private TimeUtil() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New Calendar from a Date
|
* New Calendar from a Date
|
||||||
|
*
|
||||||
* @param date
|
* @param date
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -596,7 +575,7 @@ public final class TimeUtil {
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New Calendar from an existing calendar
|
* New Calendar from an existing calendar
|
||||||
*
|
*
|
||||||
|
@ -611,7 +590,7 @@ public final class TimeUtil {
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New GMT Calendar from a Date
|
* New GMT Calendar from a Date
|
||||||
*
|
*
|
||||||
|
@ -637,11 +616,11 @@ public final class TimeUtil {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Calendar addCurrentYearCalendar(final Calendar calendar) {
|
public static Calendar addCurrentYearCalendar(final Calendar calendar) {
|
||||||
|
|
||||||
Calendar yearTime = TimeUtil.newGmtCalendar();
|
Calendar yearTime = TimeUtil.newGmtCalendar();
|
||||||
calendar.set(Calendar.YEAR, yearTime.get(Calendar.YEAR));
|
calendar.set(Calendar.YEAR, yearTime.get(Calendar.YEAR));
|
||||||
|
|
||||||
return calendar;
|
return calendar;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,10 @@ import static org.hamcrest.CoreMatchers.not;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
|
|
||||||
|
@ -54,8 +56,9 @@ import com.raytheon.uf.common.time.util.TimeUtilTest;
|
||||||
* Jan 11, 2013 1453 djohnson Add test for active period crossing year boundary.
|
* Jan 11, 2013 1453 djohnson Add test for active period crossing year boundary.
|
||||||
* Mar 28, 2013 1841 djohnson Subscription is now UserSubscription.
|
* Mar 28, 2013 1841 djohnson Subscription is now UserSubscription.
|
||||||
* May 15, 2013 1040 mpduff Office Id now a set.
|
* May 15, 2013 1040 mpduff Office Id now a set.
|
||||||
* Oct 21, 2013 2292 mpduff Implement multiple data types
|
* Oct 21, 2013 2292 mpduff Implement multiple data types.
|
||||||
* Jan 14, 2014 2459 mpduff Change Subscription status code
|
* Jan 14, 2014 2459 mpduff Change Subscription status code.
|
||||||
|
* Jan 28, 2014 2636 mpduff Added testInWindow test method.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -268,4 +271,149 @@ public class SiteSubscriptionTest {
|
||||||
System.out.println(new JAXBManager(SiteSubscription.class)
|
System.out.println(new JAXBManager(SiteSubscription.class)
|
||||||
.marshalToXml(subscription));
|
.marshalToXml(subscription));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetStatusForOneDayWindow() {
|
||||||
|
final Date tomorrow = new Date(TimeUtil.currentTimeMillis()
|
||||||
|
+ (TimeUtil.MILLIS_PER_DAY));
|
||||||
|
final Date today = new Date(TimeUtil.currentTimeMillis());
|
||||||
|
|
||||||
|
Subscription subscription = new SubscriptionBuilder()
|
||||||
|
.withActivePeriodStart(today).withActivePeriodEnd(tomorrow)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertThat(subscription.getStatus(),
|
||||||
|
is(equalTo(SubscriptionStatus.ACTIVE)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInWindowMethod() {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm");
|
||||||
|
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||||
|
Calendar startCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||||
|
Calendar endCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||||
|
Calendar checkCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||||
|
|
||||||
|
startCal.set(Calendar.MONTH, Calendar.DECEMBER);
|
||||||
|
startCal.set(Calendar.DAY_OF_MONTH, 20);
|
||||||
|
endCal.set(Calendar.MONTH, Calendar.JANUARY);
|
||||||
|
endCal.set(Calendar.DAY_OF_MONTH, 10);
|
||||||
|
|
||||||
|
// Active window crosses year boundary
|
||||||
|
// First check Jan 1
|
||||||
|
checkCal.set(Calendar.MONTH, Calendar.JANUARY);
|
||||||
|
checkCal.set(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
startCal = TimeUtil.minCalendarFields(startCal, Calendar.HOUR_OF_DAY,
|
||||||
|
Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND);
|
||||||
|
endCal = TimeUtil.minCalendarFields(endCal, Calendar.HOUR_OF_DAY,
|
||||||
|
Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND);
|
||||||
|
checkCal = TimeUtil.minCalendarFields(checkCal, Calendar.HOUR_OF_DAY,
|
||||||
|
Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND);
|
||||||
|
|
||||||
|
Subscription subscription = new SubscriptionBuilder()
|
||||||
|
.withActivePeriodStart(startCal.getTime())
|
||||||
|
.withActivePeriodEnd(endCal.getTime()).build();
|
||||||
|
|
||||||
|
System.out.println("\nStartCal: " + sdf.format(startCal.getTime()));
|
||||||
|
System.out.println("EndCal: " + sdf.format(endCal.getTime()));
|
||||||
|
System.out.println("CheckCal: " + sdf.format(checkCal.getTime()));
|
||||||
|
assertThat(subscription.inActivePeriodWindow(checkCal),
|
||||||
|
is(equalTo(Boolean.TRUE)));
|
||||||
|
|
||||||
|
// Next check Starting Day
|
||||||
|
checkCal.set(Calendar.MONTH, Calendar.DECEMBER);
|
||||||
|
checkCal.set(Calendar.DAY_OF_MONTH, 20);
|
||||||
|
|
||||||
|
System.out.println("\nStartCal: " + sdf.format(startCal.getTime()));
|
||||||
|
System.out.println("EndCal: " + sdf.format(endCal.getTime()));
|
||||||
|
System.out.println("CheckCal: " + sdf.format(checkCal.getTime()));
|
||||||
|
assertThat(subscription.inActivePeriodWindow(checkCal),
|
||||||
|
is(equalTo(Boolean.TRUE)));
|
||||||
|
|
||||||
|
// Next check Ending Day - Should be outside window
|
||||||
|
checkCal.set(Calendar.MONTH, Calendar.JANUARY);
|
||||||
|
checkCal.set(Calendar.DAY_OF_MONTH, 10);
|
||||||
|
|
||||||
|
System.out.println("\nStartCal: " + sdf.format(startCal.getTime()));
|
||||||
|
System.out.println("EndCal: " + sdf.format(endCal.getTime()));
|
||||||
|
System.out.println("CheckCal: " + sdf.format(checkCal.getTime()));
|
||||||
|
assertThat(subscription.inActivePeriodWindow(checkCal),
|
||||||
|
is(equalTo(Boolean.FALSE)));
|
||||||
|
|
||||||
|
// Next check before starting Day - Should be outside window
|
||||||
|
checkCal.set(Calendar.MONTH, Calendar.OCTOBER);
|
||||||
|
checkCal.set(Calendar.DAY_OF_MONTH, 10);
|
||||||
|
|
||||||
|
System.out.println("\nStartCal: " + sdf.format(startCal.getTime()));
|
||||||
|
System.out.println("EndCal: " + sdf.format(endCal.getTime()));
|
||||||
|
System.out.println("CheckCal: " + sdf.format(checkCal.getTime()));
|
||||||
|
assertThat(subscription.inActivePeriodWindow(checkCal),
|
||||||
|
is(equalTo(Boolean.FALSE)));
|
||||||
|
|
||||||
|
// Next check after ending Day - Should be outside window
|
||||||
|
checkCal.set(Calendar.MONTH, Calendar.MARCH);
|
||||||
|
checkCal.set(Calendar.DAY_OF_MONTH, 10);
|
||||||
|
|
||||||
|
System.out.println("\nStartCal: " + sdf.format(startCal.getTime()));
|
||||||
|
System.out.println("EndCal: " + sdf.format(endCal.getTime()));
|
||||||
|
System.out.println("CheckCal: " + sdf.format(checkCal.getTime()));
|
||||||
|
assertThat(subscription.inActivePeriodWindow(checkCal),
|
||||||
|
is(equalTo(Boolean.FALSE)));
|
||||||
|
|
||||||
|
// Change window to not be over year boundary
|
||||||
|
startCal.set(Calendar.MONTH, Calendar.MARCH);
|
||||||
|
startCal.set(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
endCal.set(Calendar.MONTH, Calendar.OCTOBER);
|
||||||
|
endCal.set(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
|
||||||
|
subscription = new SubscriptionBuilder()
|
||||||
|
.withActivePeriodStart(startCal.getTime())
|
||||||
|
.withActivePeriodEnd(endCal.getTime()).build();
|
||||||
|
|
||||||
|
// First check day in the window
|
||||||
|
checkCal.set(Calendar.MONTH, Calendar.JUNE);
|
||||||
|
checkCal.set(Calendar.DAY_OF_MONTH, 10);
|
||||||
|
System.out.println("\nStartCal: " + sdf.format(startCal.getTime()));
|
||||||
|
System.out.println("EndCal: " + sdf.format(endCal.getTime()));
|
||||||
|
System.out.println("CheckCal: " + sdf.format(checkCal.getTime()));
|
||||||
|
assertThat(subscription.inActivePeriodWindow(checkCal),
|
||||||
|
is(equalTo(Boolean.TRUE)));
|
||||||
|
|
||||||
|
// Check start day
|
||||||
|
checkCal.set(Calendar.MONTH, Calendar.MARCH);
|
||||||
|
checkCal.set(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
System.out.println("\nStartCal: " + sdf.format(startCal.getTime()));
|
||||||
|
System.out.println("EndCal: " + sdf.format(endCal.getTime()));
|
||||||
|
System.out.println("CheckCal: " + sdf.format(checkCal.getTime()));
|
||||||
|
assertThat(subscription.inActivePeriodWindow(checkCal),
|
||||||
|
is(equalTo(Boolean.TRUE)));
|
||||||
|
|
||||||
|
// Check end day - should be outside window
|
||||||
|
checkCal.set(Calendar.MONTH, Calendar.OCTOBER);
|
||||||
|
checkCal.set(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
System.out.println("\nStartCal: " + sdf.format(startCal.getTime()));
|
||||||
|
System.out.println("EndCal: " + sdf.format(endCal.getTime()));
|
||||||
|
System.out.println("CheckCal: " + sdf.format(checkCal.getTime()));
|
||||||
|
assertThat(subscription.inActivePeriodWindow(checkCal),
|
||||||
|
is(equalTo(Boolean.FALSE)));
|
||||||
|
|
||||||
|
// Check before start day - should be outside window
|
||||||
|
checkCal.set(Calendar.MONTH, Calendar.FEBRUARY);
|
||||||
|
checkCal.set(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
System.out.println("\nStartCal: " + sdf.format(startCal.getTime()));
|
||||||
|
System.out.println("EndCal: " + sdf.format(endCal.getTime()));
|
||||||
|
System.out.println("CheckCal: " + sdf.format(checkCal.getTime()));
|
||||||
|
assertThat(subscription.inActivePeriodWindow(checkCal),
|
||||||
|
is(equalTo(Boolean.FALSE)));
|
||||||
|
|
||||||
|
// Check after end day - should be outside window
|
||||||
|
checkCal.set(Calendar.MONTH, Calendar.NOVEMBER);
|
||||||
|
checkCal.set(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
System.out.println("\nStartCal: " + sdf.format(startCal.getTime()));
|
||||||
|
System.out.println("EndCal: " + sdf.format(endCal.getTime()));
|
||||||
|
System.out.println("CheckCal: " + sdf.format(checkCal.getTime()));
|
||||||
|
assertThat(subscription.inActivePeriodWindow(checkCal),
|
||||||
|
is(equalTo(Boolean.FALSE)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue