// Path: android-networking/src/main/java/com/androidnetworking/common/ANConstants.java
// public final class ANConstants {
//     public static final int MAX_CACHE_SIZE = 10 * 1024 * 1024;
//     public static final int UPDATE = 0x01;
//     public static final String CACHE_DIR_NAME = "cache_an";
//     public static final String CONNECTION_ERROR = "connectionError";
//     public static final String RESPONSE_FROM_SERVER_ERROR = "responseFromServerError";
//     public static final String REQUEST_CANCELLED_ERROR = "requestCancelledError";
//     public static final String PARSE_ERROR = "parseError";
//     public static final String PREFETCH = "prefetch";
//     public static final String FAST_ANDROID_NETWORKING = "FastAndroidNetworking";
//     public static final String USER_AGENT = "User-Agent";
//     public static final String SUCCESS = "success";
//     public static final String OPTIONS = "OPTIONS";
// }


import android.app.Application;
import android.test.ApplicationTestCase;
import com.androidnetworking.common.ANConstants;
import com.androidnetworking.error.ANError;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Rule;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import io.reactivex.Observer;
import io.reactivex.SingleObserver;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import static java.util.concurrent.TimeUnit.SECONDS;
                .addMultipartParameter("key", "value")
                .build()
                .getJSONObjectSingle()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new SingleObserver<JSONObject>() {
                    @Override
                    public void onSubscribe(@NonNull Disposable disposable) {
                        isSubscribedRef.set(true);
                    }

                    @Override
                    public void onSuccess(@NonNull JSONObject jsonObject) {
                        assertTrue(false);
                    }

                    @Override
                    public void onError(@NonNull Throwable e) {
                        ANError anError = (ANError) e;
                        errorBodyRef.set(anError.getErrorBody());
                        errorDetailRef.set(anError.getErrorDetail());
                        errorCodeRef.set(anError.getErrorCode());
                        latch.countDown();
                    }
                });

        assertTrue(latch.await(2, SECONDS));

        assertTrue(isSubscribedRef.get());

// Path: android-networking/src/main/java/com/androidnetworking/common/ANConstants.java
// public final class ANConstants {
//     public static final int MAX_CACHE_SIZE = 10 * 1024 * 1024;
//     public static final int UPDATE = 0x01;
//     public static final String CACHE_DIR_NAME = "cache_an";
//     public static final String CONNECTION_ERROR = "connectionError";
//     public static final String RESPONSE_FROM_SERVER_ERROR = "responseFromServerError";
//     public static final String REQUEST_CANCELLED_ERROR = "requestCancelledError";
//     public static final String PARSE_ERROR = "parseError";
//     public static final String PREFETCH = "prefetch";
//     public static final String FAST_ANDROID_NETWORKING = "FastAndroidNetworking";
//     public static final String USER_AGENT = "User-Agent";
//     public static final String SUCCESS = "success";
//     public static final String OPTIONS = "OPTIONS";
// }


// Path: rx2-android-networking/src/androidTest/java/com/rx2androidnetworking/Rx2MultipartJSONApiTest.java
import android.app.Application;
import android.test.ApplicationTestCase;
import com.androidnetworking.common.ANConstants;
import com.androidnetworking.error.ANError;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Rule;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import io.reactivex.Observer;
import io.reactivex.SingleObserver;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import static java.util.concurrent.TimeUnit.SECONDS;

                .addMultipartParameter("key", "value")
                .build()
                .getJSONObjectSingle()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new SingleObserver<JSONObject>() {
                    @Override
                    public void onSubscribe(@NonNull Disposable disposable) {
                        isSubscribedRef.set(true);
                    }

                    @Override
                    public void onSuccess(@NonNull JSONObject jsonObject) {
                        assertTrue(false);
                    }

                    @Override
                    public void onError(@NonNull Throwable e) {
                        ANError anError = (ANError) e;
                        errorBodyRef.set(anError.getErrorBody());
                        errorDetailRef.set(anError.getErrorDetail());
                        errorCodeRef.set(anError.getErrorCode());
                        latch.countDown();
                    }
                });

        assertTrue(latch.await(2, SECONDS));

        assertTrue(isSubscribedRef.get());

        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());