adds rest list receiver, adds local code storage

- rest class now receives a list as well as single
  messages
- adds support for threaded singleton which takes
  care of continuous checking of the bump server
  to get the most up-to-date list of messages
- adds local data class with tests to get locally saved
  code in preferences
This commit is contained in:
2021-12-29 19:42:43 +01:00
parent 7e4cfceab4
commit 734b64ce3b
10 changed files with 187 additions and 16 deletions

View File

@ -1,6 +1,8 @@
package com.example.bump
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.InstrumentationConnection
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith
@ -28,6 +30,15 @@ class MessageProcessorTest {
Assert.assertEquals(test, decrypted)
}
@Test
fun setCode() {
val test = getRandomString(512)
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
val local = LocalData(appContext)
local.code = test
Assert.assertEquals(local.code, test)
}
companion object {
@JvmStatic
fun decryptMessage(code: String, messageData: String): String {

View File

@ -68,9 +68,8 @@ class RestCryptTest{
val lock = CountDownLatch(1)
fun listTester(resultList: JSONObject) {
fun listTester(messages: JSONArray) {
val message = MessageProcessor(code)
val messages: JSONArray = resultList.get("messages") as JSONArray
var messageEncoded = messages[0] as JSONObject
var messageData = messageEncoded.get("data").toString()