Springboot中自已测试

签到的测试,需要传入日期,签到7天可获得更多的积分,

构造7天前的签到记录,重写签到方法,进行构造数据

 

import cn.com.acxiom.coty.api.ws.bean.dto.PointDetailRequest;
import cn.com.acxiom.coty.api.ws.bean.dto.SignInHisResponse;
import cn.com.acxiom.coty.api.ws.common.ResponseBean;
import cn.com.acxiom.coty.api.ws.service.PEService;
import cn.com.acxiom.coty.api.ws.service.SignInService;
import cn.com.acxiom.point.engine.domain.response.PointQueryDetail;
import com.alibaba.fastjson.JSONArray;
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.test.context.junit4.SpringRunner;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

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

    @Autowired
    PEService peService;


    @Autowired
    SignInService signInService;

    @Test
    //@Async
    public void SignIn() throws Exception {
        peService.sendEvent(500647, "coty.api.ws", "TMALLSIGNIN");
    }




    @Test
    public void CheckPEDetails() throws Exception {

        long dtLong = new Date().getTime();
        System.out.println(dtLong);
            ResponseBean<List<PointQueryDetail>> responseBean = new ResponseBean<List<PointQueryDetail>>();
            PointDetailRequest pointDetailRequest = new PointDetailRequest();
            pointDetailRequest.setEndDate("2019-12-12");
            pointDetailRequest.setPageIndex(0);
            pointDetailRequest.setPageSize(50);
            pointDetailRequest.setStartDate("2019-01-01");
            String social="AcxiomChina";
            String user="VP巴黎恋人";
            String sysName="Jasmine Test";
            String pePointDetailCode= "POINTDETAIL_QUERY";


            List<PointQueryDetail> pointQueryDetails = peService.findPointDetailByUser(social, user, sysName, pePointDetailCode, pointDetailRequest);
            JSONArray jsonArray = (JSONArray) JSONArray.toJSON(pointQueryDetails);
            responseBean.setData(pointQueryDetails);
            System.out.println(jsonArray.toJSONString()); ;


    }


    @Test
    public void Sign(){
        SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        int N =1;
        while(N<25){
        Calendar ca = Calendar.getInstance();//得到一个Calendar的实例
        ca.setTime(new Date()); //设置时间为当前时间
        ca.add(Calendar.DATE, N);
        long time= ca.getTime().getTime();
        System.out.println(sd.format(time));
        String social="AcxiomChina";
        String userId="VP巴黎恋人";

        SignInHisResponse signInHisResponse = signInService.tmallSignInWithTime(userId,social,time);
        System.out.println("signInHisResponse是个啥"+signInHisResponse);
        //JSONArray jsonArray = (JSONArray) JSONArray.toJSON(signInHisResponse);
        //System.out.println(jsonArray.toJSONString());
        N++;
        }


    }


}

  

posted @ 2019-08-29 16:05  巴黎爱工作  阅读(294)  评论(0编辑  收藏  举报