Make test compile and pass

This commit is contained in:
Benoit Marty 2019-10-24 16:36:12 +02:00
parent 9e8d8ce878
commit 7c567b04bb
2 changed files with 13 additions and 14 deletions

View file

@ -18,7 +18,7 @@ package im.vector.matrix.android.api.pushrules
import im.vector.matrix.android.api.pushrules.rest.PushRule
import im.vector.matrix.android.internal.di.MoshiProvider
import org.junit.Assert
import org.junit.Assert.*
import org.junit.Test
class PushRuleActionsTest {
@ -63,22 +63,17 @@ class PushRuleActionsTest {
val pushRule = MoshiProvider.providesMoshi().adapter<PushRule>(PushRule::class.java).fromJson(rawPushRule)
Assert.assertNotNull("Should have parsed the rule", pushRule)
Assert.assertNotNull("Failed to parse actions", Action.mapFrom(pushRule!!))
assertNotNull("Should have parsed the rule", pushRule)
val actions = Action.mapFrom(pushRule)
Assert.assertEquals(3, actions!!.size)
val actions = pushRule!!.getActions()
assertEquals(3, actions.size)
Assert.assertEquals("First action should be notify", Action.Type.NOTIFY, actions[0].type)
assertTrue("First action should be notify", actions[0] is Action.Notify)
Assert.assertEquals("Second action should be tweak", Action.Type.SET_TWEAK, actions[1].type)
Assert.assertEquals("Second action tweak key should be sound", "sound", actions[1].tweak_action)
Assert.assertEquals("Second action should have default as stringValue", "default", actions[1].stringValue)
Assert.assertNull("Second action boolValue should be null", actions[1].boolValue)
assertTrue("Second action should be sound", actions[1] is Action.Sound)
assertEquals("Second action should have default sound", "default", (actions[1] as Action.Sound).sound)
Assert.assertEquals("Third action should be tweak", Action.Type.SET_TWEAK, actions[2].type)
Assert.assertEquals("Third action tweak key should be highlight", "highlight", actions[2].tweak_action)
Assert.assertEquals("Third action tweak param should be false", false, actions[2].boolValue)
Assert.assertNull("Third action stringValue should be null", actions[2].stringValue)
assertTrue("Third action should be highlight", actions[2] is Action.Highlight)
assertEquals("Third action tweak param should be false", false, (actions[2] as Action.Highlight).highlight)
}
}

View file

@ -199,6 +199,10 @@ class PushrulesConditionTest {
}
class MockRoom(override val roomId: String, val _numberOfJoinedMembers: Int) : Room {
override fun reportContent(eventId: String, score: Int, reason: String, callback: MatrixCallback<Unit>): Cancelable {
TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
}
override fun getReadMarkerLive(): LiveData<Optional<String>> {
TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
}