Commit 1397823a authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Add RealmSpotlightTest.kt and update persistence-realm/build.gradle

parent e80b198f
...@@ -38,6 +38,11 @@ android { ...@@ -38,6 +38,11 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
} }
sourceSets {
test.java.srcDirs += 'src/test/kotlin'
androidTest.java.srcDirs += 'src/androidTest/kotlin'
}
} }
dependencies { dependencies {
...@@ -49,6 +54,11 @@ dependencies { ...@@ -49,6 +54,11 @@ dependencies {
compile "com.android.support:design:$rootProject.ext.supportLibraryVersion" compile "com.android.support:design:$rootProject.ext.supportLibraryVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$rootProject.ext.kotlinVersion" compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$rootProject.ext.kotlinVersion"
testCompile "org.jetbrains.kotlin:kotlin-test:$rootProject.ext.kotlinVersion"
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$rootProject.ext.kotlinVersion"
testCompile 'org.json:json:20170516'
testCompile 'org.skyscreamer:jsonassert:1.5.0'
compile 'io.reactivex.rxjava2:rxjava:2.1.0' compile 'io.reactivex.rxjava2:rxjava:2.1.0'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1' compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
......
package chat.rocket.persistence.realm.models.ddp
import org.json.JSONArray
import org.junit.Test
import org.skyscreamer.jsonassert.JSONAssert
class RealmSpotlightTest {
@Test
fun customizeUserJsonObjectTest() {
// This is a JSONArray that contains a single simulated user data returned from the R.C server.
val userJSONArray = JSONArray("[{\"_id\":\"1234567890\",\"status\":\"offline\",\"name\":\"John Doe\",\"username\":\"John.doe\"}]")
// We have only one JSONObject, so let's customize it.
RealmSpotlight.customizeUserJSONObject(userJSONArray.getJSONObject(0))
// The desired JSON array we want.
val expectedUserJSONArray = JSONArray("[{\"_id\":\"1234567890\",\"name\":\"John.doe\",\"t\":\"d\"}]")
JSONAssert.assertEquals(expectedUserJSONArray, userJSONArray, false)
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment