Handle not null, but empty semesters list
This commit is contained in:
parent
ef9d6dd313
commit
37201c3b40
4 changed files with 105 additions and 2 deletions
|
@ -78,7 +78,7 @@ class RegisterRepository(
|
|||
}
|
||||
} else student.getSchoolInfo(url.generate(ServiceManager.UrlGenerator.Site.STUDENT) + "UczenDziennik.mvc/Get")
|
||||
.map { it.data }
|
||||
.map { it.filter { diary -> diary.semesters != null } }
|
||||
.map { it.filter { diary -> diary.semesters?.isNotEmpty() ?: false } }
|
||||
.map { it.sortedByDescending { diary -> diary.level } }
|
||||
.map { diary -> diary.distinctBy { listOf(it.studentId, it.semesters!![0].classId) } }
|
||||
.flatMap { diaries ->
|
||||
|
|
|
@ -17,7 +17,7 @@ class StudentStartRepository(
|
|||
.map { it.data }
|
||||
.map { diaries ->
|
||||
diaries.asSequence()
|
||||
.filter { it.semesters != null }
|
||||
.filter { diary -> diary.semesters?.isNotEmpty() ?: false }
|
||||
.filter { diary -> diary.studentId == studentId }
|
||||
.filter { diary -> diary.semesters!![0].classId == classId }
|
||||
.map { diary ->
|
||||
|
|
|
@ -134,6 +134,35 @@ class RegisterTest : BaseLocalTest() {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getStudents_filterDiariesWithEmptySemester() {
|
||||
server.enqueue(MockResponse().setBody(LoginTest::class.java.getResource("LoginPage-standard.html").readText()))
|
||||
server.enqueue(MockResponse().setBody(LoginTest::class.java.getResource("Logowanie-uonet.html").readText()))
|
||||
server.enqueue(MockResponse().setBody(LoginTest::class.java.getResource("Login-success.html").readText()))
|
||||
server.enqueue(MockResponse().setBody(LoginTest::class.java.getResource("LoginPage-standard.html").readText()))
|
||||
server.enqueue(MockResponse().setBody(RegisterTest::class.java.getResource("UczenDziennik-empty-semester.json").readText()))
|
||||
server.enqueue(MockResponse().setBody(RegisterTest::class.java.getResource("WitrynaUcznia.html").readText()))
|
||||
// 4x symbol
|
||||
server.enqueue(MockResponse().setBody(LoginTest::class.java.getResource("Logowanie-brak-dostepu.html").readText()))
|
||||
server.enqueue(MockResponse().setBody(LoginTest::class.java.getResource("Logowanie-brak-dostepu.html").readText()))
|
||||
server.enqueue(MockResponse().setBody(LoginTest::class.java.getResource("Logowanie-brak-dostepu.html").readText()))
|
||||
server.enqueue(MockResponse().setBody(LoginTest::class.java.getResource("Logowanie-brak-dostepu.html").readText()))
|
||||
|
||||
server.start(3000)
|
||||
|
||||
val res = registerStudent.getStudents().blockingGet()
|
||||
|
||||
assertEquals(1, res.size)
|
||||
|
||||
res[0].run {
|
||||
assertEquals(1, studentId)
|
||||
assertEquals("Jan Kowalski", studentName)
|
||||
assertEquals(1, classId)
|
||||
assertEquals("Publiczna szkoła Wulkanowego nr 1 w fakelog.cf", schoolName)
|
||||
assertEquals("1A", className)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getStudents_classNameOrder() {
|
||||
server.enqueue(MockResponse().setBody(LoginTest::class.java.getResource("LoginPage-standard.html").readText()))
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
{
|
||||
"data": [
|
||||
{
|
||||
"Id": 1,
|
||||
"IdUczen": 1,
|
||||
"UczenImie": "Jan",
|
||||
"UczenImie2": "Marek",
|
||||
"UczenNazwisko": "Kowalski",
|
||||
"IsDziennik": true,
|
||||
"IdDziennik": 11,
|
||||
"IdPrzedszkoleDziennik": 0,
|
||||
"Poziom": 1,
|
||||
"Symbol": "A",
|
||||
"Nazwa": null,
|
||||
"DziennikRokSzkolny": 2016,
|
||||
"Okresy": [
|
||||
{
|
||||
"NumerOkresu": 1,
|
||||
"Poziom": 1,
|
||||
"DataOd": "2016-08-31 22:00:00",
|
||||
"DataDo": "2017-01-30 23:00:00",
|
||||
"IdOddzial": 1,
|
||||
"IdJednostkaSprawozdawcza": 6,
|
||||
"IsLastOkres": false,
|
||||
"Id": 1234563
|
||||
},
|
||||
{
|
||||
"NumerOkresu": 2,
|
||||
"Poziom": 1,
|
||||
"DataOd": "2017-01-31 22:00:00",
|
||||
"DataDo": "2017-08-30 23:00:00",
|
||||
"IdOddzial": 1,
|
||||
"IdJednostkaSprawozdawcza": 6,
|
||||
"IsLastOkres": true,
|
||||
"Id": 1234564
|
||||
}
|
||||
],
|
||||
"IdSioTyp": 11,
|
||||
"IsDorosli": false,
|
||||
"IsPolicealna": false,
|
||||
"Is13": false,
|
||||
"IsArtystyczna": false,
|
||||
"IsArtystyczna13": false,
|
||||
"IsSpecjalny": false,
|
||||
"IsPrzedszkola": false,
|
||||
"UczenPelnaNazwa": "1A 2016 - Jan Kowalski"
|
||||
},
|
||||
{
|
||||
"Id": 2,
|
||||
"IdUczen": 1,
|
||||
"UczenImie": "Jan",
|
||||
"UczenImie2": "Marek",
|
||||
"UczenNazwisko": "Kowalski",
|
||||
"IsDziennik": true,
|
||||
"IdDziennik": 13,
|
||||
"IdPrzedszkoleDziennik": 0,
|
||||
"Poziom": 2,
|
||||
"Symbol": "A",
|
||||
"Nazwa": null,
|
||||
"DziennikRokSzkolny": 2017,
|
||||
"Okresy": [],
|
||||
"IdSioTyp": 11,
|
||||
"IsDorosli": false,
|
||||
"IsPolicealna": false,
|
||||
"Is13": false,
|
||||
"IsArtystyczna": false,
|
||||
"IsArtystyczna13": false,
|
||||
"IsSpecjalny": false,
|
||||
"IsPrzedszkola": false,
|
||||
"UczenPelnaNazwa": "2A 2017 - Jan Kowalski"
|
||||
}
|
||||
],
|
||||
"success": true
|
||||
}
|
Loading…
Reference in a new issue