Add support for match mailboxes with more different names (#1961)

This commit is contained in:
Mikołaj Pich 2022-09-01 14:55:00 +02:00 committed by GitHub
parent e574e5e2ec
commit 6153c7b97d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 91 additions and 5 deletions

View file

@ -77,20 +77,76 @@ class MailboxRepositoryTest {
assertEquals(expectedMailbox, selectedMailbox)
}
@Test(expected = IllegalArgumentException::class)
fun `get mailbox for student with strange name`() = runTest {
@Test
fun `get mailbox for unique non-authorized student`() = runTest {
val student = getStudentEntity(
userName = "Stanisław Kowalski",
studentName = "J**** K*****",
studentName = "J** K*******",
)
val expectedMailbox = getMailboxEntity("Jan Kowalski")
coEvery { mailboxDao.loadAll(any()) } returns listOf(
expectedMailbox,
)
assertEquals(expectedMailbox, systemUnderTest.getMailbox(student))
}
@Test(expected = IllegalArgumentException::class)
fun `get mailbox for not-unique non-authorized student`() = runTest {
val student = getStudentEntity(
userName = "Stanisław Kowalski",
studentName = "J** K*******",
)
coEvery { mailboxDao.loadAll(any()) } returns listOf(
getMailboxEntity("Jan Kowalski"),
getMailboxEntity("Jan Kurowski"),
)
systemUnderTest.getMailbox(student)
}
@Test
fun `get mailbox for student with uppercase name`() = runTest {
val student = getStudentEntity(
userName = "Mochoń Julia",
studentName = "KLAUDIA MOCHOŃ",
)
val expectedMailbox = getMailboxEntity("Klaudia Mochoń")
coEvery { mailboxDao.loadAll(any()) } returns listOf(
expectedMailbox,
)
assertEquals(expectedMailbox, systemUnderTest.getMailbox(student))
}
@Test
fun `get mailbox for student with second name`() = runTest {
val student = getStudentEntity(
userName = "Fistaszek Karolina",
studentName = "Julia Fistaszek",
)
val expectedMailbox = getMailboxEntity("Julia Maria Fistaszek")
coEvery { mailboxDao.loadAll(any()) } returns listOf(
expectedMailbox,
)
assertEquals(expectedMailbox, systemUnderTest.getMailbox(student))
}
@Test
fun `get mailbox for student with second name and uppercase`() = runTest {
val student = getStudentEntity(
userName = "BEDNAREK KAMIL",
studentName = "ALEKSANDRA BEDNAREK",
)
val expectedMailbox = getMailboxEntity("Aleksandra Anna Bednarek")
coEvery { mailboxDao.loadAll(any()) } returns listOf(
expectedMailbox,
)
assertEquals(expectedMailbox, systemUnderTest.getMailbox(student))
}
private fun getMailboxEntity(
studentName: String,
) = Mailbox(