Skip to content

Commit

Permalink
fix habit importers to use description instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Rechee committed Jan 9, 2020
1 parent 557ae19 commit 88d6a8e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void importHabitsFromFile(@NonNull final File file)
String name = line[0];
if (name.equals("HabitName")) continue;

String question = line[1];
String description = line[1];
String dateString[] = line[3].split("-");
int year = Integer.parseInt(dateString[0]);
int month = Integer.parseInt(dateString[1]);
Expand All @@ -87,7 +87,7 @@ public void importHabitsFromFile(@NonNull final File file)
{
h = modelFactory.buildHabit();
h.setName(name);
h.setQuestion(question);
h.setDescription(description);
h.setFrequency(Frequency.DAILY);
habitList.add(h);
map.put(name, h);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private void createHabits(Database db)
{
int id = c.getInt(0);
String name = c.getString(1);
String question = c.getString(2);
String description = c.getString(2);
int schedule = c.getInt(3);
String activeDays = c.getString(4);
int repeatingCount = c.getInt(5);
Expand All @@ -101,7 +101,7 @@ private void createHabits(Database db)

Habit habit = modelFactory.buildHabit();
habit.setName(name);
habit.setQuestion(question);
habit.setDescription(description);

int periods[] = { 7, 31, 365 };
int numerator, denominator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ private void createHabits(Database db)
{
int id = c.getInt(0);
String name = c.getString(1);
String question = c.getString(2);
String description = c.getString(2);

Habit habit = modelFactory.buildHabit();
habit.setName(name);
habit.setQuestion(question);
habit.setDescription(description);
habit.setFrequency(Frequency.DAILY);
habitList.add(habit);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ public synchronized String getDescription()
return data.description;
}

public synchronized void setDescription(@NonNull String description)
public synchronized void setDescription(@Nullable String description)
{
data.description = description;
data.description = description == null ? "" : description;
}

@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void testHabitBullCSV() throws IOException

Habit habit = habitList.getByPosition(0);
assertThat(habit.getName(), equalTo("Breed dragons"));
assertThat(habit.getQuestion(), equalTo("with love and fire"));
assertThat(habit.getDescription(), equalTo("with love and fire"));
assertThat(habit.getFrequency(), equalTo(Frequency.DAILY));
assertTrue(containsRepetition(habit, 2016, 3, 18));
assertTrue(containsRepetition(habit, 2016, 3, 19));
Expand Down

0 comments on commit 88d6a8e

Please sign in to comment.