mirror of
https://github.com/ev-map/EVMap.git
synced 2025-12-27 09:07:46 -05:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7759c230db | ||
|
|
cdc575ff33 | ||
|
|
cb250de79e | ||
|
|
c7885ae729 | ||
|
|
024b56952d | ||
|
|
75b2240247 | ||
|
|
d8f011b64b | ||
|
|
a1760a35ff |
@@ -13,8 +13,8 @@ android {
|
||||
applicationId "net.vonforst.evmap"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 29
|
||||
versionCode 14
|
||||
versionName "0.1.6"
|
||||
versionCode 16
|
||||
versionName "0.1.8"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@@ -106,6 +106,10 @@ dependencies {
|
||||
implementation 'com.google.android.gms:play-services-base:17.3.0'
|
||||
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
|
||||
implementation 'com.google.android.gms:play-services-location:17.0.0'
|
||||
implementation 'com.google.android.gms:play-services-clearcut:17.0.0'
|
||||
implementation 'com.android.volley:volley:1.1.1'
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
implementation 'com.github.bumptech.glide:glide:4.11.0'
|
||||
|
||||
// navigation library
|
||||
def nav_version = "2.3.0-beta01"
|
||||
|
||||
@@ -18,16 +18,16 @@ interface GoingElectricApi {
|
||||
suspend fun getChargepoints(
|
||||
@Query("sw_lat") swlat: Double, @Query("sw_lng") sw_lng: Double,
|
||||
@Query("ne_lat") ne_lat: Double, @Query("ne_lng") ne_lng: Double,
|
||||
@Query("clustering") clustering: Boolean,
|
||||
@Query("zoom") zoom: Float,
|
||||
@Query("cluster_distance") clusterDistance: Int?,
|
||||
@Query("freecharging") freecharging: Boolean,
|
||||
@Query("freeparking") freeparking: Boolean,
|
||||
@Query("min_power") minPower: Int,
|
||||
@Query("plugs") plugs: String?,
|
||||
@Query("chargecards") chargecards: String?,
|
||||
@Query("networks") networks: String?,
|
||||
@Query("startkey") startkey: Int?
|
||||
@Query("clustering") clustering: Boolean = false,
|
||||
@Query("cluster_distance") clusterDistance: Int? = null,
|
||||
@Query("freecharging") freecharging: Boolean = false,
|
||||
@Query("freeparking") freeparking: Boolean = false,
|
||||
@Query("min_power") minPower: Int = 0,
|
||||
@Query("plugs") plugs: String? = null,
|
||||
@Query("chargecards") chargecards: String? = null,
|
||||
@Query("networks") networks: String? = null,
|
||||
@Query("startkey") startkey: Int? = null
|
||||
): Response<ChargepointList>
|
||||
|
||||
@GET("chargepoints/")
|
||||
|
||||
@@ -25,7 +25,7 @@ import kotlin.math.floor
|
||||
data class ChargepointList(
|
||||
val status: String,
|
||||
val chargelocations: List<ChargepointListItem>,
|
||||
val startkey: Int?
|
||||
@JsonObjectOrFalse val startkey: Int?
|
||||
)
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
@@ -278,4 +278,4 @@ data class ChargeCard(
|
||||
@Json(name = "card_id") @PrimaryKey val id: Long,
|
||||
val name: String,
|
||||
val url: String
|
||||
)
|
||||
)
|
||||
|
||||
@@ -89,6 +89,7 @@ class MapFragment : Fragment(), OnMapReadyCallback, MapsActivity.FragmentCallbac
|
||||
private var markers: MutableBiMap<Marker, ChargeLocation> = HashBiMap()
|
||||
private var clusterMarkers: List<Marker> = emptyList()
|
||||
private var searchResultMarker: Marker? = null
|
||||
private var connectionErrorSnackbar: Snackbar? = null
|
||||
|
||||
private lateinit var clusterIconGenerator: ClusterIconGenerator
|
||||
private lateinit var chargerIconGenerator: ChargerIconGenerator
|
||||
@@ -312,9 +313,31 @@ class MapFragment : Fragment(), OnMapReadyCallback, MapsActivity.FragmentCallbac
|
||||
unhighlightAllMarkers()
|
||||
}
|
||||
})
|
||||
vm.chargepoints.observe(viewLifecycleOwner, Observer {
|
||||
val chargepoints = it.data
|
||||
if (chargepoints != null) updateMap(chargepoints)
|
||||
vm.chargepoints.observe(viewLifecycleOwner, Observer { res ->
|
||||
when (res.status) {
|
||||
Status.ERROR -> {
|
||||
val view = view ?: return@Observer
|
||||
|
||||
connectionErrorSnackbar?.dismiss()
|
||||
connectionErrorSnackbar = Snackbar
|
||||
.make(view, R.string.connection_error, Snackbar.LENGTH_INDEFINITE)
|
||||
.setAction(R.string.retry) {
|
||||
connectionErrorSnackbar?.dismiss()
|
||||
vm.reloadChargepoints()
|
||||
}
|
||||
connectionErrorSnackbar!!.show()
|
||||
}
|
||||
Status.SUCCESS -> {
|
||||
connectionErrorSnackbar?.dismiss()
|
||||
}
|
||||
Status.LOADING -> {
|
||||
}
|
||||
}
|
||||
|
||||
val chargepoints = res.data
|
||||
if (chargepoints != null) {
|
||||
updateMap(chargepoints)
|
||||
}
|
||||
})
|
||||
vm.favorites.observe(viewLifecycleOwner, Observer {
|
||||
updateFavoriteToggle()
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.vonforst.evmap.ui
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.view.View
|
||||
import android.view.ViewGroup.MarginLayoutParams
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
@@ -16,6 +17,7 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import net.vonforst.evmap.R
|
||||
import net.vonforst.evmap.api.availability.ChargepointStatus
|
||||
import net.vonforst.evmap.api.goingelectric.Chargepoint
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
|
||||
@BindingAdapter("goneUnless")
|
||||
@@ -119,6 +121,16 @@ fun setHtmlTextValue(textView: TextView, htmlText: String?) {
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("android:layout_marginTop")
|
||||
fun setTopMargin(view: View, topMargin: Float) {
|
||||
val layoutParams = view.layoutParams as MarginLayoutParams
|
||||
layoutParams.setMargins(
|
||||
layoutParams.leftMargin, topMargin.roundToInt(),
|
||||
layoutParams.rightMargin, layoutParams.bottomMargin
|
||||
)
|
||||
view.layoutParams = layoutParams
|
||||
}
|
||||
|
||||
private fun availabilityColor(
|
||||
status: List<ChargepointStatus>?,
|
||||
context: Context
|
||||
|
||||
@@ -16,6 +16,7 @@ import net.vonforst.evmap.ui.cluster
|
||||
import retrofit2.Call
|
||||
import retrofit2.Callback
|
||||
import retrofit2.Response
|
||||
import java.io.IOException
|
||||
|
||||
data class MapPosition(val bounds: LatLngBounds, val zoom: Float)
|
||||
|
||||
@@ -76,9 +77,7 @@ class MapViewModel(application: Application, geApiKey: String) : AndroidViewMode
|
||||
value = Resource.loading(emptyList())
|
||||
listOf(mapPosition, filtersWithValue).forEach {
|
||||
addSource(it) {
|
||||
val pos = mapPosition.value ?: return@addSource
|
||||
val filters = filtersWithValue.value ?: return@addSource
|
||||
loadChargepoints(pos, filters)
|
||||
reloadChargepoints()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,6 +173,12 @@ class MapViewModel(application: Application, geApiKey: String) : AndroidViewMode
|
||||
}
|
||||
}
|
||||
|
||||
fun reloadChargepoints() {
|
||||
val pos = mapPosition.value ?: return
|
||||
val filters = filtersWithValue.value ?: return
|
||||
loadChargepoints(pos, filters)
|
||||
}
|
||||
|
||||
private fun loadChargepoints(
|
||||
mapPosition: MapPosition,
|
||||
filters: List<FilterWithValue<out FilterValue>>
|
||||
@@ -229,20 +234,32 @@ class MapViewModel(application: Application, geApiKey: String) : AndroidViewMode
|
||||
val data = mutableListOf<ChargepointListItem>()
|
||||
do {
|
||||
// load all pages of the response
|
||||
val response = api.getChargepoints(
|
||||
bounds.southwest.latitude, bounds.southwest.longitude,
|
||||
bounds.northeast.latitude, bounds.northeast.longitude,
|
||||
clustering = useGeClustering, zoom = zoom,
|
||||
clusterDistance = clusterDistance, freecharging = freecharging, minPower = minPower,
|
||||
freeparking = freeparking, plugs = connectors, chargecards = chargeCards,
|
||||
networks = networks, startkey = startkey
|
||||
)
|
||||
if (!response.isSuccessful || response.body()!!.status != "ok") {
|
||||
return Resource.error(response.message(), chargepoints.value?.data)
|
||||
} else {
|
||||
val body = response.body()!!
|
||||
data.addAll(body.chargelocations)
|
||||
startkey = body.startkey
|
||||
try {
|
||||
val response = api.getChargepoints(
|
||||
bounds.southwest.latitude,
|
||||
bounds.southwest.longitude,
|
||||
bounds.northeast.latitude,
|
||||
bounds.northeast.longitude,
|
||||
clustering = useGeClustering,
|
||||
zoom = zoom,
|
||||
clusterDistance = clusterDistance,
|
||||
freecharging = freecharging,
|
||||
minPower = minPower,
|
||||
freeparking = freeparking,
|
||||
plugs = connectors,
|
||||
chargecards = chargeCards,
|
||||
networks = networks,
|
||||
startkey = startkey
|
||||
)
|
||||
if (!response.isSuccessful || response.body()!!.status != "ok") {
|
||||
return Resource.error(response.message(), chargepoints.value?.data)
|
||||
} else {
|
||||
val body = response.body()!!
|
||||
data.addAll(body.chargelocations)
|
||||
startkey = body.startkey
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
return Resource.error(e.message, chargepoints.value?.data)
|
||||
}
|
||||
} while (startkey != null && startkey < 10000)
|
||||
|
||||
|
||||
@@ -30,7 +30,9 @@
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardCornerRadius="@dimen/detail_corner_radius"
|
||||
android:layout_marginBottom="@dimen/detail_corner_radius_negative"
|
||||
android:paddingBottom="@dimen/detail_corner_radius"
|
||||
app:cardElevation="6dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
||||
@@ -80,11 +80,11 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:dayOfWeek="@{DayOfWeek.MONDAY}"
|
||||
app:goneUnless="@{expandToggle.checked}"
|
||||
app:hours="@{item.hoursDays}"
|
||||
app:dayOfWeek="@{DayOfWeek.MONDAY}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView8"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView9"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView8" />
|
||||
|
||||
<include
|
||||
@@ -98,7 +98,7 @@
|
||||
app:dayOfWeek="@{DayOfWeek.TUESDAY}"
|
||||
app:hours="@{item.hoursDays}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView8"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView9"
|
||||
app:layout_constraintTop_toBottomOf="@id/hours_mon" />
|
||||
|
||||
<include
|
||||
@@ -112,7 +112,7 @@
|
||||
app:dayOfWeek="@{DayOfWeek.WEDNESDAY}"
|
||||
app:hours="@{item.hoursDays}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView8"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView9"
|
||||
app:layout_constraintTop_toBottomOf="@id/hours_tue" />
|
||||
|
||||
<include
|
||||
@@ -126,7 +126,7 @@
|
||||
app:dayOfWeek="@{DayOfWeek.THURSDAY}"
|
||||
app:hours="@{item.hoursDays}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView8"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView9"
|
||||
app:layout_constraintTop_toBottomOf="@id/hours_wed" />
|
||||
|
||||
<include
|
||||
@@ -140,7 +140,7 @@
|
||||
app:dayOfWeek="@{DayOfWeek.FRIDAY}"
|
||||
app:hours="@{item.hoursDays}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView8"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView9"
|
||||
app:layout_constraintTop_toBottomOf="@id/hours_thu" />
|
||||
|
||||
<include
|
||||
@@ -154,7 +154,7 @@
|
||||
app:dayOfWeek="@{DayOfWeek.SATURDAY}"
|
||||
app:hours="@{item.hoursDays}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView8"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView9"
|
||||
app:layout_constraintTop_toBottomOf="@id/hours_fri" />
|
||||
|
||||
<include
|
||||
@@ -168,7 +168,7 @@
|
||||
app:dayOfWeek="@{DayOfWeek.SUNDAY}"
|
||||
app:hours="@{item.hoursDays}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView8"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView9"
|
||||
app:layout_constraintTop_toBottomOf="@id/hours_sat" />
|
||||
|
||||
<include
|
||||
@@ -184,19 +184,19 @@
|
||||
app:hours="@{item.hoursDays}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView8"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView9"
|
||||
app:layout_constraintTop_toBottomOf="@id/hours_sun" />
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/expandToggle"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginTop="@{item.detailText != null ? @dimen/expand_toggle_padding_large : @dimen/expand_toggle_padding_small}"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:background="@drawable/expand_toggle"
|
||||
android:onClick="@{() -> TransitionManager.beginDelayedTransition(container)}"
|
||||
android:textOff=""
|
||||
android:textOn=""
|
||||
android:onClick="@{() -> TransitionManager.beginDelayedTransition(container)}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
@@ -92,4 +92,6 @@
|
||||
<string name="ok">OK</string>
|
||||
<string name="pref_language">Sprache</string>
|
||||
<string name="pref_language_summary">App-Sprache ändern</string>
|
||||
<string name="connection_error">Ladesäulen konnten nicht geladen werden</string>
|
||||
<string name="retry">Wiederholen</string>
|
||||
</resources>
|
||||
@@ -3,4 +3,8 @@
|
||||
<dimen name="peek_height">72dp</dimen>
|
||||
<dimen name="gallery_height">200dp</dimen>
|
||||
<dimen name="gallery_height_with_margin">208dp</dimen>
|
||||
<dimen name="detail_corner_radius">8dp</dimen>
|
||||
<dimen name="detail_corner_radius_negative">-8dp</dimen>
|
||||
<dimen name="expand_toggle_padding_large">16dp</dimen>
|
||||
<dimen name="expand_toggle_padding_small">8dp</dimen>
|
||||
</resources>
|
||||
@@ -91,4 +91,6 @@
|
||||
<string name="ok">OK</string>
|
||||
<string name="pref_language">Language</string>
|
||||
<string name="pref_language_summary">Change the app language</string>
|
||||
<string name="connection_error">Could not load charging stations</string>
|
||||
<string name="retry">Retry</string>
|
||||
</resources>
|
||||
|
||||
16
app/src/test/java/net/vonforst/evmap/TestUtils.kt
Normal file
16
app/src/test/java/net/vonforst/evmap/TestUtils.kt
Normal file
@@ -0,0 +1,16 @@
|
||||
package net.vonforst.evmap
|
||||
|
||||
import net.vonforst.evmap.api.goingelectric.GoingElectricApiTest
|
||||
import okhttp3.mockwebserver.MockResponse
|
||||
import java.net.HttpURLConnection
|
||||
|
||||
val notFoundResponse: MockResponse =
|
||||
MockResponse().setResponseCode(HttpURLConnection.HTTP_NOT_FOUND)
|
||||
|
||||
fun okResponse(file: String): MockResponse {
|
||||
val body = readResource(file) ?: return notFoundResponse
|
||||
return MockResponse().setResponseCode(HttpURLConnection.HTTP_OK).setBody(body)
|
||||
}
|
||||
|
||||
private fun readResource(s: String) =
|
||||
GoingElectricApiTest::class.java.getResource(s)?.readText()
|
||||
@@ -4,6 +4,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import net.vonforst.evmap.api.goingelectric.ChargeLocation
|
||||
import net.vonforst.evmap.api.goingelectric.GoingElectricApi
|
||||
import net.vonforst.evmap.okResponse
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.mockwebserver.Dispatcher
|
||||
import okhttp3.mockwebserver.MockResponse
|
||||
@@ -37,9 +38,7 @@ class NewMotionAvailabilityDetectorTest {
|
||||
when (urlHead) {
|
||||
"ge/chargepoints" -> {
|
||||
val id = request.requestUrl.queryParameter("ge_id")
|
||||
val body = readResource("/chargers/$id.json") ?: return notFoundResponse
|
||||
return MockResponse().setResponseCode(HttpURLConnection.HTTP_OK)
|
||||
.setBody(body)
|
||||
return okResponse("/chargers/$id.json")
|
||||
}
|
||||
"nm/markers" -> {
|
||||
val urlTail = segments.subList(2, segments.size).joinToString("/")
|
||||
@@ -48,16 +47,11 @@ class NewMotionAvailabilityDetectorTest {
|
||||
"9.444284/9.644283999999999/54.376699/54.576699000000005" -> 18284
|
||||
else -> -1
|
||||
}
|
||||
val body =
|
||||
readResource("/newmotion/$id/markers.json") ?: return notFoundResponse
|
||||
return MockResponse().setResponseCode(HttpURLConnection.HTTP_OK)
|
||||
.setBody(body)
|
||||
return okResponse("/newmotion/$id/markers.json")
|
||||
}
|
||||
"nm/locations" -> {
|
||||
val id = segments.last()
|
||||
val body = readResource("/newmotion/$id.json") ?: return notFoundResponse
|
||||
return MockResponse().setResponseCode(HttpURLConnection.HTTP_OK)
|
||||
.setBody(body)
|
||||
return okResponse("/newmotion/$id.json")
|
||||
}
|
||||
else -> return notFoundResponse
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package net.vonforst.evmap.api.goingelectric
|
||||
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import net.vonforst.evmap.notFoundResponse
|
||||
import net.vonforst.evmap.okResponse
|
||||
import okhttp3.mockwebserver.Dispatcher
|
||||
import okhttp3.mockwebserver.MockResponse
|
||||
import okhttp3.mockwebserver.MockWebServer
|
||||
import okhttp3.mockwebserver.RecordedRequest
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class GoingElectricApiTest {
|
||||
val api: GoingElectricApi
|
||||
val webServer = MockWebServer()
|
||||
|
||||
init {
|
||||
webServer.start()
|
||||
|
||||
val apikey = ""
|
||||
val baseurl = webServer.url("/ge/").toString()
|
||||
api = GoingElectricApi.create(apikey, baseurl)
|
||||
|
||||
webServer.dispatcher = object : Dispatcher() {
|
||||
override fun dispatch(request: RecordedRequest): MockResponse {
|
||||
val segments = request.requestUrl.pathSegments()
|
||||
val urlHead = segments.subList(0, 2).joinToString("/")
|
||||
when (urlHead) {
|
||||
"ge/chargepoints" -> {
|
||||
val id = request.requestUrl.queryParameter("ge_id")
|
||||
if (id != null) {
|
||||
return okResponse("/chargers/$id.json")
|
||||
} else {
|
||||
val freeparking =
|
||||
request.requestUrl.queryParameter("freeparking")!!.toBoolean()
|
||||
val freecharging =
|
||||
request.requestUrl.queryParameter("freecharging")!!.toBoolean()
|
||||
return if (freeparking && freecharging) {
|
||||
okResponse("/chargers/list-empty.json")
|
||||
} else if (freecharging) {
|
||||
okResponse("/chargers/list.json")
|
||||
} else {
|
||||
okResponse("/chargers/list-startkey.json")
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> return notFoundResponse
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLoadChargepointDetail() {
|
||||
val response = api.getChargepointDetail(2105).execute()
|
||||
assertTrue(response.isSuccessful)
|
||||
val body = response.body()!!
|
||||
assertEquals("ok", body.status)
|
||||
assertEquals(null, body.startkey)
|
||||
assertEquals(1, body.chargelocations.size)
|
||||
val charger = body.chargelocations[0] as ChargeLocation
|
||||
assertEquals(2105, charger.id)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLoadChargepointList() {
|
||||
val response = runBlocking {
|
||||
api.getChargepoints(1.0, 1.0, 2.0, 2.0, 11f, freecharging = true)
|
||||
}
|
||||
assertTrue(response.isSuccessful)
|
||||
val body = response.body()!!
|
||||
assertEquals("ok", body.status)
|
||||
assertEquals(null, body.startkey)
|
||||
assertEquals(2, body.chargelocations.size)
|
||||
val charger = body.chargelocations[0] as ChargeLocation
|
||||
assertEquals(41161, charger.id)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLoadChargepointListEmpty() {
|
||||
val response = runBlocking {
|
||||
api.getChargepoints(1.0, 1.0, 2.0, 2.0, 11f, freeparking = true, freecharging = true)
|
||||
}
|
||||
assertTrue(response.isSuccessful)
|
||||
val body = response.body()!!
|
||||
assertEquals("ok", body.status)
|
||||
assertEquals(null, body.startkey)
|
||||
assertEquals(0, body.chargelocations.size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLoadChargepointListStartkey() {
|
||||
val response = runBlocking {
|
||||
api.getChargepoints(1.0, 1.0, 2.0, 2.0, 1f)
|
||||
}
|
||||
assertTrue(response.isSuccessful)
|
||||
val body = response.body()!!
|
||||
assertEquals("ok", body.status)
|
||||
assertEquals(2, body.startkey)
|
||||
assertEquals(2, body.chargelocations.size)
|
||||
val charger = body.chargelocations[0] as ChargeLocation
|
||||
assertEquals(41161, charger.id)
|
||||
}
|
||||
}
|
||||
5
app/src/test/resources/chargers/list-empty.json
Normal file
5
app/src/test/resources/chargers/list-empty.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"status": "ok",
|
||||
"startkey": false,
|
||||
"chargelocations": []
|
||||
}
|
||||
61
app/src/test/resources/chargers/list-startkey.json
Normal file
61
app/src/test/resources/chargers/list-startkey.json
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"status": "ok",
|
||||
"chargelocations": [
|
||||
{
|
||||
"chargepoints": [
|
||||
{
|
||||
"type": "Typ2",
|
||||
"power": 22,
|
||||
"count": 2
|
||||
}
|
||||
],
|
||||
"ge_id": 41161,
|
||||
"name": "BMW Autohaus B&K",
|
||||
"address": {
|
||||
"city": "Hamburg",
|
||||
"country": "Deutschland",
|
||||
"postcode": "21073",
|
||||
"street": "Buxtehuder Straße 112"
|
||||
},
|
||||
"coordinates": {
|
||||
"lat": 53.469542,
|
||||
"lng": 9.964063
|
||||
},
|
||||
"network": "Digital Energy Solutions",
|
||||
"url": "//www.goingelectric.de/stromtankstellen/Deutschland/Hamburg/BMW-Autohaus-B-K-Buxtehuder-Strasse-112/41161/",
|
||||
"fault_report": false,
|
||||
"verified": false
|
||||
},
|
||||
{
|
||||
"chargepoints": [
|
||||
{
|
||||
"type": "Typ2",
|
||||
"power": 22,
|
||||
"count": 2
|
||||
},
|
||||
{
|
||||
"type": "Schuko",
|
||||
"power": 3.6,
|
||||
"count": 2
|
||||
}
|
||||
],
|
||||
"ge_id": 41226,
|
||||
"name": "Saseler Chaussee",
|
||||
"address": {
|
||||
"city": "Hamburg",
|
||||
"country": "Deutschland",
|
||||
"postcode": "22393",
|
||||
"street": "Saseler Chaussee 94a"
|
||||
},
|
||||
"coordinates": {
|
||||
"lat": 53.644021,
|
||||
"lng": 10.099783
|
||||
},
|
||||
"network": "Stromnetz Hamburg",
|
||||
"url": "//www.goingelectric.de/stromtankstellen/Deutschland/Hamburg/Saseler-Chaussee-Saseler-Chaussee-94a/41226/",
|
||||
"fault_report": false,
|
||||
"verified": false
|
||||
}
|
||||
],
|
||||
"startkey": 2
|
||||
}
|
||||
60
app/src/test/resources/chargers/list.json
Normal file
60
app/src/test/resources/chargers/list.json
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"status": "ok",
|
||||
"chargelocations": [
|
||||
{
|
||||
"chargepoints": [
|
||||
{
|
||||
"type": "Typ2",
|
||||
"power": 22,
|
||||
"count": 2
|
||||
}
|
||||
],
|
||||
"ge_id": 41161,
|
||||
"name": "BMW Autohaus B&K",
|
||||
"address": {
|
||||
"city": "Hamburg",
|
||||
"country": "Deutschland",
|
||||
"postcode": "21073",
|
||||
"street": "Buxtehuder Straße 112"
|
||||
},
|
||||
"coordinates": {
|
||||
"lat": 53.469542,
|
||||
"lng": 9.964063
|
||||
},
|
||||
"network": "Digital Energy Solutions",
|
||||
"url": "//www.goingelectric.de/stromtankstellen/Deutschland/Hamburg/BMW-Autohaus-B-K-Buxtehuder-Strasse-112/41161/",
|
||||
"fault_report": false,
|
||||
"verified": false
|
||||
},
|
||||
{
|
||||
"chargepoints": [
|
||||
{
|
||||
"type": "Typ2",
|
||||
"power": 22,
|
||||
"count": 2
|
||||
},
|
||||
{
|
||||
"type": "Schuko",
|
||||
"power": 3.6,
|
||||
"count": 2
|
||||
}
|
||||
],
|
||||
"ge_id": 41226,
|
||||
"name": "Saseler Chaussee",
|
||||
"address": {
|
||||
"city": "Hamburg",
|
||||
"country": "Deutschland",
|
||||
"postcode": "22393",
|
||||
"street": "Saseler Chaussee 94a"
|
||||
},
|
||||
"coordinates": {
|
||||
"lat": 53.644021,
|
||||
"lng": 10.099783
|
||||
},
|
||||
"network": "Stromnetz Hamburg",
|
||||
"url": "//www.goingelectric.de/stromtankstellen/Deutschland/Hamburg/Saseler-Chaussee-Saseler-Chaussee-94a/41226/",
|
||||
"fault_report": false,
|
||||
"verified": false
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user