///*
// * Copyright (c) 京北方信息技术股份有限公司 Corporation 2021 . All rights reserved.
// *
// */
//package net.northking.cctp;
//
//import net.northking.cctp.common.http.ResultWrapper;
//import net.northking.cctp.common.security.SecurityHttpConstants;
//import net.northking.cctp.test.HttpApiTest;
//import net.northking.cctp.test.entity.HttpApiTestCase;
//import net.northking.cctp.test.entity.HttpApiTestSuite;
//import org.junit.Before;
//import org.junit.Test;
//import org.junit.runner.RunWith;
//import org.junit.runners.Parameterized;
//import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
//import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.http.ResponseEntity;
//import org.springframework.test.context.ContextConfiguration;
//import org.springframework.web.client.RestTemplate;
//
//import java.net.URI;
//import java.net.URISyntaxException;
//import java.util.Collection;
//import java.util.HashMap;
//import java.util.Map;
//
//import static net.northking.cctp.common.security.SecurityHttpConstants.HEADER_AUTHENTICATION;
//import static net.northking.cctp.common.security.SecurityHttpConstants.HEADER_AUTHENTICATION_PREFIX;
//
///**
// * Http 接口测试，Excel用例文件解析执行
// *
// * @author : xiusong.xie
// * @version : 1.0
// */
//@RunWith(Parameterized.class)
//@ContextConfiguration
//@SpringBootTest
//@AutoConfigureMockMvc
//public class HttpApiCaseExecutor extends HttpApiTest
//{
//
//  private static String login() throws URISyntaxException
//  {
//    RestTemplate restTemplate = new RestTemplate();
//    String loginUrl = "http://192.168.77.24:8111/security/login";
//    URI uri = new URI(loginUrl);
//    Map<String, Object> postData = new HashMap<>();
//    // TODO 设置登录的用户名和密码
//    postData.put("username", "xiusong.xie");
//    postData.put("password", "123456");
//    ResponseEntity<ResultWrapper> responseEntity = restTemplate.postForEntity(uri, postData, ResultWrapper.class);
//    return responseEntity.getHeaders().getFirst(SecurityHttpConstants.HEADER_AUTHENTICATION);
//  }
//
//  @Parameterized.Parameters
//  public static Collection<HttpApiTestCase> loadTestCase() throws Exception
//  {
//    String token = login();
//
//    HttpApiTestSuite suite = new HttpApiTestSuite();
//    suite.setApiCode("API-001");
//    suite.setUrl("/v1/data-source");
//    suite.setType("POST");
//    suite.setApiMemo("创建数据源");
//    suite.setCaseFile("/datasets/data-source-add.xlsx");
////    suite.setCaseFile("/datasets/data-source-update.xlsx");
//    Map<String, Object> headers = new HashMap<>();
//    headers.put(HEADER_AUTHENTICATION, HEADER_AUTHENTICATION_PREFIX + token);
//    suite.setHeaders(headers);
//    return loadTestCaseExcel(suite);
//  }
//
//  /**
//   * 单元测试参数化的数据对象
//   */
//  @Parameterized.Parameter
//  public HttpApiTestCase httpApiTestCase;
//
//  @Test
//  public void execute() throws Exception
//  {
//    executeTestCase(httpApiTestCase);
//  }
//
//  @Before
//  public void setUp() throws Exception
//  {
//    initTestContextManager();
//  }
//}
