Skip to content

Commit

Permalink
[chore] : reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
ham2174 committed Feb 17, 2024
1 parent 940fe4f commit aa7b3b7
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.moya.funch.datasource.remote

import com.moya.funch.network.dto.response.subway_station.SubwayStationsResponse
import com.moya.funch.network.dto.response.subwaystation.SubwayStationsResponse

fun interface RemoteSubwayDataSource {

suspend fun fetchSubwayStations(subwayStation: String): Result<List<SubwayStationsResponse>>

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.moya.funch.datasource.remote

import com.moya.funch.network.dto.response.subway_station.SubwayStationsResponse
import com.moya.funch.network.dto.response.subwaystation.SubwayStationsResponse
import com.moya.funch.network.service.SubwayService
import javax.inject.Inject

Expand All @@ -13,5 +13,4 @@ class RemoteSubwayDataSourceImpl @Inject constructor(
subwayStationService.findSubwayStations(subwayStation = subwayStation)
}.mapCatching { response -> response.data }
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package com.moya.funch.mapper

import com.moya.funch.entity.SubwayLine
import com.moya.funch.entity.SubwayStation
import com.moya.funch.network.dto.response.subway_station.SubwayStationsResponse
import com.moya.funch.network.dto.response.subwaystation.SubwayStationsResponse

fun SubwayStationsResponse.toDomain() =
SubwayStation(
name = name,
lines = lines.map { SubwayLine.valueOf(it) }
)
fun SubwayStationsResponse.toDomain() = SubwayStation(
name = name,
lines = lines.map { SubwayLine.valueOf(it) }
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ class SubwayRepositoryImpl(

override suspend fun fetchSubwayStations(subwayStation: String): Result<List<SubwayStation>> {
return remoteSubwayDataSource.fetchSubwayStations(subwayStation = subwayStation)
.mapCatching { response ->
.mapCatching { response ->
response.map { it.toDomain() }
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ import com.moya.funch.entity.SubwayStation
interface SubwayRepository {

suspend fun fetchSubwayStations(subwayStation: String): Result<List<SubwayStation>>

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class LoadSubwayStationsUseCaseImpl @Inject constructor(
override suspend operator fun invoke(subwayStation: String): Result<List<SubwayStation>> {
return subwayRepository.fetchSubwayStations(subwayStation = subwayStation)
}

}

fun interface LoadSubwayStationsUseCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
import retrofit2.Retrofit
import retrofit2.create
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.moya.funch.network.dto.response.subway_station
package com.moya.funch.network.dto.response.subwaystation

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.moya.funch.network.dto.response.subway_station
package com.moya.funch.network.dto.response.subwaystation

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable


@Serializable
data class SubwayStationsResponse(
@SerialName("id")
Expand All @@ -13,5 +12,5 @@ data class SubwayStationsResponse(
@SerialName("lines")
val lines: List<String> = listOf(),
@SerialName("location")
val location: LocationResponse = LocationResponse(),
val location: LocationResponse = LocationResponse()
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.moya.funch.network.service

import com.moya.funch.network.dto.response.BaseResponse
import com.moya.funch.network.dto.response.subway_station.SubwayStationsResponse
import com.moya.funch.network.dto.response.subwaystation.SubwayStationsResponse
import retrofit2.http.GET
import retrofit2.http.Query

interface SubwayService {

@GET("api/v1/subway-stations/search")
suspend fun findSubwayStations(@Query("query") subwayStation: String): BaseResponse<List<SubwayStationsResponse>>

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package com.moya.funch.network.service
import com.google.common.truth.Truth
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import com.moya.funch.network.dto.response.BaseResponse
import com.moya.funch.network.dto.response.subway_station.LocationResponse
import com.moya.funch.network.dto.response.subway_station.SubwayStationsResponse
import com.moya.funch.network.dto.response.subwaystation.LocationResponse
import com.moya.funch.network.dto.response.subwaystation.SubwayStationsResponse
import com.moya.funch.rule.CoroutinesTestExtension
import io.mockk.junit5.MockKExtension
import java.io.File
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import kotlinx.serialization.json.Json
Expand All @@ -18,7 +19,6 @@ import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import retrofit2.Retrofit
import retrofit2.create
import java.io.File

@OptIn(ExperimentalCoroutinesApi::class)
@ExtendWith(MockKExtension::class)
Expand Down Expand Up @@ -77,5 +77,4 @@ internal class SubwayServiceTest {
// then
Truth.assertThat(actualResponse).isEqualTo(expected)
}

}

0 comments on commit aa7b3b7

Please sign in to comment.