Skip to content

Commit

Permalink
Update some dependencies; remove example unit tests; add beginning of…
Browse files Browse the repository at this point in the history
… RxFirestoreDbTests
  • Loading branch information
btrautmann committed May 6, 2018
1 parent ee96ee4 commit 9d29128
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 42 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ buildscript {
// Two necessary plugins
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:${bintrayPluginVersion}"
classpath "com.github.dcendents:android-maven-gradle-plugin:${mavenGradlePluginVersion}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
6 changes: 5 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ ext {
// Libraries
supportLibraryVersion = '27.1.1'
firebaseVersion = '16.0.0'
junitVersion = '4.12'
kotlinVersion = '1.2.41'
rxJavaVersion = '2.1.8'

// Test libraries
mockitoVersion = '2.18.3'
kotlinMockitoVersion = '1.5.0'
junitVersion = '4.12'

// Build plugins
androidPluginVersion = '3.1.2'
bintrayPluginVersion = '1.8.0'
Expand Down
16 changes: 13 additions & 3 deletions rxfirestore/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion rootProject.ext.compileSdkVersion
Expand All @@ -18,6 +19,9 @@ android {
disable 'InvalidPackage'
abortOnError true
}
sourceSets {
test.java.srcDirs += 'src/test/kotlin'
}
}

ext {
Expand Down Expand Up @@ -46,9 +50,15 @@ apply from: '../bintray.gradle'

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "io.reactivex.rxjava2:rxjava:${rxJavaVersion}"
implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
implementation "com.google.firebase:firebase-firestore:$firebaseVersion"
implementation "com.android.support:support-annotations:${supportLibraryVersion}"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
implementation "com.android.support:support-annotations:$supportLibraryVersion"
// Testing
testImplementation 'junit:junit:4.12'
testImplementation "junit:junit:$junitVersion"
testImplementation "com.nhaarman:mockito-kotlin:$kotlinMockitoVersion"
testImplementation "org.mockito:mockito-core:${mockitoVersion}"
}
repositories {
mavenCentral()
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.oakwoodsc.rxfirestore

import com.google.firebase.firestore.DocumentReference
import com.google.firebase.firestore.DocumentSnapshot
import com.google.firebase.firestore.EventListener
import com.nhaarman.mockito_kotlin.argumentCaptor
import com.nhaarman.mockito_kotlin.mock
import com.nhaarman.mockito_kotlin.times
import com.nhaarman.mockito_kotlin.verify
import io.reactivex.subscribers.TestSubscriber
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.mockito.MockitoAnnotations

class RxFirestoreDbTests {

private val documentSnapshotListener = argumentCaptor<EventListener<DocumentSnapshot>>()

@Before

fun setUp() {
MockitoAnnotations.initMocks(this)
}

@Test
fun sanityTest() {
assertEquals(4, (2 + 2).toLong())
}

@Test
fun testDocumentSnapshots() {
val docReference = mock<DocumentReference>()
val snapshot = mock<DocumentSnapshot>()

with(TestSubscriber.create<DocumentSnapshot>()) {
RxFirestoreDb.documentSnapshots(docReference).subscribe()

docReference.verifySnapshotListenerAdded()

}

}

private fun DocumentReference.verifySnapshotListenerAdded() {
verify(this, times(1))
.addSnapshotListener(documentSnapshotListener.capture())
}

}


6 changes: 3 additions & 3 deletions rxfirestorekt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ apply from: '../bintray.gradle'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':rxfirestore')
implementation "io.reactivex.rxjava2:rxjava:${rxJavaVersion}"
implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
implementation "com.google.firebase:firebase-firestore:$firebaseVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
implementation "com.android.support:support-annotations:${supportLibraryVersion}"
implementation "com.android.support:support-annotations:$supportLibraryVersion"
// Testing
testImplementation 'junit:junit:4.12'
testImplementation "junit:junit:$junitVersion"
}
repositories {
mavenCentral()
Expand Down

This file was deleted.

0 comments on commit 9d29128

Please sign in to comment.