package ${domain}.wsvr;

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 org.springframework.transaction.annotation.Transactional;
import ${domain}.frame.auth.Token;
import ${domain}.frame.utils.MapperUtil;
import ${domain}.module.wsvr.mgr.SequenceManager;
import ${domain}.module.wsvr.req.SequenceNextRequest;
import ${domain}.module.wsvr.rsp.SequenceNextResponse;

/**
 * SequenceTest -  - 序列测试用例
 *
 * @author wangbing
 * @version 0.0.1
 * @since 2020-06-25
 */
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class SequenceTest {

    @Autowired
    private Token token;

    @Autowired
    private SequenceManager sequenceManager;

    @Test
    public void testGet() {
        SequenceNextRequest request = new SequenceNextRequest();
        request.setSeqName("测试");
        request.setSeqNote("测试");
        request.setSeqPrefix("CS");
        request.setMaxValue(999);
        request.setByYear(true);
        request.setByMonth(false);
        request.setByDate(false);

        for (int i = 0; i < 1000; i++) {
            SequenceNextResponse response = sequenceManager.next(request, token);
            System.out.println("=================================================================================");
            System.out.println(response.getSequence());
            if (response.hasError()) System.err.println(MapperUtil.toJson(response));
            System.out.println("=================================================================================");
        }
    }
}
