import com.house365.common.util.RestTemplateBean;
import net.sf.json.JSONObject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.autoconfigure.web.client.RestClientTest;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * Description
 * <p>
 * Created by 365 on 2017/1/3 0003.
 */
@RunWith(SpringRunner.class)
@RestClientTest(RestTemplateBean.class)
@SpringBootTest(classes = RestTest.class)
public class RestTest {


    @Test
    public void getVehicleDetailsWhenResultIsSuccessShouldReturnDetails()
            throws Exception {
//        MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
//        map.add("cropId", "wx107e48645858c81a");
//        map.add("secret", "ewb6MIU7yo1TMOii9k6-A0cT-tkDOWWqbAVaPsVf334CLVcrXXQaSlRu5X8XCFIf");
//
//        RestTemplateBuilder restTemplateBuilder = new RestTemplateBuilder();
//        RestTemplateBean restTemplateBean = new RestTemplateBean(restTemplateBuilder);
//        String result = restTemplateBean.doPostParamter("enterprise/agent/list", map);
//        System.out.println("=========" + result);

        JSONObject map = new JSONObject();
        map.put("cropId", "wx107e48645858c81a");
        map.put("secret", "ewb6MIU7yo1TMOii9k6-A0cT-tkDOWWqbAVaPsVf334CLVcrXXQaSlRu5X8XCFIf");

        RestTemplateBuilder restTemplateBuilder = new RestTemplateBuilder();
        RestTemplateBean restTemplateBean = new RestTemplateBean(restTemplateBuilder);
        String result = restTemplateBean.doPost("127.0.0.1:8089/enterprise/agent/list", map);
        System.out.println("=========" + result);
    }
}
