AlarmControlHandler supplement test cases (#785)

* AlarmControlHandler supplement test cases

* Update "AlarmControlHandler supplement test cases"

* AlarmControlHandler supplement test cases
pull/786/head
Lijx 2 years ago committed by GitHub
parent 02abc63f71
commit 9c3bf6a5e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -35,6 +35,11 @@
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>

@ -18,12 +18,12 @@
package cn.hippo4j.message.dto;
import cn.hippo4j.message.enums.NotifyTypeEnum;
import lombok.Builder;
import lombok.Data;
import lombok.*;
/**
* Alarm control DTO.
*/
@AllArgsConstructor
@Data
@Builder
public class AlarmControlDTO {

@ -0,0 +1,34 @@
package cn.hippo4j.message.service;
import cn.hippo4j.message.dto.AlarmControlDTO;
import cn.hippo4j.message.enums.NotifyTypeEnum;
import org.junit.Assert;
import org.junit.Test;
public class AlarmControlHandlerTest {
@Test
public void assertIsNotSendAlarm() {
AlarmControlHandler alarmControlHandler = new AlarmControlHandler();
AlarmControlDTO alarmControlDTO = new AlarmControlDTO("1", "Wechat", NotifyTypeEnum.ACTIVITY);
Assert.assertFalse(alarmControlHandler.isSendAlarm(alarmControlDTO));
}
@Test
public void assertIsSendAlarm() {
AlarmControlHandler alarmControlHandler = new AlarmControlHandler();
AlarmControlDTO alarmControlDTO = new AlarmControlDTO("1", "Wechat", NotifyTypeEnum.ACTIVITY);
alarmControlHandler.initCacheAndLock("1", "Wechat", 1);
Assert.assertTrue(alarmControlHandler.isSendAlarm(alarmControlDTO));
}
@Test
public void assertExpireAfterSendAlarm() throws InterruptedException {
AlarmControlHandler alarmControlHandler = new AlarmControlHandler();
AlarmControlDTO alarmControlDTO = new AlarmControlDTO("1", "Wechat", NotifyTypeEnum.ACTIVITY);
alarmControlHandler.initCacheAndLock("1", "Wechat", 1);
alarmControlHandler.isSendAlarm(alarmControlDTO);
Thread.sleep(60 * 1000);
Assert.assertTrue(alarmControlHandler.isSendAlarm(alarmControlDTO));
}
}
Loading…
Cancel
Save