|
|
|
@ -28,9 +28,8 @@ import java.util.*;
|
|
|
|
|
|
|
|
|
|
import nl.jqno.equalsverifier.*;
|
|
|
|
|
|
|
|
|
|
import static java.util.Calendar.JANUARY;
|
|
|
|
|
import static java.util.Calendar.JULY;
|
|
|
|
|
import static java.util.Calendar.JUNE;
|
|
|
|
|
import static java.util.Calendar.*;
|
|
|
|
|
import static junit.framework.TestCase.*;
|
|
|
|
|
import static org.hamcrest.MatcherAssert.*;
|
|
|
|
|
import static org.hamcrest.core.IsEqual.*;
|
|
|
|
|
import static org.isoron.uhabits.core.models.Checkmark.*;
|
|
|
|
@ -422,4 +421,44 @@ public class CheckmarkListTest extends BaseUnitTest
|
|
|
|
|
assertThat(byYear.get(1), equalTo(new Checkmark(timestamp(2014, JANUARY, 1), 8227)));
|
|
|
|
|
assertThat(byYear.get(2), equalTo(new Checkmark(timestamp(2013, JANUARY, 1), 16172)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetTodayValue() throws Exception
|
|
|
|
|
{
|
|
|
|
|
Habit habit = fixtures.createLongNumericalHabit(timestamp(2014, JUNE, 1));
|
|
|
|
|
CheckmarkList checkmarks = habit.getCheckmarks();
|
|
|
|
|
|
|
|
|
|
DateUtils.setFixedLocalTime(unixTime(2050, MAY, 1));
|
|
|
|
|
assertThat(checkmarks.getTodayValue(), equalTo(0));
|
|
|
|
|
assertThat(checkmarks.getThisWeekValue(SATURDAY), equalTo(0));
|
|
|
|
|
assertThat(checkmarks.getThisMonthValue(), equalTo(0));
|
|
|
|
|
assertThat(checkmarks.getThisQuarterValue(), equalTo(0));
|
|
|
|
|
assertThat(checkmarks.getThisYearValue(), equalTo(0));
|
|
|
|
|
|
|
|
|
|
DateUtils.setFixedLocalTime(unixTime(2014, JUNE, 6));
|
|
|
|
|
assertThat(checkmarks.getTodayValue(), equalTo(0));
|
|
|
|
|
assertThat(checkmarks.getThisWeekValue(SATURDAY), equalTo(230));
|
|
|
|
|
assertThat(checkmarks.getThisWeekValue(SUNDAY), equalTo(230));
|
|
|
|
|
assertThat(checkmarks.getThisWeekValue(MONDAY), equalTo(0));
|
|
|
|
|
assertThat(checkmarks.getThisMonthValue(), equalTo(230));
|
|
|
|
|
assertThat(checkmarks.getThisQuarterValue(), equalTo(3263));
|
|
|
|
|
assertThat(checkmarks.getThisYearValue(), equalTo(8227));
|
|
|
|
|
|
|
|
|
|
DateUtils.setFixedLocalTime(unixTime(2014, JUNE, 1));
|
|
|
|
|
assertThat(checkmarks.getTodayValue(), equalTo(230));
|
|
|
|
|
assertThat(checkmarks.getThisWeekValue(SATURDAY), equalTo(230));
|
|
|
|
|
assertThat(checkmarks.getThisWeekValue(SUNDAY), equalTo(230));
|
|
|
|
|
assertThat(checkmarks.getThisMonthValue(), equalTo(230));
|
|
|
|
|
|
|
|
|
|
DateUtils.setFixedLocalTime(unixTime(2014, MAY, 16));
|
|
|
|
|
assertThat(checkmarks.getTodayValue(), equalTo(0));
|
|
|
|
|
assertThat(checkmarks.getThisWeekValue(SATURDAY), equalTo(419));
|
|
|
|
|
assertThat(checkmarks.getThisWeekValue(THURSDAY), equalTo(134));
|
|
|
|
|
assertThat(checkmarks.getThisMonthValue(), equalTo(1006));
|
|
|
|
|
|
|
|
|
|
DateUtils.setFixedLocalTime(unixTime(2000, MAY, 1));
|
|
|
|
|
assertThat(checkmarks.getTodayValue(), equalTo(0));
|
|
|
|
|
assertThat(checkmarks.getThisWeekValue(SATURDAY), equalTo(0));
|
|
|
|
|
assertThat(checkmarks.getThisMonthValue(), equalTo(0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|