From 82d7cf94e87a9037c89a9b89636524998320749e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Wed, 20 Feb 2019 15:34:24 +0100 Subject: [PATCH] Mark as read items older than student registration date (#253) --- .../repositories/local/StudentLocalTest.kt | 3 ++- .../github/wulkanowy/data/db/AppDatabase.kt | 14 +++++++---- .../github/wulkanowy/data/db/dao/NoteDao.kt | 8 +++---- .../github/wulkanowy/data/db/entities/Note.kt | 3 --- .../wulkanowy/data/db/entities/Student.kt | 6 ++++- .../data/db/migrations/Migration5.kt | 24 +++++++++++++++++++ .../repositories/grade/GradeRepository.kt | 9 ++++--- .../data/repositories/note/NoteLocal.kt | 10 ++++---- .../data/repositories/note/NoteRemote.kt | 1 - .../data/repositories/note/NoteRepository.kt | 19 ++++++++------- .../repositories/student/StudentRemote.kt | 4 +++- .../wulkanowy/services/job/SyncWorker.kt | 5 ++-- .../grade/details/GradeDetailsPresenter.kt | 4 ++-- .../grade/summary/GradeSummaryPresenter.kt | 8 +++---- .../ui/modules/note/NotePresenter.kt | 4 ++-- .../login/form/LoginFormPresenterTest.kt | 3 ++- .../LoginStudentSelectPresenterTest.kt | 3 ++- 17 files changed, 83 insertions(+), 45 deletions(-) create mode 100644 app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration5.kt diff --git a/app/src/androidTest/java/io/github/wulkanowy/data/repositories/local/StudentLocalTest.kt b/app/src/androidTest/java/io/github/wulkanowy/data/repositories/local/StudentLocalTest.kt index 6670eb6e..6152d0d7 100644 --- a/app/src/androidTest/java/io/github/wulkanowy/data/repositories/local/StudentLocalTest.kt +++ b/app/src/androidTest/java/io/github/wulkanowy/data/repositories/local/StudentLocalTest.kt @@ -12,6 +12,7 @@ import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith +import org.threeten.bp.LocalDateTime.now import kotlin.test.assertEquals @RunWith(AndroidJUnit4::class) @@ -39,7 +40,7 @@ class StudentLocalTest { @Test fun saveAndReadTest() { - studentLocal.saveStudent(Student(email = "test", password = "test123", schoolSymbol = "23", endpoint = "fakelog.cf", loginType = "AUTO", isCurrent = true, studentName = "", schoolName = "", studentId = 0, symbol = "")) + studentLocal.saveStudent(Student(email = "test", password = "test123", schoolSymbol = "23", endpoint = "fakelog.cf", loginType = "AUTO", isCurrent = true, studentName = "", schoolName = "", studentId = 0, symbol = "", registrationDate = now())) .blockingGet() val student = studentLocal.getCurrentStudent(true).blockingGet() diff --git a/app/src/main/java/io/github/wulkanowy/data/db/AppDatabase.kt b/app/src/main/java/io/github/wulkanowy/data/db/AppDatabase.kt index dd8c0344..de3429da 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/AppDatabase.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/AppDatabase.kt @@ -8,6 +8,7 @@ import androidx.room.RoomDatabase.JournalMode.TRUNCATE import androidx.room.TypeConverters import io.github.wulkanowy.data.db.dao.AttendanceDao import io.github.wulkanowy.data.db.dao.AttendanceSummaryDao +import io.github.wulkanowy.data.db.dao.CompletedLessonsDao import io.github.wulkanowy.data.db.dao.ExamDao import io.github.wulkanowy.data.db.dao.GradeDao import io.github.wulkanowy.data.db.dao.GradeSummaryDao @@ -15,13 +16,13 @@ import io.github.wulkanowy.data.db.dao.HomeworkDao import io.github.wulkanowy.data.db.dao.LuckyNumberDao import io.github.wulkanowy.data.db.dao.MessagesDao import io.github.wulkanowy.data.db.dao.NoteDao -import io.github.wulkanowy.data.db.dao.CompletedLessonsDao import io.github.wulkanowy.data.db.dao.SemesterDao import io.github.wulkanowy.data.db.dao.StudentDao import io.github.wulkanowy.data.db.dao.SubjectDao import io.github.wulkanowy.data.db.dao.TimetableDao import io.github.wulkanowy.data.db.entities.Attendance import io.github.wulkanowy.data.db.entities.AttendanceSummary +import io.github.wulkanowy.data.db.entities.CompletedLesson import io.github.wulkanowy.data.db.entities.Exam import io.github.wulkanowy.data.db.entities.Grade import io.github.wulkanowy.data.db.entities.GradeSummary @@ -29,7 +30,6 @@ import io.github.wulkanowy.data.db.entities.Homework import io.github.wulkanowy.data.db.entities.LuckyNumber import io.github.wulkanowy.data.db.entities.Message import io.github.wulkanowy.data.db.entities.Note -import io.github.wulkanowy.data.db.entities.CompletedLesson import io.github.wulkanowy.data.db.entities.Semester import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.data.db.entities.Subject @@ -37,6 +37,7 @@ import io.github.wulkanowy.data.db.entities.Timetable import io.github.wulkanowy.data.db.migrations.Migration2 import io.github.wulkanowy.data.db.migrations.Migration3 import io.github.wulkanowy.data.db.migrations.Migration4 +import io.github.wulkanowy.data.db.migrations.Migration5 import javax.inject.Singleton @Singleton @@ -57,22 +58,25 @@ import javax.inject.Singleton LuckyNumber::class, CompletedLesson::class ], - version = 4, + version = AppDatabase.VERSION_SCHEMA, exportSchema = false ) @TypeConverters(Converters::class) abstract class AppDatabase : RoomDatabase() { companion object { + const val VERSION_SCHEMA = 5 + fun newInstance(context: Context): AppDatabase { return Room.databaseBuilder(context, AppDatabase::class.java, "wulkanowy_database") .setJournalMode(TRUNCATE) - .fallbackToDestructiveMigrationFrom(5) + .fallbackToDestructiveMigrationFrom(VERSION_SCHEMA + 1) .fallbackToDestructiveMigrationOnDowngrade() .addMigrations( Migration2(), Migration3(), - Migration4() + Migration4(), + Migration5() ) .build() } diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/NoteDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/NoteDao.kt index 2c182860..89443506 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/NoteDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/NoteDao.kt @@ -25,9 +25,9 @@ interface NoteDao { @Delete fun deleteAll(notes: List) - @Query("SELECT * FROM Notes WHERE semester_id = :semesterId AND student_id = :studentId") - fun loadAll(semesterId: Int, studentId: Int): Maybe> + @Query("SELECT * FROM Notes WHERE student_id = :studentId") + fun loadAll(studentId: Int): Maybe> - @Query("SELECT * FROM Notes WHERE is_read = 0 AND semester_id = :semesterId AND student_id = :studentId") - fun loadNew(semesterId: Int, studentId: Int): Maybe> + @Query("SELECT * FROM Notes WHERE is_read = 0 AND student_id = :studentId") + fun loadNew(studentId: Int): Maybe> } diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/Note.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/Note.kt index 16fce130..b089c477 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/entities/Note.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/entities/Note.kt @@ -9,9 +9,6 @@ import java.io.Serializable @Entity(tableName = "Notes") data class Note( - @ColumnInfo(name = "semester_id") - val semesterId: Int, - @ColumnInfo(name = "student_id") val studentId: Int, diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/Student.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/Student.kt index a4756bbb..261b35fb 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/entities/Student.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/entities/Student.kt @@ -4,6 +4,7 @@ import androidx.room.ColumnInfo import androidx.room.Entity import androidx.room.Index import androidx.room.PrimaryKey +import org.threeten.bp.LocalDateTime import java.io.Serializable @Entity(tableName = "Students", indices = [Index(value = ["email", "symbol", "student_id", "school_id"], unique = true)]) @@ -32,7 +33,10 @@ data class Student( val schoolName: String, @ColumnInfo(name = "is_current") - val isCurrent: Boolean + val isCurrent: Boolean, + + @ColumnInfo(name = "registration_date") + val registrationDate: LocalDateTime ) : Serializable { @PrimaryKey(autoGenerate = true) diff --git a/app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration5.kt b/app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration5.kt new file mode 100644 index 00000000..ff215fc3 --- /dev/null +++ b/app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration5.kt @@ -0,0 +1,24 @@ +package io.github.wulkanowy.data.db.migrations + +import androidx.room.migration.Migration +import androidx.sqlite.db.SupportSQLiteDatabase +import org.threeten.bp.LocalDateTime.now +import org.threeten.bp.ZoneOffset + +class Migration5 : Migration(4, 5) { + + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL("ALTER TABLE Students ADD COLUMN `registration_date` INTEGER NOT NULL DEFAULT 0") + database.execSQL("UPDATE Students SET `registration_date` = '${now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli()}'") + database.execSQL("DROP TABLE IF EXISTS `Notes`") + database.execSQL("CREATE TABLE IF NOT EXISTS `Notes` (" + + "`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL," + + "`is_read` INTEGER NOT NULL," + + "`is_notified` INTEGER NOT NULL," + + "`student_id` INTEGER NOT NULL," + + "`date` INTEGER NOT NULL," + + "`teacher` TEXT NOT NULL," + + "`category` TEXT NOT NULL," + + "`content` TEXT NOT NULL)") + } +} diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/grade/GradeRepository.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/grade/GradeRepository.kt index 6f01e079..8ff3a86f 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/grade/GradeRepository.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/grade/GradeRepository.kt @@ -4,6 +4,7 @@ import com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork import com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.InternetObservingSettings import io.github.wulkanowy.data.db.entities.Grade import io.github.wulkanowy.data.db.entities.Semester +import io.github.wulkanowy.data.db.entities.Student import io.reactivex.Completable import io.reactivex.Single import java.net.UnknownHostException @@ -17,7 +18,7 @@ class GradeRepository @Inject constructor( private val remote: GradeRemote ) { - fun getGrades(semester: Semester, forceRefresh: Boolean = false, notify: Boolean = false): Single> { + fun getGrades(student: Student, semester: Semester, forceRefresh: Boolean = false, notify: Boolean = false): Single> { return local.getGrades(semester).filter { !forceRefresh } .switchIfEmpty(ReactiveNetwork.checkInternetConnectivity(settings) .flatMap { @@ -29,8 +30,10 @@ class GradeRepository @Inject constructor( local.deleteGrades(oldGrades - newGrades) local.saveGrades((newGrades - oldGrades) .onEach { - if (oldGrades.isNotEmpty()) it.isRead = false - if (notify) it.isNotified = false + if (student.registrationDate <= it.date.atStartOfDay()) { + if (notify) it.isNotified = false + it.isRead = false + } }) } }.flatMap { local.getGrades(semester).toSingle(emptyList()) }) diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/note/NoteLocal.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/note/NoteLocal.kt index 05e06116..3c849e2d 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/note/NoteLocal.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/note/NoteLocal.kt @@ -2,7 +2,7 @@ package io.github.wulkanowy.data.repositories.note import io.github.wulkanowy.data.db.dao.NoteDao import io.github.wulkanowy.data.db.entities.Note -import io.github.wulkanowy.data.db.entities.Semester +import io.github.wulkanowy.data.db.entities.Student import io.reactivex.Completable import io.reactivex.Maybe import javax.inject.Inject @@ -11,12 +11,12 @@ import javax.inject.Singleton @Singleton class NoteLocal @Inject constructor(private val noteDb: NoteDao) { - fun getNotes(semester: Semester): Maybe> { - return noteDb.loadAll(semester.semesterId, semester.studentId).filter { !it.isEmpty() } + fun getNotes(student: Student): Maybe> { + return noteDb.loadAll(student.studentId).filter { !it.isEmpty() } } - fun getNewNotes(semester: Semester): Maybe> { - return noteDb.loadNew(semester.semesterId, semester.studentId) + fun getNewNotes(student: Student): Maybe> { + return noteDb.loadNew(student.studentId) } fun saveNotes(notes: List) { diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/note/NoteRemote.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/note/NoteRemote.kt index 44ecbde1..aebc6230 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/note/NoteRemote.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/note/NoteRemote.kt @@ -17,7 +17,6 @@ class NoteRemote @Inject constructor(private val api: Api) { .map { notes -> notes.map { Note( - semesterId = semester.semesterId, studentId = semester.studentId, date = it.date.toLocalDate(), teacher = it.teacher, diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/note/NoteRepository.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/note/NoteRepository.kt index 9979d99d..9d575693 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/note/NoteRepository.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/note/NoteRepository.kt @@ -4,6 +4,7 @@ import com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork import com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.InternetObservingSettings import io.github.wulkanowy.data.db.entities.Note import io.github.wulkanowy.data.db.entities.Semester +import io.github.wulkanowy.data.db.entities.Student import io.reactivex.Completable import io.reactivex.Single import java.net.UnknownHostException @@ -17,27 +18,29 @@ class NoteRepository @Inject constructor( private val remote: NoteRemote ) { - fun getNotes(semester: Semester, forceRefresh: Boolean = false, notify: Boolean = false): Single> { - return local.getNotes(semester).filter { !forceRefresh } + fun getNotes(student: Student, semester: Semester, forceRefresh: Boolean = false, notify: Boolean = false): Single> { + return local.getNotes(student).filter { !forceRefresh } .switchIfEmpty(ReactiveNetwork.checkInternetConnectivity(settings) .flatMap { if (it) remote.getNotes(semester) else Single.error(UnknownHostException()) }.flatMap { new -> - local.getNotes(semester).toSingle(emptyList()) + local.getNotes(student).toSingle(emptyList()) .doOnSuccess { old -> local.deleteNotes(old - new) local.saveNotes((new - old) .onEach { - if (notify) it.isNotified = false + if (student.registrationDate <= it.date.atStartOfDay()) { + if (notify) it.isNotified = false + it.isRead = false + } }) } - }.flatMap { local.getNotes(semester).toSingle(emptyList()) } - ) + }.flatMap { local.getNotes(student).toSingle(emptyList()) }) } - fun getNewNotes(semester: Semester): Single> { - return local.getNewNotes(semester).toSingle(emptyList()) + fun getNewNotes(student: Student): Single> { + return local.getNewNotes(student).toSingle(emptyList()) } fun updateNote(note: Note): Completable { diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/student/StudentRemote.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/student/StudentRemote.kt index dad63d3a..7a504cca 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/student/StudentRemote.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/student/StudentRemote.kt @@ -3,6 +3,7 @@ package io.github.wulkanowy.data.repositories.student import io.github.wulkanowy.api.Api import io.github.wulkanowy.data.db.entities.Student import io.reactivex.Single +import org.threeten.bp.LocalDateTime.now import javax.inject.Inject import javax.inject.Singleton @@ -22,7 +23,8 @@ class StudentRemote @Inject constructor(private val api: Api) { schoolName = student.schoolName, endpoint = endpoint, loginType = student.loginType.name, - isCurrent = false + isCurrent = false, + registrationDate = now() ) } } diff --git a/app/src/main/java/io/github/wulkanowy/services/job/SyncWorker.kt b/app/src/main/java/io/github/wulkanowy/services/job/SyncWorker.kt index 22c6840f..cb994a03 100644 --- a/app/src/main/java/io/github/wulkanowy/services/job/SyncWorker.kt +++ b/app/src/main/java/io/github/wulkanowy/services/job/SyncWorker.kt @@ -101,13 +101,13 @@ class SyncWorker : SimpleJobService() { .flatMapCompletable { Completable.merge( listOf( - gradesDetails.getGrades(it.first, true, notify).ignoreElement(), + gradesDetails.getGrades(it.second, it.first, true, notify).ignoreElement(), gradesSummary.getGradesSummary(it.first, true).ignoreElement(), attendance.getAttendance(it.first, start, end, true).ignoreElement(), exam.getExams(it.first, start, end, true).ignoreElement(), timetable.getTimetable(it.first, start, end, true).ignoreElement(), message.getMessages(it.second, RECEIVED, true, notify).ignoreElement(), - note.getNotes(it.first, true, notify).ignoreElement(), + note.getNotes(it.second, it.first, true, notify).ignoreElement(), homework.getHomework(it.first, LocalDate.now(), true).ignoreElement(), homework.getHomework(it.first, LocalDate.now().plusDays(1), true).ignoreElement(), luckyNumber.getLuckyNumber(it.first, true, notify).ignoreElement(), @@ -168,7 +168,6 @@ class SyncWorker : SimpleJobService() { private fun sendNoteNotification() { disposable.add(student.getCurrentStudent() - .flatMap { semester.getCurrentSemester(it) } .flatMap { note.getNewNotes(it) } .map { it.filter { note -> !note.isNotified } } .doOnSuccess { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsPresenter.kt index 88f38c43..2d5b64b4 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsPresenter.kt @@ -108,8 +108,8 @@ class GradeDetailsPresenter @Inject constructor( private fun loadData(semesterId: Int, forceRefresh: Boolean) { Timber.i("Loading grade details data started") disposable.add(studentRepository.getCurrentStudent() - .flatMap { semesterRepository.getSemesters(it) } - .flatMap { gradeRepository.getGrades(it.first { item -> item.semesterId == semesterId }, forceRefresh) } + .flatMap { semesterRepository.getSemesters(it).map { semester -> semester to it } } + .flatMap { gradeRepository.getGrades(it.second, it.first.first { item -> item.semesterId == semesterId }, forceRefresh) } .map { it.sortedByDescending { grade -> grade.date } } .map { it.map { item -> item.changeModifier(preferencesRepository.gradePlusModifier, preferencesRepository.gradeMinusModifier) } } .map { createGradeItems(it.groupBy { grade -> grade.subject }.toSortedMap()) } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/summary/GradeSummaryPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/summary/GradeSummaryPresenter.kt index ba22f45b..61853f70 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/summary/GradeSummaryPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/summary/GradeSummaryPresenter.kt @@ -36,12 +36,12 @@ class GradeSummaryPresenter @Inject constructor( fun onParentViewLoadData(semesterId: Int, forceRefresh: Boolean) { Timber.i("Loading grade summary data started") disposable.add(studentRepository.getCurrentStudent() - .flatMap { semesterRepository.getSemesters(it) } - .map { semester -> semester.first { it.semesterId == semesterId } } + .flatMap { semesterRepository.getSemesters(it).map { semester -> semester to it } } + .map { pair -> pair.first.first { it.semesterId == semesterId } to pair.second } .flatMap { - gradeSummaryRepository.getGradesSummary(it, forceRefresh) + gradeSummaryRepository.getGradesSummary(it.first, forceRefresh) .flatMap { gradesSummary -> - gradeRepository.getGrades(it, forceRefresh) + gradeRepository.getGrades(it.second, it.first, forceRefresh) .map { grades -> grades.map { item -> item.changeModifier(preferencesRepository.gradePlusModifier, preferencesRepository.gradeMinusModifier) } .groupBy { grade -> grade.subject } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/note/NotePresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/note/NotePresenter.kt index 6542c6a6..a96bc7e0 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/note/NotePresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/note/NotePresenter.kt @@ -36,8 +36,8 @@ class NotePresenter @Inject constructor( private fun loadData(forceRefresh: Boolean = false) { Timber.i("Loading note data started") disposable.add(studentRepository.getCurrentStudent() - .flatMap { semesterRepository.getCurrentSemester(it) } - .flatMap { noteRepository.getNotes(it, forceRefresh) } + .flatMap { semesterRepository.getCurrentSemester(it).map { semester -> semester to it } } + .flatMap { noteRepository.getNotes(it.second, it.first, forceRefresh) } .map { items -> items.map { NoteItem(it) } } .map { items -> items.sortedByDescending { it.note.date } } .subscribeOn(schedulers.backgroundThread) diff --git a/app/src/test/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenterTest.kt b/app/src/test/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenterTest.kt index d0ac7374..b9c39590 100644 --- a/app/src/test/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenterTest.kt +++ b/app/src/test/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenterTest.kt @@ -16,6 +16,7 @@ import org.mockito.Mockito.never import org.mockito.Mockito.times import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations +import org.threeten.bp.LocalDateTime.now class LoginFormPresenterTest { @@ -75,7 +76,7 @@ class LoginFormPresenterTest { @Test fun loginTest() { - val studentTest = Student(email = "test@", password = "123", endpoint = "https://fakelog.cf", loginType = "AUTO", studentName = "", schoolSymbol = "", schoolName = "", studentId = 0, isCurrent = false, symbol = "") + val studentTest = Student(email = "test@", password = "123", endpoint = "https://fakelog.cf", loginType = "AUTO", studentName = "", schoolSymbol = "", schoolName = "", studentId = 0, isCurrent = false, symbol = "", registrationDate = now()) doReturn(Single.just(listOf(studentTest))) .`when`(repository).getStudents(anyString(), anyString(), anyString(), anyString()) presenter.attemptLogin("@", "123456", "https://fakelog.cf") diff --git a/app/src/test/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectPresenterTest.kt b/app/src/test/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectPresenterTest.kt index f345ea56..e19e8a11 100644 --- a/app/src/test/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectPresenterTest.kt +++ b/app/src/test/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectPresenterTest.kt @@ -16,6 +16,7 @@ import org.mockito.Mockito.clearInvocations import org.mockito.Mockito.doReturn import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations +import org.threeten.bp.LocalDateTime.now class LoginStudentSelectPresenterTest { @@ -36,7 +37,7 @@ class LoginStudentSelectPresenterTest { private lateinit var presenter: LoginStudentSelectPresenter - private val testStudent by lazy { Student(email = "test", password = "test123", endpoint = "https://fakelog.cf", loginType = "AUTO", symbol = "", isCurrent = false, studentId = 0, schoolName = "", schoolSymbol = "", studentName = "") } + private val testStudent by lazy { Student(email = "test", password = "test123", endpoint = "https://fakelog.cf", loginType = "AUTO", symbol = "", isCurrent = false, studentId = 0, schoolName = "", schoolSymbol = "", studentName = "", registrationDate = now()) } private val testException by lazy { RuntimeException("Problem") }