issue#6 Add DisplayName annotation to all tests in network module
This commit is contained in:
parent
364b726484
commit
c9d4223ce6
5 changed files with 69 additions and 39 deletions
|
|
@ -12,6 +12,7 @@ import org.fnives.test.showcase.network.shared.exceptions.NetworkException
|
||||||
import org.fnives.test.showcase.network.shared.exceptions.ParsingException
|
import org.fnives.test.showcase.network.shared.exceptions.ParsingException
|
||||||
import org.junit.jupiter.api.Assertions
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
|
import org.junit.jupiter.api.DisplayName
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import retrofit2.Response
|
import retrofit2.Response
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
@ -26,8 +27,9 @@ class LoginErrorConverterTest {
|
||||||
sut = LoginErrorConverter()
|
sut = LoginErrorConverter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN throwing lambda WHEN parsing login error THEN network exception is thrown")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_throwing_lambda_WHEN_parsing_login_error_THEN_network_exception_is_thrown() {
|
fun generallyThrowingLambdaResultsInNetworkException() {
|
||||||
Assertions.assertThrows(NetworkException::class.java) {
|
Assertions.assertThrows(NetworkException::class.java) {
|
||||||
runBlocking {
|
runBlocking {
|
||||||
sut.invoke { throw IOException() }
|
sut.invoke { throw IOException() }
|
||||||
|
|
@ -35,8 +37,9 @@ class LoginErrorConverterTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN jsonException throwing lambda WHEN parsing login error THEN network exception is thrown")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_jsonException_throwing_lambda_WHEN_parsing_login_error_THEN_network_exception_is_thrown() {
|
fun jsonDataThrowingLambdaResultsInParsingException() {
|
||||||
Assertions.assertThrows(ParsingException::class.java) {
|
Assertions.assertThrows(ParsingException::class.java) {
|
||||||
runBlocking {
|
runBlocking {
|
||||||
sut.invoke { throw JsonDataException("") }
|
sut.invoke { throw JsonDataException("") }
|
||||||
|
|
@ -44,8 +47,9 @@ class LoginErrorConverterTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN 400 error response WHEN parsing login error THEN invalid credentials is returned")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_400_error_response_WHEN_parsing_login_error_THEN_invalid_credentials_is_returned() = runBlockingTest {
|
fun code400ResponseResultsInInvalidCredentials() = runBlockingTest {
|
||||||
val expected = LoginStatusResponses.InvalidCredentials
|
val expected = LoginStatusResponses.InvalidCredentials
|
||||||
|
|
||||||
val actual = sut.invoke {
|
val actual = sut.invoke {
|
||||||
|
|
@ -56,8 +60,9 @@ class LoginErrorConverterTest {
|
||||||
Assertions.assertEquals(expected, actual)
|
Assertions.assertEquals(expected, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN successful response WHEN parsing login error THEN successful response is returned")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_successful_response_WHEN_parsing_login_error_THEN_successful_response_is_returned() = runBlockingTest {
|
fun successResponseResultsInSessionResponse() = runBlockingTest {
|
||||||
val loginResponse = LoginResponse("a", "r")
|
val loginResponse = LoginResponse("a", "r")
|
||||||
val expectedSession = Session(accessToken = loginResponse.accessToken, refreshToken = loginResponse.refreshToken)
|
val expectedSession = Session(accessToken = loginResponse.accessToken, refreshToken = loginResponse.refreshToken)
|
||||||
val expected = LoginStatusResponses.Success(expectedSession)
|
val expected = LoginStatusResponses.Success(expectedSession)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import org.fnives.test.showcase.network.shared.exceptions.NetworkException
|
||||||
import org.fnives.test.showcase.network.shared.exceptions.ParsingException
|
import org.fnives.test.showcase.network.shared.exceptions.ParsingException
|
||||||
import org.junit.jupiter.api.Assertions
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
|
import org.junit.jupiter.api.DisplayName
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension
|
import org.junit.jupiter.api.extension.RegisterExtension
|
||||||
import org.mockito.kotlin.mock
|
import org.mockito.kotlin.mock
|
||||||
|
|
@ -41,8 +42,9 @@ class LoginRemoteSourceRefreshActionImplTest {
|
||||||
.inject(this)
|
.inject(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN_successful_response_WHEN_refresh_request_is_fired_THEN_session_is_returned")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_successful_response_WHEN_refresh_request_is_fired_THEN_session() = runBlocking {
|
fun successResponseResultsInSession() = runBlocking {
|
||||||
mockServerScenarioSetup.setScenario(RefreshTokenScenario.Success)
|
mockServerScenarioSetup.setScenario(RefreshTokenScenario.Success)
|
||||||
val expected = ContentData.refreshSuccessResponse
|
val expected = ContentData.refreshSuccessResponse
|
||||||
|
|
||||||
|
|
@ -51,26 +53,27 @@ class LoginRemoteSourceRefreshActionImplTest {
|
||||||
Assertions.assertEquals(expected, actual)
|
Assertions.assertEquals(expected, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN_successful_response_WHEN_refresh_request_is_fired_THEN_the_request_is_setup_properly")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_successful_response_WHEN_refresh_request_is_fired_THEN_the_request_is_setup_properly() =
|
fun refreshRequestIsSetupProperly() = runBlocking {
|
||||||
runBlocking {
|
mockServerScenarioSetup.setScenario(RefreshTokenScenario.Success, false)
|
||||||
mockServerScenarioSetup.setScenario(RefreshTokenScenario.Success, false)
|
|
||||||
|
|
||||||
sut.refresh(ContentData.refreshSuccessResponse.refreshToken)
|
sut.refresh(ContentData.refreshSuccessResponse.refreshToken)
|
||||||
val request = mockServerScenarioSetup.takeRequest()
|
val request = mockServerScenarioSetup.takeRequest()
|
||||||
|
|
||||||
Assertions.assertEquals("PUT", request.method)
|
Assertions.assertEquals("PUT", request.method)
|
||||||
Assertions.assertEquals("Android", request.getHeader("Platform"))
|
Assertions.assertEquals("Android", request.getHeader("Platform"))
|
||||||
Assertions.assertEquals(null, request.getHeader("Authorization"))
|
Assertions.assertEquals(null, request.getHeader("Authorization"))
|
||||||
Assertions.assertEquals(
|
Assertions.assertEquals(
|
||||||
"/login/${ContentData.refreshSuccessResponse.refreshToken}",
|
"/login/${ContentData.refreshSuccessResponse.refreshToken}",
|
||||||
request.path
|
request.path
|
||||||
)
|
)
|
||||||
Assertions.assertEquals("", request.body.readUtf8())
|
Assertions.assertEquals("", request.body.readUtf8())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN_internal_error_response_WHEN_refresh_request_is_fired_THEN_network_exception_is_thrown")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_internal_error_response_WHEN_refresh_request_is_fired_THEN_network_exception_is_thrown() {
|
fun generalErrorResponseResultsInNetworkException() {
|
||||||
mockServerScenarioSetup.setScenario(RefreshTokenScenario.Error)
|
mockServerScenarioSetup.setScenario(RefreshTokenScenario.Error)
|
||||||
|
|
||||||
Assertions.assertThrows(NetworkException::class.java) {
|
Assertions.assertThrows(NetworkException::class.java) {
|
||||||
|
|
@ -78,8 +81,9 @@ class LoginRemoteSourceRefreshActionImplTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN_invalid_json_response_WHEN_refresh_request_is_fired_THEN_network_exception_is_thrown")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_invalid_json_response_WHEN_refresh_request_is_fired_THEN_network_exception_is_thrown() {
|
fun jsonErrorResponseResultsInParsingException() {
|
||||||
mockServerScenarioSetup.setScenario(RefreshTokenScenario.UnexpectedJsonAsSuccessResponse)
|
mockServerScenarioSetup.setScenario(RefreshTokenScenario.UnexpectedJsonAsSuccessResponse)
|
||||||
|
|
||||||
Assertions.assertThrows(ParsingException::class.java) {
|
Assertions.assertThrows(ParsingException::class.java) {
|
||||||
|
|
@ -87,8 +91,9 @@ class LoginRemoteSourceRefreshActionImplTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN_malformed_json_response_WHEN_refresh_request_is_fired_THEN_parsing_exception_is_thrown")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_malformed_json_response_WHEN_refresh_request_is_fired_THEN_network_exception_is_thrown() {
|
fun malformedJsonErrorResponseResultsInParsingException() {
|
||||||
mockServerScenarioSetup.setScenario(RefreshTokenScenario.MalformedJson)
|
mockServerScenarioSetup.setScenario(RefreshTokenScenario.MalformedJson)
|
||||||
|
|
||||||
Assertions.assertThrows(ParsingException::class.java) {
|
Assertions.assertThrows(ParsingException::class.java) {
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import org.fnives.test.showcase.network.shared.exceptions.ParsingException
|
||||||
import org.junit.jupiter.api.AfterEach
|
import org.junit.jupiter.api.AfterEach
|
||||||
import org.junit.jupiter.api.Assertions
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
|
import org.junit.jupiter.api.DisplayName
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension
|
import org.junit.jupiter.api.extension.RegisterExtension
|
||||||
import org.koin.core.context.startKoin
|
import org.koin.core.context.startKoin
|
||||||
|
|
@ -53,8 +54,9 @@ class LoginRemoteSourceRefreshActionImplTest : KoinTest {
|
||||||
stopKoin()
|
stopKoin()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN_successful_response_WHEN_refresh_request_is_fired_THEN_session_is_returned")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_successful_response_WHEN_refresh_request_is_fired_THEN_session() = runBlocking {
|
fun successResponseResultsInSession() = runBlocking {
|
||||||
mockServerScenarioSetup.setScenario(RefreshTokenScenario.Success)
|
mockServerScenarioSetup.setScenario(RefreshTokenScenario.Success)
|
||||||
val expected = ContentData.refreshSuccessResponse
|
val expected = ContentData.refreshSuccessResponse
|
||||||
|
|
||||||
|
|
@ -63,8 +65,9 @@ class LoginRemoteSourceRefreshActionImplTest : KoinTest {
|
||||||
Assertions.assertEquals(expected, actual)
|
Assertions.assertEquals(expected, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN_successful_response_WHEN_refresh_request_is_fired_THEN_the_request_is_setup_properly")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_successful_response_WHEN_refresh_request_is_fired_THEN_the_request_is_setup_properly() = runBlocking {
|
fun refreshRequestIsSetupProperly() = runBlocking {
|
||||||
mockServerScenarioSetup.setScenario(RefreshTokenScenario.Success, false)
|
mockServerScenarioSetup.setScenario(RefreshTokenScenario.Success, false)
|
||||||
|
|
||||||
sut.refresh(ContentData.refreshSuccessResponse.refreshToken)
|
sut.refresh(ContentData.refreshSuccessResponse.refreshToken)
|
||||||
|
|
@ -77,8 +80,9 @@ class LoginRemoteSourceRefreshActionImplTest : KoinTest {
|
||||||
Assertions.assertEquals("", request.body.readUtf8())
|
Assertions.assertEquals("", request.body.readUtf8())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN_internal_error_response_WHEN_refresh_request_is_fired_THEN_network_exception_is_thrown")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_internal_error_response_WHEN_refresh_request_is_fired_THEN_network_exception_is_thrown() {
|
fun generalErrorResponseResultsInNetworkException() {
|
||||||
mockServerScenarioSetup.setScenario(RefreshTokenScenario.Error)
|
mockServerScenarioSetup.setScenario(RefreshTokenScenario.Error)
|
||||||
|
|
||||||
Assertions.assertThrows(NetworkException::class.java) {
|
Assertions.assertThrows(NetworkException::class.java) {
|
||||||
|
|
@ -86,8 +90,9 @@ class LoginRemoteSourceRefreshActionImplTest : KoinTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN_invalid_json_response_WHEN_refresh_request_is_fired_THEN_network_exception_is_thrown")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_invalid_json_response_WHEN_refresh_request_is_fired_THEN_network_exception_is_thrown() {
|
fun jsonErrorResponseResultsInParsingException() {
|
||||||
mockServerScenarioSetup.setScenario(RefreshTokenScenario.UnexpectedJsonAsSuccessResponse)
|
mockServerScenarioSetup.setScenario(RefreshTokenScenario.UnexpectedJsonAsSuccessResponse)
|
||||||
|
|
||||||
Assertions.assertThrows(ParsingException::class.java) {
|
Assertions.assertThrows(ParsingException::class.java) {
|
||||||
|
|
@ -95,8 +100,9 @@ class LoginRemoteSourceRefreshActionImplTest : KoinTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN_malformed_json_response_WHEN_refresh_request_is_fired_THEN_parsing_exception_is_thrown")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_malformed_json_response_WHEN_refresh_request_is_fired_THEN_network_exception_is_thrown() {
|
fun malformedJsonErrorResponseResultsInParsingException() {
|
||||||
mockServerScenarioSetup.setScenario(RefreshTokenScenario.MalformedJson)
|
mockServerScenarioSetup.setScenario(RefreshTokenScenario.MalformedJson)
|
||||||
|
|
||||||
Assertions.assertThrows(ParsingException::class.java) {
|
Assertions.assertThrows(ParsingException::class.java) {
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import org.fnives.test.showcase.network.shared.exceptions.NetworkException
|
||||||
import org.fnives.test.showcase.network.shared.exceptions.ParsingException
|
import org.fnives.test.showcase.network.shared.exceptions.ParsingException
|
||||||
import org.junit.jupiter.api.Assertions
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
|
import org.junit.jupiter.api.DisplayName
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension
|
import org.junit.jupiter.api.extension.RegisterExtension
|
||||||
import org.koin.test.inject
|
import org.koin.test.inject
|
||||||
|
|
@ -44,8 +45,9 @@ class ContentRemoteSourceImplTest {
|
||||||
.inject(this)
|
.inject(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN successful response WHEN getting content THEN its parsed and returned correctly")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_successful_response_WHEN_getting_content_THEN_its_parsed_and_returned_correctly() = runBlocking {
|
fun successResponseParsing() = runBlocking {
|
||||||
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
||||||
mockServerScenarioSetup.setScenario(ContentScenario.Success(false))
|
mockServerScenarioSetup.setScenario(ContentScenario.Success(false))
|
||||||
val expected = ContentData.contentSuccess
|
val expected = ContentData.contentSuccess
|
||||||
|
|
@ -55,8 +57,9 @@ class ContentRemoteSourceImplTest {
|
||||||
Assertions.assertEquals(expected, actual)
|
Assertions.assertEquals(expected, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN successful response WHEN getting content THEN the request is setup properly")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_successful_response_WHEN_getting_content_THEN_the_request_is_setup_properly() = runBlocking {
|
fun successResponseRequestIsCorrect() = runBlocking {
|
||||||
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
||||||
mockServerScenarioSetup.setScenario(ContentScenario.Success(false), false)
|
mockServerScenarioSetup.setScenario(ContentScenario.Success(false), false)
|
||||||
|
|
||||||
|
|
@ -70,8 +73,9 @@ class ContentRemoteSourceImplTest {
|
||||||
Assertions.assertEquals("", request.body.readUtf8())
|
Assertions.assertEquals("", request.body.readUtf8())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN response with missing Field WHEN getting content THEN invalid is ignored others are returned")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_response_with_missing_Field_WHEN_getting_content_THEN_invalid_is_ignored_others_are_returned() = runBlocking {
|
fun dataMissingFieldIsIgnored() = runBlocking {
|
||||||
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
||||||
mockServerScenarioSetup.setScenario(ContentScenario.SuccessWithMissingFields(false))
|
mockServerScenarioSetup.setScenario(ContentScenario.SuccessWithMissingFields(false))
|
||||||
|
|
||||||
|
|
@ -82,8 +86,9 @@ class ContentRemoteSourceImplTest {
|
||||||
Assertions.assertEquals(expected, actual)
|
Assertions.assertEquals(expected, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN error response WHEN getting content THEN network request is thrown")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_error_response_WHEN_getting_content_THEN_network_request_is_thrown() {
|
fun errorResponseResultsInNetworkException() {
|
||||||
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
||||||
mockServerScenarioSetup.setScenario(ContentScenario.Error(false))
|
mockServerScenarioSetup.setScenario(ContentScenario.Error(false))
|
||||||
|
|
||||||
|
|
@ -92,8 +97,9 @@ class ContentRemoteSourceImplTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN unexpected json response WHEN getting content THEN parsing request is thrown")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_unexpected_json_response_WHEN_getting_content_THEN_parsing_request_is_thrown() {
|
fun unexpectedJSONResultsInParsingException() {
|
||||||
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
||||||
mockServerScenarioSetup.setScenario(ContentScenario.UnexpectedJsonAsSuccessResponse(false))
|
mockServerScenarioSetup.setScenario(ContentScenario.UnexpectedJsonAsSuccessResponse(false))
|
||||||
|
|
||||||
|
|
@ -102,8 +108,9 @@ class ContentRemoteSourceImplTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN malformed json response WHEN getting content THEN parsing request is thrown")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_malformed_json_response_WHEN_getting_content_THEN_parsing_request_is_thrown() {
|
fun malformedJSONResultsInParsingException() {
|
||||||
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
||||||
mockServerScenarioSetup.setScenario(ContentScenario.MalformedJsonAsSuccessResponse(false))
|
mockServerScenarioSetup.setScenario(ContentScenario.MalformedJsonAsSuccessResponse(false))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import org.fnives.test.showcase.network.shared.exceptions.ParsingException
|
||||||
import org.junit.jupiter.api.AfterEach
|
import org.junit.jupiter.api.AfterEach
|
||||||
import org.junit.jupiter.api.Assertions
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
|
import org.junit.jupiter.api.DisplayName
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension
|
import org.junit.jupiter.api.extension.RegisterExtension
|
||||||
import org.koin.core.context.startKoin
|
import org.koin.core.context.startKoin
|
||||||
|
|
@ -55,8 +56,9 @@ class ContentRemoteSourceImplTest : KoinTest {
|
||||||
stopKoin()
|
stopKoin()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN successful response WHEN getting content THEN its parsed and returned correctly")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_successful_response_WHEN_getting_content_THEN_its_parsed_and_returned_correctly() = runBlocking {
|
fun successResponseParsing() = runBlocking {
|
||||||
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
||||||
mockServerScenarioSetup.setScenario(ContentScenario.Success(false))
|
mockServerScenarioSetup.setScenario(ContentScenario.Success(false))
|
||||||
val expected = ContentData.contentSuccess
|
val expected = ContentData.contentSuccess
|
||||||
|
|
@ -66,8 +68,9 @@ class ContentRemoteSourceImplTest : KoinTest {
|
||||||
Assertions.assertEquals(expected, actual)
|
Assertions.assertEquals(expected, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN successful response WHEN getting content THEN the request is setup properly")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_successful_response_WHEN_getting_content_THEN_the_request_is_setup_properly() = runBlocking {
|
fun successResponseRequestIsCorrect() = runBlocking {
|
||||||
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
||||||
mockServerScenarioSetup.setScenario(ContentScenario.Success(false), false)
|
mockServerScenarioSetup.setScenario(ContentScenario.Success(false), false)
|
||||||
|
|
||||||
|
|
@ -81,8 +84,9 @@ class ContentRemoteSourceImplTest : KoinTest {
|
||||||
Assertions.assertEquals("", request.body.readUtf8())
|
Assertions.assertEquals("", request.body.readUtf8())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN response with missing Field WHEN getting content THEN invalid is ignored others are returned")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_response_with_missing_Field_WHEN_getting_content_THEN_invalid_is_ignored_others_are_returned() = runBlocking {
|
fun dataMissingFieldIsIgnored() = runBlocking {
|
||||||
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
||||||
mockServerScenarioSetup.setScenario(ContentScenario.SuccessWithMissingFields(false))
|
mockServerScenarioSetup.setScenario(ContentScenario.SuccessWithMissingFields(false))
|
||||||
|
|
||||||
|
|
@ -93,8 +97,9 @@ class ContentRemoteSourceImplTest : KoinTest {
|
||||||
Assertions.assertEquals(expected, actual)
|
Assertions.assertEquals(expected, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN error response WHEN getting content THEN network request is thrown")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_error_response_WHEN_getting_content_THEN_network_request_is_thrown() {
|
fun errorResponseResultsInNetworkException() {
|
||||||
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
||||||
mockServerScenarioSetup.setScenario(ContentScenario.Error(false))
|
mockServerScenarioSetup.setScenario(ContentScenario.Error(false))
|
||||||
|
|
||||||
|
|
@ -103,8 +108,9 @@ class ContentRemoteSourceImplTest : KoinTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN unexpected json response WHEN getting content THEN parsing request is thrown")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_unexpected_json_response_WHEN_getting_content_THEN_parsing_request_is_thrown() {
|
fun unexpectedJSONResultsInParsingException() {
|
||||||
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
||||||
mockServerScenarioSetup.setScenario(ContentScenario.UnexpectedJsonAsSuccessResponse(false))
|
mockServerScenarioSetup.setScenario(ContentScenario.UnexpectedJsonAsSuccessResponse(false))
|
||||||
|
|
||||||
|
|
@ -113,8 +119,9 @@ class ContentRemoteSourceImplTest : KoinTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("GIVEN malformed json response WHEN getting content THEN parsing request is thrown")
|
||||||
@Test
|
@Test
|
||||||
fun GIVEN_malformed_json_response_WHEN_getting_content_THEN_parsing_request_is_thrown() {
|
fun malformedJSONResultsInParsingException() {
|
||||||
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
whenever(mockNetworkSessionLocalStorage.session).doReturn(ContentData.loginSuccessResponse)
|
||||||
mockServerScenarioSetup.setScenario(ContentScenario.MalformedJsonAsSuccessResponse(false))
|
mockServerScenarioSetup.setScenario(ContentScenario.MalformedJsonAsSuccessResponse(false))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue