/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved. <a>http://www.crunii.com</a>
 */
package com.crunii.micro.api.test;

import com.crunii.micro.common.constants.RedisKeys;
import com.crunii.micro.common.utils.JsonUtil;
import com.crunii.micro.common.utils.NanoIdUtil;
import com.crunii.micro.domain.repo.main.TsmWorkerRepo;
import com.crunii.micro.service.sysmgr.dto.sysmgr.WorkerInfo;
import com.crunii.micro.service.sysmgr.service.AuthService;
import com.crunii.micro.service.sysmgr.service.LoginService;
import com.crunii.micro.service.sysmgr.service.WorkerService;
import org.junit.Test;
import org.redisson.api.RMapCache;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.concurrent.TimeUnit;

/**
 * @author 田平 create 2018年10月31日上午11:35:01
 */
public class LoginServiceTest extends SysmgrBaseTest {

	@Autowired
	private LoginService loginService;
	@Autowired
	private TsmWorkerRepo tsmWorkerRepo;

	@Autowired
	private AuthService authService;

	@Autowired
	private RedissonClient redisson;
	@Autowired
	private WorkerService workerService;

	 @Test
	public void testRedisson() {
		workerService.doModifyPwd(1,"kh404+++","kh404+++");
	}

	// @Test
	public void testWorker() {
		System.out.println(tsmWorkerRepo.getOne(10000));
	}

	 @Test
	public void mockWebLoginToken() {
		String token = "WEB_lnjpbwxnrwwgijpkzwywbeav";
		RMapCache<String, String> tokenMap = redisson.getMapCache(RedisKeys.TOKEN_WEB_KEY);
		WorkerInfo admin = workerService.getWorkerInfo(9999);
		tokenMap.put(token, JsonUtil.getJsonString(admin), 30, TimeUnit.DAYS);
		System.out.println(token);
	}
}
