mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-30 14:23:55 +01:00
Move login client out of the data-client (#5476)
This commit is contained in:
parent
8789879f10
commit
0541aacdff
23 changed files with 195 additions and 234 deletions
|
|
@ -1,44 +0,0 @@
|
|||
package org.wikipedia.login;
|
||||
|
||||
import com.google.gson.stream.MalformedJsonException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.wikipedia.dataclient.mwapi.MwQueryResponse;
|
||||
import org.wikipedia.test.MockRetrofitTest;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.observers.TestObserver;
|
||||
|
||||
public class UserExtendedInfoClientTest extends MockRetrofitTest {
|
||||
|
||||
@Test public void testRequestSuccess() throws Throwable {
|
||||
enqueueFromFile("user_extended_info.json");
|
||||
TestObserver<MwQueryResponse> observer = new TestObserver<>();
|
||||
getObservable().subscribe(observer);
|
||||
|
||||
final int id = 24531888;
|
||||
observer.assertComplete().assertNoErrors()
|
||||
.assertValue(result -> result.query().userInfo().id() == id
|
||||
&& result.query().getUserResponse("USER").name().equals("USER"));
|
||||
}
|
||||
|
||||
@Test public void testRequestResponse404() {
|
||||
enqueue404();
|
||||
TestObserver<MwQueryResponse> observer = new TestObserver<>();
|
||||
getObservable().subscribe(observer);
|
||||
|
||||
observer.assertError(Exception.class);
|
||||
}
|
||||
|
||||
@Test public void testRequestResponseMalformed() {
|
||||
enqueueMalformed();
|
||||
TestObserver<MwQueryResponse> observer = new TestObserver<>();
|
||||
getObservable().subscribe(observer);
|
||||
|
||||
observer.assertError(MalformedJsonException.class);
|
||||
}
|
||||
|
||||
private Observable<MwQueryResponse> getObservable() {
|
||||
return getApiService().getUserInfo("USER");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue