Fix incorrectly splitted recipient name
This commit is contained in:
parent
0d8da3ec5e
commit
1bce1e6d42
4 changed files with 50 additions and 7 deletions
|
@ -57,7 +57,7 @@ class MessagesRepository(private val api: MessagesService) {
|
|||
listOf(Recipient("0", message.recipient ?: "unknown", 0, 0, 2, "unknown"))
|
||||
})
|
||||
}.map {
|
||||
message.copy(recipient = it.name.split(" -").first(), messageId = message.id).apply {
|
||||
message.copy(recipient = it.name.substringBeforeLast(" -"), messageId = message.id).apply {
|
||||
recipientId = it.loginId
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package io.github.wulkanowy.api.messages
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonParser
|
||||
import io.github.wulkanowy.api.BaseLocalTest
|
||||
import io.github.wulkanowy.api.repository.MessagesRepository
|
||||
|
@ -38,7 +37,7 @@ class MessagesTest : BaseLocalTest() {
|
|||
server.enqueue(MockResponse().setBody(MessagesTest::class.java.getResource("Adresaci.json").readText()))
|
||||
server.start(3000)
|
||||
|
||||
assertEquals(1, api.getSentMessages(null, null).blockingGet().size)
|
||||
assertEquals(2, api.getSentMessages(null, null).blockingGet().size)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -48,7 +47,33 @@ class MessagesTest : BaseLocalTest() {
|
|||
// server.enqueue(MockResponse().setBody(MessagesTest::class.java.getResource("Adresaci.json").readText()))
|
||||
server.start(3000)
|
||||
|
||||
assertEquals(1, api.getSentMessages(null, null).blockingGet().size)
|
||||
assertEquals(2, api.getSentMessages(null, null).blockingGet().size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getMessagesSent_recipientWithDashInName() {
|
||||
server.enqueue(MockResponse().setBody(MessagesTest::class.java.getResource("WiadomosciWyslane.json").readText()))
|
||||
server.enqueue(MockResponse().setBody(MessagesTest::class.java.getResource("JednostkiUzytkownika.json").readText()))
|
||||
server.enqueue(MockResponse().setBody(MessagesTest::class.java.getResource("Adresaci.json").readText()))
|
||||
server.start(3000)
|
||||
|
||||
val recipients = api.getSentMessages(null, null).blockingGet()
|
||||
|
||||
assertEquals("Czerwieńska - Kowalska Joanna [CJ]", recipients[1].recipient)
|
||||
assertEquals(95, recipients[1].recipientId)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getMessagesSent_recipientWithDashInNameAndEmptyUnits() {
|
||||
server.enqueue(MockResponse().setBody(MessagesTest::class.java.getResource("WiadomosciWyslane.json").readText()))
|
||||
server.enqueue(MockResponse().setBody(MessagesTest::class.java.getResource("JednostkiUzytkownika-empty.json").readText()))
|
||||
// server.enqueue(MockResponse().setBody(MessagesTest::class.java.getResource("Adresaci.json").readText()))
|
||||
server.start(3000)
|
||||
|
||||
val recipients = api.getSentMessages(null, null).blockingGet()
|
||||
|
||||
assertEquals("Czerwieńska - Kowalska Joanna [CJ]", recipients[1].recipient)
|
||||
assertEquals(0, recipients[1].recipientId)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -65,7 +90,8 @@ class MessagesTest : BaseLocalTest() {
|
|||
server.start(3000)
|
||||
|
||||
api.sendMessage("Temat wiadomości", "Tak wygląda zawartość wiadomości.\nZazwyczaj ma wiele linijek.\n\nZ poważaniem,\nNazwisko Imię",
|
||||
listOf(Recipient("0", "Kowalski Jan", 0, 0, 2, "hash"))).blockingGet()
|
||||
listOf(Recipient("0", "Kowalski Jan", 0, 0, 2, "hash"))
|
||||
).blockingGet()
|
||||
|
||||
val parser = JsonParser()
|
||||
val expected = parser.parse(MessagesTest::class.java.getResource("NowaWiadomosc.json").readText())
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"data": [
|
||||
{
|
||||
"Id": "18rPracownik",
|
||||
"Nazwa": "Janusz Tracz [TJ] - pracownik (Fake123456)",
|
||||
"Nazwa": "Tracz Janusz [TJ] - pracownik (Fake123456)",
|
||||
"IdLogin": 18,
|
||||
"IdJednostkaSprawozdawcza": 6,
|
||||
"RolaEnum": null,
|
||||
|
@ -18,6 +18,15 @@
|
|||
"RolaEnum": null,
|
||||
"Rola": 2,
|
||||
"PushWiadomosc": null
|
||||
},
|
||||
{
|
||||
"Id": "95rPracownik",
|
||||
"Nazwa": "Czerwieńska - Kowalska Joanna [CJ] - pracownik (Fake123456)",
|
||||
"IdLogin": 95,
|
||||
"IdJednostkaSprawozdawcza": 6,
|
||||
"RolaEnum": null,
|
||||
"Rola": 2,
|
||||
"PushWiadomosc": null
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -4,10 +4,18 @@
|
|||
{
|
||||
"Data": "2018-06-11T07:38:35.000Z",
|
||||
"Temat": "Usprawiedliwienie nieobecności",
|
||||
"Adresaci": "Janusz Tracz [TJ] - pracownik (Fake123456)",
|
||||
"Adresaci": "Tracz Janusz [TJ] - pracownik (Fake123456)",
|
||||
"Nieprzeczytane": "1",
|
||||
"Przeczytane": "0",
|
||||
"Id": 32798
|
||||
},
|
||||
{
|
||||
"Data": "2018-06-11T09:38:35.000Z",
|
||||
"Temat": "Wiadomość testowa",
|
||||
"Adresaci": "Czerwieńska - Kowalska Joanna [CJ] - pracownik (Fake123456)",
|
||||
"Nieprzeczytane": "1",
|
||||
"Przeczytane": "0",
|
||||
"Id": 32799
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue