package com.usoft.fin.grpc.service.impl;

import com.usoft.fin.grpc.BaseTest;
import com.usoft.fin.grpc.api.protobuf.GetCreditApplyInfoRequest;
import com.usoft.fin.grpc.api.protobuf.GetCreditApplyInfoResponse;
import com.usoft.fin.grpc.api.protobuf.ICreditGrpcServiceGrpc;
import com.usoft.protobuf.utils.ProtoBufUtil;
import org.junit.Test;
import org.springframework.util.Assert;

/**
 *
 */
public class ICreditGrpcServiceTest extends BaseTest {

	ICreditGrpcServiceGrpc.ICreditGrpcServiceBlockingStub creditGSBS = ICreditGrpcServiceGrpc.newBlockingStub(this.grpcChannel);

	@Test
	public void getCreditInfo() {
		GetCreditApplyInfoRequest.Builder request = GetCreditApplyInfoRequest.newBuilder();
		request.setCode("1");
		GetCreditApplyInfoResponse response = creditGSBS.getCreditApplyInfo(request.build());
		Assert.isTrue(response.getResponseHeader().getCode() == 0, response.getResponseHeader().getMsg());
		System.out.println("------返回结果--------");
		System.out.println(ProtoBufUtil.toJSONHasTryCatch(response));
	}

//	@Test
//	public void insertUserInfo() {
//		InsertUserInfoRequest.Builder request = InsertUserInfoRequest.newBuilder();
//		UserInfo.Builder userInfo = UserInfo.newBuilder();
//		userInfo.setCode("333336");
//		userInfo.setName("mmm");
//		userInfo.setAge(11);
//		userInfo.setAmount(1.22);
//		userInfo.setGender(1);
//		userInfo.setBirthday("2018-07-10 20:20:20");
//		request.setUserInfo(userInfo);
//		InsertUserInfoResponse response = iegUserServiceBlockingStub.insertUserInfo(request.build());
//		Assert.isTrue(response.getResponseHeader().getCode() == 0, response.getResponseHeader().getMsg());
//		System.out.println("------返回结果--------");
//		System.out.println(ProtoBufUtil.toJSONHasTryCatch(response));
//	}
}
