|
|
@@ -9,6 +9,7 @@ import com.mangoo.rating.recommend.po.CardPopPO;
|
|
|
import com.mangoo.rating.recommend.po.CardValueHistoryPO;
|
|
|
import com.mangoo.rating.recommend.po.RatingRecommendRulePO;
|
|
|
import com.mangoo.rating.recommend.response.recommend.CardDetailVO;
|
|
|
+import com.mangoo.rating.recommend.request.recommend.CardDetailRequest;
|
|
|
import com.mangoo.rating.recommend.service.impl.CardDetailServiceImpl;
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
@@ -90,6 +91,14 @@ class CardDetailServiceImplTest {
|
|
|
return (CardDetailVO) r.get("data");
|
|
|
}
|
|
|
|
|
|
+ /** 构造详情查询请求对象 */
|
|
|
+ private CardDetailRequest reqOf(String cardId, String period) {
|
|
|
+ CardDetailRequest req = new CardDetailRequest();
|
|
|
+ req.setCardId(cardId);
|
|
|
+ req.setPeriod(period);
|
|
|
+ return req;
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
void 正常_组装详情() {
|
|
|
when(ruleManager.selectByCardId("C1", "B1")).thenReturn(rule());
|
|
|
@@ -105,7 +114,7 @@ class CardDetailServiceImplTest {
|
|
|
h.setRecordDate(LocalDate.now().minusDays(1));
|
|
|
when(cardValueHistoryManager.selectTrend(eq("C1"), org.mockito.ArgumentMatchers.any())).thenReturn(Arrays.asList(h));
|
|
|
|
|
|
- AjaxResult result = service.getDetail("C1", "30d");
|
|
|
+ AjaxResult result = service.getDetail(reqOf("C1", "30d"));
|
|
|
assertEquals(0, code(result));
|
|
|
CardDetailVO d = data(result);
|
|
|
assertEquals("AIPOM", d.getName());
|
|
|
@@ -119,27 +128,27 @@ class CardDetailServiceImplTest {
|
|
|
@Test
|
|
|
void 无生效批次_返回error() {
|
|
|
when(activeBatchManager.selectActiveBatchNo()).thenReturn(null);
|
|
|
- AjaxResult result = service.getDetail("C1", "30d");
|
|
|
+ AjaxResult result = service.getDetail(reqOf("C1", "30d"));
|
|
|
assertNotEquals(0, code(result));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
void 卡片不存在_返回error() {
|
|
|
when(ruleManager.selectByCardId("C1", "B1")).thenReturn(null);
|
|
|
- AjaxResult result = service.getDetail("C1", "30d");
|
|
|
+ AjaxResult result = service.getDetail(reqOf("C1", "30d"));
|
|
|
assertNotEquals(0, code(result));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
void cardId为空_返回error() {
|
|
|
- AjaxResult result = service.getDetail(" ", "30d");
|
|
|
+ AjaxResult result = service.getDetail(reqOf(" ", "30d"));
|
|
|
assertNotEquals(0, code(result));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
void period_7d_起始为7天前() {
|
|
|
when(ruleManager.selectByCardId("C1", "B1")).thenReturn(rule());
|
|
|
- service.getDetail("C1", "7d");
|
|
|
+ service.getDetail(reqOf("C1", "7d"));
|
|
|
verify(cardValueHistoryManager).selectTrend(eq("C1"), dateCaptor.capture());
|
|
|
assertEquals(LocalDate.now().minusDays(7), dateCaptor.getValue());
|
|
|
}
|
|
|
@@ -147,7 +156,7 @@ class CardDetailServiceImplTest {
|
|
|
@Test
|
|
|
void period_all_起始为null() {
|
|
|
when(ruleManager.selectByCardId("C1", "B1")).thenReturn(rule());
|
|
|
- service.getDetail("C1", "all");
|
|
|
+ service.getDetail(reqOf("C1", "all"));
|
|
|
verify(cardValueHistoryManager).selectTrend(eq("C1"), isNull());
|
|
|
}
|
|
|
}
|