package com.priusis;

import com.priusis.vo.MqttRpcDataMessage;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.client.RestTemplate;

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

@RunWith(SpringRunner.class)
@SpringBootTest
public class RestTest {

    @Autowired
    private RestTemplate restTemplate;

    @Test
    public void test1() throws Exception {
        // 获取硬件监控配置 params == data
        ResponseEntity<MqttRpcDataMessage> forEntity = restTemplate.getForEntity("http://localhost:8765/rpc_cmd/controll", MqttRpcDataMessage.class);
        System.out.println(forEntity.getBody().getMethod());
        System.out.println(forEntity.getBody().getParams());

        // 上报硬件监控数据
        Map mapRequest = new HashMap();
        Map map = restTemplate.postForObject("http://localhost:8765/uplink/oc-client", mapRequest, Map.class);
        System.out.println(map);
    }
}
