Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.app.rachmad.movie
- import com.app.rachmad.movie.webservice.AccessSite
- import okhttp3.OkHttpClient
- import org.junit.Before
- import org.junit.Test
- import org.junit.Assert.*
- import org.mockito.Mock
- import retrofit2.Retrofit
- import retrofit2.converter.gson.GsonConverterFactory
- class RemoteTest {
- @Mock
- private lateinit var accessSite: AccessSite
- @Before
- fun setup(){
- accessSite = Retrofit.Builder()
- .baseUrl(BuildConfig.SERVER_URL)
- .addConverterFactory(GsonConverterFactory.create())
- .client(OkHttpClient())
- .build()
- .create(AccessSite::class.java)
- // accessSite = MovieSite.connect()
- }
- @Test
- fun movieDataTest(){
- val movie = accessSite.movieSite(1, "en-US").execute()
- assertEquals(movie.body()!!.results!!.size, 20)
- movie.body()!!.results!!.forEach {
- assertNotEquals(it.poster_path, null)
- assertNotEquals(it.original_title, null)
- assertNotEquals(it.overview, null)
- assertNotEquals(it.release_date, null)
- assertNotEquals(it.vote_average, null)
- }
- }
- @Test
- fun movieDetailsDataTest(){
- val movie = accessSite.movieDetail(429203, "en-US").execute()
- with(movie.body()){
- assertEquals(this!!.title, "The Old Man & the Gun")
- assertEquals(this.backdrop_path, "/6X2YjjYcs8XyZRDmJAHNDlls7L4.jpg")
- assertEquals(this.poster_path, "/a4BfxRK8dBgbQqbRxPs8kmLd8LG.jpg")
- assertEquals(this.overview, "The true story of Forrest Tucker, from his audacious escape from San Quentin at the age of 70 to an unprecedented string of heists that confounded authorities and enchanted the public. Wrapped up in the pursuit are a detective, who becomes captivated with Forrest’s commitment to his craft, and a woman, who loves him in spite of his chosen profession.")
- assertEquals(this.release_date, "2018-09-27")
- this.genres.forEach {
- assertNotEquals(it.name, null)
- }
- assertEquals(this.vote_average, 6.3F)
- this.production_companies.forEach {
- assertNotEquals(it.name, null)
- // assertNotEquals(it.logo_path, null)
- }
- }
- }
- @Test
- fun tvDataTest(){
- val movie = accessSite.tvSite(1, "en-US").execute()
- assertEquals(movie.body()!!.results!!.size, 20)
- movie.body()!!.results!!.forEach {
- assertNotEquals(it.name, null)
- assertNotEquals(it.overview, null)
- assertNotEquals(it.poster_path, null)
- assertNotEquals(it.name, null)
- assertNotEquals(it.overview, null)
- assertNotEquals(it.first_air_date, null)
- assertNotEquals(it.vote_average, null)
- }
- }
- @Test
- fun tvDetailsDataTest(){
- val tv = accessSite.tvDetail(60735, "en-US").execute()
- with(tv.body()){
- assertEquals(this!!.name, "The Flash")
- assertEquals(this.backdrop_path, "/6ZdQTBy20HzWudZthAV7NkZWfIb.jpg")
- assertEquals(this.poster_path, "/wHa6KOJAoNTFLFtp7wguUJKSnju.jpg")
- assertEquals(this.overview, "After a particle accelerator causes a freak storm, CSI Investigator Barry Allen is struck by lightning and falls into a coma. Months later he awakens with the power of super speed, granting him the ability to move through Central City like an unseen guardian angel. Though initially excited by his newfound powers, Barry is shocked to discover he is not the only \"meta-human\" who was created in the wake of the accelerator explosion -- and not everyone is using their new powers for good. Barry partners with S.T.A.R. Labs and dedicates his life to protect the innocent. For now, only a few close friends and associates know that Barry is literally the fastest man alive, but it won't be long before the world learns what Barry Allen has become...The Flash.")
- assertEquals(this.first_air_date, "2014-10-07")
- this.genres.forEach {
- assertNotEquals(it.name, null)
- }
- assertEquals(this.vote_average, 6.7F)
- this.production_companies.forEach {
- assertNotEquals(it.name, null)
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement