package com.bxzk.afxj;

import com.bxzk.afxj.retrofit.ApiManager;
import com.bxzk.afxj.retrofit.ModelFilteredFactory;
import com.bxzk.afxj.retrofit.Node;
import com.bxzk.afxj.util.GZipUtil;
import com.bxzk.afxj.util.Log;


import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class TestDemo {

    @Test
    public void compress() {
        byte[] bytes  = "H4sIAAAAAAAAA1M1di5QNTJIzkksLlY1dlE1MirM0U3MyUzP001OzStJLQKKqBq7GhoZIyNVY2dVI7cCoIQqcfqNDI0hAMQjUa+hsRF2uwEMekq0vAAAAA==".getBytes();
        System.out.println(GZipUtil.uncompressToString(bytes));
    }
    @Test
    public void test() {
       double  d = 1/100;
        String str1 = String.format("%.2f", d);
        System.out.println("str1--->"+str1);
    }

    @Test
    public void test1() {
        String str = "";
        int i = Integer.parseInt(str);
        System.out.println("str1--->"+i);
    }

    @Test
    public void test2() {
       /* Map<String, String> map = new HashMap<>();
        map.put("username", "");
        map.put("pwd", "");
        Observable<RequestBody> login = ApiManager.getInstence().getXmlService().login(map);*/

    }

    @Test
    public void test3() {
       /* Map<String, String> map = new HashMap<>();
        map.put("username", "");
        map.put("pwd", "");
        Observable<RequestBody> login = ApiManager.getInstence().getXmlService().login(map);*/
        Observable<RequestBody> login = ApiManager.getInstence().getXmlService().hello();
        Observable<RequestBody> loginWebBeanInObservable = ModelFilteredFactory.simpleCompose2(login);
        loginWebBeanInObservable.subscribe(new Observer<RequestBody>() {
            @Override
            public void onSubscribe(@NonNull Disposable d) {

            }

            @Override
            public void onNext(@NonNull RequestBody loginWebBeanIn) {
                Log.e("");
            }

            @Override
            public void onError(@NonNull Throwable e) {
                Log.e("");

            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Test
    public void test4() {
        Map<String,String> map=new HashMap<>();
        map.put("username",10+"");
        map.put("pwd",1+"");
        String request= Node.getRequestParams("UserLogin",map);
        Observable<ResponseBody> login = ApiManager.getInstence().getXmlService().login(request);
        Observable<ResponseBody> loginWebBeanInObservable = ModelFilteredFactory.simpleCompose2(login);
        loginWebBeanInObservable.subscribe(new Observer<ResponseBody>() {
            @Override
            public void onSubscribe(@NonNull Disposable d) {

            }

            @Override
            public void onNext(@NonNull ResponseBody loginWebBeanIn) {
                Log.e("");
            }

            @Override
            public void onError(@NonNull Throwable e) {
                Log.e("");

            }

            @Override
            public void onComplete() {

            }
        });
    }
    @Test
    public void test6() {
       /* Map<String, String> map = new HashMap<>();
        map.put("username", "");
        map.put("pwd", "");
        Observable<RequestBody> login = ApiManager.getInstence().getXmlService().login(map);*/

      /*  RequestEnvelope beanIn = new RequestEnvelope();
        MyBody body = new MyBody();
        body.setUserLogin(new WebBeanIn1("111","222"));
        beanIn.setBody(body);
                Call<ResponseBody> login = ApiManager.getInstence().getXmlService().login1(beanIn);

        */
        Map<String,String> map=new HashMap<>();
        map.put("username",10+"");
        map.put("pwd",1+"");
        String request= Node.getRequestParams("UserLogin",map);
        Call<ResponseBody> login = ApiManager.getInstence().getXmlService().login1(request);
       login.enqueue(new Callback<ResponseBody>() {
           @Override
           public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
               Log.e("");
           }

           @Override
           public void onFailure(Call<ResponseBody> call, Throwable t) {
               Log.e("");

           }
       });
    }

}
