1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package pwc.taxtech.atms.service.impl;
import static org.assertj.core.api.Assertions.*;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import pwc.taxtech.atms.CommonIT;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.entitiy.Cache;
import pwc.taxtech.atms.service.CacheService;
public class CacheServiceIT extends CommonIT {
@Autowired
private CacheService cacheService;
@Before
public void setUp() {
cacheMapper.deleteByExample(null);
}
@Test
public void getAllCache() {
insertData();
// see assertj document
// http://joel-costigliola.github.io/assertj/assertj-core-quick-start.html
assertThat(cacheService.getAllCache()).isNotEmpty().filteredOn(x -> x.getCacheKey().equals("cachekey1"))
.isNotEmpty().extracting("lastModifyTime").contains("2017-10-18T14:11:01.840+08:00");
}
@Test
public void shoudWork() {
insertData();
assertThat(cacheService.getCacheByKey("cachekey1")).isNotNull().extracting("lastModifyTime")
.contains("2017-10-18T14:11:01.840+08:00");
}
private void insertData() {
Cache record = new Cache();
record.setID(CommonUtils.getUUID());
record.setCacheKey("cachekey1");
record.setLastModifyTime("2017-10-18T14:11:01.840+08:00");
cacheMapper.insert(record);
}
}