AlarmControlHandler supplement test cases

pull/785/head
Lijx 3 years ago
parent b99e21c754
commit 0ddfaec0df

@ -15,10 +15,12 @@
<artifactId>hippo4j-common</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>alibaba-dingtalk-service-sdk</artifactId>
@ -31,10 +33,18 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<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>
@ -47,5 +57,33 @@
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Implementation-Title>${project.artifactId}</Implementation-Title>
<Implementation-Version>${project.version}</Implementation-Version>
<Build-Time>${maven.build.timestamp}</Build-Time>
<Built-By>chen.ma</Built-By>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -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,35 @@
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