From 2e8859ae138212eebd7e018c6bb8f0cc9b1603e6 Mon Sep 17 00:00:00 2001 From: "zuoping.liu" <2330163321@qq.com> Date: 2022年5月30日 21:01:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 31 +++ springboot-file.iml | 30 +-- .../java/com/lemonyliu/BaseMockitoTest.java | 10 + .../lemonyliu/service/ReportServiceTest.java | 182 ++++++++++++++++++ 4 files changed, 242 insertions(+), 11 deletions(-) create mode 100644 src/test/java/com/lemonyliu/BaseMockitoTest.java create mode 100644 src/test/java/com/lemonyliu/service/ReportServiceTest.java diff --git a/pom.xml b/pom.xml index f856d0c..a7693d0 100644 --- a/pom.xml +++ b/pom.xml @@ -86,6 +86,37 @@ spring-boot-starter-test test + + + + org.springframework + spring-test + 5.1.2.RELEASE + test + + + + org.mockito + mockito-core + + + org.junit.jupiter + junit-jupiter + test + + + org.powermock + powermock-module-junit4 + 2.0.0 + test + + + + org.powermock + powermock-api-mockito2 + 2.0.0 + test + diff --git a/springboot-file.iml b/springboot-file.iml index c7ab54d..ef93d39 100644 --- a/springboot-file.iml +++ b/springboot-file.iml @@ -141,6 +141,17 @@ + + + + + + + + + + + @@ -149,16 +160,13 @@ - - - - - - - - - - - + + + + + + + + \ No newline at end of file diff --git a/src/test/java/com/lemonyliu/BaseMockitoTest.java b/src/test/java/com/lemonyliu/BaseMockitoTest.java new file mode 100644 index 0000000..175521b --- /dev/null +++ b/src/test/java/com/lemonyliu/BaseMockitoTest.java @@ -0,0 +1,10 @@ +package com.lemonyliu; + +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; + +//test.java.com.qxwz.monitor包下 +@RunWith(MockitoJUnitRunner.Silent.class) +public abstract class BaseMockitoTest { + +} \ No newline at end of file diff --git a/src/test/java/com/lemonyliu/service/ReportServiceTest.java b/src/test/java/com/lemonyliu/service/ReportServiceTest.java new file mode 100644 index 0000000..102919f --- /dev/null +++ b/src/test/java/com/lemonyliu/service/ReportServiceTest.java @@ -0,0 +1,182 @@ +package com.lemonyliu.service; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.lemonyliu.BaseMockitoTest; +import com.lemonyliu.service.impl.ReportServiceImpl; +import org.junit.jupiter.api.Assertions; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +import java.util.ArrayList; + +public class ReportServiceTest extends BaseMockitoTest { + @InjectMocks + private ReportServiceImpl reportService; + @Mock + private BaseMapper baseMapper; +// @Test +// public void countWarning(){ +// int count = 1; +// when(baseMapper.selectCount(any(Wrapper.class))).thenReturn(count); +// int count1 = noticeAlarmRecordService.countWarning(new ArrayList(),"2022-03-01","2022-03-22"); +// Assertions.assertTrue(count1 == 0); +// int count2 = noticeAlarmRecordService.countWarning(Arrays.asList(11L),"2022-03-01","2022-03-22"); +// Assertions.assertEquals(count2, 1); +// } +// +// @Test +// public void countByItemCode(){ +// List noticeAlarmRecordList = new ArrayList(); +// NoticeAlarmRecord noticeAlarmRecord = new NoticeAlarmRecord(); +// noticeAlarmRecord.setId(11L); +// noticeAlarmRecordList.add(noticeAlarmRecord); +// when(baseMapper.selectList(any(Wrapper.class))).thenReturn(noticeAlarmRecordList); +// List noticeAlarmRecordList1 = noticeAlarmRecordService.countByItemCode(new ArrayList(),"2022-03-01","2022-03-22",4); +// Assertions.assertTrue(noticeAlarmRecordList1.size() == 0); +// List noticeAlarmRecordList2 = noticeAlarmRecordService.countByItemCode(Arrays.asList(11L),"2022-03-01","2022-03-22",4); +// Assertions.assertEquals(noticeAlarmRecordList2.get(0).getId(), 11L); +// } +// +// @Test +// public void countUndoByItemCode(){ +// List noticeAlarmRecordList = new ArrayList(); +// NoticeAlarmRecord noticeAlarmRecord = new NoticeAlarmRecord(); +// noticeAlarmRecord.setId(11L); +// noticeAlarmRecordList.add(noticeAlarmRecord); +// when(baseMapper.selectList(any(Wrapper.class))).thenReturn(noticeAlarmRecordList); +// List noticeAlarmRecordList1 = noticeAlarmRecordService.countUndoByItemCode(new ArrayList(),"2022-03-01","2022-03-22", StatusTypeEnum.TODO,4); +// Assertions.assertTrue(noticeAlarmRecordList1.size() == 0); +// List noticeAlarmRecordList2 = noticeAlarmRecordService.countUndoByItemCode(Arrays.asList(11L),"2022-03-01","2022-03-22",StatusTypeEnum.TODO,4); +// Assertions.assertEquals(noticeAlarmRecordList2.get(0).getId(), 11L); +// } +// +// @Test +// public void getAlarmRecordList(){ +// List noticeAlarmRecordList = new ArrayList(); +// NoticeAlarmRecord noticeAlarmRecord = new NoticeAlarmRecord(); +// noticeAlarmRecord.setId(11L); +// noticeAlarmRecordList.add(noticeAlarmRecord); +// when(baseMapper.selectList(any(Wrapper.class))).thenReturn(noticeAlarmRecordList); +// List noticeAlarmRecordList1 = noticeAlarmRecordService.getAlarmRecordList(new ArrayList(),"2022-03-01","2022-03-22"); +// Assertions.assertTrue(noticeAlarmRecordList1.size() == 0); +// List noticeAlarmRecordList2 = noticeAlarmRecordService.getAlarmRecordList(Arrays.asList(11L),"2022-03-01","2022-03-22"); +// Assertions.assertEquals(noticeAlarmRecordList2.get(0).getId(), 11L); +// } +// +// @Test +// public void countTodoEvent(){ +// int count = 1; +// when(baseMapper.selectCount(any(Wrapper.class))).thenReturn(count); +// int count1 = noticeAlarmRecordService.countTodoEvent(new ArrayList(),"2022-03-01","2022-03-22"); +// Assertions.assertTrue(count1 == 0); +// int count2 = noticeAlarmRecordService.countTodoEvent(Arrays.asList(11L),"2022-03-01","2022-03-22"); +// Assertions.assertEquals(count2, 1); +// } +// +// @Test +// public void countDoneEvent(){ +// int count = 1; +// when(baseMapper.selectCount(any(Wrapper.class))).thenReturn(count); +// int count1 = noticeAlarmRecordService.countDoneEvent(new ArrayList(),"2022-03-01","2022-03-22"); +// Assertions.assertTrue(count1 == 0); +// int count2 = noticeAlarmRecordService.countDoneEvent(Arrays.asList(11L),"2022-03-01","2022-03-22"); +// Assertions.assertEquals(count2, 1); +// } +// +// @Test +// public void getAlarmRecord(){ +// try { +// List noticeAlarmRecordList = new ArrayList(); +// NoticeAlarmRecord noticeAlarmRecord = new NoticeAlarmRecord(); +// noticeAlarmRecord.setId(11L); +// noticeAlarmRecordList.add(noticeAlarmRecord); +// when(baseMapper.selectList(any(Wrapper.class))).thenReturn(noticeAlarmRecordList); +// List noticeAlarmRecordList1 = noticeAlarmRecordService.getAlarmRecord(new ArrayList(),"2022-03-01","2022-03-22","YL"); +// Assertions.assertTrue(noticeAlarmRecordList1.size() == 0); +// List noticeAlarmRecordList2 = noticeAlarmRecordService.getAlarmRecord(Arrays.asList(11L),"2022-03-01","2022-03-22","YL"); +// Assertions.assertEquals(noticeAlarmRecordList2.get(0).getId(), 11L); +// }catch (Exception e){ +// System.out.println(e.getMessage()); +// } +// } +// +// @Test +// public void countRedAlarmLevel(){ +// int count = 1; +// when(baseMapper.selectCount(any(Wrapper.class))).thenReturn(count); +// int count1 = noticeAlarmRecordService.countRedAlarmLevel(new ArrayList(),"2022-03-01","2022-03-22"); +// Assertions.assertTrue(count1 == 0); +// int count2 = noticeAlarmRecordService.countRedAlarmLevel(Arrays.asList(11L),"2022-03-01","2022-03-22"); +// Assertions.assertEquals(count2, 1); +// } +// +// @Test +// public void countOrangeAlarmLevel(){ +// int count = 1; +// when(baseMapper.selectCount(any(Wrapper.class))).thenReturn(count); +// int count1 = noticeAlarmRecordService.countOrangeAlarmLevel(new ArrayList(),"2022-03-01","2022-03-22"); +// Assertions.assertTrue(count1 == 0); +// int count2 = noticeAlarmRecordService.countOrangeAlarmLevel(Arrays.asList(11L),"2022-03-01","2022-03-22"); +// Assertions.assertEquals(count2, 1); +// } +// +// @Test +// public void countYellowAlarmLevel(){ +// int count = 1; +// when(baseMapper.selectCount(any(Wrapper.class))).thenReturn(count); +// int count1 = noticeAlarmRecordService.countYellowAlarmLevel(new ArrayList(),"2022-03-01","2022-03-22"); +// Assertions.assertTrue(count1 == 0); +// int count2 = noticeAlarmRecordService.countYellowAlarmLevel(Arrays.asList(11L),"2022-03-01","2022-03-22"); +// Assertions.assertEquals(count2, 1); +// } +// +// @Test +// public void countBlueAlarmLevel(){ +// int count = 1; +// when(baseMapper.selectCount(any(Wrapper.class))).thenReturn(count); +// int count1 = noticeAlarmRecordService.countBlueAlarmLevel(new ArrayList(),"2022-03-01","2022-03-22"); +// Assertions.assertTrue(count1 == 0); +// int count2 = noticeAlarmRecordService.countBlueAlarmLevel(Arrays.asList(11L),"2022-03-01","2022-03-22"); +// Assertions.assertEquals(count2, 1); +// } +// +// @Test +// public void countDoneRedAlarm(){ +// int count = 1; +// when(baseMapper.selectCount(any(Wrapper.class))).thenReturn(count); +// int count1 = noticeAlarmRecordService.countDoneRedAlarm(new ArrayList(),"2022-03-01","2022-03-22"); +// Assertions.assertTrue(count1 == 0); +// int count2 = noticeAlarmRecordService.countDoneRedAlarm(Arrays.asList(11L),"2022-03-01","2022-03-22"); +// Assertions.assertEquals(count2, 1); +// } +// +// @Test +// public void countDoneOrangeAlarm(){ +// int count = 1; +// when(baseMapper.selectCount(any(Wrapper.class))).thenReturn(count); +// int count1 = noticeAlarmRecordService.countDoneOrangeAlarm(new ArrayList(),"2022-03-01","2022-03-22"); +// Assertions.assertTrue(count1 == 0); +// int count2 = noticeAlarmRecordService.countDoneOrangeAlarm(Arrays.asList(11L),"2022-03-01","2022-03-22"); +// Assertions.assertEquals(count2, 1); +// } +// +// @Test +// public void countDoneYellowAlarm(){ +// int count = 1; +// when(baseMapper.selectCount(any(Wrapper.class))).thenReturn(count); +// int count1 = noticeAlarmRecordService.countDoneYellowAlarm(new ArrayList(),"2022-03-01","2022-03-22"); +// Assertions.assertTrue(count1 == 0); +// int count2 = noticeAlarmRecordService.countDoneYellowAlarm(Arrays.asList(11L),"2022-03-01","2022-03-22"); +// Assertions.assertEquals(count2, 1); +// } +// +// @Test +// public void countDoneBlueAlarm(){ +// int count = 1; +// when(baseMapper.selectCount(any(Wrapper.class))).thenReturn(count); +// int count1 = noticeAlarmRecordService.countDoneBlueAlarm(new ArrayList(),"2022-03-01","2022-03-22"); +// Assertions.assertTrue(count1 == 0); +// int count2 = noticeAlarmRecordService.countDoneBlueAlarm(Arrays.asList(11L),"2022-03-01","2022-03-22"); +// Assertions.assertEquals(count2, 1); +// } +} AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル