Преглед на файлове

test(water): cover device GIS points

Kazerin преди 2 месеца
родител
ревизия
7e77b023b5
променени са 1 файла, в които са добавени 24 реда и са изтрити 0 реда
  1. 24 0
      pipe-network-service/zksy-system/src/test/java/com/zksy/base/service/impl/WaterSupplyDeviceServiceImplTest.java

+ 24 - 0
pipe-network-service/zksy-system/src/test/java/com/zksy/base/service/impl/WaterSupplyDeviceServiceImplTest.java

@@ -32,6 +32,7 @@ import org.mockito.ArgumentCaptor;
 import org.mockito.Mockito;
 import org.springframework.test.util.ReflectionTestUtils;
 
+import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.util.Arrays;
 import java.util.Collections;
@@ -450,6 +451,29 @@ class WaterSupplyDeviceServiceImplTest {
                 .collect(Collectors.toList()));
     }
 
+    @Test
+    void deviceGisPointsIncludeWaterOnlyWithCoordinatesAndStatuses() {
+        pressureDevice.setLongitude(new BigDecimal("113.28000000"));
+        pressureDevice.setLatitude(new BigDecimal("23.12000000"));
+        gasDevice.setLongitude(new BigDecimal("113.32000000"));
+        gasDevice.setLatitude(new BigDecimal("23.16000000"));
+        when(equipmentStatusMapper.selectList(any())).thenReturn(Collections.singletonList(
+                status(pressureDevice.getEquipmentId(), 1, 1, 1)));
+        when(equipmentTypeMapper.selectBatchIds(any())).thenReturn(Collections.singletonList(
+                type("water-pressure", "压力监测", "water-root")));
+
+        List<DeviceGisVO> points = service.getAllDeviceGisPoints(null);
+
+        assertEquals(Collections.singletonList("water-pressure-1"), points.stream()
+                .map(DeviceGisVO::getEquipmentId)
+                .collect(Collectors.toList()));
+        assertEquals("压力监测", points.get(0).getEquipmentTypeName());
+        assertEquals(1, points.get(0).getOnlineStatus());
+        assertEquals(1, points.get(0).getAlarmStatus());
+        assertEquals(1, points.get(0).getCurrentStatus());
+        assertEquals(new BigDecimal("113.28000000"), points.get(0).getLongitude());
+    }
+
     @Test
     void deviceDetailIncludesAlarmAndRelatedWorkOrderSummary() {
         doReturn(pressureDevice).when(service).getById(pressureDevice.getEquipmentId());