diff --git a/app/src/androidTest/java/io/github/wulkanowy/data/repositories/timetable/TestTimetableEntityCreator.kt b/app/src/androidTest/java/io/github/wulkanowy/data/repositories/timetable/TestTimetableEntityCreator.kt index 438e95f4..eea5463d 100644 --- a/app/src/androidTest/java/io/github/wulkanowy/data/repositories/timetable/TestTimetableEntityCreator.kt +++ b/app/src/androidTest/java/io/github/wulkanowy/data/repositories/timetable/TestTimetableEntityCreator.kt @@ -7,7 +7,7 @@ import org.threeten.bp.LocalDateTime.now import io.github.wulkanowy.api.timetable.Timetable as TimetableRemote import io.github.wulkanowy.data.db.entities.Timetable as TimetableLocal -fun createTimetableLocal(number: Int, start: LocalDateTime, room: String = "", subject: String = ""): TimetableLocal { +fun createTimetableLocal(number: Int, start: LocalDateTime, room: String = "", subject: String = "", teacher: String = ""): TimetableLocal { return TimetableLocal( studentId = 1, diaryId = 2, @@ -20,7 +20,7 @@ fun createTimetableLocal(number: Int, start: LocalDateTime, room: String = "", s group = "", room = room, roomOld = "", - teacher = "", + teacher = teacher, teacherOld = "", info = "", changes = false, @@ -28,7 +28,7 @@ fun createTimetableLocal(number: Int, start: LocalDateTime, room: String = "", s ) } -fun createTimetableRemote(number: Int, start: LocalDateTime, room: String, subject: String = ""): TimetableRemote { +fun createTimetableRemote(number: Int, start: LocalDateTime, room: String, subject: String = "", teacher: String = ""): TimetableRemote { return TimetableRemote( number = number, start = start.toDate(), @@ -37,7 +37,7 @@ fun createTimetableRemote(number: Int, start: LocalDateTime, room: String, subje subject = subject, group = "", room = room, - teacher = "", + teacher = teacher, info = "", changes = false, canceled = false diff --git a/app/src/androidTest/java/io/github/wulkanowy/data/repositories/timetable/TimetableRepositoryTest.kt b/app/src/androidTest/java/io/github/wulkanowy/data/repositories/timetable/TimetableRepositoryTest.kt index 1c080263..79216d55 100644 --- a/app/src/androidTest/java/io/github/wulkanowy/data/repositories/timetable/TimetableRepositoryTest.kt +++ b/app/src/androidTest/java/io/github/wulkanowy/data/repositories/timetable/TimetableRepositoryTest.kt @@ -63,23 +63,27 @@ class TimetableRepositoryTest { fun copyDetailsToCompletedFromPrevious() { timetableLocal.saveTimetable(listOf( createTimetableLocal(1, of(2019, 3, 5, 8, 0), "123", "Przyroda"), - createTimetableLocal(1, of(2019, 3, 5, 8, 50), "321", "Religia"), - createTimetableLocal(1, of(2019, 3, 5, 9, 40), "213", "W-F") + createTimetableLocal(2, of(2019, 3, 5, 8, 50), "321", "Religia"), + createTimetableLocal(3, of(2019, 3, 5, 9, 40), "213", "W-F"), + createTimetableLocal(4, of(2019, 3, 5, 10, 30), "213", "W-F", "Jan Kowalski") )) every { mockApi.getTimetable(any(), any()) } returns Single.just(listOf( createTimetableRemote(1, of(2019, 3, 5, 8, 0), "", "Przyroda"), - createTimetableRemote(1, of(2019, 3, 5, 8, 50), "", "Religia"), - createTimetableRemote(1, of(2019, 3, 5, 9, 40), "", "W-F") + createTimetableRemote(2, of(2019, 3, 5, 8, 50), "", "Religia"), + createTimetableRemote(3, of(2019, 3, 5, 9, 40), "", "W-F"), + createTimetableRemote(4, of(2019, 3, 5, 10, 30), "", "W-F") )) val lessons = TimetableRepository(settings, timetableLocal, timetableRemote) .getTimetable(semesterMock, LocalDate.of(2019, 3, 5), LocalDate.of(2019, 3, 5), true) .blockingGet() - assertEquals(3, lessons.size) + assertEquals(4, lessons.size) assertEquals("123", lessons[0].room) assertEquals("321", lessons[1].room) assertEquals("213", lessons[2].room) + + assertEquals("", lessons[3].teacher) } } diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/timetable/TimetableRepository.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/timetable/TimetableRepository.kt index c3f23811..0e6331f9 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/timetable/TimetableRepository.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/timetable/TimetableRepository.kt @@ -35,8 +35,7 @@ class TimetableRepository @Inject constructor( item.apply { old.singleOrNull { this.start == it.start }?.let { return@map copy( - room = if (room.isEmpty()) it.room else room, - teacher = if (teacher.isEmpty()) it.teacher else teacher + room = if (room.isEmpty()) it.room else room ) } }