/*
 * @Author: Kane
 * 
 * @Date: 2025-03-11 09:27:40
 * 
 * @LastEditors: Kane
 * 
 * @FilePath: /cpicxim-XMNHSA-repeater/src/test/java/com/cpic/xim/huixiabao/AppTest.java
 * 
 * @Description:
 *
 * Copyright (c) ${2023} by Kane, All Rights Reserved.
 */
package com.cpic.xim.huixiabao;

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

import java.util.Vector;

import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.cpic.xim.huixiabao.data.pojo.HmbXyxInfo;
import com.cpic.xim.huixiabao.nhs.CpicximToXMNHS;

import cn.hsa.zephyr.apisdk.DefaultZephyrClient;
import cn.hsa.zephyr.apisdk.internal.exception.ZephyrApiException;
import cn.hsa.zephyr.apisdk.internal.util.encrypt.EncryptionModeEnum;
import cn.hsa.zephyr.apisdk.internal.util.encrypt.SignTypeEnum;
import cn.hsa.zephyr.apisdk.request.DefaultZephyrRequest;
import cn.hsa.zephyr.apisdk.response.DefaultZephyrResponse;


/**
 * Unit test for simple App.
 */
public class AppTest
{
    private Logger logger = LoggerFactory.getLogger( AppTest.class );

    /**
     * Rigorous Test :-)
     */
    @Test
    public void shouldAnswerWithTrue()
    {
        assertTrue( true );
    }

    @Test
    public void testLog()
    {
        for (
              int i = 0;
              i < 10000;
              i++
        )
        {
            // System.out.print("test!");
            logger.error( "test!!!!" );
        }
    }

    @Test
    public void nhsTest()
    {
        String url       = "172.18.1.150:9040";
        String appId     = "待定";
        String appSecret = "待定";
        String funId     = "xxx";
        String encKey    = "A5B6E00DA599G56C41ABFE23A74E6E60";
        String signKey   = "待定";

        SignTypeEnum       signType = SignTypeEnum.SM3;
        EncryptionModeEnum encType  = EncryptionModeEnum.SM4;

        try
        {
            DefaultZephyrClient client = new DefaultZephyrClient( url,
                                                                  funId,
                                                                  appId,
                                                                  appSecret,
                                                                  signType,
                                                                  signKey,
                                                                  encType,
                                                                  encKey );

            DefaultZephyrRequest  req         = new DefaultZephyrRequest();
            JSONObject            jsonObject1 = new JSONObject();
            DefaultZephyrResponse resp        = null;

            jsonObject1.put( "code", "XXXXXXXXXXXXXXXXXX" );
            jsonObject1.put( "scene_code", "XXX" );

            req.setData( jsonObject1 );
            resp = client.execute( req );

            System.out.println( resp.getData() );
        }
        catch ( ZephyrApiException e )
        {
            e.printStackTrace();
        }
    }

    @Test
    public void jsonTest()
    {
        JSONObject requestObject = new JSONObject();
        JSONObject item          = new JSONObject();
        JSONArray  hmbList       = new JSONArray();

        requestObject.put( "topic", "hmbXyxInfo" );
        requestObject.put( "hmbList", hmbList );

        item.put( "psnName", "王炜" );
        item.put( "cerno", "350402198106130016" );
        item.put( "serviceId", "100007" );
        item.put( "status", "1" );
        item.put( "xyxNo", "1234567" );

        hmbList.add( item );

        String json = requestObject.toJSONString();

        System.out.println( json );
    }

    @Test
    public void testMysql()
    { 
        Vector<HmbXyxInfo> items = CpicximToXMNHS.getNeverTransHmbList();

        System.out.println( items.toString() );

        assert( items.size() > 0 );
    }
}
