package com.qiuguo.iot.third.service;

import com.qiuguo.iot.data.resp.third.ThirdIpInfoResp;
import com.qiuguo.iot.data.resp.third.ThirdRpcResp;
import org.junit.jupiter.api.Test;
import org.springframework.beans.BeanUtils;
import org.springframework.boot.test.context.SpringBootTest;
import reactor.core.publisher.Mono;

import javax.annotation.Resource;

import static org.junit.jupiter.api.Assertions.*;

/**
 * @author simon
 * @date 2023/9/21
 * @description
 **/

@SpringBootTest(classes = IpService.class)
class IpServiceTest {
   @Resource
   private IpService ipService;

   @Test
   void contextLoads() throws InterruptedException {
      Mono<ThirdRpcResp<ThirdIpInfoResp>> ipInfo = ipService.getIpInfo("60.186.105.204");
      System.out.println("contextLoads");

      Mono<ThirdRpcResp<ThirdIpInfoResp>> thirdRpcRespMono = ipInfo.flatMap(resp -> {
         System.out.println(resp.getData().getCity());
         return Mono.just(resp);
      });

      thirdRpcRespMono.subscribe(System.out::println);
      Thread.sleep(20000);

      // StepVerifier.create(ipInfo)
      //         //.expectNext("Hello, World!") // 验证预期的输出值
      //         //.expectNext()
      //         .expectComplete() // 验证是否正常完成
      //         .verify(); // 执行验证
      System.out.println("contextLoads");
   }
}