Last active
October 1, 2019 15:13
-
-
Save biodunalfet/a8fafa22ea66464a8b1f022ce6054113 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
abi you dey switch thread for
localDataStore .getAccessToken
andlocalDataStore.getUserData()
?