mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Rename Entries to EntryList
This commit is contained in:
@@ -46,7 +46,7 @@ public class BarChartTest extends BaseViewTest
|
|||||||
Habit habit = fixtures.createLongNumericalHabit();
|
Habit habit = fixtures.createLongNumericalHabit();
|
||||||
view = new BarChart(targetContext);
|
view = new BarChart(targetContext);
|
||||||
Timestamp today = DateUtils.getToday();
|
Timestamp today = DateUtils.getToday();
|
||||||
Entries entries = habit.getComputedEntries();
|
EntryList entries = habit.getComputedEntries();
|
||||||
view.setEntries(entries.getByInterval(today.minus(20), today));
|
view.setEntries(entries.getByInterval(today.minus(20), today));
|
||||||
view.setColor(PaletteUtilsKt.toThemedAndroidColor(habit.getColor(), targetContext));
|
view.setColor(PaletteUtilsKt.toThemedAndroidColor(habit.getColor(), targetContext));
|
||||||
view.setTarget(200.0);
|
view.setTarget(200.0);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class CheckmarkWidgetTest extends BaseViewTest
|
|||||||
|
|
||||||
private Habit habit;
|
private Habit habit;
|
||||||
|
|
||||||
private Entries entries;
|
private EntryList entries;
|
||||||
|
|
||||||
private FrameLayout view;
|
private FrameLayout view;
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ public class CreateRepetitionCommand implements Command
|
|||||||
@Override
|
@Override
|
||||||
public void execute()
|
public void execute()
|
||||||
{
|
{
|
||||||
Entries checks = habit.getOriginalEntries();
|
EntryList entries = habit.getOriginalEntries();
|
||||||
checks.add(new Entry(timestamp, value));
|
entries.add(new Entry(timestamp, value));
|
||||||
habit.recompute();
|
habit.recompute();
|
||||||
habitList.resort();
|
habitList.resort();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ public class HabitsCSVExporter
|
|||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeEntries(String habitDirName, Entries entries)
|
private void writeEntries(String habitDirName, EntryList entries)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
String filename = habitDirName + "Checkmarks.csv";
|
String filename = habitDirName + "Checkmarks.csv";
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import kotlin.collections.HashMap
|
|||||||
import kotlin.collections.set
|
import kotlin.collections.set
|
||||||
import kotlin.math.*
|
import kotlin.math.*
|
||||||
|
|
||||||
open class Entries {
|
open class EntryList {
|
||||||
|
|
||||||
private val entriesByTimestamp: HashMap<Timestamp, Entry> = HashMap()
|
private val entriesByTimestamp: HashMap<Timestamp, Entry> = HashMap()
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ open class Entries {
|
|||||||
* to the frequency of the habit. For numerical habits, this function simply copies all entries.
|
* to the frequency of the habit. For numerical habits, this function simply copies all entries.
|
||||||
*/
|
*/
|
||||||
open fun recomputeFrom(
|
open fun recomputeFrom(
|
||||||
originalEntries: Entries,
|
originalEntries: EntryList,
|
||||||
frequency: Frequency,
|
frequency: Frequency,
|
||||||
isNumerical: Boolean,
|
isNumerical: Boolean,
|
||||||
) {
|
) {
|
||||||
@@ -35,8 +35,8 @@ data class Habit(
|
|||||||
var type: Int = YES_NO_HABIT,
|
var type: Int = YES_NO_HABIT,
|
||||||
var unit: String = "",
|
var unit: String = "",
|
||||||
var uuid: String? = null,
|
var uuid: String? = null,
|
||||||
val computedEntries: Entries,
|
val computedEntries: EntryList,
|
||||||
val originalEntries: Entries,
|
val originalEntries: EntryList,
|
||||||
val scores: ScoreList,
|
val scores: ScoreList,
|
||||||
val streaks: StreakList,
|
val streaks: StreakList,
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -34,14 +34,14 @@ interface ModelFactory {
|
|||||||
scores = scores,
|
scores = scores,
|
||||||
streaks = streaks,
|
streaks = streaks,
|
||||||
originalEntries = buildOriginalEntries(),
|
originalEntries = buildOriginalEntries(),
|
||||||
computedEntries = buildNewComputedEntries(),
|
computedEntries = buildComputedEntries(),
|
||||||
)
|
)
|
||||||
scores.setHabit(habit)
|
scores.setHabit(habit)
|
||||||
streaks.setHabit(habit)
|
streaks.setHabit(habit)
|
||||||
return habit
|
return habit
|
||||||
}
|
}
|
||||||
fun buildNewComputedEntries(): Entries
|
fun buildComputedEntries(): EntryList
|
||||||
fun buildOriginalEntries(): Entries
|
fun buildOriginalEntries(): EntryList
|
||||||
fun buildHabitList(): HabitList
|
fun buildHabitList(): HabitList
|
||||||
fun buildScoreList(): ScoreList
|
fun buildScoreList(): ScoreList
|
||||||
fun buildStreakList(): StreakList
|
fun buildStreakList(): StreakList
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ package org.isoron.uhabits.core.models.memory
|
|||||||
import org.isoron.uhabits.core.models.*
|
import org.isoron.uhabits.core.models.*
|
||||||
|
|
||||||
class MemoryModelFactory : ModelFactory {
|
class MemoryModelFactory : ModelFactory {
|
||||||
override fun buildNewComputedEntries() = Entries()
|
override fun buildComputedEntries() = EntryList()
|
||||||
override fun buildOriginalEntries() = Entries()
|
override fun buildOriginalEntries() = EntryList()
|
||||||
override fun buildHabitList() = MemoryHabitList()
|
override fun buildHabitList() = MemoryHabitList()
|
||||||
override fun buildScoreList() = MemoryScoreList()
|
override fun buildScoreList() = MemoryScoreList()
|
||||||
override fun buildStreakList() = MemoryStreakList()
|
override fun buildStreakList() = MemoryStreakList()
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ class SQLModelFactory
|
|||||||
@Inject constructor(
|
@Inject constructor(
|
||||||
val database: Database,
|
val database: Database,
|
||||||
) : ModelFactory {
|
) : ModelFactory {
|
||||||
override fun buildOriginalEntries() = SQLiteEntries(database)
|
override fun buildOriginalEntries() = SQLiteEntryList(database)
|
||||||
override fun buildNewComputedEntries() = Entries()
|
override fun buildComputedEntries() = EntryList()
|
||||||
override fun buildHabitList() = SQLiteHabitList(this)
|
override fun buildHabitList() = SQLiteHabitList(this)
|
||||||
override fun buildScoreList() = MemoryScoreList()
|
override fun buildScoreList() = MemoryScoreList()
|
||||||
override fun buildStreakList() = MemoryStreakList()
|
override fun buildStreakList() = MemoryStreakList()
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import org.isoron.uhabits.core.models.*
|
|||||||
import org.isoron.uhabits.core.models.sqlite.records.*
|
import org.isoron.uhabits.core.models.sqlite.records.*
|
||||||
import org.isoron.uhabits.core.utils.*
|
import org.isoron.uhabits.core.utils.*
|
||||||
|
|
||||||
class SQLiteEntries(database: Database) : Entries() {
|
class SQLiteEntryList(database: Database) : EntryList() {
|
||||||
val repository = Repository(EntryRecord::class.java, database)
|
val repository = Repository(EntryRecord::class.java, database)
|
||||||
var habitId: Long? = null
|
var habitId: Long? = null
|
||||||
var isLoaded = false
|
var isLoaded = false
|
||||||
@@ -76,7 +76,7 @@ class SQLiteEntries(database: Database) : Entries() {
|
|||||||
return super.groupBy(field, firstWeekday, isNumerical)
|
return super.groupBy(field, firstWeekday, isNumerical)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun recomputeFrom(originalEntries: Entries, frequency: Frequency, isNumerical: Boolean) {
|
override fun recomputeFrom(originalEntries: EntryList, frequency: Frequency, isNumerical: Boolean) {
|
||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ public class SQLiteHabitList extends HabitList
|
|||||||
|
|
||||||
Habit h = modelFactory.buildHabit();
|
Habit h = modelFactory.buildHabit();
|
||||||
rec.copyTo(h);
|
rec.copyTo(h);
|
||||||
((SQLiteEntries) h.getOriginalEntries()).setHabitId(h.getId());
|
((SQLiteEntryList) h.getOriginalEntries()).setHabitId(h.getId());
|
||||||
list.add(h);
|
list.add(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ public class SQLiteHabitList extends HabitList
|
|||||||
record.copyFrom(habit);
|
record.copyFrom(habit);
|
||||||
repository.save(record);
|
repository.save(record);
|
||||||
habit.setId(record.id);
|
habit.setId(record.id);
|
||||||
((SQLiteEntries) habit.getOriginalEntries()).setHabitId(record.id);
|
((SQLiteEntryList) habit.getOriginalEntries()).setHabitId(record.id);
|
||||||
|
|
||||||
list.add(habit);
|
list.add(habit);
|
||||||
getObservable().notifyListeners();
|
getObservable().notifyListeners();
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ public class HabitFixtures
|
|||||||
|
|
||||||
private void saveIfSQLite(Habit habit)
|
private void saveIfSQLite(Habit habit)
|
||||||
{
|
{
|
||||||
if (!(habit.getOriginalEntries() instanceof SQLiteEntries)) return;
|
if (!(habit.getOriginalEntries() instanceof SQLiteEntryList)) return;
|
||||||
habitList.add(habit);
|
habitList.add(habit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class ListHabitsBehavior
|
|||||||
|
|
||||||
public void onEdit(@NonNull Habit habit, Timestamp timestamp)
|
public void onEdit(@NonNull Habit habit, Timestamp timestamp)
|
||||||
{
|
{
|
||||||
Entries entries = habit.getComputedEntries();
|
EntryList entries = habit.getComputedEntries();
|
||||||
double oldValue = entries.get(timestamp).getValue();
|
double oldValue = entries.get(timestamp).getValue();
|
||||||
|
|
||||||
screen.showNumberPicker(oldValue / 1000, habit.getUnit(), newValue ->
|
screen.showNumberPicker(oldValue / 1000, habit.getUnit(), newValue ->
|
||||||
|
|||||||
@@ -51,12 +51,12 @@ public class CreateRepetitionCommandTest extends BaseUnitTest
|
|||||||
@Test
|
@Test
|
||||||
public void testExecute()
|
public void testExecute()
|
||||||
{
|
{
|
||||||
Entries originalEntries = habit.getOriginalEntries();
|
EntryList entries = habit.getOriginalEntries();
|
||||||
Entry entry = originalEntries.get(today);
|
Entry entry = entries.get(today);
|
||||||
assertEquals(YES_MANUAL, entry.getValue());
|
assertEquals(YES_MANUAL, entry.getValue());
|
||||||
|
|
||||||
command.execute();
|
command.execute();
|
||||||
entry = originalEntries.get(today);
|
entry = entries.get(today);
|
||||||
assertEquals(100, entry.getValue());
|
assertEquals(100, entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,10 +30,10 @@ import org.junit.*
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
class EntriesTest {
|
class EntryListTest {
|
||||||
@Test
|
@Test
|
||||||
fun testEmptyList() {
|
fun testEmptyList() {
|
||||||
val entries = Entries()
|
val entries = EntryList()
|
||||||
val today = DateUtils.getToday()
|
val today = DateUtils.getToday()
|
||||||
|
|
||||||
assertEquals(Entry(today.minus(0), UNKNOWN), entries.get(today.minus(0)))
|
assertEquals(Entry(today.minus(0), UNKNOWN), entries.get(today.minus(0)))
|
||||||
@@ -66,7 +66,7 @@ class EntriesTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testGetValues() {
|
fun testGetValues() {
|
||||||
val entries = Entries()
|
val entries = EntryList()
|
||||||
val today = DateUtils.getToday()
|
val today = DateUtils.getToday()
|
||||||
|
|
||||||
entries.add(Entry(today.minus(3), YES_MANUAL))
|
entries.add(Entry(today.minus(3), YES_MANUAL))
|
||||||
@@ -89,12 +89,12 @@ class EntriesTest {
|
|||||||
fun testComputeBoolean() {
|
fun testComputeBoolean() {
|
||||||
val today = DateUtils.getToday()
|
val today = DateUtils.getToday()
|
||||||
|
|
||||||
val original = Entries()
|
val original = EntryList()
|
||||||
original.add(Entry(today.minus(4), YES_MANUAL))
|
original.add(Entry(today.minus(4), YES_MANUAL))
|
||||||
original.add(Entry(today.minus(9), YES_MANUAL))
|
original.add(Entry(today.minus(9), YES_MANUAL))
|
||||||
original.add(Entry(today.minus(10), YES_MANUAL))
|
original.add(Entry(today.minus(10), YES_MANUAL))
|
||||||
|
|
||||||
val computed = Entries()
|
val computed = EntryList()
|
||||||
computed.recomputeFrom(original, Frequency(1, 3), isNumerical = false)
|
computed.recomputeFrom(original, Frequency(1, 3), isNumerical = false)
|
||||||
|
|
||||||
val expected = listOf(
|
val expected = listOf(
|
||||||
@@ -111,7 +111,7 @@ class EntriesTest {
|
|||||||
assertEquals(expected, computed.getKnown())
|
assertEquals(expected, computed.getKnown())
|
||||||
|
|
||||||
// Second call should replace all previously added entries
|
// Second call should replace all previously added entries
|
||||||
computed.recomputeFrom(Entries(), Frequency(1, 3), isNumerical = false)
|
computed.recomputeFrom(EntryList(), Frequency(1, 3), isNumerical = false)
|
||||||
assertEquals(listOf(), computed.getKnown())
|
assertEquals(listOf(), computed.getKnown())
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -120,12 +120,12 @@ class EntriesTest {
|
|||||||
fun testComputeNumerical() {
|
fun testComputeNumerical() {
|
||||||
val today = DateUtils.getToday()
|
val today = DateUtils.getToday()
|
||||||
|
|
||||||
val original = Entries()
|
val original = EntryList()
|
||||||
original.add(Entry(today.minus(4), 100))
|
original.add(Entry(today.minus(4), 100))
|
||||||
original.add(Entry(today.minus(9), 200))
|
original.add(Entry(today.minus(9), 200))
|
||||||
original.add(Entry(today.minus(10), 300))
|
original.add(Entry(today.minus(10), 300))
|
||||||
|
|
||||||
val computed = Entries()
|
val computed = EntryList()
|
||||||
computed.recomputeFrom(original, Frequency.DAILY, isNumerical = true)
|
computed.recomputeFrom(original, Frequency.DAILY, isNumerical = true)
|
||||||
|
|
||||||
val expected = listOf(
|
val expected = listOf(
|
||||||
@@ -156,7 +156,7 @@ class EntriesTest {
|
|||||||
370, 187, 208, 231, 341, 312)
|
370, 187, 208, 231, 341, 312)
|
||||||
|
|
||||||
val reference = Timestamp.from(2014, Calendar.JUNE, 1)
|
val reference = Timestamp.from(2014, Calendar.JUNE, 1)
|
||||||
val entries = Entries()
|
val entries = EntryList()
|
||||||
offsets.indices.forEach {
|
offsets.indices.forEach {
|
||||||
entries.add(Entry(reference.minus(offsets[it]), values[it]))
|
entries.add(Entry(reference.minus(offsets[it]), values[it]))
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ class EntriesTest {
|
|||||||
455, 460, 462, 465, 470, 471, 479, 481, 485, 489, 494, 495, 500, 501, 503, 507)
|
455, 460, 462, 465, 470, 471, 479, 481, 485, 489, 494, 495, 500, 501, 503, 507)
|
||||||
|
|
||||||
val reference = Timestamp.from(2014, Calendar.JUNE, 1)
|
val reference = Timestamp.from(2014, Calendar.JUNE, 1)
|
||||||
val entries = Entries()
|
val entries = EntryList()
|
||||||
offsets.indices.forEach {
|
offsets.indices.forEach {
|
||||||
entries.add(Entry(reference.minus(offsets[it]), YES_MANUAL))
|
entries.add(Entry(reference.minus(offsets[it]), YES_MANUAL))
|
||||||
}
|
}
|
||||||
@@ -246,9 +246,9 @@ class EntriesTest {
|
|||||||
Entry(day(10), YES_MANUAL),
|
Entry(day(10), YES_MANUAL),
|
||||||
)
|
)
|
||||||
val intervals = listOf(
|
val intervals = listOf(
|
||||||
Entries.Interval(day(2), day(2), day(1)),
|
EntryList.Interval(day(2), day(2), day(1)),
|
||||||
Entries.Interval(day(6), day(5), day(4)),
|
EntryList.Interval(day(6), day(5), day(4)),
|
||||||
Entries.Interval(day(10), day(8), day(8)),
|
EntryList.Interval(day(10), day(8), day(8)),
|
||||||
)
|
)
|
||||||
val expected = listOf(
|
val expected = listOf(
|
||||||
Entry(day(1), YES_MANUAL),
|
Entry(day(1), YES_MANUAL),
|
||||||
@@ -262,39 +262,39 @@ class EntriesTest {
|
|||||||
Entry(day(9), YES_AUTO),
|
Entry(day(9), YES_AUTO),
|
||||||
Entry(day(10), YES_MANUAL),
|
Entry(day(10), YES_MANUAL),
|
||||||
)
|
)
|
||||||
val actual = Entries.buildEntriesFromInterval(entries, intervals)
|
val actual = EntryList.buildEntriesFromInterval(entries, intervals)
|
||||||
assertThat(actual, equalTo(expected))
|
assertThat(actual, equalTo(expected))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testSnapIntervalsTogether1() {
|
fun testSnapIntervalsTogether1() {
|
||||||
val original = arrayListOf(
|
val original = arrayListOf(
|
||||||
Entries.Interval(day(8), day(8), day(2)),
|
EntryList.Interval(day(8), day(8), day(2)),
|
||||||
Entries.Interval(day(12), day(12), day(6)),
|
EntryList.Interval(day(12), day(12), day(6)),
|
||||||
Entries.Interval(day(20), day(20), day(14)),
|
EntryList.Interval(day(20), day(20), day(14)),
|
||||||
Entries.Interval(day(27), day(27), day(21)),
|
EntryList.Interval(day(27), day(27), day(21)),
|
||||||
)
|
)
|
||||||
val expected = arrayListOf(
|
val expected = arrayListOf(
|
||||||
Entries.Interval(day(8), day(8), day(2)),
|
EntryList.Interval(day(8), day(8), day(2)),
|
||||||
Entries.Interval(day(15), day(12), day(9)),
|
EntryList.Interval(day(15), day(12), day(9)),
|
||||||
Entries.Interval(day(22), day(20), day(16)),
|
EntryList.Interval(day(22), day(20), day(16)),
|
||||||
Entries.Interval(day(29), day(27), day(23)),
|
EntryList.Interval(day(29), day(27), day(23)),
|
||||||
)
|
)
|
||||||
Entries.snapIntervalsTogether(original)
|
EntryList.snapIntervalsTogether(original)
|
||||||
assertThat(original, equalTo(expected))
|
assertThat(original, equalTo(expected))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testSnapIntervalsTogether2() {
|
fun testSnapIntervalsTogether2() {
|
||||||
val original = arrayListOf(
|
val original = arrayListOf(
|
||||||
Entries.Interval(day(6), day(4), day(0)),
|
EntryList.Interval(day(6), day(4), day(0)),
|
||||||
Entries.Interval(day(11), day(8), day(5)),
|
EntryList.Interval(day(11), day(8), day(5)),
|
||||||
)
|
)
|
||||||
val expected = arrayListOf(
|
val expected = arrayListOf(
|
||||||
Entries.Interval(day(6), day(4), day(0)),
|
EntryList.Interval(day(6), day(4), day(0)),
|
||||||
Entries.Interval(day(13), day(8), day(7)),
|
EntryList.Interval(day(13), day(8), day(7)),
|
||||||
)
|
)
|
||||||
Entries.snapIntervalsTogether(original)
|
EntryList.snapIntervalsTogether(original)
|
||||||
assertThat(original, equalTo(expected))
|
assertThat(original, equalTo(expected))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,11 +306,11 @@ class EntriesTest {
|
|||||||
Entry(day(23), YES_MANUAL),
|
Entry(day(23), YES_MANUAL),
|
||||||
)
|
)
|
||||||
val expected = listOf(
|
val expected = listOf(
|
||||||
Entries.Interval(day(8), day(8), day(2)),
|
EntryList.Interval(day(8), day(8), day(2)),
|
||||||
Entries.Interval(day(18), day(18), day(12)),
|
EntryList.Interval(day(18), day(18), day(12)),
|
||||||
Entries.Interval(day(23), day(23), day(17)),
|
EntryList.Interval(day(23), day(23), day(17)),
|
||||||
)
|
)
|
||||||
val actual = Entries.buildIntervals(Frequency.WEEKLY, entries)
|
val actual = EntryList.buildIntervals(Frequency.WEEKLY, entries)
|
||||||
assertThat(actual, equalTo(expected))
|
assertThat(actual, equalTo(expected))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,11 +322,11 @@ class EntriesTest {
|
|||||||
Entry(day(23), YES_MANUAL),
|
Entry(day(23), YES_MANUAL),
|
||||||
)
|
)
|
||||||
val expected = listOf(
|
val expected = listOf(
|
||||||
Entries.Interval(day(8), day(8), day(8)),
|
EntryList.Interval(day(8), day(8), day(8)),
|
||||||
Entries.Interval(day(18), day(18), day(18)),
|
EntryList.Interval(day(18), day(18), day(18)),
|
||||||
Entries.Interval(day(23), day(23), day(23)),
|
EntryList.Interval(day(23), day(23), day(23)),
|
||||||
)
|
)
|
||||||
val actual = Entries.buildIntervals(Frequency.DAILY, entries)
|
val actual = EntryList.buildIntervals(Frequency.DAILY, entries)
|
||||||
assertThat(actual, equalTo(expected))
|
assertThat(actual, equalTo(expected))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,11 +340,11 @@ class EntriesTest {
|
|||||||
Entry(day(23), YES_MANUAL),
|
Entry(day(23), YES_MANUAL),
|
||||||
)
|
)
|
||||||
val expected = listOf(
|
val expected = listOf(
|
||||||
Entries.Interval(day(18), day(15), day(12)),
|
EntryList.Interval(day(18), day(15), day(12)),
|
||||||
Entries.Interval(day(22), day(18), day(16)),
|
EntryList.Interval(day(22), day(18), day(16)),
|
||||||
Entries.Interval(day(23), day(22), day(17)),
|
EntryList.Interval(day(23), day(22), day(17)),
|
||||||
)
|
)
|
||||||
val actual = Entries.buildIntervals(Frequency.TWO_TIMES_PER_WEEK, entries)
|
val actual = EntryList.buildIntervals(Frequency.TWO_TIMES_PER_WEEK, entries)
|
||||||
assertThat(actual, equalTo(expected))
|
assertThat(actual, equalTo(expected))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,16 +357,16 @@ class EntriesTest {
|
|||||||
Entry(day(30), YES_MANUAL),
|
Entry(day(30), YES_MANUAL),
|
||||||
)
|
)
|
||||||
val expected = listOf(
|
val expected = listOf(
|
||||||
Entries.Interval(day(10), day(10), day(8)),
|
EntryList.Interval(day(10), day(10), day(8)),
|
||||||
Entries.Interval(day(30), day(30), day(28)),
|
EntryList.Interval(day(30), day(30), day(28)),
|
||||||
)
|
)
|
||||||
val actual = Entries.buildIntervals(Frequency(1, 3), entries)
|
val actual = EntryList.buildIntervals(Frequency(1, 3), entries)
|
||||||
assertThat(actual, equalTo(expected))
|
assertThat(actual, equalTo(expected))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testWeekdayFrequency() {
|
fun testWeekdayFrequency() {
|
||||||
val entries = Entries()
|
val entries = EntryList()
|
||||||
val random = Random(123L)
|
val random = Random(123L)
|
||||||
val weekdayCount = Array(12) { Array(7) { 0 } }
|
val weekdayCount = Array(12) { Array(7) { 0 } }
|
||||||
val monthCount = Array(12) { 0 }
|
val monthCount = Array(12) { 0 }
|
||||||
@@ -332,14 +332,14 @@ public class ScoreListTest extends BaseUnitTest
|
|||||||
|
|
||||||
private void check(final int offset)
|
private void check(final int offset)
|
||||||
{
|
{
|
||||||
Entries entries = habit.getOriginalEntries();
|
EntryList entries = habit.getOriginalEntries();
|
||||||
Timestamp today = DateUtils.getToday();
|
Timestamp today = DateUtils.getToday();
|
||||||
entries.add(new Entry(today.minus(offset), YES_MANUAL));
|
entries.add(new Entry(today.minus(offset), YES_MANUAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void check(final int from, final int to)
|
private void check(final int from, final int to)
|
||||||
{
|
{
|
||||||
Entries entries = habit.getOriginalEntries();
|
EntryList entries = habit.getOriginalEntries();
|
||||||
Timestamp today = DateUtils.getToday();
|
Timestamp today = DateUtils.getToday();
|
||||||
|
|
||||||
for (int i = from; i < to; i++)
|
for (int i = from; i < to; i++)
|
||||||
@@ -349,7 +349,7 @@ public class ScoreListTest extends BaseUnitTest
|
|||||||
|
|
||||||
private void check(ArrayList<Integer> values)
|
private void check(ArrayList<Integer> values)
|
||||||
{
|
{
|
||||||
Entries entries = habit.getOriginalEntries();
|
EntryList entries = habit.getOriginalEntries();
|
||||||
Timestamp today = DateUtils.getToday();
|
Timestamp today = DateUtils.getToday();
|
||||||
for (int i = 0; i < values.size(); i++)
|
for (int i = 0; i < values.size(); i++)
|
||||||
if (values.get(i) == YES_MANUAL)
|
if (values.get(i) == YES_MANUAL)
|
||||||
@@ -359,7 +359,7 @@ public class ScoreListTest extends BaseUnitTest
|
|||||||
|
|
||||||
private void addSkip(final int day)
|
private void addSkip(final int day)
|
||||||
{
|
{
|
||||||
Entries entries = habit.getOriginalEntries();
|
EntryList entries = habit.getOriginalEntries();
|
||||||
Timestamp today = DateUtils.getToday();
|
Timestamp today = DateUtils.getToday();
|
||||||
entries.add(new Entry(today.minus(day), Entry.SKIP));
|
entries.add(new Entry(today.minus(day), Entry.SKIP));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,11 +28,11 @@ import org.isoron.uhabits.core.models.sqlite.records.*
|
|||||||
import org.isoron.uhabits.core.utils.*
|
import org.isoron.uhabits.core.utils.*
|
||||||
import org.junit.*
|
import org.junit.*
|
||||||
|
|
||||||
class SQLiteEntriesTest {
|
class SQLiteEntryListTest {
|
||||||
|
|
||||||
private val database = buildMemoryDatabase()
|
private val database = buildMemoryDatabase()
|
||||||
private val repository = Repository(EntryRecord::class.java, database)
|
private val repository = Repository(EntryRecord::class.java, database)
|
||||||
private val entries = SQLiteEntries(database)
|
private val entries = SQLiteEntryList(database)
|
||||||
private val today = DateUtils.getToday()
|
private val today = DateUtils.getToday()
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
Reference in New Issue
Block a user