Made Nearby show all pins that could be presented on the screen, rather than a circle (#5553)

* Changed nearby from circle to rectangle

* Fixed bug

* Removed MAPBOX Token

* Fixed minor issues

* Fixed minor issues

* Changed query files

* Changed monuments query file

* Fixed Unit Tests

* Fixed failing tests

* Fixed errors due to merging
This commit is contained in:
Kanahia 2024-03-24 19:54:39 +05:30 committed by GitHub
parent f404ac9b47
commit 724e4db0fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 576 additions and 219 deletions

View file

@ -62,7 +62,8 @@ class OkHttpJsonApiClientTests {
fun testGetNearbyPlacesCustomQuery() {
Mockito.`when`(response.message).thenReturn("test")
try {
okHttpJsonApiClient.getNearbyPlaces(latLng, "test", 10.0, true, "test")
okHttpJsonApiClient.getNearbyPlaces(latLng, "test", 10.0, "test")
okHttpJsonApiClient.getNearbyPlaces(latLng, latLng, "test", true, "test")
} catch (e: Exception) {
assert(e.message.equals("test"))
}
@ -75,7 +76,8 @@ class OkHttpJsonApiClientTests {
fun testGetNearbyPlaces() {
Mockito.`when`(response.message).thenReturn("test")
try {
okHttpJsonApiClient.getNearbyPlaces(latLng, "test", 10.0, true)
okHttpJsonApiClient.getNearbyPlaces(latLng, "test", 10.0, null)
okHttpJsonApiClient.getNearbyPlaces(latLng, latLng, "test", true, null)
} catch (e: Exception) {
assert(e.message.equals("test"))
}

View file

@ -35,6 +35,12 @@ class NearbyControllerTest {
@Mock
private lateinit var nearbyPlaces: NearbyPlaces
@Mock
private lateinit var screenTopRight: LatLng
@Mock
private lateinit var screenBottomLeft: LatLng
@Mock
private lateinit var searchLatLong: LatLng
@ -56,41 +62,48 @@ class NearbyControllerTest {
@Test
fun testLoadAttractionsForLocationTest() {
`when`(nearbyPlaces.radiusExpander(any(), any(), any(), any(), any()))
`when`(nearbyPlaces.radiusExpander(any(), any(), any(), any()))
.thenReturn(Collections.emptyList())
nearbyController.loadAttractionsFromLocation(
searchLatLong,
currentLatLng,
false,
searchLatLong,
false,
true,
customQuery
)
nearbyController.loadAttractionsFromLocation(
currentLatLng,
screenTopRight,
screenBottomLeft,
searchLatLong,
false,
true,
false,
customQuery
)
Mockito.verify(nearbyPlaces).radiusExpander(
eq(currentLatLng),
eq(searchLatLong),
any(String::class.java),
eq(false),
eq(true),
eq(customQuery)
)
}
@Test
fun testLoadAttractionsForLocationTestNoQuery() {
`when`(nearbyPlaces.radiusExpander(any(), any(), any(), any(), anyOrNull()))
`when`(nearbyPlaces.radiusExpander(any(), any(), any(), anyOrNull()))
.thenReturn(Collections.emptyList())
nearbyController.loadAttractionsFromLocation(
searchLatLong,
currentLatLng,
searchLatLong,
false,
false,
true
true,
null
)
Mockito.verify(nearbyPlaces).radiusExpander(
eq(currentLatLng),
eq(searchLatLong),
any(String::class.java),
eq(false),
eq(true),
eq(null)
)
}
@ -102,8 +115,7 @@ class NearbyControllerTest {
currentLatLng,
null,
false,
false,
false,
true,
customQuery
), null
)
@ -136,7 +148,7 @@ class NearbyControllerTest {
`when`(
nearbyPlaces.radiusExpander(
searchLatLong, Locale.getDefault().language, false,
false, customQuery
customQuery
)
).thenReturn(mutableListOf(place1, place2))
val result = nearbyController.loadAttractionsFromLocation(
@ -144,6 +156,15 @@ class NearbyControllerTest {
searchLatLong,
false,
true,
customQuery
)
nearbyController.loadAttractionsFromLocation(
currentLatLng,
screenTopRight,
screenBottomLeft,
searchLatLong,
false,
true,
false,
customQuery
)
@ -178,7 +199,7 @@ class NearbyControllerTest {
`when`(
nearbyPlaces.radiusExpander(
searchLatLong, Locale.getDefault().language, false,
false, customQuery
customQuery
)
).thenReturn(mutableListOf(place1, place2))
val result = nearbyController.loadAttractionsFromLocation(
@ -186,7 +207,6 @@ class NearbyControllerTest {
searchLatLong,
false,
true,
false,
customQuery
)
assertEquals(result.curLatLng, currentLatLng)
@ -220,7 +240,7 @@ class NearbyControllerTest {
`when`(
nearbyPlaces.radiusExpander(
searchLatLong, Locale.getDefault().language, false,
false, customQuery
customQuery
)
).thenReturn(mutableListOf(place1, place2))
val result = nearbyController.loadAttractionsFromLocation(
@ -228,7 +248,6 @@ class NearbyControllerTest {
searchLatLong,
false,
true,
false,
customQuery
)
assertEquals(result.curLatLng, currentLatLng)

View file

@ -28,12 +28,11 @@ class NearbyPlacesTest {
@Test
fun testRadiusExpander() {
nearbyPlaces.radiusExpander(currentLatLong, "test", true, true, "test")
nearbyPlaces.radiusExpander(currentLatLong, "test", true, "test")
verify(okHttpJsonApiClient, times(5)).getNearbyPlaces(
eq(currentLatLong),
eq("test"),
any(),
eq(true),
eq("test")
)
}

View file

@ -217,8 +217,10 @@ class UploadRepositoryUnitTest {
@Test
fun testSetSelectedExistingDepictions() {
assertEquals(repository.setSelectedExistingDepictions(listOf("")),
uploadModel.setSelectedExistingDepictions(listOf("")))
assertEquals(
repository.setSelectedExistingDepictions(listOf("")),
uploadModel.setSelectedExistingDepictions(listOf(""))
)
}
@Test
@ -264,7 +266,7 @@ class UploadRepositoryUnitTest {
nearbyPlaces.getFromWikidataQuery(
LatLng(0.0, 0.0, 0.0f),
java.util.Locale.getDefault().language, 0.1,
false, null
null
)
).thenReturn(listOf(place))
assertEquals(
@ -287,7 +289,7 @@ class UploadRepositoryUnitTest {
nearbyPlaces.getFromWikidataQuery(
LatLng(0.0, 0.0, 0.0f),
java.util.Locale.getDefault().language, 0.1,
false, null
null
)
).thenThrow(Exception())
assertEquals(
@ -348,19 +350,25 @@ class UploadRepositoryUnitTest {
@Test
fun testGetSelectedExistingCategories() {
assertEquals(repository.selectedExistingCategories,
categoriesModel.getSelectedExistingCategories())
assertEquals(
repository.selectedExistingCategories,
categoriesModel.getSelectedExistingCategories()
)
}
@Test
fun testSetSelectedExistingCategories() {
assertEquals(repository.setSelectedExistingCategories(listOf("Test")),
categoriesModel.setSelectedExistingCategories(mutableListOf("Test")))
assertEquals(
repository.setSelectedExistingCategories(listOf("Test")),
categoriesModel.setSelectedExistingCategories(mutableListOf("Test"))
)
}
@Test
fun testGetCategories() {
assertEquals(repository.getCategories(listOf("Test")),
categoriesModel.getCategoriesByName(mutableListOf("Test")))
assertEquals(
repository.getCategories(listOf("Test")),
categoriesModel.getCategoriesByName(mutableListOf("Test"))
)
}
}