Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: OONIAPIClientTest using failing API endpoint and incorrect testing logic #784

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ public OONICheckInConfig getOONICheckInConfig() {

public ActivityComponent getActivityComponent() { return component.activityComponent(); }

public OkHttpClient getOkHttpClient() {
return _okHttpClient;
}

public OONIAPIClient getApiClient() {
return _apiClient;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.openobservatory.ooniprobe.client

import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Test
import org.openobservatory.ooniprobe.RobolectricAbstractTest

class OONIAPIClientTest : RobolectricAbstractTest() {

@Test
fun measurementSuccess() {
val response = apiClient.getMeasurement(EXISTING_REPORT_ID, null).execute()

assertTrue(response.isSuccessful)
response.body().use { body ->
assertNotNull(body)
assertNotNull(body!!.string())
}
}

@Test
fun measurementError() {
val response = apiClient.getMeasurement(NON_EXISTING_REPORT_ID, null).execute()

assertFalse(response.isSuccessful)
}

@Test
fun testSelectMeasurementsWithJson() {
val response = apiClient.checkReportId(EXISTING_REPORT_ID).execute()

assertTrue(response.isSuccessful)
with(response.body()) {
assertNotNull(this)
assertTrue(this!!.found)
}
}

private val apiClient get() = a.apiClient

companion object {
private const val EXISTING_REPORT_ID =
"20190113T202156Z_AS327931_CgoC3KbgM6zKajvIIt1AxxybJ1HbjwwWJjsJnlxy9rpcGY54VH"
private const val NON_EXISTING_REPORT_ID = "EMPTY"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@Module
public class TestAppModule extends ApplicationModule {

private static final String CLIENT_URL = "https://ams-pg.ooni.org";
private static final String CLIENT_URL = "https://backend-hel.ooni.org";

public TestAppModule(Application application) {
super(application);
Expand Down
Loading