package com.iailab.sdk; import com.iailab.sdk.auth.client.IailabAuthClient; import com.iailab.sdk.auth.client.dto.ApiDataQueryDTO; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * {@link IailabClientTest} 的单元测试 * * @author iailab */ @RunWith(SpringRunner.class) @SpringBootTest public class IailabClientTest { @Test public void testLogin() { IailabAuthClient.authenticate(); } @Test public void testRefreshToken() throws Exception { // 准备参数 IailabAuthClient.refreshToken(); } @Test public void testDoHttp() throws Exception { Map params = new HashMap(); List itemNos = new ArrayList(); params.put("start", "2024-06-11 07:24:00"); params.put("end", "2024-06-13 00:00:00"); itemNos.add("P0000100010"); params.put("itemNos", itemNos); // 准备参数 String s = IailabAuthClient.doHttp("POST", "http://172.16.8.100/admin-api/data/api/query-plans/chart", params); System.out.println(s); } @Test public void testQueryPlanChart() throws Exception { ApiDataQueryDTO apiDataQueryDTO = new ApiDataQueryDTO(); List itemNos = new ArrayList<>(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); apiDataQueryDTO.setStart(sdf.parse("2024-06-11 07:24:00")); apiDataQueryDTO.setEnd(sdf.parse("2024-06-13 00:00:00")); itemNos.add("P0000100010"); apiDataQueryDTO.setItemNos(itemNos); Map stringObjectMap = IailabAuthClient.getInstance().queryPlanChart(apiDataQueryDTO); System.out.println(stringObjectMap); } @Test public void testQueryPointsRealValue() throws Exception { List pointNos = new ArrayList<>(); pointNos.add("111"); Map stringObjectMap = IailabAuthClient.getInstance().queryPointsRealValue(pointNos); System.out.println(stringObjectMap); } }