-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f9702a3
commit 6b5929a
Showing
6 changed files
with
56 additions
and
14 deletions.
There are no files selected for viewing
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
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
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
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
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
43 changes: 43 additions & 0 deletions
43
src/test/kotlin/concept/stc/data/remote/ApiClientIntegrationTest.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package concept.stc.data.remote | ||
|
||
import com.github.tomakehurst.wiremock.client.WireMock | ||
import com.github.tomakehurst.wiremock.client.WireMock.aResponse | ||
import com.github.tomakehurst.wiremock.client.WireMock.get | ||
import com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo | ||
import concept.stc.config.OmdbApiProperties | ||
import kotlinx.coroutines.test.runTest | ||
import org.junit.jupiter.api.Test | ||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.wiremock.spring.EnableWireMock | ||
import kotlin.test.assertEquals | ||
|
||
@SpringBootTest | ||
@EnableWireMock | ||
class ApiClientIntegrationTest { | ||
|
||
@Value("\${wiremock.server.baseUrl}") | ||
private lateinit var wiremockUrl: String | ||
|
||
@Test | ||
fun `when getting movies, given api properties, then response is correct`() = runTest { | ||
// Given | ||
val key = "testKey" | ||
val title = "testTitle" | ||
val properties = OmdbApiProperties(baseUrl = wiremockUrl, apiKey = key) | ||
|
||
val url = "/?apikey=$key&s=$title" | ||
val aResponse = aResponse() | ||
.withStatus(200) | ||
.withHeader("Content-Type", "application/json") | ||
.withBody("SUCCESS") | ||
|
||
WireMock.stubFor(get(urlEqualTo(url)).willReturn(aResponse)) | ||
|
||
// When | ||
val response = ApiClient(properties).getMovies(title) | ||
|
||
// Then | ||
assertEquals("SUCCESS", response) | ||
} | ||
} |