Remove getStudents() API

This commit is contained in:
Mikołaj Pich 2023-04-15 22:39:36 +02:00
parent 4ce5701f5a
commit 07d68f5425
15 changed files with 243 additions and 222 deletions

2
.gitignore vendored
View file

@ -75,3 +75,5 @@ classes
.idea/kotlinc.xml .idea/kotlinc.xml
.idea/jpa-buddy.xml .idea/jpa-buddy.xml
.idea/kotlinScripting.xml .idea/kotlinScripting.xml
Snap.*.trc
javacore.*.txt

View file

@ -19,3 +19,10 @@ dependencies {
testImplementation "io.mockk:mockk-jvm:1.13.4" testImplementation "io.mockk:mockk-jvm:1.13.4"
} }
tasks.withType(Test) {
/**
* fix for retrofit https://github.com/square/retrofit/issues/3341
*/
jvmArgs = ["--add-opens", "java.base/java.lang.invoke=ALL-UNNAMED"]
}

View file

@ -27,7 +27,6 @@ import io.github.wulkanowy.sdk.scrapper.mobile.TokenResponse
import io.github.wulkanowy.sdk.scrapper.notes.Note import io.github.wulkanowy.sdk.scrapper.notes.Note
import io.github.wulkanowy.sdk.scrapper.register.RegisterUser import io.github.wulkanowy.sdk.scrapper.register.RegisterUser
import io.github.wulkanowy.sdk.scrapper.register.Semester import io.github.wulkanowy.sdk.scrapper.register.Semester
import io.github.wulkanowy.sdk.scrapper.register.Student
import io.github.wulkanowy.sdk.scrapper.repository.AccountRepository import io.github.wulkanowy.sdk.scrapper.repository.AccountRepository
import io.github.wulkanowy.sdk.scrapper.repository.HomepageRepository import io.github.wulkanowy.sdk.scrapper.repository.HomepageRepository
import io.github.wulkanowy.sdk.scrapper.repository.MessagesRepository import io.github.wulkanowy.sdk.scrapper.repository.MessagesRepository
@ -264,8 +263,6 @@ class Scrapper {
return account.sendPasswordResetRequest(registerBaseUrl, symbol, email.trim(), captchaCode) return account.sendPasswordResetRequest(registerBaseUrl, symbol, email.trim(), captchaCode)
} }
suspend fun getStudents(): List<Student> = register.getStudents()
suspend fun getUserSubjects(): RegisterUser = register.getUserSubjects() suspend fun getUserSubjects(): RegisterUser = register.getUserSubjects()
suspend fun getSemesters(): List<Semester> = studentStart.getSemesters() suspend fun getSemesters(): List<Semester> = studentStart.getSemesters()

View file

@ -1,24 +0,0 @@
package io.github.wulkanowy.sdk.scrapper.register
import io.github.wulkanowy.sdk.scrapper.Scrapper
data class Student(
val email: String,
val userName: String,
val userLogin: String,
val userLoginId: Int,
val symbol: String,
val studentId: Int,
val studentName: String,
val studentSecondName: String,
val studentSurname: String,
val schoolSymbol: String,
val schoolShortName: String,
val schoolName: String,
val className: String,
val classId: Int,
val baseUrl: String,
val loginType: Scrapper.LoginType,
val isParent: Boolean,
val semesters: List<Semester>,
)

View file

@ -2,14 +2,11 @@ package io.github.wulkanowy.sdk.scrapper.repository
import com.migcomponents.migbase64.Base64 import com.migcomponents.migbase64.Base64
import io.github.wulkanowy.sdk.scrapper.Scrapper import io.github.wulkanowy.sdk.scrapper.Scrapper
import io.github.wulkanowy.sdk.scrapper.exception.AccountInactiveException
import io.github.wulkanowy.sdk.scrapper.exception.ScrapperException import io.github.wulkanowy.sdk.scrapper.exception.ScrapperException
import io.github.wulkanowy.sdk.scrapper.exception.StudentGraduateException import io.github.wulkanowy.sdk.scrapper.exception.StudentGraduateException
import io.github.wulkanowy.sdk.scrapper.exception.TemporarilyDisabledException
import io.github.wulkanowy.sdk.scrapper.getNormalizedSymbol import io.github.wulkanowy.sdk.scrapper.getNormalizedSymbol
import io.github.wulkanowy.sdk.scrapper.getScriptParam import io.github.wulkanowy.sdk.scrapper.getScriptParam
import io.github.wulkanowy.sdk.scrapper.interceptor.handleErrors import io.github.wulkanowy.sdk.scrapper.interceptor.handleErrors
import io.github.wulkanowy.sdk.scrapper.login.AccountPermissionException
import io.github.wulkanowy.sdk.scrapper.login.CertificateResponse import io.github.wulkanowy.sdk.scrapper.login.CertificateResponse
import io.github.wulkanowy.sdk.scrapper.login.InvalidSymbolException import io.github.wulkanowy.sdk.scrapper.login.InvalidSymbolException
import io.github.wulkanowy.sdk.scrapper.login.LoginHelper import io.github.wulkanowy.sdk.scrapper.login.LoginHelper
@ -24,7 +21,6 @@ import io.github.wulkanowy.sdk.scrapper.register.RegisterStudent
import io.github.wulkanowy.sdk.scrapper.register.RegisterSymbol import io.github.wulkanowy.sdk.scrapper.register.RegisterSymbol
import io.github.wulkanowy.sdk.scrapper.register.RegisterUnit import io.github.wulkanowy.sdk.scrapper.register.RegisterUnit
import io.github.wulkanowy.sdk.scrapper.register.RegisterUser import io.github.wulkanowy.sdk.scrapper.register.RegisterUser
import io.github.wulkanowy.sdk.scrapper.register.Student
import io.github.wulkanowy.sdk.scrapper.register.toSemesters import io.github.wulkanowy.sdk.scrapper.register.toSemesters
import io.github.wulkanowy.sdk.scrapper.repository.AccountRepository.Companion.SELECTOR_ADFS import io.github.wulkanowy.sdk.scrapper.repository.AccountRepository.Companion.SELECTOR_ADFS
import io.github.wulkanowy.sdk.scrapper.repository.AccountRepository.Companion.SELECTOR_ADFS_CARDS import io.github.wulkanowy.sdk.scrapper.repository.AccountRepository.Companion.SELECTOR_ADFS_CARDS
@ -51,7 +47,7 @@ class RegisterRepository(
private val url: UrlGenerator, private val url: UrlGenerator,
) { ) {
companion object { private companion object {
@JvmStatic @JvmStatic
private val logger = LoggerFactory.getLogger(this::class.java) private val logger = LoggerFactory.getLogger(this::class.java)
} }
@ -60,48 +56,6 @@ class RegisterRepository(
ignoreUnknownKeys = true ignoreUnknownKeys = true
} }
suspend fun getStudents(): List<Student> {
val user = getUserSubjects()
return user.symbols.flatMap { symbol ->
symbol.error?.takeIf {
val isAccountNotRegistered = it is AccountPermissionException
val isInvalidSymbol = it is InvalidSymbolException
val isGraduated = it is StudentGraduateException
val isInactive = it is AccountInactiveException
(!isAccountNotRegistered && !isInvalidSymbol && !isGraduated && !isInactive)
}?.let { throw it }
symbol.schools.flatMap { unit ->
unit.error?.takeIf { it !is TemporarilyDisabledException }?.let { throw it }
unit.subjects.filterIsInstance<RegisterStudent>().map { student ->
Student(
email = user.login, // for compatibility
userLogin = user.login,
userName = symbol.userName,
userLoginId = unit.userLoginId,
symbol = symbol.symbol,
studentId = student.studentId,
studentName = student.studentName,
studentSecondName = student.studentSecondName,
studentSurname = student.studentSurname,
schoolSymbol = unit.schoolId,
schoolShortName = unit.schoolShortName,
schoolName = unit.schoolName,
className = student.className,
classId = student.classId,
baseUrl = user.baseUrl,
loginType = user.loginType,
isParent = student.isParent,
semesters = student.semesters,
)
}
}
}
}
suspend fun getUserSubjects(): RegisterUser { suspend fun getUserSubjects(): RegisterUser {
val symbolLoginType = getLoginType(startSymbol.getNormalizedSymbol()) val symbolLoginType = getLoginType(startSymbol.getNormalizedSymbol())
val certificateResponse = getCert(symbolLoginType) val certificateResponse = getCert(symbolLoginType)

View file

@ -23,7 +23,7 @@ class StudentStartRepository(
return diaries?.toSemesters(studentId, classId, unitId).orEmpty() return diaries?.toSemesters(studentId, classId, unitId).orEmpty()
.sortedByDescending { it.semesterId } .sortedByDescending { it.semesterId }
.ifEmpty { .ifEmpty {
logger.debug("Student $studentId, class $classId not found in diaries: $diaries") logger.debug("Student {}, class {} not found in diaries: {}", studentId, classId, diaries)
emptyList() emptyList()
} }
} }

View file

@ -35,7 +35,7 @@ class HostsRemoteTest : BaseTest() {
fun loginTest() = runBlocking { fun loginTest() = runBlocking {
knownHosts.forEach { (host, symbol) -> knownHosts.forEach { (host, symbol) ->
println("$host/$symbol") println("$host/$symbol")
val res = runCatching { getScrapper(host, symbol).getStudents() } val res = runCatching { getScrapper(host, symbol).getUserSubjects() }
requireNotNull(res.exceptionOrNull()).cause!!.printStackTrace() requireNotNull(res.exceptionOrNull()).cause!!.printStackTrace()
assert(res.exceptionOrNull() is BadCredentialsException) assert(res.exceptionOrNull() is BadCredentialsException)
println() println()

View file

@ -2,7 +2,10 @@ package io.github.wulkanowy.sdk.scrapper
import io.github.wulkanowy.sdk.scrapper.attendance.AttendanceCategory import io.github.wulkanowy.sdk.scrapper.attendance.AttendanceCategory
import io.github.wulkanowy.sdk.scrapper.messages.Folder import io.github.wulkanowy.sdk.scrapper.messages.Folder
import io.github.wulkanowy.sdk.scrapper.register.RegisterStudent
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.runTest
import okhttp3.logging.HttpLoggingInterceptor import okhttp3.logging.HttpLoggingInterceptor
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
@ -12,6 +15,7 @@ import org.junit.Test
import java.time.LocalDate import java.time.LocalDate
import java.time.Month import java.time.Month
@OptIn(ExperimentalCoroutinesApi::class)
@Ignore @Ignore
class ScrapperRemoteTest : BaseTest() { class ScrapperRemoteTest : BaseTest() {
@ -67,20 +71,21 @@ class ScrapperRemoteTest : BaseTest() {
} }
@Test @Test
fun studentsTest() { fun studentsTest() = runTest {
val students = runBlocking { api.getStudents() } val user = api.getUserSubjects()
val symbol = user.symbols[0]
val school = symbol.schools[0]
val student = school.subjects[0] as RegisterStudent
students[0].run { assertEquals("powiatwulkanowy", symbol.symbol)
assertEquals("powiatwulkanowy", symbol) assertEquals("jan@fakelog.cf", user.email)
assertEquals("jan@fakelog.cf", email) assertEquals("Jan", student.studentName)
assertEquals("Jan", studentName) assertEquals("Kowalski", student.studentSurname)
assertEquals("Kowalski", studentSurname) assertEquals("123456", school.schoolId)
assertEquals("123456", schoolSymbol) assertEquals(1, student.studentId)
assertEquals(1, studentId) assertEquals(1, student.classId)
assertEquals(1, classId) assertEquals("A", student.className)
assertEquals("A", className) assertEquals("Publiczna szkoła Wulkanowego nr 1 w fakelog.cf", school.schoolName)
assertEquals("Publiczna szkoła Wulkanowego nr 1 w fakelog.cf", schoolName)
}
} }
@Test @Test

View file

@ -9,11 +9,13 @@ import io.github.wulkanowy.sdk.scrapper.repository.RegisterRepository
import io.github.wulkanowy.sdk.scrapper.service.LoginService import io.github.wulkanowy.sdk.scrapper.service.LoginService
import io.github.wulkanowy.sdk.scrapper.service.RegisterService import io.github.wulkanowy.sdk.scrapper.service.RegisterService
import io.github.wulkanowy.sdk.scrapper.service.StudentService import io.github.wulkanowy.sdk.scrapper.service.StudentService
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Test import org.junit.Test
import java.net.CookieManager import java.net.CookieManager
@OptIn(ExperimentalCoroutinesApi::class)
class RegisterTest : BaseLocalTest() { class RegisterTest : BaseLocalTest() {
private val login by lazy { private val login by lazy {
@ -57,7 +59,7 @@ class RegisterTest : BaseLocalTest() {
} }
@Test @Test
fun filterStudentsByClass() { fun filterStudentsByClass() = runTest {
with(server) { with(server) {
enqueue("LoginPage-standard.html", LoginTest::class.java) enqueue("LoginPage-standard.html", LoginTest::class.java)
enqueue("Logowanie-uonet.html", LoginTest::class.java) enqueue("Logowanie-uonet.html", LoginTest::class.java)
@ -72,7 +74,10 @@ class RegisterTest : BaseLocalTest() {
start(3000) start(3000)
} }
val res = runBlocking { registerStudent.getStudents() } val res = registerStudent.getUserSubjects().symbols
.flatMap { it.schools }
.flatMap { it.subjects }
.filterIsInstance<RegisterStudent>()
assertEquals(2, res.size) assertEquals(2, res.size)
@ -81,7 +86,7 @@ class RegisterTest : BaseLocalTest() {
assertEquals("Jan", studentName) assertEquals("Jan", studentName)
assertEquals("Kowalski", studentSurname) assertEquals("Kowalski", studentSurname)
assertEquals(121, classId) assertEquals(121, classId)
assertEquals("Publiczna szkoła Wulkanowego nr 1 w fakelog.cf", schoolName) // assertEquals("Publiczna szkoła Wulkanowego nr 1 w fakelog.cf", schoolName)
assertEquals("Te", className) assertEquals("Te", className)
} }
@ -90,13 +95,13 @@ class RegisterTest : BaseLocalTest() {
assertEquals("Jan", studentName) assertEquals("Jan", studentName)
assertEquals("Kowalski", studentSurname) assertEquals("Kowalski", studentSurname)
assertEquals(119, classId) assertEquals(119, classId)
assertEquals("Publiczna szkoła Wulkanowego nr 1 w fakelog.cf", schoolName) // assertEquals("Publiczna szkoła Wulkanowego nr 1 w fakelog.cf", schoolName)
assertEquals("Ti", className) assertEquals("Ti", className)
} }
} }
@Test @Test
fun getStudents_kindergartenDiaries() { fun getStudents_kindergartenDiaries() = runTest {
with(server) { with(server) {
enqueue("LoginPage-standard.html", LoginTest::class.java) enqueue("LoginPage-standard.html", LoginTest::class.java)
enqueue("Logowanie-uonet.html", LoginTest::class.java) enqueue("Logowanie-uonet.html", LoginTest::class.java)
@ -114,7 +119,10 @@ class RegisterTest : BaseLocalTest() {
start(3000) start(3000)
} }
val res = runBlocking { registerStudent.getStudents() } val res = registerStudent.getUserSubjects().symbols
.flatMap { it.schools }
.flatMap { it.subjects }
.filterIsInstance<RegisterStudent>()
assertEquals(1, res.size) assertEquals(1, res.size)
@ -123,17 +131,17 @@ class RegisterTest : BaseLocalTest() {
assertEquals("Jan", studentName) assertEquals("Jan", studentName)
assertEquals("Kowalski", studentSurname) assertEquals("Kowalski", studentSurname)
assertEquals(0, classId) // always 0 for kindergarten assertEquals(0, classId) // always 0 for kindergarten
assertEquals("Publiczna szkoła Wulkanowego nr 1 w fakelog.cf", schoolName) // assertEquals("Publiczna szkoła Wulkanowego nr 1 w fakelog.cf", schoolName)
assertEquals("123456", schoolSymbol) // assertEquals("123456", schoolSymbol)
assertEquals(654321, userLoginId) // assertEquals(654321, userLoginId)
assertEquals("Jan Kowalski", userName) // assertEquals("Jan Kowalski", fullname) // todo
assertEquals(2016, semesters[0].schoolYear) assertEquals(2016, semesters[0].schoolYear)
assertEquals(2017, semesters[1].schoolYear) assertEquals(2017, semesters[1].schoolYear)
} }
} }
@Test @Test
fun getStudents_filterNoDiares() { fun getStudents_filterNoDiares() = runTest {
with(server) { with(server) {
enqueue("LoginPage-standard.html", LoginTest::class.java) enqueue("LoginPage-standard.html", LoginTest::class.java)
enqueue("Logowanie-uonet.html", LoginTest::class.java) enqueue("Logowanie-uonet.html", LoginTest::class.java)
@ -151,13 +159,15 @@ class RegisterTest : BaseLocalTest() {
start(3000) start(3000)
} }
val res = runBlocking { registerStudent.getStudents() } val res = registerStudent.getUserSubjects().symbols
.flatMap { it.schools }
.flatMap { it.subjects }
assertEquals(0, res.size) assertEquals(0, res.size)
} }
@Test @Test
fun getStudents_classNameOrder() { fun getStudents_classNameOrder() = runTest {
with(server) { with(server) {
enqueue("LoginPage-standard.html", LoginTest::class.java) enqueue("LoginPage-standard.html", LoginTest::class.java)
enqueue("Logowanie-uonet.html", LoginTest::class.java) enqueue("Logowanie-uonet.html", LoginTest::class.java)
@ -173,7 +183,10 @@ class RegisterTest : BaseLocalTest() {
start(3000) start(3000)
} }
val res = runBlocking { registerStudent.getStudents() } val res = registerStudent.getUserSubjects().symbols
.flatMap { it.schools }
.flatMap { it.subjects }
.filterIsInstance<RegisterStudent>()
assertEquals(2, res.size) assertEquals(2, res.size)
@ -183,7 +196,7 @@ class RegisterTest : BaseLocalTest() {
assertEquals("Kowalski", studentSurname) assertEquals("Kowalski", studentSurname)
assertEquals(1, classId) assertEquals(1, classId)
assertEquals("A", className) assertEquals("A", className)
assertEquals("Publiczna szkoła Wulkanowego nr 1 w fakelog.cf", schoolName) // assertEquals("Publiczna szkoła Wulkanowego nr 1 w fakelog.cf", schoolName)
} }
res[1].run { res[1].run {
@ -192,7 +205,7 @@ class RegisterTest : BaseLocalTest() {
assertEquals("Czerwińska", studentSurname) assertEquals("Czerwińska", studentSurname)
assertEquals(2, classId) assertEquals(2, classId)
assertEquals("A", className) assertEquals("A", className)
assertEquals("Publiczna szkoła Wulkanowego nr 1 w fakelog.cf", schoolName) // assertEquals("Publiczna szkoła Wulkanowego nr 1 w fakelog.cf", schoolName) // todo
} }
} }
} }

View file

@ -7,12 +7,12 @@ import io.github.wulkanowy.sdk.scrapper.interceptor.ErrorInterceptorTest
import io.github.wulkanowy.sdk.scrapper.login.LoginHelper import io.github.wulkanowy.sdk.scrapper.login.LoginHelper
import io.github.wulkanowy.sdk.scrapper.login.LoginTest import io.github.wulkanowy.sdk.scrapper.login.LoginTest
import io.github.wulkanowy.sdk.scrapper.login.UrlGenerator import io.github.wulkanowy.sdk.scrapper.login.UrlGenerator
import io.github.wulkanowy.sdk.scrapper.register.RegisterStudent
import io.github.wulkanowy.sdk.scrapper.register.RegisterTest import io.github.wulkanowy.sdk.scrapper.register.RegisterTest
import io.github.wulkanowy.sdk.scrapper.service.LoginService import io.github.wulkanowy.sdk.scrapper.service.LoginService
import io.github.wulkanowy.sdk.scrapper.service.RegisterService import io.github.wulkanowy.sdk.scrapper.service.RegisterService
import io.github.wulkanowy.sdk.scrapper.service.StudentService import io.github.wulkanowy.sdk.scrapper.service.StudentService
import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
@ -48,7 +48,7 @@ class RegisterRepositoryTest : BaseLocalTest() {
} }
@Test @Test
fun normalLogin_one() { fun normalLogin_one() = runTest {
with(server) { with(server) {
enqueue("LoginPage-standard.html", LoginTest::class.java) enqueue("LoginPage-standard.html", LoginTest::class.java)
enqueue("Logowanie-uonet.html", LoginTest::class.java) enqueue("Logowanie-uonet.html", LoginTest::class.java)
@ -65,18 +65,20 @@ class RegisterRepositoryTest : BaseLocalTest() {
start(3000) start(3000)
} }
val students = runBlocking { getRegisterRepository("Default").getStudents() } val user = getRegisterRepository("Default").getUserSubjects()
val school = user.symbols[0].schools[0]
val students = school.subjects.filterIsInstance<RegisterStudent>()
assertEquals(1, students.size) with(school) {
with(students[0]) { assertEquals("123456", schoolId)
assertEquals("123456", schoolSymbol)
assertEquals("Fake123456", schoolShortName) assertEquals("Fake123456", schoolShortName)
assertEquals(2, semesters.size)
} }
assertEquals(1, students.size)
assertEquals(2, students[0].semesters.size)
} }
@Test @Test
fun normalLogin_semesters() { fun normalLogin_semesters() = runTest {
with(server) { with(server) {
enqueue("LoginPage-standard.html", LoginTest::class.java) enqueue("LoginPage-standard.html", LoginTest::class.java)
enqueue("Logowanie-uonet.html", LoginTest::class.java) enqueue("Logowanie-uonet.html", LoginTest::class.java)
@ -93,19 +95,21 @@ class RegisterRepositoryTest : BaseLocalTest() {
start(3000) start(3000)
} }
val students = runBlocking { getRegisterRepository("Default").getStudents() } val user = getRegisterRepository("Default").getUserSubjects()
val school = user.symbols[0].schools[0]
val students = school.subjects.filterIsInstance<RegisterStudent>()
assertEquals(2, students.size) with(school) {
with(students[0]) { assertEquals("123456", schoolId)
assertEquals("123456", schoolSymbol)
assertEquals("Fake123456", schoolShortName) assertEquals("Fake123456", schoolShortName)
assertEquals(6, semesters.size)
} }
assertEquals(6, students[0].semesters.size)
assertEquals(2, students.size)
assertEquals(6, students[1].semesters.size) assertEquals(6, students[1].semesters.size)
} }
@Test @Test
fun normalLogin_triple() { fun normalLogin_triple() = runTest {
with(server) { with(server) {
enqueue("LoginPage-standard.html", LoginTest::class.java) enqueue("LoginPage-standard.html", LoginTest::class.java)
enqueue("Logowanie-uonet.html", LoginTest::class.java) enqueue("Logowanie-uonet.html", LoginTest::class.java)
@ -124,21 +128,22 @@ class RegisterRepositoryTest : BaseLocalTest() {
start(3000) start(3000)
} }
val students = runBlocking { getRegisterRepository("Default").getStudents() } val user = getRegisterRepository("Default").getUserSubjects()
assertEquals(3, students.size) val schools = user.symbols[0].schools
assertEquals(3, schools.size)
with(students[0]) { with(schools[0]) {
assertEquals("000788", schoolSymbol) assertEquals("000788", schoolId)
assertEquals("ZST-CKZiU", schoolShortName) assertEquals("ZST-CKZiU", schoolShortName)
} }
with(students[1]) { with(schools[1]) {
assertEquals("004355", schoolSymbol) assertEquals("004355", schoolId)
assertEquals("ZSET", schoolShortName) assertEquals("ZSET", schoolShortName)
} }
with(students[2]) { with(schools[2]) {
assertEquals("016636", schoolSymbol) assertEquals("016636", schoolId)
assertEquals("G7 Wulkanowo", schoolShortName) assertEquals("G7 Wulkanowo", schoolShortName)
} }
} }
@ -165,7 +170,12 @@ class RegisterRepositoryTest : BaseLocalTest() {
start(3000) start(3000)
} }
val students = getRegisterRepository("Default").getStudents() val user = getRegisterRepository("Default").getUserSubjects()
val students = user.symbols
.flatMap { it.schools }
.flatMap { it.subjects }
.filterIsInstance<RegisterStudent>()
assertEquals(2, students.size) assertEquals(2, students.size)
} }
@ -174,25 +184,26 @@ class RegisterRepositoryTest : BaseLocalTest() {
with(server) { with(server) {
enqueue("LoginPage-standard.html", LoginTest::class.java) enqueue("LoginPage-standard.html", LoginTest::class.java)
enqueue("Logowanie-uonet.html", LoginTest::class.java) enqueue("Logowanie-uonet.html", LoginTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
enqueue("Offline.html", ErrorInterceptorTest::class.java) enqueue("Offline.html", ErrorInterceptorTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
start(3000) start(3000)
} }
val res = runCatching { normal.getStudents() } val res = normal.getUserSubjects().symbols
assertEquals(5, res.size)
assertEquals( assertEquals(
"Wystąpił nieoczekiwany błąd. Wystąpił błąd aplikacji. Prosimy zalogować się ponownie. Jeśli problem będzie się powtarzał, prosimy o kontakt z serwisem.", "Wystąpił nieoczekiwany błąd. Wystąpił błąd aplikacji. Prosimy zalogować się ponownie. Jeśli problem będzie się powtarzał, prosimy o kontakt z serwisem.",
res.exceptionOrNull()?.message, res[1].error?.message,
) )
assertEquals(VulcanException::class.java, res.exceptionOrNull()!!::class.java) assertEquals(VulcanException::class.java, res[1].error!!::class.java)
} }
@Test @Test
fun filterSymbolsWithSpaces() { fun filterSymbolsWithSpaces() = runTest {
with(server) { with(server) {
enqueue("LoginPage-standard.html", LoginTest::class.java) enqueue("LoginPage-standard.html", LoginTest::class.java)
enqueue("Logowanie-uonet.html", LoginTest::class.java) enqueue("Logowanie-uonet.html", LoginTest::class.java)
@ -204,18 +215,21 @@ class RegisterRepositoryTest : BaseLocalTest() {
start(3000) start(3000)
} }
val students = runBlocking { normal.getStudents() } val user = normal.getUserSubjects().symbols
assertEquals(0, students.size) .flatMap { it.schools }
.flatMap { it.subjects }
assertEquals(0, user.size)
} }
@Test @Test
fun normalizeInvalidSymbol_default() { fun normalizeInvalidSymbol_default() = runTest {
with(server) { with(server) {
enqueue("LoginPage-standard.html", LoginTest::class.java) enqueue("LoginPage-standard.html", LoginTest::class.java)
enqueue("Logowanie-uonet.html", LoginTest::class.java) enqueue("Logowanie-uonet.html", LoginTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
enqueue("Offline.html", ErrorInterceptorTest::class.java) enqueue("Offline.html", ErrorInterceptorTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
@ -223,23 +237,24 @@ class RegisterRepositoryTest : BaseLocalTest() {
start(3000) start(3000)
} }
val res = runCatching { runBlocking { getRegisterRepository("Default").getStudents() } } val res = getRegisterRepository("Default").getUserSubjects()
assertEquals(5, res.symbols.size)
assertEquals( assertEquals(
"Wystąpił nieoczekiwany błąd. Wystąpił błąd aplikacji. Prosimy zalogować się ponownie. Jeśli problem będzie się powtarzał, prosimy o kontakt z serwisem.", "Wystąpił nieoczekiwany błąd. Wystąpił błąd aplikacji. Prosimy zalogować się ponownie. Jeśli problem będzie się powtarzał, prosimy o kontakt z serwisem.",
res.exceptionOrNull()?.message, res.symbols[1].error?.message,
) )
assertTrue(res.exceptionOrNull() is VulcanException) assertTrue(res.symbols[1].error is VulcanException)
assertEquals("/Default/Account/LogOn", server.takeRequest().path) assertEquals("/Default/Account/LogOn", server.takeRequest().path)
} }
@Test @Test
fun normalizeInvalidSymbol_custom() { fun normalizeInvalidSymbol_custom() = runTest {
with(server) { with(server) {
enqueue("LoginPage-standard.html", LoginTest::class.java) enqueue("LoginPage-standard.html", LoginTest::class.java)
enqueue("Logowanie-uonet.html", LoginTest::class.java) enqueue("Logowanie-uonet.html", LoginTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
enqueue("Offline.html", ErrorInterceptorTest::class.java) enqueue("Offline.html", ErrorInterceptorTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
@ -247,23 +262,24 @@ class RegisterRepositoryTest : BaseLocalTest() {
start(3000) start(3000)
} }
val res = runCatching { runBlocking { getRegisterRepository(" Rzeszów + ").getStudents() } } val res = getRegisterRepository(" Rzeszów + ").getUserSubjects()
assertTrue(res.exceptionOrNull() is VulcanException) assertEquals(5, res.symbols.size)
assertTrue(res.symbols[1].error is VulcanException)
assertEquals( assertEquals(
"Wystąpił nieoczekiwany błąd. Wystąpił błąd aplikacji. Prosimy zalogować się ponownie. Jeśli problem będzie się powtarzał, prosimy o kontakt z serwisem.", "Wystąpił nieoczekiwany błąd. Wystąpił błąd aplikacji. Prosimy zalogować się ponownie. Jeśli problem będzie się powtarzał, prosimy o kontakt z serwisem.",
res.exceptionOrNull()?.message, res.symbols[1].error?.message,
) )
assertEquals("/rzeszow/Account/LogOn", server.takeRequest().path) assertEquals("/rzeszow/Account/LogOn", server.takeRequest().path)
} }
@Test @Test
fun normalizeInvalidSymbol_trimMultipleSpaces() { fun normalizeInvalidSymbol_trimMultipleSpaces() = runTest {
with(server) { with(server) {
enqueue("LoginPage-standard.html", LoginTest::class.java) enqueue("LoginPage-standard.html", LoginTest::class.java)
enqueue("Logowanie-uonet.html", LoginTest::class.java) enqueue("Logowanie-uonet.html", LoginTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
enqueue("Offline.html", ErrorInterceptorTest::class.java) enqueue("Offline.html", ErrorInterceptorTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
@ -271,24 +287,24 @@ class RegisterRepositoryTest : BaseLocalTest() {
start(3000) start(3000)
} }
val res = runCatching { runBlocking { getRegisterRepository(" Niepoprawny symbol no ale + ").getStudents() } } val res = getRegisterRepository(" Niepoprawny symbol no ale + ").getUserSubjects()
assertTrue(res.exceptionOrNull() is VulcanException) assertTrue(res.symbols[1].error is VulcanException)
assertEquals( assertEquals(
"Wystąpił nieoczekiwany błąd. Wystąpił błąd aplikacji. Prosimy zalogować się ponownie. Jeśli problem będzie się powtarzał, prosimy o kontakt z serwisem.", "Wystąpił nieoczekiwany błąd. Wystąpił błąd aplikacji. Prosimy zalogować się ponownie. Jeśli problem będzie się powtarzał, prosimy o kontakt z serwisem.",
res.exceptionOrNull()?.message, res.symbols[1].error?.message,
) )
assertEquals("/niepoprawnysymbolnoale/Account/LogOn", server.takeRequest().path) assertEquals("/niepoprawnysymbolnoale/Account/LogOn", server.takeRequest().path)
} }
@Test @Test
fun normalizeInvalidSymbol_emptyFallback() { fun normalizeInvalidSymbol_emptyFallback() = runTest {
with(server) { with(server) {
enqueue("LoginPage-standard.html", LoginTest::class.java) enqueue("LoginPage-standard.html", LoginTest::class.java)
enqueue("Logowanie-uonet.html", LoginTest::class.java) enqueue("Logowanie-uonet.html", LoginTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
enqueue("Offline.html", ErrorInterceptorTest::class.java) enqueue("Offline.html", ErrorInterceptorTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
@ -296,23 +312,24 @@ class RegisterRepositoryTest : BaseLocalTest() {
start(3000) start(3000)
} }
val res = runCatching { runBlocking { getRegisterRepository(" + ").getStudents() } } val res = getRegisterRepository(" + ").getUserSubjects()
assertTrue(res.exceptionOrNull() is VulcanException) assertEquals(5, res.symbols.size)
assertTrue(res.symbols[1].error is VulcanException)
assertEquals( assertEquals(
"Wystąpił nieoczekiwany błąd. Wystąpił błąd aplikacji. Prosimy zalogować się ponownie. Jeśli problem będzie się powtarzał, prosimy o kontakt z serwisem.", "Wystąpił nieoczekiwany błąd. Wystąpił błąd aplikacji. Prosimy zalogować się ponownie. Jeśli problem będzie się powtarzał, prosimy o kontakt z serwisem.",
res.exceptionOrNull()?.message, res.symbols[1].error?.message,
) )
assertEquals("/Default/Account/LogOn", server.takeRequest().path) assertEquals("/Default/Account/LogOn", server.takeRequest().path)
} }
@Test @Test
fun normalizeInvalidSymbol_digits() { fun normalizeInvalidSymbol_digits() = runTest {
with(server) { with(server) {
enqueue("LoginPage-standard.html", LoginTest::class.java) enqueue("LoginPage-standard.html", LoginTest::class.java)
enqueue("Logowanie-uonet.html", LoginTest::class.java) enqueue("Logowanie-uonet.html", LoginTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
enqueue("Offline.html", ErrorInterceptorTest::class.java) enqueue("Offline.html", ErrorInterceptorTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java) enqueue("Logowanie-brak-dostepu.html", LoginTest::class.java)
@ -320,11 +337,12 @@ class RegisterRepositoryTest : BaseLocalTest() {
start(3000) start(3000)
} }
val res = runCatching { runBlocking { getRegisterRepository("Default").getStudents() } } val res = getRegisterRepository("Default").getUserSubjects()
assertTrue(res.exceptionOrNull() is VulcanException) assertEquals(5, res.symbols.size)
assertTrue(res.symbols[1].error is VulcanException)
assertEquals( assertEquals(
"Wystąpił nieoczekiwany błąd. Wystąpił błąd aplikacji. Prosimy zalogować się ponownie. Jeśli problem będzie się powtarzał, prosimy o kontakt z serwisem.", "Wystąpił nieoczekiwany błąd. Wystąpił błąd aplikacji. Prosimy zalogować się ponownie. Jeśli problem będzie się powtarzał, prosimy o kontakt z serwisem.",
res.exceptionOrNull()?.message, res.symbols[1].error?.message,
) )
assertEquals("/Default/Account/LogOn", server.takeRequest().path) assertEquals("/Default/Account/LogOn", server.takeRequest().path)
assertEquals(true, server.takeRequest().path?.startsWith("/Account/LogOn?ReturnUrl=%2FDefault")) assertEquals(true, server.takeRequest().path?.startsWith("/Account/LogOn?ReturnUrl=%2FDefault"))

View file

@ -108,7 +108,7 @@ class ServiceManagerTest : BaseLocalTest() {
} }
try { try {
runBlocking { api.getStudents() } runBlocking { api.getUserSubjects() }
} catch (e: Throwable) { } catch (e: Throwable) {
assertTrue(e is ScrapperException) assertTrue(e is ScrapperException)
} }

View file

@ -22,13 +22,13 @@ import io.github.wulkanowy.sdk.mapper.mapSchool
import io.github.wulkanowy.sdk.mapper.mapScrapperMessage import io.github.wulkanowy.sdk.mapper.mapScrapperMessage
import io.github.wulkanowy.sdk.mapper.mapSemesters import io.github.wulkanowy.sdk.mapper.mapSemesters
import io.github.wulkanowy.sdk.mapper.mapStudent import io.github.wulkanowy.sdk.mapper.mapStudent
import io.github.wulkanowy.sdk.mapper.mapStudents
import io.github.wulkanowy.sdk.mapper.mapSubjects import io.github.wulkanowy.sdk.mapper.mapSubjects
import io.github.wulkanowy.sdk.mapper.mapTeachers import io.github.wulkanowy.sdk.mapper.mapTeachers
import io.github.wulkanowy.sdk.mapper.mapTimetableFull import io.github.wulkanowy.sdk.mapper.mapTimetableFull
import io.github.wulkanowy.sdk.mapper.mapToScrapperAbsent import io.github.wulkanowy.sdk.mapper.mapToScrapperAbsent
import io.github.wulkanowy.sdk.mapper.mapToUnits import io.github.wulkanowy.sdk.mapper.mapToUnits
import io.github.wulkanowy.sdk.mapper.mapToken import io.github.wulkanowy.sdk.mapper.mapToken
import io.github.wulkanowy.sdk.mapper.mapUser
import io.github.wulkanowy.sdk.pojo.Absent import io.github.wulkanowy.sdk.pojo.Absent
import io.github.wulkanowy.sdk.pojo.Attendance import io.github.wulkanowy.sdk.pojo.Attendance
import io.github.wulkanowy.sdk.pojo.AttendanceSummary import io.github.wulkanowy.sdk.pojo.AttendanceSummary
@ -51,9 +51,9 @@ import io.github.wulkanowy.sdk.pojo.MessageDetails
import io.github.wulkanowy.sdk.pojo.MessageReplayDetails import io.github.wulkanowy.sdk.pojo.MessageReplayDetails
import io.github.wulkanowy.sdk.pojo.Note import io.github.wulkanowy.sdk.pojo.Note
import io.github.wulkanowy.sdk.pojo.Recipient import io.github.wulkanowy.sdk.pojo.Recipient
import io.github.wulkanowy.sdk.pojo.RegisterUser
import io.github.wulkanowy.sdk.pojo.School import io.github.wulkanowy.sdk.pojo.School
import io.github.wulkanowy.sdk.pojo.Semester import io.github.wulkanowy.sdk.pojo.Semester
import io.github.wulkanowy.sdk.pojo.Student
import io.github.wulkanowy.sdk.pojo.StudentInfo import io.github.wulkanowy.sdk.pojo.StudentInfo
import io.github.wulkanowy.sdk.pojo.StudentPhoto import io.github.wulkanowy.sdk.pojo.StudentPhoto
import io.github.wulkanowy.sdk.pojo.Subject import io.github.wulkanowy.sdk.pojo.Subject
@ -61,7 +61,6 @@ import io.github.wulkanowy.sdk.pojo.Teacher
import io.github.wulkanowy.sdk.pojo.Timetable import io.github.wulkanowy.sdk.pojo.Timetable
import io.github.wulkanowy.sdk.pojo.Token import io.github.wulkanowy.sdk.pojo.Token
import io.github.wulkanowy.sdk.scrapper.Scrapper import io.github.wulkanowy.sdk.scrapper.Scrapper
import io.github.wulkanowy.sdk.scrapper.register.RegisterUser
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import okhttp3.Interceptor import okhttp3.Interceptor
@ -225,23 +224,18 @@ class Sdk {
scrapper.sendPasswordResetRequest(registerBaseUrl, symbol, email, captchaCode) scrapper.sendPasswordResetRequest(registerBaseUrl, symbol, email, captchaCode)
} }
suspend fun getStudentsFromScrapper(email: String, password: String, scrapperBaseUrl: String, symbol: String = "Default"): List<Student> = withContext(Dispatchers.IO) { suspend fun getUserSubjectsFromScrapper(
email: String,
password: String,
scrapperBaseUrl: String,
symbol: String = "Default",
): RegisterUser = withContext(Dispatchers.IO) {
scrapper.let { scrapper.let {
it.baseUrl = scrapperBaseUrl it.baseUrl = scrapperBaseUrl
it.email = email it.email = email
it.password = password it.password = password
it.symbol = symbol it.symbol = symbol
it.getStudents().mapStudents() it.getUserSubjects().mapUser()
}
}
suspend fun getUserSubjectsFromScrapper(email: String, password: String, scrapperBaseUrl: String, symbol: String = "Default"): RegisterUser = withContext(Dispatchers.IO) {
scrapper.let {
it.baseUrl = scrapperBaseUrl
it.email = email
it.password = password
it.symbol = symbol
it.getUserSubjects()
} }
} }

View file

@ -1,31 +1,64 @@
package io.github.wulkanowy.sdk.mapper package io.github.wulkanowy.sdk.mapper
import io.github.wulkanowy.sdk.Sdk import io.github.wulkanowy.sdk.pojo.RegisterEmployee
import io.github.wulkanowy.sdk.pojo.Student import io.github.wulkanowy.sdk.pojo.RegisterStudent
import io.github.wulkanowy.sdk.scrapper.register.Student as ScrapperStudent import io.github.wulkanowy.sdk.pojo.RegisterSubject
import io.github.wulkanowy.sdk.pojo.RegisterSymbol
import io.github.wulkanowy.sdk.pojo.RegisterUnit
import io.github.wulkanowy.sdk.pojo.RegisterUser
import io.github.wulkanowy.sdk.scrapper.register.RegisterEmployee as ScrapperRegisterEmploye
import io.github.wulkanowy.sdk.scrapper.register.RegisterStudent as ScrapperRegisterStudent
import io.github.wulkanowy.sdk.scrapper.register.RegisterSubject as ScrapperRegisterSubject
import io.github.wulkanowy.sdk.scrapper.register.RegisterSymbol as SdkRegisterSymbol
import io.github.wulkanowy.sdk.scrapper.register.RegisterUnit as ScrapperRegisterUnit
import io.github.wulkanowy.sdk.scrapper.register.RegisterUser as ScrapperRegisterUser
fun List<ScrapperStudent>.mapStudents() = map { fun ScrapperRegisterUser.mapUser(): RegisterUser = RegisterUser(
Student( email = email,
email = it.email, login = login,
userName = it.userName, baseUrl = baseUrl,
userLogin = it.userLogin, loginType = loginType,
userLoginId = it.userLoginId, symbols = symbols.map { it.mapSymbol() },
isParent = it.isParent, )
className = it.className,
classId = it.classId, fun SdkRegisterSymbol.mapSymbol(): RegisterSymbol = RegisterSymbol(
studentId = it.studentId, symbol = symbol,
symbol = it.symbol, userName = userName,
loginType = Sdk.ScrapperLoginType.valueOf(it.loginType.name), error = error,
schoolName = it.schoolName, schools = schools.map { it.mapUnit() },
schoolShortName = it.schoolShortName, )
schoolSymbol = it.schoolSymbol,
studentName = it.studentName, fun ScrapperRegisterUnit.mapUnit(): RegisterUnit = RegisterUnit(
studentSurname = it.studentSurname, userLoginId = userLoginId,
loginMode = Sdk.Mode.SCRAPPER, schoolId = schoolId,
scrapperBaseUrl = it.baseUrl, schoolName = schoolName,
mobileBaseUrl = "", schoolShortName = schoolShortName,
certificateKey = "", parentIds = parentIds,
privateKey = "", studentIds = studentIds,
semesters = it.semesters.mapSemesters(), employeeIds = employeeIds,
) error = error,
subjects = subjects.map { it.mapSubject() },
)
fun ScrapperRegisterSubject.mapSubject(): RegisterSubject {
return when (this) {
is ScrapperRegisterStudent -> mapStudent()
is ScrapperRegisterEmploye -> mapEmployee()
}
} }
fun ScrapperRegisterEmploye.mapEmployee(): RegisterEmployee = RegisterEmployee(
employeeId = employeeId,
employeeName = employeeName,
)
fun ScrapperRegisterStudent.mapStudent(): RegisterStudent = RegisterStudent(
studentId = studentId,
studentName = studentName,
studentSecondName = studentSecondName,
studentSurname = studentSurname,
className = className,
classId = classId,
isParent = isParent,
semesters = semesters.mapSemesters(),
)

View file

@ -1,27 +1,48 @@
package io.github.wulkanowy.sdk.pojo package io.github.wulkanowy.sdk.pojo
import io.github.wulkanowy.sdk.Sdk import io.github.wulkanowy.sdk.scrapper.Scrapper
data class Student( data class RegisterUser(
val email: String, val email: String,
val userName: String, val login: String, // may be the same as email
val userLogin: String, val baseUrl: String,
val userLoginId: Int, val loginType: Scrapper.LoginType?,
val symbols: List<RegisterSymbol>,
)
data class RegisterSymbol(
val symbol: String, val symbol: String,
val isParent: Boolean, val error: Throwable?,
val userName: String,
val schools: List<RegisterUnit>,
)
data class RegisterUnit(
val userLoginId: Int,
val schoolId: String,
val schoolName: String,
val schoolShortName: String,
val parentIds: List<Int>,
val studentIds: List<Int>,
val employeeIds: List<Int>,
val error: Throwable?,
val subjects: List<RegisterSubject>,
)
sealed interface RegisterSubject
data class RegisterEmployee(
val employeeId: Int,
val employeeName: String,
) : RegisterSubject
data class RegisterStudent(
val studentId: Int, val studentId: Int,
val studentName: String, val studentName: String,
val studentSecondName: String,
val studentSurname: String, val studentSurname: String,
val schoolSymbol: String,
val schoolShortName: String,
val schoolName: String,
val className: String, val className: String,
val classId: Int, val classId: Int,
val loginType: Sdk.ScrapperLoginType, val isParent: Boolean,
val loginMode: Sdk.Mode,
val scrapperBaseUrl: String,
val mobileBaseUrl: String,
val certificateKey: String,
val privateKey: String,
val semesters: List<Semester>, val semesters: List<Semester>,
) ) : RegisterSubject

View file

@ -26,8 +26,9 @@ class SdkRemoteTest {
// mode = Sdk.Mode.SCRAPPER // mode = Sdk.Mode.SCRAPPER
} }
val students = val students = runBlocking {
runBlocking { sdk.getStudentsFromScrapper(email = "jan@fakelog.cf", password = "jan123", scrapperBaseUrl = "http://fakelog.cf", symbol = "powiatwulkanowy") } sdk.getUserSubjectsFromScrapper(email = "jan@fakelog.cf", password = "jan123", scrapperBaseUrl = "http://fakelog.cf", symbol = "powiatwulkanowy")
}.symbols.flatMap { it.schools }.flatMap { it.subjects }
assertEquals(6, students.size) assertEquals(6, students.size)
} }