Skip to content

Instantly share code, notes, and snippets.

@biodunalfet
Last active October 1, 2019 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biodunalfet/a8fafa22ea66464a8b1f022ce6054113 to your computer and use it in GitHub Desktop.
Save biodunalfet/a8fafa22ea66464a8b1f022ce6054113 to your computer and use it in GitHub Desktop.
override fun requestStatement(startDate: String?, endDate: String?, statementType: String, cardLastFourDigits : String?): Single<GenericResponse> {
return localDataStore.getAccessToken().zipWith(localDataStore.getUserData(), BiFunction { t1: String, t2: DataUserData ->
Pair(t1, t2)
}).flatMap {
remoteDataSource.requestStatement(startDate, endDate, statementType, cardLastFourDigits, it.first).map { entity ->
mapper.customMapFromEntity(entity, it.second.EmailAddress)
}
}
}
@Test
fun testRequestStatement_correctParamsPassed() {
//arrange
val captor = argumentCaptor<String>()
val startDate = randomString()
val endDate = randomString()
val statementType = randomString()
val cardLastFourDigits = randomString()
whenever(localDataSourceMock.getAccessToken()).thenReturn(Single.just(randomString()))
whenever(remoteDataSourceMock.requestStatement(any(), any(), any(), any(), any())).thenReturn(Single.just(FakeDataObjectGenerator.randomGenericResponseEntity()))
whenever(localDataSourceMock.getUserData()).thenReturn(Single.just(dataUserDataMock))
//act
getBarterRepository.requestStatement(startDate,
endDate, statementType, cardLastFourDigits).test()
verify(remoteDataSourceMock).requestStatement(captor.capture(), captor.capture(), captor.capture(), captor.capture(), captor.capture())
//assert
assertEquals(startDate, captor.firstValue)
assertEquals(endDate, captor.allValues[1])
assertEquals(statementType, captor.allValues[2])
assertEquals(cardLastFourDigits, captor.allValues[3])
}
@aliumujib
Copy link

abi you dey switch thread for localDataStore .getAccessToken and localDataStore.getUserData()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment