| | |
| | | |
| | | import com.ycl.common.util.UtilNumber; |
| | | import com.ycl.enums.common.DictTypeEnum; |
| | | import com.ycl.remote.dto.smoke.*; |
| | | import com.ycl.remote.service.ISmokeDetectionService; |
| | | import com.ycl.service.caseHandler.IBaseCaseService; |
| | | import com.ycl.service.redis.RedisService; |
| | | import com.ycl.utils.MD5Util; |
| | | import com.ycl.utils.redis.RedisKey; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @SpringBootTest |
| | |
| | | |
| | | @Test |
| | | void contextLoads() { |
| | | String msg = baseCaseService.processEvent(3); |
| | | System.out.println("123456a".matches("^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{6,16}$")); |
| | | } |
| | | |
| | | @Test |
| | | void createCode() { |
| | | // LocalDateTime parse = LocalDateTime.parse("2017-02-02 08:59:12", DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss")); |
| | | LocalDateTime ldt = LocalDateTime.parse("2017-02-02 08:44:12", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | System.out.println(ldt); |
| | | String randomKey = "f83bf56491350983146a1e463f46e59d_7318061173768192"; |
| | | String realm = "D62D265605378973"; |
| | | String userName = "suichang"; /// 用户名 |
| | | String password = "a12345677"; /// 该用户的明文密码 |
| | | /// 一共计算五次MD5 |
| | | |
| | | String signature = MD5Util.md5Encrypt(password); |
| | | signature = MD5Util.md5Encrypt(userName + signature); |
| | | signature = MD5Util.md5Encrypt(signature); |
| | | signature = MD5Util.md5Encrypt(userName + ":" + realm + ":" + signature); |
| | | signature = MD5Util.md5Encrypt(signature + ":" + randomKey); |
| | | System.out.println(signature); |
| | | } |
| | | |
| | | @Test |
| | | void enumMapTest(){ |
| | | Map<String,String> s =DictTypeEnum.getAllToMap(); |
| | | void enumMapTest() { |
| | | Map<String, String> s = DictTypeEnum.getAllToMap(); |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | ISmokeDetectionService smokeDetectionService; |
| | | |
| | | @Resource |
| | | private RedisService redisService; |
| | | |
| | | @Test |
| | | void smokeLoginTest() { |
| | | login(); |
| | | } |
| | | |
| | | void login() { |
| | | LoginParamDto loginParamDto = LoginParamDto.builder().username("connect_test2").password("test@234").noCode(true).build(); |
| | | SmokeResultResponseDto<LoginResponseDto> responseDto = smokeDetectionService.loginAction(loginParamDto); |
| | | if (responseDto.getStatus() == 200) { |
| | | System.out.println(responseDto.getData().getToken()); |
| | | redisService.set(RedisKey.SMOKE_TOKEN, responseDto.getData().getToken()); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | void smokeAlarmMsgTest() { |
| | | AlarmMsgParamDto paramDto = AlarmMsgParamDto.builder().StartAt(0).Size(100).build(); |
| | | |
| | | SmokeResultResponseDto<AlarmMsgResponseDto> responseDto = smokeDetectionService.getListAlarmMsg(paramDto, redisService.get(RedisKey.SMOKE_TOKEN).toString()); |
| | | if (responseDto.getStatus() == 200) { |
| | | AlarmMsgResponseDto dto = responseDto.getData(); |
| | | List<AlarmMsgDataVo> list = dto.getContent(); |
| | | System.out.println(list.size()); |
| | | } else if (responseDto.getStatus() == 114) { |
| | | login(); |
| | | smokeAlarmMsgTest(); |
| | | } |
| | | } |
| | | } |