From eb3dd00b0b7fcda477229d518d250f9c842b790b Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 21 十月 2025 17:45:44 +0800
Subject: [PATCH] 2025.10.21 1. 走航季度报告相关数据计算逻辑调整
---
src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImplTest.kt | 88 +++++++------------------------------------
1 files changed, 15 insertions(+), 73 deletions(-)
diff --git a/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImplTest.kt b/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImplTest.kt
index f21cc8c..d66b52b 100644
--- a/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImplTest.kt
+++ b/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImplTest.kt
@@ -2,30 +2,25 @@
import com.flightfeather.uav.biz.FactorFilter
import com.flightfeather.uav.biz.report.MissionReport
-import com.flightfeather.uav.common.exception.BizException
-import com.flightfeather.uav.domain.repository.MissionRep
+import com.flightfeather.uav.domain.entity.Mission
+import com.flightfeather.uav.domain.mapper.MissionMapper
import com.flightfeather.uav.lightshare.service.MissionService
-
+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 javax.servlet.http.HttpServletResponse
+import tk.mybatis.mapper.entity.Example
-import org.junit.jupiter.api.Assertions.*
-import org.junit.jupiter.api.Test
-import org.junit.jupiter.api.assertThrows
-import org.junit.runner.RunWith
-
-import io.mockk.every
-import io.mockk.mockk
-import io.mockk.verify
-
+@RunWith(SpringRunner::class)
+@SpringBootTest
class MissionServiceImplTest {
@Autowired
lateinit var missionService: MissionService
- private var missionRep: MissionRep = mockk()
+ @Autowired
+ lateinit var missionMapper: MissionMapper
@Autowired
lateinit var missionReport: MissionReport
@@ -37,65 +32,12 @@
}
@Test
- fun `calMissionInfo should throw BizException when mission not found`() {
- // Arrange
- val missionCode = "M001"
- every { missionRep.findOne(missionCode) } returns null
-
- // Act & Assert
- val exception = assertThrows<BizException> {
- missionService.calMissionInfo(missionCode)
+ fun calMissionInfo() {
+ missionMapper.selectByExample(Example(Mission::class.java).apply {
+ createCriteria().andGreaterThanOrEqualTo("startTime", "2025-07-08 08:30:00")
+ }).forEach {mission ->
+ mission?.let { missionService.calMissionInfo(it.missionCode) }
+ Thread.sleep(1000)
}
- assertEquals("璧拌埅浠诲姟涓嶅瓨鍦�", exception.message)
- }
-
- @Test
- fun `calMissionInfo should calculate and update mission info successfully`() {
- // Arrange
- val missionCode = "M001"
- val mission = Mission(missionCode)
- val data = listOf<RealTimeData>()
-
- every { missionRep.findOne(missionCode) } returns mission
- every { realTimeDataRep.fetchData(mission) } returns data
- every { missionUtil.calKilometres(data) } returns 100.0
- every { missionUtil.calRegion(data) } returns "Center"
- every { missionRep.updateMission(mission) } returns true
-
- // Act
- val result = missionService.calMissionInfo(missionCode)
-
- // Assert
- assertTrue(result)
- assertEquals(100.0f, mission.kilometres)
- assertEquals("Center", mission.region)
-
- verify {
- missionRep.findOne(missionCode)
- realTimeDataRep.fetchData(mission)
- missionUtil.calKilometres(data)
- missionUtil.calRegion(data)
- missionRep.updateMission(mission)
- }
- }
-
- @Test
- fun `calMissionInfo should return false when update fails`() {
- // Arrange
- val missionCode = "M001"
- val mission = Mission(missionCode)
- val data = listOf<RealTimeData>()
-
- every { missionRep.findOne(missionCode) } returns mission
- every { realTimeDataRep.fetchData(mission) } returns data
- every { missionUtil.calKilometres(data) } returns 100.0
- every { missionUtil.calRegion(data) } returns "Center"
- every { missionRep.updateMission(mission) } returns false
-
- // Act
- val result = missionService.calMissionInfo(missionCode)
-
- // Assert
- assertFalse(result)
}
}
\ No newline at end of file
--
Gitblit v1.9.3