|
|
@ -34,9 +34,8 @@ import org.junit.runner.*;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.hamcrest.CoreMatchers.*;
|
|
|
|
import static android.support.test.espresso.matcher.ViewMatchers.*;
|
|
|
|
import static org.hamcrest.MatcherAssert.*;
|
|
|
|
import static org.hamcrest.core.IsEqual.*;
|
|
|
|
import static org.hamcrest.core.IsNot.not;
|
|
|
|
|
|
|
|
import static org.isoron.uhabits.core.models.Checkmark.*;
|
|
|
|
import static org.isoron.uhabits.core.models.Checkmark.*;
|
|
|
|
|
|
|
|
|
|
|
|
@RunWith(AndroidJUnit4.class)
|
|
|
|
@RunWith(AndroidJUnit4.class)
|
|
|
@ -66,13 +65,14 @@ public class SQLiteRepetitionListTest extends BaseAndroidTest
|
|
|
|
public void testAdd()
|
|
|
|
public void testAdd()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
RepetitionRecord record = getByTimestamp(today + day);
|
|
|
|
RepetitionRecord record = getByTimestamp(today + day);
|
|
|
|
assertThat(record, is(nullValue()));
|
|
|
|
assertNull(record);
|
|
|
|
|
|
|
|
|
|
|
|
Repetition rep = new Repetition(today + day, CHECKED_EXPLICITLY);
|
|
|
|
Repetition rep = new Repetition(today + day, CHECKED_EXPLICITLY);
|
|
|
|
habit.getRepetitions().add(rep);
|
|
|
|
habit.getRepetitions().add(rep);
|
|
|
|
|
|
|
|
|
|
|
|
record = getByTimestamp(today + day);
|
|
|
|
record = getByTimestamp(today + day);
|
|
|
|
assertThat(record, is(not(nullValue())));
|
|
|
|
assertNotNull(record);
|
|
|
|
|
|
|
|
assertThat(record.value, equalTo(CHECKED_EXPLICITLY));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
@ -91,18 +91,18 @@ public class SQLiteRepetitionListTest extends BaseAndroidTest
|
|
|
|
public void testGetByTimestamp()
|
|
|
|
public void testGetByTimestamp()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Repetition rep = repetitions.getByTimestamp(today);
|
|
|
|
Repetition rep = repetitions.getByTimestamp(today);
|
|
|
|
assertThat(rep, is(not(nullValue())));
|
|
|
|
assertNotNull(rep);
|
|
|
|
assertThat(rep.getTimestamp(), equalTo(today));
|
|
|
|
assertThat(rep.getTimestamp(), equalTo(today));
|
|
|
|
|
|
|
|
|
|
|
|
rep = repetitions.getByTimestamp(today - 2 * day);
|
|
|
|
rep = repetitions.getByTimestamp(today - 2 * day);
|
|
|
|
assertThat(rep, is(nullValue()));
|
|
|
|
assertNull(rep);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testGetOldest()
|
|
|
|
public void testGetOldest()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Repetition rep = repetitions.getOldest();
|
|
|
|
Repetition rep = repetitions.getOldest();
|
|
|
|
assertThat(rep, is(not(nullValue())));
|
|
|
|
assertNotNull(rep);
|
|
|
|
assertThat(rep.getTimestamp(), equalTo(today - 120 * day));
|
|
|
|
assertThat(rep.getTimestamp(), equalTo(today - 120 * day));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -111,20 +111,20 @@ public class SQLiteRepetitionListTest extends BaseAndroidTest
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Habit empty = fixtures.createEmptyHabit();
|
|
|
|
Habit empty = fixtures.createEmptyHabit();
|
|
|
|
Repetition rep = empty.getRepetitions().getOldest();
|
|
|
|
Repetition rep = empty.getRepetitions().getOldest();
|
|
|
|
assertThat(rep, is(nullValue()));
|
|
|
|
assertNull(rep);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testRemove()
|
|
|
|
public void testRemove()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
RepetitionRecord record = getByTimestamp(today);
|
|
|
|
RepetitionRecord record = getByTimestamp(today);
|
|
|
|
assertThat(record, is(not(nullValue())));
|
|
|
|
assertNotNull(record);
|
|
|
|
|
|
|
|
|
|
|
|
Repetition rep = record.toRepetition();
|
|
|
|
Repetition rep = record.toRepetition();
|
|
|
|
repetitions.remove(rep);
|
|
|
|
repetitions.remove(rep);
|
|
|
|
|
|
|
|
|
|
|
|
record = getByTimestamp(today);
|
|
|
|
record = getByTimestamp(today);
|
|
|
|
assertThat(record, is(nullValue()));
|
|
|
|
assertNull(record);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@Nullable
|
|
|
|