mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-02-07 18:14:37 +01:00
Fix lint errors (#873)
This commit is contained in:
parent
a05da2656a
commit
a529836937
@ -120,23 +120,23 @@ class Migration13Test : AbstractMigrationTest() {
|
|||||||
assertEquals(2, first.diaryId)
|
assertEquals(2, first.diaryId)
|
||||||
}
|
}
|
||||||
|
|
||||||
getSemesters(db, "SELECT * FROM Semesters WHERE student_id = 2 AND class_id = 5").let {
|
getSemesters(db, "SELECT * FROM Semesters WHERE student_id = 2 AND class_id = 5").let { semesters ->
|
||||||
assertTrue { it.single { it.second }.second }
|
assertTrue { semesters.single { it.second }.second }
|
||||||
assertEquals(1970, it[0].first.schoolYear)
|
assertEquals(1970, semesters[0].first.schoolYear)
|
||||||
assertEquals(of(1970, 1, 1), it[0].first.end)
|
assertEquals(of(1970, 1, 1), semesters[0].first.end)
|
||||||
assertEquals(of(1970, 1, 1), it[0].first.start)
|
assertEquals(of(1970, 1, 1), semesters[0].first.start)
|
||||||
assertFalse(it[0].second)
|
assertFalse(semesters[0].second)
|
||||||
assertFalse(it[1].second)
|
assertFalse(semesters[1].second)
|
||||||
assertFalse(it[2].second)
|
assertFalse(semesters[2].second)
|
||||||
assertTrue(it[3].second)
|
assertTrue(semesters[3].second)
|
||||||
}
|
}
|
||||||
|
|
||||||
getSemesters(db, "SELECT * FROM Semesters WHERE student_id = 2 AND class_id = 5").let {
|
getSemesters(db, "SELECT * FROM Semesters WHERE student_id = 2 AND class_id = 5").let { semesters ->
|
||||||
assertTrue { it.single { it.second }.second }
|
assertTrue { semesters.single { it.second }.second }
|
||||||
assertFalse(it[0].second)
|
assertFalse(semesters[0].second)
|
||||||
assertFalse(it[1].second)
|
assertFalse(semesters[1].second)
|
||||||
assertFalse(it[2].second)
|
assertFalse(semesters[2].second)
|
||||||
assertTrue(it[3].second)
|
assertTrue(semesters[3].second)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ 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.now
|
import org.threeten.bp.LocalDate.now
|
||||||
import org.threeten.bp.LocalDate.of
|
import org.threeten.bp.LocalDate.of
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
@ -35,9 +36,18 @@ class AttendanceLocalTest {
|
|||||||
@Test
|
@Test
|
||||||
fun saveAndReadTest() {
|
fun saveAndReadTest() {
|
||||||
attendanceLocal.saveAttendance(listOf(
|
attendanceLocal.saveAttendance(listOf(
|
||||||
Attendance(1, 2, 3, of(2018, 9, 10), 0, "", "", false, false, false, false, false, false, false, SentExcuseStatus.ACCEPTED.name),
|
getAttendanceEntity(
|
||||||
Attendance(1, 2, 3, of(2018, 9, 14), 0, "", "", false, false, false, false, false, false, false, SentExcuseStatus.WAITING.name),
|
of(2018, 9, 10),
|
||||||
Attendance(1, 2, 3, of(2018, 9, 17), 0, "", "", false, false, false, false, false, false, false, SentExcuseStatus.ACCEPTED.name)
|
SentExcuseStatus.ACCEPTED
|
||||||
|
),
|
||||||
|
getAttendanceEntity(
|
||||||
|
of(2018, 9, 14),
|
||||||
|
SentExcuseStatus.WAITING
|
||||||
|
),
|
||||||
|
getAttendanceEntity(
|
||||||
|
of(2018, 9, 17),
|
||||||
|
SentExcuseStatus.ACCEPTED
|
||||||
|
)
|
||||||
))
|
))
|
||||||
|
|
||||||
val attendance = attendanceLocal
|
val attendance = attendanceLocal
|
||||||
@ -50,4 +60,25 @@ class AttendanceLocalTest {
|
|||||||
assertEquals(attendance[0].date, of(2018, 9, 10))
|
assertEquals(attendance[0].date, of(2018, 9, 10))
|
||||||
assertEquals(attendance[1].date, of(2018, 9, 14))
|
assertEquals(attendance[1].date, of(2018, 9, 14))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getAttendanceEntity(
|
||||||
|
date: LocalDate,
|
||||||
|
excuseStatus: SentExcuseStatus
|
||||||
|
) = Attendance(
|
||||||
|
studentId = 1,
|
||||||
|
diaryId = 2,
|
||||||
|
timeId = 3,
|
||||||
|
date = date,
|
||||||
|
number = 0,
|
||||||
|
subject = "",
|
||||||
|
name = "",
|
||||||
|
presence = false,
|
||||||
|
absence = false,
|
||||||
|
exemption = false,
|
||||||
|
lateness = false,
|
||||||
|
excused = false,
|
||||||
|
deleted = false,
|
||||||
|
excusable = false,
|
||||||
|
excuseStatus = excuseStatus.name
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import androidx.test.core.app.ApplicationProvider
|
|||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
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.Student
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
package io.github.wulkanowy.utils
|
package io.github.wulkanowy.utils
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
open class TimberTreeNoOp : Timber.Tree() {
|
open class TimberTreeNoOp : Timber.Tree() {
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
package io.github.wulkanowy.data
|
package io.github.wulkanowy.data
|
||||||
|
|
||||||
import android.app.AlarmManager
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.content.res.AssetManager
|
import android.content.res.AssetManager
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import androidx.core.content.getSystemService
|
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.InternetObservingSettings
|
|
||||||
import com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.strategy.WalledGardenInternetObservingStrategy
|
|
||||||
import com.chuckerteam.chucker.api.ChuckerCollector
|
import com.chuckerteam.chucker.api.ChuckerCollector
|
||||||
import com.chuckerteam.chucker.api.ChuckerInterceptor
|
import com.chuckerteam.chucker.api.ChuckerInterceptor
|
||||||
import com.chuckerteam.chucker.api.RetentionManager
|
import com.chuckerteam.chucker.api.RetentionManager
|
||||||
|
import com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.InternetObservingSettings
|
||||||
|
import com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.strategy.WalledGardenInternetObservingStrategy
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import io.github.wulkanowy.data.db.AppDatabase
|
import io.github.wulkanowy.data.db.AppDatabase
|
||||||
|
@ -10,7 +10,7 @@ import javax.inject.Singleton
|
|||||||
@Singleton
|
@Singleton
|
||||||
class AppCreatorRepository @Inject constructor(private val assets: AssetManager) {
|
class AppCreatorRepository @Inject constructor(private val assets: AssetManager) {
|
||||||
fun getAppCreators(): Single<List<Contributor>> {
|
fun getAppCreators(): Single<List<Contributor>> {
|
||||||
return Single.fromCallable<List<Contributor>> {
|
return Single.fromCallable {
|
||||||
Gson().fromJson(
|
Gson().fromJson(
|
||||||
assets.open("contributors.json").bufferedReader().use { it.readText() },
|
assets.open("contributors.json").bufferedReader().use { it.readText() },
|
||||||
Array<Contributor>::class.java
|
Array<Contributor>::class.java
|
||||||
|
@ -13,7 +13,7 @@ class ExamLocal @Inject constructor(private val examDb: ExamDao) {
|
|||||||
|
|
||||||
fun getExams(semester: Semester, startDate: LocalDate, endDate: LocalDate): Maybe<List<Exam>> {
|
fun getExams(semester: Semester, startDate: LocalDate, endDate: LocalDate): Maybe<List<Exam>> {
|
||||||
return examDb.loadAll(semester.diaryId, semester.studentId, startDate, endDate)
|
return examDb.loadAll(semester.diaryId, semester.studentId, startDate, endDate)
|
||||||
.filter { !it.isEmpty() }
|
.filter { it.isNotEmpty() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveExams(exams: List<Exam>) {
|
fun saveExams(exams: List<Exam>) {
|
||||||
|
@ -12,7 +12,7 @@ import javax.inject.Singleton
|
|||||||
class RecipientLocal @Inject constructor(private val recipientDb: RecipientDao) {
|
class RecipientLocal @Inject constructor(private val recipientDb: RecipientDao) {
|
||||||
|
|
||||||
fun getRecipients(student: Student, role: Int, unit: ReportingUnit): Maybe<List<Recipient>> {
|
fun getRecipients(student: Student, role: Int, unit: ReportingUnit): Maybe<List<Recipient>> {
|
||||||
return recipientDb.load(student.studentId, role, unit.realId).filter { !it.isEmpty() }
|
return recipientDb.load(student.studentId, role, unit.realId).filter { it.isNotEmpty() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveRecipients(recipients: List<Recipient>): List<Long> {
|
fun saveRecipients(recipients: List<Recipient>): List<Long> {
|
||||||
|
@ -11,7 +11,7 @@ import javax.inject.Singleton
|
|||||||
class ReportingUnitLocal @Inject constructor(private val reportingUnitDb: ReportingUnitDao) {
|
class ReportingUnitLocal @Inject constructor(private val reportingUnitDb: ReportingUnitDao) {
|
||||||
|
|
||||||
fun getReportingUnits(student: Student): Maybe<List<ReportingUnit>> {
|
fun getReportingUnits(student: Student): Maybe<List<ReportingUnit>> {
|
||||||
return reportingUnitDb.load(student.studentId).filter { !it.isEmpty() }
|
return reportingUnitDb.load(student.studentId).filter { it.isNotEmpty() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getReportingUnit(student: Student, unitId: Int): Maybe<ReportingUnit> {
|
fun getReportingUnit(student: Student, unitId: Int): Maybe<ReportingUnit> {
|
||||||
|
@ -9,7 +9,7 @@ import javax.inject.Inject
|
|||||||
class GradeStatisticsWork @Inject constructor(private val gradeStatisticsRepository: GradeStatisticsRepository) : Work {
|
class GradeStatisticsWork @Inject constructor(private val gradeStatisticsRepository: GradeStatisticsRepository) : Work {
|
||||||
|
|
||||||
override fun create(student: Student, semester: Semester): Completable {
|
override fun create(student: Student, semester: Semester): Completable {
|
||||||
return gradeStatisticsRepository.getGradesStatistics(student, semester, "Wszystkie", false, true)
|
return gradeStatisticsRepository.getGradesStatistics(student, semester, "Wszystkie", false, forceRefresh = true)
|
||||||
.ignoreElement()
|
.ignoreElement()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,9 @@ class LogViewerPresenter @Inject constructor(
|
|||||||
disposable.add(loggerRepository.getLogFiles()
|
disposable.add(loggerRepository.getLogFiles()
|
||||||
.subscribeOn(schedulers.backgroundThread)
|
.subscribeOn(schedulers.backgroundThread)
|
||||||
.observeOn(schedulers.mainThread)
|
.observeOn(schedulers.mainThread)
|
||||||
.subscribe({
|
.subscribe({ files ->
|
||||||
Timber.i("Loading logs files result: ${it.joinToString { it.name }}")
|
Timber.i("Loading logs files result: ${files.joinToString { it.name }}")
|
||||||
view?.shareLogs(it)
|
view?.shareLogs(files)
|
||||||
}, {
|
}, {
|
||||||
Timber.i("Loading logs files result: An exception occurred")
|
Timber.i("Loading logs files result: An exception occurred")
|
||||||
errorHandler.dispatch(it)
|
errorHandler.dispatch(it)
|
||||||
|
@ -20,7 +20,6 @@ import org.threeten.bp.LocalDate
|
|||||||
import org.threeten.bp.LocalDate.now
|
import org.threeten.bp.LocalDate.now
|
||||||
import org.threeten.bp.LocalDate.ofEpochDay
|
import org.threeten.bp.LocalDate.ofEpochDay
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class AttendancePresenter @Inject constructor(
|
class AttendancePresenter @Inject constructor(
|
||||||
|
@ -43,7 +43,7 @@ class CompletedLessonsPresenter @Inject constructor(
|
|||||||
completedLessonsErrorHandler.showErrorMessage = ::showErrorViewOnError
|
completedLessonsErrorHandler.showErrorMessage = ::showErrorViewOnError
|
||||||
completedLessonsErrorHandler.onFeatureDisabled = {
|
completedLessonsErrorHandler.onFeatureDisabled = {
|
||||||
this.view?.showFeatureDisabled()
|
this.view?.showFeatureDisabled()
|
||||||
this.view?.showEmpty(true);
|
this.view?.showEmpty(true)
|
||||||
Timber.i("Completed lessons feature disabled by school")
|
Timber.i("Completed lessons feature disabled by school")
|
||||||
}
|
}
|
||||||
loadData(ofEpochDay(date ?: baseDate.toEpochDay()))
|
loadData(ofEpochDay(date ?: baseDate.toEpochDay()))
|
||||||
|
@ -52,4 +52,4 @@ class LifecycleAwareVariableActivity<T : Any> : ReadWriteProperty<AppCompatActiv
|
|||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
fun <T : Any> Fragment.lifecycleAwareVariable() = LifecycleAwareVariable<T>()
|
fun <T : Any> Fragment.lifecycleAwareVariable() = LifecycleAwareVariable<T>()
|
||||||
|
|
||||||
fun <T : Any> AppCompatActivity.lifecycleAwareVariable() = LifecycleAwareVariableActivity<T>()
|
fun <T : Any> lifecycleAwareVariable() = LifecycleAwareVariableActivity<T>()
|
||||||
|
@ -343,7 +343,7 @@
|
|||||||
<string name="all_prev">Prev</string>
|
<string name="all_prev">Prev</string>
|
||||||
<string name="all_next">Next</string>
|
<string name="all_next">Next</string>
|
||||||
<string name="all_search">Search</string>
|
<string name="all_search">Search</string>
|
||||||
<string name="all_search_hint">Search...</string>
|
<string name="all_search_hint">Search…</string>
|
||||||
|
|
||||||
|
|
||||||
<!--Timetable Widget-->
|
<!--Timetable Widget-->
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.github.wulkanowy
|
package io.github.wulkanowy
|
||||||
|
|
||||||
|
import io.github.wulkanowy.data.db.entities.Message
|
||||||
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 io.github.wulkanowy.data.db.entities.Student
|
||||||
import io.github.wulkanowy.data.db.entities.Timetable
|
import io.github.wulkanowy.data.db.entities.Timetable
|
||||||
@ -72,3 +73,25 @@ fun getTimetableEntity(
|
|||||||
teacher = "",
|
teacher = "",
|
||||||
teacherOld = ""
|
teacherOld = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fun getMessageEntity(
|
||||||
|
messageId: Int,
|
||||||
|
content: String,
|
||||||
|
unread: Boolean
|
||||||
|
) = Message(
|
||||||
|
studentId = 1,
|
||||||
|
realId = 1,
|
||||||
|
messageId = messageId,
|
||||||
|
sender = "",
|
||||||
|
senderId = 1,
|
||||||
|
recipient = "",
|
||||||
|
subject = "",
|
||||||
|
content = content,
|
||||||
|
date = now(),
|
||||||
|
folderId = 1,
|
||||||
|
unread = unread,
|
||||||
|
unreadBy = 1,
|
||||||
|
readBy = 1,
|
||||||
|
removed = false,
|
||||||
|
hasAttachments = false
|
||||||
|
)
|
||||||
|
@ -2,10 +2,10 @@ package io.github.wulkanowy.data.repositories.message
|
|||||||
|
|
||||||
import androidx.room.EmptyResultSetException
|
import androidx.room.EmptyResultSetException
|
||||||
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.Message
|
|
||||||
import io.github.wulkanowy.data.db.entities.MessageWithAttachment
|
import io.github.wulkanowy.data.db.entities.MessageWithAttachment
|
||||||
import io.github.wulkanowy.data.db.entities.Student
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
import io.github.wulkanowy.data.repositories.UnitTestInternetObservingStrategy
|
import io.github.wulkanowy.data.repositories.UnitTestInternetObservingStrategy
|
||||||
|
import io.github.wulkanowy.getMessageEntity
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
import io.reactivex.observers.TestObserver
|
import io.reactivex.observers.TestObserver
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
@ -15,7 +15,6 @@ import org.mockito.Mock
|
|||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.mockito.MockitoAnnotations
|
import org.mockito.MockitoAnnotations
|
||||||
import org.threeten.bp.LocalDateTime.now
|
|
||||||
import java.net.UnknownHostException
|
import java.net.UnknownHostException
|
||||||
|
|
||||||
class MessageRepositoryTest {
|
class MessageRepositoryTest {
|
||||||
@ -44,7 +43,7 @@ class MessageRepositoryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `throw error when message is not in the db`() {
|
fun `throw error when message is not in the db`() {
|
||||||
val testMessage = Message(1, 1, 1, "", 1, "", "", "", now(), 1, false, 1, 1, false, false)
|
val testMessage = getMessageEntity(1, "", false)
|
||||||
`when`(local.getMessageWithAttachment(student, testMessage)).thenReturn(Single.error(EmptyResultSetException("No message in database")))
|
`when`(local.getMessageWithAttachment(student, testMessage)).thenReturn(Single.error(EmptyResultSetException("No message in database")))
|
||||||
|
|
||||||
val message = repo.getMessage(student, testMessage)
|
val message = repo.getMessage(student, testMessage)
|
||||||
@ -55,7 +54,7 @@ class MessageRepositoryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `get message when content already in db`() {
|
fun `get message when content already in db`() {
|
||||||
val testMessage = Message(1, 1, 123, "", 1, "", "", "Test", now(), 1, false, 1, 1, false, false)
|
val testMessage = getMessageEntity(123, "Test", false)
|
||||||
val messageWithAttachment = MessageWithAttachment(testMessage, emptyList())
|
val messageWithAttachment = MessageWithAttachment(testMessage, emptyList())
|
||||||
|
|
||||||
`when`(local.getMessageWithAttachment(student, testMessage)).thenReturn(Single.just(messageWithAttachment))
|
`when`(local.getMessageWithAttachment(student, testMessage)).thenReturn(Single.just(messageWithAttachment))
|
||||||
@ -67,7 +66,7 @@ class MessageRepositoryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `get message when content in db is empty`() {
|
fun `get message when content in db is empty`() {
|
||||||
val testMessage = Message(1, 1, 123, "", 1, "", "", "", now(), 1, true, 1, 1, false, false)
|
val testMessage = getMessageEntity(123, "", true)
|
||||||
val testMessageWithContent = testMessage.copy(content = "Test")
|
val testMessageWithContent = testMessage.copy(content = "Test")
|
||||||
|
|
||||||
val mWa = MessageWithAttachment(testMessage, emptyList())
|
val mWa = MessageWithAttachment(testMessage, emptyList())
|
||||||
@ -86,7 +85,7 @@ class MessageRepositoryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `get message when content in db is empty and there is no internet connection`() {
|
fun `get message when content in db is empty and there is no internet connection`() {
|
||||||
val testMessage = Message(1, 1, 123, "", 1, "", "", "", now(), 1, false, 1, 1, false, false)
|
val testMessage = getMessageEntity(123, "", false)
|
||||||
val messageWithAttachment = MessageWithAttachment(testMessage, emptyList())
|
val messageWithAttachment = MessageWithAttachment(testMessage, emptyList())
|
||||||
|
|
||||||
testObservingStrategy.isInternetConnection = false
|
testObservingStrategy.isInternetConnection = false
|
||||||
@ -100,7 +99,7 @@ class MessageRepositoryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `get message when content in db is empty, unread and there is no internet connection`() {
|
fun `get message when content in db is empty, unread and there is no internet connection`() {
|
||||||
val testMessage = Message(1, 1, 123, "", 1, "", "", "", now(), 1, true, 1, 1, false, false)
|
val testMessage = getMessageEntity(123, "", true)
|
||||||
val messageWithAttachment = MessageWithAttachment(testMessage, emptyList())
|
val messageWithAttachment = MessageWithAttachment(testMessage, emptyList())
|
||||||
|
|
||||||
testObservingStrategy.isInternetConnection = false
|
testObservingStrategy.isInternetConnection = false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user