Skip to content

Commit

Permalink
Merge pull request #55 from jarekkopaczewski/develop
Browse files Browse the repository at this point in the history
Add sprint 2 & 3
  • Loading branch information
danielglazer26 authored May 8, 2022
2 parents 780f480 + 83fac3f commit 96c0275
Show file tree
Hide file tree
Showing 204 changed files with 8,391 additions and 1,334 deletions.
25 changes: 14 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ android {
applicationId "skills.future.planer"
minSdk 26
targetSdk 31
versionCode 1
versionName "1.0"

versionCode 32
versionName "0.4.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand All @@ -33,9 +32,18 @@ android {
}

dependencies {

implementation 'com.github.CodeBoy722:ViewPager2_Transformers:1.0.0'
implementation 'com.jaredrummler:colorpicker:1.1.0'
implementation 'com.github.prolificinteractive:material-calendarview:2.0.0'
testImplementation 'org.junit.jupiter:junit-jupiter'
implementation 'com.jakewharton.threetenabp:threetenabp:1.2.0'
implementation 'com.github.antonKozyriatskyi:CircularProgressIndicator:1.3.0'
// Android preferences
implementation 'com.github.alokverma:circle-menu:1.1'
implementation 'androidx.preference:preference:1.2.0'
implementation "android.arch.lifecycle:extensions:1.1.1"
implementation "android.arch.lifecycle:viewmodel:1.1.1"
implementation 'com.ramotion.circlemenu:circle-menu:0.3.2'
implementation "com.github.skydoves:powerspinner:1.1.9"
//noinspection AnnotationProcessorOnCompilePath
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
Expand All @@ -48,6 +56,7 @@ dependencies {
implementation 'androidx.navigation:navigation-fragment:2.4.1'
implementation 'androidx.navigation:navigation-ui:2.4.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.6.0-beta01'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// Required -- JUnit 4 framework
Expand All @@ -60,22 +69,16 @@ dependencies {
testImplementation "org.mockito.kotlin:mockito-kotlin:3.2.0"
// Optional -- Mockk framework
testImplementation "io.mockk:mockk:1.4.1"

implementation "androidx.room:room-runtime:2.4.2"
annotationProcessor "androidx.room:room-compiler:2.4.2"

// optional - RxJava2 support for Room
implementation "androidx.room:room-rxjava2:2.4.2"

// optional - RxJava3 support for Room
implementation "androidx.room:room-rxjava3:2.4.2"

// optional - Guava support for Room, including Optional and ListenableFuture
implementation "androidx.room:room-guava:2.4.2"

// optional - Test helpers
testImplementation "androidx.room:room-testing:2.4.2"

// optional - Paging 3 Integration
implementation "androidx.room:room-paging:2.5.0-alpha01"
}
20 changes: 20 additions & 0 deletions app/release/output-metadata.json
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"
}
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() {
}
}
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);
}
}
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());
}
}
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());
}
}
Loading

0 comments on commit 96c0275

Please sign in to comment.