-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from jarekkopaczewski/develop
Add sprint 2 & 3
- Loading branch information
Showing
204 changed files
with
8,391 additions
and
1,334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"version": 3, | ||
"artifactType": { | ||
"type": "APK", | ||
"kind": "Directory" | ||
}, | ||
"applicationId": "skills.future.planer", | ||
"variantName": "release", | ||
"elements": [ | ||
{ | ||
"type": "SINGLE", | ||
"filters": [], | ||
"attributes": [], | ||
"versionCode": 32, | ||
"versionName": "0.4.1", | ||
"outputFile": "app-release.apk" | ||
} | ||
], | ||
"elementType": "File" | ||
} |
62 changes: 62 additions & 0 deletions
62
app/src/androidTest/java/skills/future/planer/db/goal/GoalsDaoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package skills.future.planer.db.goal; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.room.Room; | ||
import androidx.test.core.app.ApplicationProvider; | ||
|
||
import com.prolificinteractive.materialcalendarview.CalendarDay; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.time.LocalDate; | ||
import java.util.Calendar; | ||
|
||
import skills.future.planer.db.AppDatabase; | ||
import skills.future.planer.db.habit.HabitData; | ||
import skills.future.planer.db.habit.HabitDuration; | ||
import skills.future.planer.db.task.TaskData; | ||
import skills.future.planer.db.task.enums.category.TaskCategory; | ||
import skills.future.planer.db.task.enums.priority.Priorities; | ||
import skills.future.planer.db.task.enums.priority.TimePriority; | ||
|
||
public class GoalsDaoTest { | ||
private GoalsDao goalsDao; | ||
private AppDatabase db; | ||
private HabitData habit; | ||
GoalData goal; | ||
private TaskData taskData; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
Context context = ApplicationProvider.getApplicationContext(); | ||
db = Room.inMemoryDatabaseBuilder(context, AppDatabase.class).allowMainThreadQueries().build(); | ||
goalsDao = db.goalsDao(); | ||
goal = new GoalData("tsego", "asfasf"); | ||
goal.setGoalId(goalsDao.insert(goal)); | ||
var cal = Calendar.getInstance(); | ||
cal.set(Calendar.HOUR_OF_DAY, 12); | ||
cal.set(Calendar.MINUTE, 0); | ||
habit = new HabitData("test", "1111111", HabitDuration.Short, | ||
LocalDate.of(2022, 1, 1), cal.getTimeInMillis(), goal.getGoalId()); | ||
habit.setHabitId(db.habitDao().insert(habit)); | ||
taskData = new TaskData(TaskCategory.Work, Priorities.Important, TimePriority.Urgent, | ||
"test", "", CalendarDay.from(2022, 1, 1), CalendarDay.from(2022, 1, 3), goal.getGoalId()); | ||
taskData.setTaskDataId(db.taskDataTabDao().insert(taskData)); | ||
} | ||
|
||
@Test | ||
public void getGoalsWithHabits() { | ||
// var test = goalsDao.getHabitsFromGoal(); | ||
// assertEquals(habit,goalsDao.getHabitsFromGoal().get(goal)); | ||
} | ||
|
||
@Test | ||
public void testGetGoalsWithHabits() { | ||
} | ||
|
||
@Test | ||
public void getGoalsWithTasks() { | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
app/src/androidTest/java/skills/future/planer/db/habit/HabitDaoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package skills.future.planer.db.habit; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.room.Room; | ||
import androidx.test.core.app.ApplicationProvider; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.time.LocalDate; | ||
import java.util.Calendar; | ||
|
||
import skills.future.planer.db.AppDatabase; | ||
|
||
public class HabitDaoTest { | ||
private HabitDao habitDao; | ||
private AppDatabase db; | ||
private HabitData habit; | ||
|
||
@Test | ||
public void getNextNotification() throws Exception { | ||
var cal = Calendar.getInstance(); | ||
cal.set(Calendar.HOUR_OF_DAY, 21); | ||
cal.set(Calendar.MINUTE, 0); | ||
var zm = cal.getTimeInMillis(); | ||
System.out.println(zm); | ||
System.out.println(habitDao.getNextNotification(zm)); | ||
//assertEquals(habit, habitDao.getNextNotification(zm)); | ||
} | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
Context context = ApplicationProvider.getApplicationContext(); | ||
db = Room.inMemoryDatabaseBuilder(context, AppDatabase.class).allowMainThreadQueries().build(); | ||
habitDao = db.habitDao(); | ||
var cal = Calendar.getInstance(); | ||
cal.set(Calendar.HOUR_OF_DAY, 22); | ||
cal.set(Calendar.MINUTE, 0); | ||
habit = new HabitData("test", "1111111", HabitDuration.Short, LocalDate.of(2022, 12, 1), cal.getTimeInMillis()); | ||
habitDao.insert(habit); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
app/src/androidTest/java/skills/future/planer/db/habit/HabitDataTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package skills.future.planer.db.habit; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
import static java.util.stream.Collectors.joining; | ||
import static java.util.stream.Stream.generate; | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
import com.prolificinteractive.materialcalendarview.CalendarDay; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.time.LocalDate; | ||
import java.util.Calendar; | ||
|
||
import skills.future.planer.db.DataBaseException; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class HabitDataTest { | ||
HabitData habit; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
Calendar calendar = Calendar.getInstance(); | ||
calendar.set(Calendar.HOUR, 12); | ||
calendar.set(Calendar.MONTH, 0); | ||
habit = new HabitData("test", "1111111", HabitDuration.Short, | ||
LocalDate.of(2022, 1, 1), calendar.getTimeInMillis()); | ||
} | ||
|
||
@Test | ||
public void checkDaysOfWeekNoCheckedDays() throws Exception { | ||
String days = "0000000"; | ||
habit.editDaysOfWeek(days); | ||
assertEquals(habit.getDaysOfWeek(), days); | ||
} | ||
|
||
@Test(expected = DataBaseException.class) | ||
public void checkDaysOfWeekTooMuchCheckedDays() throws Exception { | ||
String days = "00000001"; | ||
habit.editDaysOfWeek(days); | ||
assertEquals(habit.getDaysOfWeek(), days); | ||
} | ||
|
||
@Test | ||
public void checkChangingHabitState() throws DataBaseException { | ||
habit.setHabitDoneIn(CalendarDay.from(2022, 1, 1)); | ||
habit.setHabitDoneIn(CalendarDay.from(2022, 2, 1)); | ||
habit.setHabitDoneIn(CalendarDay.from(2022, 3, 31)); | ||
var expected = "1" + | ||
generate(() -> "0").limit(30).collect(joining()) + | ||
"1" + | ||
generate(() -> "0").limit(habit.getHabitDuration().getDaysNumber() - 33).collect(joining()) + | ||
"1"; | ||
var actual = habit.getDayChecking(); | ||
assertEquals(expected, actual); | ||
} | ||
|
||
@Test(expected = DataBaseException.class) | ||
public void checkChangingHabitStateNotSetDayChecking() throws DataBaseException { | ||
habit = new HabitData(); | ||
habit.setHabitDoneIn(CalendarDay.from(2022, 1, 1)); | ||
} | ||
|
||
@Test(expected = DataBaseException.class) | ||
public void checkChangingHabitStateWrongDate() throws DataBaseException { | ||
habit = new HabitData(); | ||
habit.setHabitDoneIn(CalendarDay.from(2022, 5, 1)); | ||
} | ||
|
||
@Test | ||
public void getAllDaysWhereHabitsWasDone() throws DataBaseException { | ||
assertTrue(habit.getAllDaysWhereHabitsWasDone().isEmpty()); | ||
habit.setHabitDoneIn(CalendarDay.from(2022, 1, 1)); | ||
habit.setHabitDoneIn(CalendarDay.from(2022, 2, 1)); | ||
habit.setHabitDoneIn(CalendarDay.from(2022, 3, 31)); | ||
assertEquals(3, habit.getAllDaysWhereHabitsWasDone().size()); | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
app/src/androidTest/java/skills/future/planer/db/task/TaskDataDaoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package skills.future.planer.db.task; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.room.Room; | ||
import androidx.test.core.app.ApplicationProvider; | ||
|
||
import com.prolificinteractive.materialcalendarview.CalendarDay; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import skills.future.planer.db.AppDatabase; | ||
import skills.future.planer.db.task.enums.category.TaskCategory; | ||
import skills.future.planer.db.task.enums.priority.Priorities; | ||
import skills.future.planer.db.task.enums.priority.TimePriority; | ||
|
||
public class TaskDataDaoTest { | ||
private TaskDataDao userDao; | ||
private AppDatabase db; | ||
private TaskData taskData,taskData2; | ||
@Before | ||
public void setUp() { | ||
Context context = ApplicationProvider.getApplicationContext(); | ||
db = Room.inMemoryDatabaseBuilder(context, AppDatabase.class).allowMainThreadQueries().build(); | ||
userDao = db.taskDataTabDao(); | ||
taskData = new TaskData(TaskCategory.Private, Priorities.Important, | ||
TimePriority.Urgent, "Title","Details"); | ||
taskData.setTaskDataId(1L); | ||
taskData2 = new TaskData(TaskCategory.Private, Priorities.Important, | ||
TimePriority.Urgent, "Title","Details", | ||
CalendarDay.from(2000,1,1),CalendarDay.from(2020,2,2)); | ||
taskData2.setTaskDataId(2L); | ||
userDao.insert(taskData); | ||
userDao.insert(taskData2); | ||
} | ||
|
||
@After | ||
public void tearDown(){ | ||
db.close(); | ||
} | ||
|
||
@Test | ||
public void findById() throws Exception { | ||
assertEquals(taskData, userDao.findById(taskData.getTaskDataId())); | ||
} | ||
|
||
@Test | ||
public void insert() throws Exception { | ||
TaskData taskData1 = new TaskData(TaskCategory.Private, Priorities.NotImportant, | ||
TimePriority.NotUrgent, "Title","Details"); | ||
taskData1.setTaskDataId(3L); | ||
userDao.insert(taskData1); | ||
TaskData res = userDao.findById(taskData1.getTaskDataId()); | ||
assertEquals(taskData1,res); | ||
} | ||
|
||
@Test | ||
public void getTaskData() { | ||
List<TaskData> exp = new ArrayList<>(Arrays.asList(taskData,taskData2)); | ||
assertEquals(exp,userDao.getTaskData().getValue()); | ||
} | ||
|
||
@Test | ||
public void testGetTaskData() { | ||
List<TaskData> exp = new ArrayList<>(Arrays.asList(taskData,taskData2)); | ||
assertEquals(exp,userDao.getTaskData(TaskCategory.Private)); | ||
} | ||
|
||
@Test | ||
public void testGetTaskData1() { | ||
List<TaskData> exp = new ArrayList<>(Arrays.asList(taskData,taskData2)); | ||
assertEquals(exp,userDao.getTaskData(Priorities.Important,TimePriority.Urgent)); | ||
} | ||
|
||
@Test | ||
public void deleteOne() { | ||
userDao.deleteOne(taskData); | ||
List<TaskData> exp = new ArrayList<>(Collections.singletonList(taskData2)); | ||
assertEquals(exp,userDao.getTaskData().getValue()); | ||
} | ||
|
||
@Test | ||
public void deleteAll() { | ||
userDao.deleteAll(); | ||
assertTrue(Objects.requireNonNull(userDao.getTaskData().getValue()).isEmpty()); | ||
} | ||
|
||
@Test | ||
public void editOne() { | ||
} | ||
|
||
@Test | ||
public void getIdOfLastAddedTask() { | ||
assertEquals(taskData2.getTaskDataId(),userDao.getIdOfLastAddedTask()); | ||
} | ||
} |
Oops, something went wrong.