forked from github/wulkanowy-mirror
Filter lucky numbers by school shortcut (#708)
This commit is contained in:
parent
8aaa066142
commit
87107ec474
@ -122,7 +122,7 @@ configurations.all {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "io.github.wulkanowy:sdk:6789442"
|
implementation "io.github.wulkanowy:sdk:b3cdb3f"
|
||||||
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||||
implementation "androidx.core:core-ktx:1.2.0"
|
implementation "androidx.core:core-ktx:1.2.0"
|
||||||
|
1658
app/schemas/io.github.wulkanowy.data.db.AppDatabase/22.json
Normal file
1658
app/schemas/io.github.wulkanowy.data.db.AppDatabase/22.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -6,11 +6,13 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
|
|||||||
import io.github.wulkanowy.data.db.AppDatabase
|
import io.github.wulkanowy.data.db.AppDatabase
|
||||||
import io.github.wulkanowy.data.db.entities.LuckyNumber
|
import io.github.wulkanowy.data.db.entities.LuckyNumber
|
||||||
import io.github.wulkanowy.data.db.entities.Semester
|
import io.github.wulkanowy.data.db.entities.Semester
|
||||||
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.threeten.bp.LocalDate
|
import org.threeten.bp.LocalDate
|
||||||
|
import org.threeten.bp.LocalDateTime.now
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@ -36,7 +38,7 @@ class LuckyNumberLocalTest {
|
|||||||
fun saveAndReadTest() {
|
fun saveAndReadTest() {
|
||||||
luckyNumberLocal.saveLuckyNumber(LuckyNumber(1, LocalDate.of(2019, 1, 20), 14))
|
luckyNumberLocal.saveLuckyNumber(LuckyNumber(1, LocalDate.of(2019, 1, 20), 14))
|
||||||
|
|
||||||
val luckyNumber = luckyNumberLocal.getLuckyNumber(Semester(1, 1, "", 1, 3, 2019, LocalDate.now(), LocalDate.now(), 1, 1),
|
val luckyNumber = luckyNumberLocal.getLuckyNumber(Student("", "", "", "", "", "", false, "", "", "", 1, 1, "", "", "", "", "", 1, false, now()),
|
||||||
LocalDate.of(2019, 1, 20)
|
LocalDate.of(2019, 1, 20)
|
||||||
).blockingGet()
|
).blockingGet()
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class RecipientLocalTest {
|
|||||||
))
|
))
|
||||||
|
|
||||||
val recipients = recipientLocal.getRecipients(
|
val recipients = recipientLocal.getRecipients(
|
||||||
Student("fakelog.cf", "AUTO", "", "", "", "", false, "", "", "", 1, 0, "", "", "", "", 1, true, LocalDateTime.now()),
|
Student("fakelog.cf", "AUTO", "", "", "", "", false, "", "", "", 1, 0, "", "", "", "", "", 1, true, LocalDateTime.now()),
|
||||||
2,
|
2,
|
||||||
ReportingUnit(1, 4, "", 0, "", emptyList())
|
ReportingUnit(1, 4, "", 0, "", emptyList())
|
||||||
).blockingGet()
|
).blockingGet()
|
||||||
|
@ -39,7 +39,7 @@ class StudentLocalTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun saveAndReadTest() {
|
fun saveAndReadTest() {
|
||||||
studentLocal.saveStudents(listOf(Student(email = "test", password = "test123", schoolSymbol = "23", scrapperBaseUrl = "fakelog.cf", loginType = "AUTO", isCurrent = true, studentName = "", schoolName = "", studentId = 0, classId = 1, symbol = "", registrationDate = now(), className = "", loginMode = "API", certificateKey = "", privateKey = "", mobileBaseUrl = "", userLoginId = 0, isParent = false)))
|
studentLocal.saveStudents(listOf(Student(email = "test", password = "test123", schoolSymbol = "23", scrapperBaseUrl = "fakelog.cf", loginType = "AUTO", isCurrent = true, studentName = "", schoolShortName = "", schoolName = "", studentId = 0, classId = 1, symbol = "", registrationDate = now(), className = "", loginMode = "API", certificateKey = "", privateKey = "", mobileBaseUrl = "", userLoginId = 0, isParent = false)))
|
||||||
.blockingGet()
|
.blockingGet()
|
||||||
|
|
||||||
val student = studentLocal.getCurrentStudent(true).blockingGet()
|
val student = studentLocal.getCurrentStudent(true).blockingGet()
|
||||||
|
@ -62,6 +62,7 @@ import io.github.wulkanowy.data.db.migrations.Migration19
|
|||||||
import io.github.wulkanowy.data.db.migrations.Migration2
|
import io.github.wulkanowy.data.db.migrations.Migration2
|
||||||
import io.github.wulkanowy.data.db.migrations.Migration20
|
import io.github.wulkanowy.data.db.migrations.Migration20
|
||||||
import io.github.wulkanowy.data.db.migrations.Migration21
|
import io.github.wulkanowy.data.db.migrations.Migration21
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration22
|
||||||
import io.github.wulkanowy.data.db.migrations.Migration3
|
import io.github.wulkanowy.data.db.migrations.Migration3
|
||||||
import io.github.wulkanowy.data.db.migrations.Migration4
|
import io.github.wulkanowy.data.db.migrations.Migration4
|
||||||
import io.github.wulkanowy.data.db.migrations.Migration5
|
import io.github.wulkanowy.data.db.migrations.Migration5
|
||||||
@ -103,7 +104,7 @@ import javax.inject.Singleton
|
|||||||
abstract class AppDatabase : RoomDatabase() {
|
abstract class AppDatabase : RoomDatabase() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val VERSION_SCHEMA = 21
|
const val VERSION_SCHEMA = 22
|
||||||
|
|
||||||
fun getMigrations(sharedPrefProvider: SharedPrefProvider): Array<Migration> {
|
fun getMigrations(sharedPrefProvider: SharedPrefProvider): Array<Migration> {
|
||||||
return arrayOf(
|
return arrayOf(
|
||||||
@ -126,7 +127,8 @@ abstract class AppDatabase : RoomDatabase() {
|
|||||||
Migration18(),
|
Migration18(),
|
||||||
Migration19(sharedPrefProvider),
|
Migration19(sharedPrefProvider),
|
||||||
Migration20(),
|
Migration20(),
|
||||||
Migration21()
|
Migration21(),
|
||||||
|
Migration22()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +49,9 @@ data class Student(
|
|||||||
@ColumnInfo(name = "school_id")
|
@ColumnInfo(name = "school_id")
|
||||||
val schoolSymbol: String,
|
val schoolSymbol: String,
|
||||||
|
|
||||||
|
@ColumnInfo(name ="school_short")
|
||||||
|
val schoolShortName: String,
|
||||||
|
|
||||||
@ColumnInfo(name = "school_name")
|
@ColumnInfo(name = "school_name")
|
||||||
val schoolName: String,
|
val schoolName: String,
|
||||||
|
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package io.github.wulkanowy.data.db.migrations
|
||||||
|
|
||||||
|
import androidx.room.migration.Migration
|
||||||
|
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||||
|
|
||||||
|
class Migration22 : Migration(21, 22) {
|
||||||
|
|
||||||
|
override fun migrate(database: SupportSQLiteDatabase) {
|
||||||
|
database.execSQL("ALTER TABLE Students ADD COLUMN school_short TEXT NOT NULL DEFAULT ''")
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,7 @@ package io.github.wulkanowy.data.repositories.luckynumber
|
|||||||
|
|
||||||
import io.github.wulkanowy.data.db.dao.LuckyNumberDao
|
import io.github.wulkanowy.data.db.dao.LuckyNumberDao
|
||||||
import io.github.wulkanowy.data.db.entities.LuckyNumber
|
import io.github.wulkanowy.data.db.entities.LuckyNumber
|
||||||
import io.github.wulkanowy.data.db.entities.Semester
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
import io.reactivex.Maybe
|
import io.reactivex.Maybe
|
||||||
import org.threeten.bp.LocalDate
|
import org.threeten.bp.LocalDate
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -23,7 +23,7 @@ class LuckyNumberLocal @Inject constructor(private val luckyNumberDb: LuckyNumbe
|
|||||||
luckyNumberDb.deleteAll(listOf(luckyNumber))
|
luckyNumberDb.deleteAll(listOf(luckyNumber))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getLuckyNumber(semester: Semester, date: LocalDate): Maybe<LuckyNumber> {
|
fun getLuckyNumber(student: Student, date: LocalDate): Maybe<LuckyNumber> {
|
||||||
return luckyNumberDb.load(semester.studentId, date)
|
return luckyNumberDb.load(student.studentId, date)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package io.github.wulkanowy.data.repositories.luckynumber
|
package io.github.wulkanowy.data.repositories.luckynumber
|
||||||
|
|
||||||
import io.github.wulkanowy.data.db.entities.LuckyNumber
|
import io.github.wulkanowy.data.db.entities.LuckyNumber
|
||||||
import io.github.wulkanowy.data.db.entities.Semester
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
import io.github.wulkanowy.sdk.Sdk
|
import io.github.wulkanowy.sdk.Sdk
|
||||||
import io.reactivex.Maybe
|
import io.reactivex.Maybe
|
||||||
import org.threeten.bp.LocalDate
|
import org.threeten.bp.LocalDate
|
||||||
@ -11,11 +11,10 @@ import javax.inject.Singleton
|
|||||||
@Singleton
|
@Singleton
|
||||||
class LuckyNumberRemote @Inject constructor(private val sdk: Sdk) {
|
class LuckyNumberRemote @Inject constructor(private val sdk: Sdk) {
|
||||||
|
|
||||||
fun getLuckyNumber(semester: Semester): Maybe<LuckyNumber> {
|
fun getLuckyNumber(student: Student): Maybe<LuckyNumber> {
|
||||||
return sdk.getLuckyNumber()
|
return sdk.getLuckyNumber(student.schoolShortName).map {
|
||||||
.map {
|
|
||||||
LuckyNumber(
|
LuckyNumber(
|
||||||
studentId = semester.studentId,
|
studentId = student.studentId,
|
||||||
date = LocalDate.now(),
|
date = LocalDate.now(),
|
||||||
luckyNumber = it
|
luckyNumber = it
|
||||||
)
|
)
|
||||||
|
@ -3,7 +3,7 @@ package io.github.wulkanowy.data.repositories.luckynumber
|
|||||||
import com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork
|
import com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork
|
||||||
import com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.InternetObservingSettings
|
import com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.InternetObservingSettings
|
||||||
import io.github.wulkanowy.data.db.entities.LuckyNumber
|
import io.github.wulkanowy.data.db.entities.LuckyNumber
|
||||||
import io.github.wulkanowy.data.db.entities.Semester
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
import io.reactivex.Completable
|
import io.reactivex.Completable
|
||||||
import io.reactivex.Maybe
|
import io.reactivex.Maybe
|
||||||
import org.threeten.bp.LocalDate
|
import org.threeten.bp.LocalDate
|
||||||
@ -18,14 +18,14 @@ class LuckyNumberRepository @Inject constructor(
|
|||||||
private val remote: LuckyNumberRemote
|
private val remote: LuckyNumberRemote
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun getLuckyNumber(semester: Semester, forceRefresh: Boolean = false, notify: Boolean = false): Maybe<LuckyNumber> {
|
fun getLuckyNumber(student: Student, forceRefresh: Boolean = false, notify: Boolean = false): Maybe<LuckyNumber> {
|
||||||
return local.getLuckyNumber(semester, LocalDate.now()).filter { !forceRefresh }
|
return local.getLuckyNumber(student, LocalDate.now()).filter { !forceRefresh }
|
||||||
.switchIfEmpty(ReactiveNetwork.checkInternetConnectivity(settings)
|
.switchIfEmpty(ReactiveNetwork.checkInternetConnectivity(settings)
|
||||||
.flatMapMaybe {
|
.flatMapMaybe {
|
||||||
if (it) remote.getLuckyNumber(semester)
|
if (it) remote.getLuckyNumber(student)
|
||||||
else Maybe.error(UnknownHostException())
|
else Maybe.error(UnknownHostException())
|
||||||
}.flatMap { new ->
|
}.flatMap { new ->
|
||||||
local.getLuckyNumber(semester, LocalDate.now())
|
local.getLuckyNumber(student, LocalDate.now())
|
||||||
.doOnSuccess { old ->
|
.doOnSuccess { old ->
|
||||||
if (new != old) {
|
if (new != old) {
|
||||||
local.deleteLuckyNumber(old)
|
local.deleteLuckyNumber(old)
|
||||||
@ -39,13 +39,13 @@ class LuckyNumberRepository @Inject constructor(
|
|||||||
if (notify) isNotified = false
|
if (notify) isNotified = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}.flatMap({ local.getLuckyNumber(semester, LocalDate.now()) }, { Maybe.error(it) },
|
}.flatMap({ local.getLuckyNumber(student, LocalDate.now()) }, { Maybe.error(it) },
|
||||||
{ local.getLuckyNumber(semester, LocalDate.now()) })
|
{ local.getLuckyNumber(student, LocalDate.now()) })
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getNotNotifiedLuckyNumber(semester: Semester): Maybe<LuckyNumber> {
|
fun getNotNotifiedLuckyNumber(student: Student): Maybe<LuckyNumber> {
|
||||||
return local.getLuckyNumber(semester, LocalDate.now()).filter { !it.isNotified }
|
return local.getLuckyNumber(student, LocalDate.now()).filter { !it.isNotified }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateLuckyNumber(luckyNumber: LuckyNumber): Completable {
|
fun updateLuckyNumber(luckyNumber: LuckyNumber): Completable {
|
||||||
|
@ -22,6 +22,7 @@ class StudentRemote @Inject constructor(private val sdk: Sdk) {
|
|||||||
userLoginId = student.userLoginId,
|
userLoginId = student.userLoginId,
|
||||||
studentName = student.studentName,
|
studentName = student.studentName,
|
||||||
schoolSymbol = student.schoolSymbol,
|
schoolSymbol = student.schoolSymbol,
|
||||||
|
schoolShortName = student.schoolShortName,
|
||||||
schoolName = student.schoolName,
|
schoolName = student.schoolName,
|
||||||
className = student.className,
|
className = student.className,
|
||||||
classId = student.classId,
|
classId = student.classId,
|
||||||
|
@ -29,8 +29,8 @@ class LuckyNumberWork @Inject constructor(
|
|||||||
) : Work {
|
) : Work {
|
||||||
|
|
||||||
override fun create(student: Student, semester: Semester): Completable {
|
override fun create(student: Student, semester: Semester): Completable {
|
||||||
return luckyNumberRepository.getLuckyNumber(semester, true, preferencesRepository.isNotificationsEnable)
|
return luckyNumberRepository.getLuckyNumber(student, true, preferencesRepository.isNotificationsEnable)
|
||||||
.flatMap { luckyNumberRepository.getNotNotifiedLuckyNumber(semester) }
|
.flatMap { luckyNumberRepository.getNotNotifiedLuckyNumber(student) }
|
||||||
.flatMapCompletable {
|
.flatMapCompletable {
|
||||||
notify(it)
|
notify(it)
|
||||||
luckyNumberRepository.updateLuckyNumber(it.apply { isNotified = true })
|
luckyNumberRepository.updateLuckyNumber(it.apply { isNotified = true })
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package io.github.wulkanowy.ui.modules.luckynumber
|
package io.github.wulkanowy.ui.modules.luckynumber
|
||||||
|
|
||||||
import io.github.wulkanowy.data.repositories.luckynumber.LuckyNumberRepository
|
import io.github.wulkanowy.data.repositories.luckynumber.LuckyNumberRepository
|
||||||
import io.github.wulkanowy.data.repositories.semester.SemesterRepository
|
|
||||||
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
||||||
import io.github.wulkanowy.ui.base.BasePresenter
|
import io.github.wulkanowy.ui.base.BasePresenter
|
||||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||||
@ -15,7 +14,6 @@ class LuckyNumberPresenter @Inject constructor(
|
|||||||
errorHandler: ErrorHandler,
|
errorHandler: ErrorHandler,
|
||||||
studentRepository: StudentRepository,
|
studentRepository: StudentRepository,
|
||||||
private val luckyNumberRepository: LuckyNumberRepository,
|
private val luckyNumberRepository: LuckyNumberRepository,
|
||||||
private val semesterRepository: SemesterRepository,
|
|
||||||
private val analytics: FirebaseAnalyticsHelper
|
private val analytics: FirebaseAnalyticsHelper
|
||||||
) : BasePresenter<LuckyNumberView>(errorHandler, studentRepository, schedulers) {
|
) : BasePresenter<LuckyNumberView>(errorHandler, studentRepository, schedulers) {
|
||||||
|
|
||||||
@ -38,7 +36,6 @@ class LuckyNumberPresenter @Inject constructor(
|
|||||||
disposable.apply {
|
disposable.apply {
|
||||||
clear()
|
clear()
|
||||||
add(studentRepository.getCurrentStudent()
|
add(studentRepository.getCurrentStudent()
|
||||||
.flatMap { semesterRepository.getCurrentSemester(it) }
|
|
||||||
.flatMapMaybe { luckyNumberRepository.getLuckyNumber(it, forceRefresh) }
|
.flatMapMaybe { luckyNumberRepository.getLuckyNumber(it, forceRefresh) }
|
||||||
.subscribeOn(schedulers.backgroundThread)
|
.subscribeOn(schedulers.backgroundThread)
|
||||||
.observeOn(schedulers.mainThread)
|
.observeOn(schedulers.mainThread)
|
||||||
|
@ -18,7 +18,6 @@ import io.github.wulkanowy.data.db.SharedPrefProvider
|
|||||||
import io.github.wulkanowy.data.db.entities.LuckyNumber
|
import io.github.wulkanowy.data.db.entities.LuckyNumber
|
||||||
import io.github.wulkanowy.data.exceptions.NoCurrentStudentException
|
import io.github.wulkanowy.data.exceptions.NoCurrentStudentException
|
||||||
import io.github.wulkanowy.data.repositories.luckynumber.LuckyNumberRepository
|
import io.github.wulkanowy.data.repositories.luckynumber.LuckyNumberRepository
|
||||||
import io.github.wulkanowy.data.repositories.semester.SemesterRepository
|
|
||||||
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
||||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
@ -32,9 +31,6 @@ class LuckyNumberWidgetProvider : AppWidgetProvider() {
|
|||||||
@Inject
|
@Inject
|
||||||
lateinit var studentRepository: StudentRepository
|
lateinit var studentRepository: StudentRepository
|
||||||
|
|
||||||
@Inject
|
|
||||||
lateinit var semesterRepository: SemesterRepository
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var luckyNumberRepository: LuckyNumberRepository
|
lateinit var luckyNumberRepository: LuckyNumberRepository
|
||||||
|
|
||||||
@ -156,7 +152,6 @@ class LuckyNumberWidgetProvider : AppWidgetProvider() {
|
|||||||
else -> Maybe.empty()
|
else -> Maybe.empty()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.flatMap { semesterRepository.getCurrentSemester(it).toMaybe() }
|
|
||||||
.flatMap { luckyNumberRepository.getLuckyNumber(it) }
|
.flatMap { luckyNumberRepository.getLuckyNumber(it) }
|
||||||
.subscribeOn(schedulers.backgroundThread)
|
.subscribeOn(schedulers.backgroundThread)
|
||||||
.blockingGet()
|
.blockingGet()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package io.github.wulkanowy.data.repositories.luckynumber
|
package io.github.wulkanowy.data.repositories.luckynumber
|
||||||
|
|
||||||
import io.github.wulkanowy.data.db.entities.Semester
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
import io.github.wulkanowy.sdk.Sdk
|
import io.github.wulkanowy.sdk.Sdk
|
||||||
import io.mockk.MockKAnnotations
|
import io.mockk.MockKAnnotations
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
@ -18,7 +18,7 @@ class LuckyNumberRemoteTest {
|
|||||||
private var mockSdk = Sdk()
|
private var mockSdk = Sdk()
|
||||||
|
|
||||||
@MockK
|
@MockK
|
||||||
private lateinit var semesterMock: Semester
|
private lateinit var studentMock: Student
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun initApi() {
|
fun initApi() {
|
||||||
@ -27,18 +27,18 @@ class LuckyNumberRemoteTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun getLuckyNumberTest() {
|
fun getLuckyNumberTest() {
|
||||||
every { mockSdk.getLuckyNumber() } returns Maybe.just(14)
|
every { mockSdk.getLuckyNumber("test") } returns Maybe.just(14)
|
||||||
|
|
||||||
every { mockSdk.diaryId } returns 1
|
every { mockSdk.diaryId } returns 1
|
||||||
every { semesterMock.studentId } returns 1
|
every { studentMock.studentId } returns 1
|
||||||
every { semesterMock.diaryId } returns 1
|
every { studentMock.schoolShortName } returns "test"
|
||||||
|
|
||||||
val luckyNumber = LuckyNumberRemote(mockSdk)
|
val luckyNumber = LuckyNumberRemote(mockSdk)
|
||||||
.getLuckyNumber(semesterMock)
|
.getLuckyNumber(studentMock)
|
||||||
.blockingGet()
|
.blockingGet()
|
||||||
|
|
||||||
assertEquals(14, luckyNumber.luckyNumber)
|
assertEquals(14, luckyNumber.luckyNumber)
|
||||||
assertEquals(LocalDate.now(), luckyNumber.date)
|
assertEquals(LocalDate.now(), luckyNumber.date)
|
||||||
assertEquals(semesterMock.studentId, luckyNumber.studentId)
|
assertEquals(studentMock.studentId, luckyNumber.studentId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ class StudentRemoteTest {
|
|||||||
userLoginId = 0,
|
userLoginId = 0,
|
||||||
studentName = name,
|
studentName = name,
|
||||||
schoolSymbol = "",
|
schoolSymbol = "",
|
||||||
|
schoolShortName = "",
|
||||||
schoolName = "",
|
schoolName = "",
|
||||||
className = "",
|
className = "",
|
||||||
classId = 0,
|
classId = 0,
|
||||||
|
@ -32,7 +32,7 @@ class GradeAverageProviderTest {
|
|||||||
|
|
||||||
private lateinit var gradeAverageProvider: GradeAverageProvider
|
private lateinit var gradeAverageProvider: GradeAverageProvider
|
||||||
|
|
||||||
private val student = Student("", "", "", "SCRAPPER", "", "", false, "", "", "", 101, 0, "", "", "", "", 1, true, LocalDateTime.now())
|
private val student = Student("", "", "", "SCRAPPER", "", "", false, "", "", "", 101, 0, "", "", "", "", "", 1, true, LocalDateTime.now())
|
||||||
|
|
||||||
private val semesters = mutableListOf(
|
private val semesters = mutableListOf(
|
||||||
createSemesterEntity(10, 21, of(2019, 1, 31), of(2019, 6, 23)),
|
createSemesterEntity(10, 21, of(2019, 1, 31), of(2019, 6, 23)),
|
||||||
|
@ -86,7 +86,7 @@ class LoginFormPresenterTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun loginTest() {
|
fun loginTest() {
|
||||||
val studentTest = Student(email = "test@", password = "123", scrapperBaseUrl = "https://fakelog.cf", loginType = "AUTO", studentName = "", schoolSymbol = "", schoolName = "", studentId = 0, classId = 1, isCurrent = false, symbol = "", registrationDate = now(), className = "", mobileBaseUrl = "", privateKey = "", certificateKey = "", loginMode = "", userLoginId = 0, isParent = false)
|
val studentTest = Student(email = "test@", password = "123", scrapperBaseUrl = "https://fakelog.cf", loginType = "AUTO", studentName = "", schoolSymbol = "", schoolName = "", studentId = 0, classId = 1, isCurrent = false, symbol = "", registrationDate = now(), className = "", mobileBaseUrl = "", privateKey = "", certificateKey = "", loginMode = "", userLoginId = 0, schoolShortName = "", isParent = false)
|
||||||
doReturn(Single.just(listOf(studentTest))).`when`(repository).getStudentsScrapper(anyString(), anyString(), anyString(), anyString())
|
doReturn(Single.just(listOf(studentTest))).`when`(repository).getStudentsScrapper(anyString(), anyString(), anyString(), anyString())
|
||||||
|
|
||||||
`when`(loginFormView.formUsernameValue).thenReturn("@")
|
`when`(loginFormView.formUsernameValue).thenReturn("@")
|
||||||
|
@ -32,7 +32,7 @@ class LoginStudentSelectPresenterTest {
|
|||||||
|
|
||||||
private lateinit var presenter: LoginStudentSelectPresenter
|
private lateinit var presenter: LoginStudentSelectPresenter
|
||||||
|
|
||||||
private val testStudent by lazy { Student(email = "test", password = "test123", scrapperBaseUrl = "https://fakelog.cf", loginType = "AUTO", symbol = "", isCurrent = false, studentId = 0, schoolName = "", schoolSymbol = "", classId = 1, studentName = "", registrationDate = now(), className = "", loginMode = "", certificateKey = "", privateKey = "", mobileBaseUrl = "", userLoginId = 1, isParent = false) }
|
private val testStudent by lazy { Student(email = "test", password = "test123", scrapperBaseUrl = "https://fakelog.cf", loginType = "AUTO", symbol = "", isCurrent = false, studentId = 0, schoolName = "", schoolSymbol = "", classId = 1, studentName = "", registrationDate = now(), className = "", loginMode = "", certificateKey = "", privateKey = "", mobileBaseUrl = "", schoolShortName = "", userLoginId = 1, isParent = false) }
|
||||||
|
|
||||||
private val testException by lazy { RuntimeException("Problem") }
|
private val testException by lazy { RuntimeException("Problem") }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user