import com.tourism.sms.contact.message.Example;
import com.tourism.sms.contact.message.entity.SendMsg;
import com.tourism.sms.contact.message.service.impl.RedisImpl;
import com.tourism.sms.contact.message.util.RedisClient;
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 static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Example.class)//你的启动类名称
public class redisImplTest {
@Autowired
private RedisImpl redisImpl;
@Test
public void shouldBeReturnTrueWhenPassExamineOrExcute() throws Exception {
String smsId = "SMS1143794821643759617";
boolean status = redisImpl.passExamineOrExcute(smsId);
SendMsg sendMsg =(SendMsg) RedisClient.get(smsId);
assertThat(sendMsg.getPeriod(),is("16:27:30-18:27:30"));
assertThat(sendMsg.getStartTime(),is(1143037104302133249L));
assertThat(status,is(true));
}
@Test
public void shouldBeReturnTrueStopMessage(){
String smsId = "SMS1143794821643759617";
boolean status = redisImpl.stopMessage(smsId);
assertThat(status,is(true));
}
@Test
public void shouldBeReturnTrueWhenComplishMessage() throws Exception {
String smsId = "SMS1143794821643759617";
boolean status = redisImpl.complishMessage(smsId);
assertThat(status,is(true));
}
}