mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-09 18:48:51 -06:00
Rebuild order after removing habit
This commit is contained in:
@@ -140,7 +140,7 @@ public class CommandParserTest extends BaseUnitTest
|
||||
public void testDecodeToggleCommand() throws JSONException
|
||||
{
|
||||
ToggleRepetitionCommand original, decoded;
|
||||
original = new ToggleRepetitionCommand(habit, 1000);
|
||||
original = new ToggleRepetitionCommand(habitList, habit, 1000);
|
||||
decoded = (ToggleRepetitionCommand) parser.parse(original.toJson());
|
||||
|
||||
MatcherAssert.assertThat(decoded.getId(), equalTo(original.getId()));
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ToggleRepetitionCommandTest extends BaseUnitTest
|
||||
habitList.add(habit);
|
||||
|
||||
today = DateUtils.getStartOfToday();
|
||||
command = new ToggleRepetitionCommand(habit, today);
|
||||
command = new ToggleRepetitionCommand(habitList, habit, today);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.junit.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static junit.framework.TestCase.*;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
@@ -70,11 +71,6 @@ public class StreakListTest extends BaseUnitTest
|
||||
public void testFindBeginning_withLongHistory()
|
||||
{
|
||||
streaks.rebuild();
|
||||
assertThat(streaks.findBeginning(), equalTo(today - day));
|
||||
|
||||
streaks.invalidateNewerThan(today - 20 * day);
|
||||
assertThat(streaks.findBeginning(), equalTo(today - 28 * day));
|
||||
|
||||
streaks.invalidateNewerThan(0);
|
||||
assertThat(streaks.findBeginning(), equalTo(today - 120 * day));
|
||||
}
|
||||
@@ -111,20 +107,6 @@ public class StreakListTest extends BaseUnitTest
|
||||
assertThat(best.get(1).getLength(), equalTo(6L));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNewestComputed() throws Exception
|
||||
{
|
||||
Streak s = streaks.getNewestComputed();
|
||||
assertThat(s.getEnd(), equalTo(today));
|
||||
assertThat(s.getStart(), equalTo(today - day));
|
||||
|
||||
streaks.invalidateNewerThan(today - 8 * day);
|
||||
|
||||
s = streaks.getNewestComputed();
|
||||
assertThat(s.getEnd(), equalTo(today - 12 * day));
|
||||
assertThat(s.getStart(), equalTo(today - 12 * day));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidateNewer()
|
||||
{
|
||||
@@ -135,6 +117,6 @@ public class StreakListTest extends BaseUnitTest
|
||||
verify(listener).onModelChange();
|
||||
|
||||
s = streaks.getNewestComputed();
|
||||
assertThat(s.getEnd(), equalTo(today - 12 * day));
|
||||
assertNull(s);
|
||||
}
|
||||
}
|
||||
@@ -168,4 +168,19 @@ public class SQLiteHabitListTest extends BaseUnitTest
|
||||
h2.setId(1000L);
|
||||
assertThat(habitList.indexOf(h2), equalTo(-1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemove() throws Exception
|
||||
{
|
||||
Habit h = habitList.getByPosition(2);
|
||||
habitList.remove(h);
|
||||
assertThat(habitList.indexOf(h), equalTo(-1));
|
||||
|
||||
HabitRecord rec = repository.find(2L);
|
||||
assertNull(rec);
|
||||
|
||||
rec = repository.find(3L);
|
||||
assertNotNull(rec);
|
||||
assertThat(rec.position, equalTo(2));
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public class HabitCardListCacheTest extends BaseUnitTest
|
||||
{
|
||||
Habit h2 = habitList.getByPosition(2);
|
||||
long today = DateUtils.getStartOfToday();
|
||||
commandRunner.execute(new ToggleRepetitionCommand(h2, today),
|
||||
commandRunner.execute(new ToggleRepetitionCommand(habitList, h2, today),
|
||||
h2.getId());
|
||||
|
||||
verify(listener).onItemChanged(2);
|
||||
|
||||
Reference in New Issue
Block a user