|
|
@@ -63,7 +63,7 @@ class CockpitMonitoringDistributionControllerTest {
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void distributionExposesEnvelopeSixStateDistributionDistrictIndustryTypeAndMapFilter() throws Exception {
|
|
|
+ void distributionExposesEnvelopeGlobalEightStateDistributionAndMapFilter() throws Exception {
|
|
|
mockMvc.perform(get(ENDPOINT)
|
|
|
.param("snapshotAt", SNAPSHOT_AT)
|
|
|
.header("X-Request-Id", "monitoring-distribution-001"))
|
|
|
@@ -76,7 +76,7 @@ class CockpitMonitoringDistributionControllerTest {
|
|
|
.andExpect(jsonPath("$.data.timezone").value("Asia/Shanghai"))
|
|
|
.andExpect(jsonPath("$.data.pagination.page").value(1))
|
|
|
.andExpect(jsonPath("$.data.pagination.pageSize").value(500))
|
|
|
- .andExpect(jsonPath("$.data.pagination.total").value(8))
|
|
|
+ .andExpect(jsonPath("$.data.pagination.total").value(9))
|
|
|
.andExpect(jsonPath("$.data.pagination.totalPages").value(1))
|
|
|
.andExpect(jsonPath("$.data.pagination.hasMore").value(false))
|
|
|
.andExpect(jsonPath("$.data.monitoringPoints", hasSize(5)))
|
|
|
@@ -91,31 +91,31 @@ class CockpitMonitoringDistributionControllerTest {
|
|
|
.andExpect(jsonPath("$.data.monitoringPoints[3].pointStatus").value("WORK_ORDER"))
|
|
|
.andExpect(jsonPath("$.data.monitoringPoints[4].pointCode").value("P-WS-2"))
|
|
|
.andExpect(jsonPath("$.data.monitoringPoints[4].pointStatus").value("EMPTY"))
|
|
|
- .andExpect(jsonPath("$.data.unassociatedEquipment", hasSize(3)))
|
|
|
+ .andExpect(jsonPath("$.data.unassociatedEquipment", hasSize(4)))
|
|
|
.andExpect(jsonPath("$.data.unassociatedEquipment[0].deviceCode").value("EQ-FREE-001"))
|
|
|
.andExpect(jsonPath("$.data.unassociatedEquipment[0].pointStatus").value("NORMAL"))
|
|
|
.andExpect(jsonPath("$.data.unassociatedEquipment[1].deviceCode").value("EQ-FREE-002"))
|
|
|
.andExpect(jsonPath("$.data.unassociatedEquipment[1].pointStatus").value("WARNING"))
|
|
|
.andExpect(jsonPath("$.data.unassociatedEquipment[2].deviceCode").value("EQ-FREE-003"))
|
|
|
.andExpect(jsonPath("$.data.unassociatedEquipment[2].pointStatus").value("OFFLINE"))
|
|
|
- .andExpect(jsonPath("$.data.pointStatusDistribution", hasSize(6)))
|
|
|
+ .andExpect(jsonPath("$.data.pointStatusDistribution", hasSize(8)))
|
|
|
.andExpect(jsonPath("$.data.pointStatusDistribution[0].status").value("ALARM"))
|
|
|
.andExpect(jsonPath("$.data.pointStatusDistribution[0].count").value(1))
|
|
|
.andExpect(jsonPath("$.data.pointStatusDistribution[1].status").value("WARNING"))
|
|
|
- .andExpect(jsonPath("$.data.pointStatusDistribution[1].count").value(2))
|
|
|
+ .andExpect(jsonPath("$.data.pointStatusDistribution[1].count").value(1))
|
|
|
.andExpect(jsonPath("$.data.pointStatusDistribution[2].status").value("WORK_ORDER"))
|
|
|
.andExpect(jsonPath("$.data.pointStatusDistribution[2].count").value(1))
|
|
|
.andExpect(jsonPath("$.data.pointStatusDistribution[3].status").value("NORMAL"))
|
|
|
- .andExpect(jsonPath("$.data.pointStatusDistribution[3].count").value(1))
|
|
|
+ .andExpect(jsonPath("$.data.pointStatusDistribution[3].count").value(2))
|
|
|
.andExpect(jsonPath("$.data.pointStatusDistribution[4].status").value("OFFLINE"))
|
|
|
- .andExpect(jsonPath("$.data.pointStatusDistribution[4].count").value(2))
|
|
|
+ .andExpect(jsonPath("$.data.pointStatusDistribution[4].count").value(1))
|
|
|
.andExpect(jsonPath("$.data.pointStatusDistribution[5].status").value("EMPTY"))
|
|
|
.andExpect(jsonPath("$.data.pointStatusDistribution[5].count").value(1))
|
|
|
.andExpect(jsonPath("$.data.districtDistribution", hasSize(3)))
|
|
|
.andExpect(jsonPath("$.data.districtDistribution[0].district").value(0))
|
|
|
.andExpect(jsonPath("$.data.districtDistribution[0].districtName").value("城南"))
|
|
|
.andExpect(jsonPath("$.data.districtDistribution[0].pointCount").value(2))
|
|
|
- .andExpect(jsonPath("$.data.districtDistribution[0].deviceCount").value(4))
|
|
|
+ .andExpect(jsonPath("$.data.districtDistribution[0].deviceCount").value(5))
|
|
|
.andExpect(jsonPath("$.data.districtDistribution[1].district").value(1))
|
|
|
.andExpect(jsonPath("$.data.districtDistribution[1].districtName").value("城北"))
|
|
|
.andExpect(jsonPath("$.data.districtDistribution[1].pointCount").value(2))
|
|
|
@@ -127,14 +127,14 @@ class CockpitMonitoringDistributionControllerTest {
|
|
|
.andExpect(jsonPath("$.data.industryDistribution", hasSize(3)))
|
|
|
.andExpect(jsonPath("$.data.industryDistribution[0].industry").value("GAS"))
|
|
|
.andExpect(jsonPath("$.data.industryDistribution[0].pointCount").value(2))
|
|
|
- .andExpect(jsonPath("$.data.industryDistribution[0].deviceCount").value(4))
|
|
|
+ .andExpect(jsonPath("$.data.industryDistribution[0].deviceCount").value(5))
|
|
|
.andExpect(jsonPath("$.data.industryDistribution[1].industry").value("WATER_SUPPLY"))
|
|
|
.andExpect(jsonPath("$.data.industryDistribution[1].deviceCount").value(2))
|
|
|
.andExpect(jsonPath("$.data.industryDistribution[2].industry").value("DRAINAGE"))
|
|
|
.andExpect(jsonPath("$.data.industryDistribution[2].deviceCount").value(2))
|
|
|
.andExpect(jsonPath("$.data.deviceTypeDistribution", hasSize(3)))
|
|
|
.andExpect(jsonPath("$.data.deviceTypeDistribution[0].deviceType.code").value("GAS_SENSOR"))
|
|
|
- .andExpect(jsonPath("$.data.deviceTypeDistribution[0].deviceCount").value(4))
|
|
|
+ .andExpect(jsonPath("$.data.deviceTypeDistribution[0].deviceCount").value(5))
|
|
|
.andExpect(jsonPath("$.data.deviceTypeDistribution[1].deviceType.code").value("SEWAGE_ENV"))
|
|
|
.andExpect(jsonPath("$.data.deviceTypeDistribution[2].deviceType.code").value("WATER_SUPPLY_SENSOR"))
|
|
|
.andExpect(jsonPath("$.data.mapFilter.industry").value(nullValue()))
|
|
|
@@ -144,11 +144,11 @@ class CockpitMonitoringDistributionControllerTest {
|
|
|
.andExpect(jsonPath("$.data.mapFilter.districtName").value(nullValue()))
|
|
|
.andExpect(jsonPath("$.data.mapFilter.districtFilter").value("NONE"))
|
|
|
.andExpect(jsonPath("$.data.mapFilter.pointCodes", hasSize(5)))
|
|
|
- .andExpect(jsonPath("$.data.mapFilter.deviceCodes", hasSize(8)))
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.deviceCodes", hasSize(9)))
|
|
|
.andExpect(jsonPath("$.data.excluded.unknownTypeCount").value(1))
|
|
|
.andExpect(jsonPath("$.data.excluded.typeKindMismatchCount").value(1))
|
|
|
.andExpect(jsonPath("$.data.excluded.nonFormalIndustryCount").value(1))
|
|
|
- .andExpect(jsonPath("$.data.excluded.invalidCoordinateCount").value(1))
|
|
|
+ .andExpect(jsonPath("$.data.excluded.invalidCoordinateCount").value(0))
|
|
|
.andExpect(jsonPath("$.data.freshness.status").value("CURRENT"))
|
|
|
.andExpect(jsonPath("$.data.freshness.reason").value("READY"));
|
|
|
}
|
|
|
@@ -157,24 +157,24 @@ class CockpitMonitoringDistributionControllerTest {
|
|
|
void associatedDevicesRenderAsOnePointAndPaginationMatchesStatusTotals() throws Exception {
|
|
|
mockMvc.perform(get(ENDPOINT))
|
|
|
.andExpect(status().isOk())
|
|
|
- .andExpect(jsonPath("$.data.pagination.total").value(8))
|
|
|
+ .andExpect(jsonPath("$.data.pagination.total").value(9))
|
|
|
.andExpect(jsonPath("$.data.pointStatusDistribution[0].count").value(1))
|
|
|
.andExpect(jsonPath("$.data.monitoringPoints", hasSize(5)))
|
|
|
- .andExpect(jsonPath("$.data.unassociatedEquipment", hasSize(3)));
|
|
|
+ .andExpect(jsonPath("$.data.unassociatedEquipment", hasSize(4)));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
void industryFilterNarrowsDistributionAndMapFilter() throws Exception {
|
|
|
mockMvc.perform(get(ENDPOINT).param("industry", "GAS"))
|
|
|
.andExpect(status().isOk())
|
|
|
- .andExpect(jsonPath("$.data.pagination.total").value(3))
|
|
|
+ .andExpect(jsonPath("$.data.pagination.total").value(4))
|
|
|
.andExpect(jsonPath("$.data.monitoringPoints", hasSize(2)))
|
|
|
- .andExpect(jsonPath("$.data.unassociatedEquipment", hasSize(1)))
|
|
|
+ .andExpect(jsonPath("$.data.unassociatedEquipment", hasSize(2)))
|
|
|
.andExpect(jsonPath("$.data.mapFilter.industry").value("GAS"))
|
|
|
.andExpect(jsonPath("$.data.industryDistribution", hasSize(1)))
|
|
|
.andExpect(jsonPath("$.data.industryDistribution[0].industry").value("GAS"))
|
|
|
.andExpect(jsonPath("$.data.pointStatusDistribution[0].count").value(1))
|
|
|
- .andExpect(jsonPath("$.data.pointStatusDistribution[3].count").value(1))
|
|
|
+ .andExpect(jsonPath("$.data.pointStatusDistribution[3].count").value(2))
|
|
|
.andExpect(jsonPath("$.data.pointStatusDistribution[4].count").value(1));
|
|
|
}
|
|
|
|
|
|
@@ -182,7 +182,7 @@ class CockpitMonitoringDistributionControllerTest {
|
|
|
void deviceTypeFilterNarrowsDistribution() throws Exception {
|
|
|
mockMvc.perform(get(ENDPOINT).param("deviceType", "GAS_SENSOR"))
|
|
|
.andExpect(status().isOk())
|
|
|
- .andExpect(jsonPath("$.data.pagination.total").value(3))
|
|
|
+ .andExpect(jsonPath("$.data.pagination.total").value(4))
|
|
|
.andExpect(jsonPath("$.data.mapFilter.deviceType").value("GAS_SENSOR"))
|
|
|
.andExpect(jsonPath("$.data.deviceTypeDistribution", hasSize(1)))
|
|
|
.andExpect(jsonPath("$.data.deviceTypeDistribution[0].deviceType.code").value("GAS_SENSOR"));
|
|
|
@@ -194,13 +194,13 @@ class CockpitMonitoringDistributionControllerTest {
|
|
|
.andExpect(status().isOk())
|
|
|
.andExpect(jsonPath("$.data.pagination.total").value(2))
|
|
|
.andExpect(jsonPath("$.data.mapFilter.pointStatus").value("WARNING"))
|
|
|
- .andExpect(jsonPath("$.data.pointStatusDistribution[0].count").value(0))
|
|
|
- .andExpect(jsonPath("$.data.pointStatusDistribution[1].count").value(2))
|
|
|
- .andExpect(jsonPath("$.data.pointStatusDistribution[4].count").value(0));
|
|
|
+ .andExpect(jsonPath("$.data.pointStatusDistribution[0].count").value(1))
|
|
|
+ .andExpect(jsonPath("$.data.pointStatusDistribution[1].count").value(1))
|
|
|
+ .andExpect(jsonPath("$.data.pointStatusDistribution[4].count").value(1));
|
|
|
|
|
|
mockMvc.perform(get(ENDPOINT))
|
|
|
.andExpect(status().isOk())
|
|
|
- .andExpect(jsonPath("$.data.pagination.total").value(8))
|
|
|
+ .andExpect(jsonPath("$.data.pagination.total").value(9))
|
|
|
.andExpect(jsonPath("$.data.mapFilter.pointStatus").value(nullValue()));
|
|
|
}
|
|
|
|
|
|
@@ -253,7 +253,7 @@ class CockpitMonitoringDistributionControllerTest {
|
|
|
.andExpect(status().isOk())
|
|
|
.andExpect(jsonPath("$.data.pagination.total").value(0))
|
|
|
.andExpect(jsonPath("$.data.monitoringPoints", hasSize(0)))
|
|
|
- .andExpect(jsonPath("$.data.pointStatusDistribution[0].count").value(0))
|
|
|
+ .andExpect(jsonPath("$.data.pointStatusDistribution[0].count").value(1))
|
|
|
.andExpect(jsonPath("$.data.mapFilter.deviceType").value("NOT_A_TYPE"))
|
|
|
.andExpect(jsonPath("$.data.excluded.invalidCoordinateCount").value(0))
|
|
|
.andExpect(jsonPath("$.data.freshness.status").value("EMPTY"))
|
|
|
@@ -279,7 +279,7 @@ class CockpitMonitoringDistributionControllerTest {
|
|
|
.andExpect(jsonPath("$.code").value(400))
|
|
|
.andExpect(jsonPath("$.data.category").value("INVALID_REQUEST"))
|
|
|
.andExpect(jsonPath("$.data.message").value(
|
|
|
- "pointStatus must be ALARM, WARNING, WORK_ORDER, NORMAL, OFFLINE or EMPTY"));
|
|
|
+ "pointStatus must be ALARM, WARNING, WORK_ORDER, NORMAL, OFFLINE, EMPTY, UNKNOWN or UNASSOCIATED"));
|
|
|
|
|
|
verifyNoInteractions(adapter);
|
|
|
}
|
|
|
@@ -351,8 +351,8 @@ class CockpitMonitoringDistributionControllerTest {
|
|
|
void webSocketDeltaRecomputesStatusCountsAndIgnoresOldOrUnknownDeltas() {
|
|
|
CockpitMonitoringDistributionResponse initial = service.load(
|
|
|
"delta-baseline", null, null, null, null, 1, 100, SNAPSHOT_AT);
|
|
|
- assertEquals(2, statusCount(initial, CockpitMonitoringPointStatus.OFFLINE));
|
|
|
- assertEquals(1, statusCount(initial, CockpitMonitoringPointStatus.NORMAL));
|
|
|
+ assertEquals(1, statusCount(initial, CockpitMonitoringPointStatus.OFFLINE));
|
|
|
+ assertEquals(2, statusCount(initial, CockpitMonitoringPointStatus.NORMAL));
|
|
|
|
|
|
CockpitMonitoringDistributionResponse applied = service.applyDeviceStatusDelta(
|
|
|
"delta-1", null, null, null, null, 1, 100, SNAPSHOT_AT,
|
|
|
@@ -360,8 +360,8 @@ class CockpitMonitoringDistributionControllerTest {
|
|
|
"GAS-003", null, "ONLINE", "2026-09-02T09:59:00+08:00",
|
|
|
"2026-09-02T10:05:00+08:00"));
|
|
|
|
|
|
- assertEquals(1, statusCount(applied, CockpitMonitoringPointStatus.OFFLINE));
|
|
|
- assertEquals(2, statusCount(applied, CockpitMonitoringPointStatus.NORMAL));
|
|
|
+ assertEquals(0, statusCount(applied, CockpitMonitoringPointStatus.OFFLINE));
|
|
|
+ assertEquals(3, statusCount(applied, CockpitMonitoringPointStatus.NORMAL));
|
|
|
|
|
|
CockpitMonitoringDistributionResponse ignoredOld = service.applyDeviceStatusDelta(
|
|
|
"delta-2", null, null, null, null, 1, 100, SNAPSHOT_AT,
|
|
|
@@ -369,8 +369,8 @@ class CockpitMonitoringDistributionControllerTest {
|
|
|
"GAS-003", null, "OFFLINE", "2026-09-02T09:59:00+08:00",
|
|
|
"2026-09-02T10:04:00+08:00"));
|
|
|
|
|
|
- assertEquals(1, statusCount(ignoredOld, CockpitMonitoringPointStatus.OFFLINE));
|
|
|
- assertEquals(2, statusCount(ignoredOld, CockpitMonitoringPointStatus.NORMAL));
|
|
|
+ assertEquals(0, statusCount(ignoredOld, CockpitMonitoringPointStatus.OFFLINE));
|
|
|
+ assertEquals(3, statusCount(ignoredOld, CockpitMonitoringPointStatus.NORMAL));
|
|
|
|
|
|
CockpitMonitoringDistributionResponse ignoredUnknown = service.applyDeviceStatusDelta(
|
|
|
"delta-3", null, null, null, null, 1, 100, SNAPSHOT_AT,
|
|
|
@@ -378,8 +378,115 @@ class CockpitMonitoringDistributionControllerTest {
|
|
|
"NO-SUCH-DEVICE", null, "ONLINE", "2026-09-02T09:59:00+08:00",
|
|
|
"2026-09-02T10:06:00+08:00"));
|
|
|
|
|
|
- assertEquals(1, statusCount(ignoredUnknown, CockpitMonitoringPointStatus.OFFLINE));
|
|
|
- assertEquals(2, statusCount(ignoredUnknown, CockpitMonitoringPointStatus.NORMAL));
|
|
|
+ assertEquals(0, statusCount(ignoredUnknown, CockpitMonitoringPointStatus.OFFLINE));
|
|
|
+ assertEquals(3, statusCount(ignoredUnknown, CockpitMonitoringPointStatus.NORMAL));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void sixEmptyUntypedPointsRemainInLedgerAndStatusTotalsWithoutVerifiedCoordinates() throws Exception {
|
|
|
+ List<CockpitMonitoringDistributionSnapshot.SourceMonitoringPoint> points = new java.util.ArrayList<>();
|
|
|
+ for (String code : Arrays.asList("GS001", "GS002", "PS001", "PS002", "RQ001", "RQ002")) {
|
|
|
+ points.add(new CockpitMonitoringDistributionSnapshot.SourceMonitoringPoint(
|
|
|
+ code, code, null, null, new BigDecimal("110.399876"), new BigDecimal("28.458287"),
|
|
|
+ false, Collections.emptyList()));
|
|
|
+ }
|
|
|
+ CockpitMonitoringDistributionSnapshot snapshot = new CockpitMonitoringDistributionSnapshot(
|
|
|
+ SNAPSHOT_AT, SNAPSHOT_AT, Collections.emptyList(), points, Collections.emptyList());
|
|
|
+ when(adapter.load(null)).thenReturn(snapshot);
|
|
|
+ when(adapter.load(SNAPSHOT_AT)).thenReturn(snapshot);
|
|
|
+
|
|
|
+ mockMvc.perform(get(ENDPOINT).param("pointStatus", "EMPTY").param("pageSize", "2"))
|
|
|
+ .andExpect(status().isOk())
|
|
|
+ .andExpect(jsonPath("$.data.pagination.total").value(6))
|
|
|
+ .andExpect(jsonPath("$.data.pagination.totalPages").value(3))
|
|
|
+ .andExpect(jsonPath("$.data.pagination.hasMore").value(true))
|
|
|
+ .andExpect(jsonPath("$.data.monitoringPoints", hasSize(2)))
|
|
|
+ .andExpect(jsonPath("$.data.monitoringPoints[0].pointCode").value("GS001"))
|
|
|
+ .andExpect(jsonPath("$.data.monitoringPoints[0].pointStatus").value("EMPTY"))
|
|
|
+ .andExpect(jsonPath("$.data.monitoringPoints[0].industry").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.monitoringPoints[0].deviceType.code").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.monitoringPoints[0].coordinateValidation.renderable").value(false))
|
|
|
+ .andExpect(jsonPath("$.data.pointStatusDistribution[5].count").value(6))
|
|
|
+ .andExpect(jsonPath("$.data.districtDistribution[0].districtName").value("未分区"))
|
|
|
+ .andExpect(jsonPath("$.data.districtDistribution[0].pointCount").value(6))
|
|
|
+ .andExpect(jsonPath("$.data.industryDistribution[0].industry").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.industryDistribution[0].pointCount").value(6))
|
|
|
+ .andExpect(jsonPath("$.data.deviceTypeDistribution[0].deviceType.code").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.pointCodes", hasSize(6)))
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.deviceCodes", hasSize(0)))
|
|
|
+ .andExpect(jsonPath("$.data.excluded.unknownTypeCount").value(0))
|
|
|
+ .andExpect(jsonPath("$.data.excluded.invalidCoordinateCount").value(0))
|
|
|
+ .andExpect(jsonPath("$.data.freshness.status").value("CURRENT"))
|
|
|
+ .andExpect(jsonPath("$.data.freshness.reason").value("READY"));
|
|
|
+ mockMvc.perform(get(ENDPOINT).param("page", "3").param("pageSize", "2").param("snapshotAt", SNAPSHOT_AT))
|
|
|
+ .andExpect(status().isOk())
|
|
|
+ .andExpect(jsonPath("$.data.pagination.total").value(6))
|
|
|
+ .andExpect(jsonPath("$.data.pagination.hasMore").value(false))
|
|
|
+ .andExpect(jsonPath("$.data.monitoringPoints[0].pointCode").value("RQ001"));
|
|
|
+ mockMvc.perform(get(ENDPOINT).param("district", "UNASSIGNED"))
|
|
|
+ .andExpect(status().isOk()).andExpect(jsonPath("$.data.pagination.total").value(6));
|
|
|
+ for (String[] filter : Arrays.asList(new String[]{"industry", "GAS"},
|
|
|
+ new String[]{"deviceType", "GAS_SENSOR"}, new String[]{"district", "0"},
|
|
|
+ new String[]{"pointStatus", "NORMAL"})) {
|
|
|
+ mockMvc.perform(get(ENDPOINT).param(filter[0], filter[1]))
|
|
|
+ .andExpect(status().isOk()).andExpect(jsonPath("$.data.pagination.total").value(0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void coordinatesDoNotAffectStatisticsAndAssociatedDevicesNeverBecomeStandaloneMarkers() {
|
|
|
+ CockpitMonitoringPointDeviceSnapshot bound = device(
|
|
|
+ "BOUND", "关联设备", true, true, false, false, Collections.emptyList());
|
|
|
+ CockpitMonitoringDistributionSnapshot snapshot = new CockpitMonitoringDistributionSnapshot(
|
|
|
+ SNAPSHOT_AT, SNAPSHOT_AT, fixture().getTypes(),
|
|
|
+ Collections.singletonList(new CockpitMonitoringDistributionSnapshot.SourceMonitoringPoint(
|
|
|
+ "P", "点位", 0, "GAS_SENSOR", null, null, false, Collections.singletonList(bound))),
|
|
|
+ Arrays.asList(smartDevice("BOUND", "关联设备", 1, "GAS_SENSOR", "110.4", "28.4", false,
|
|
|
+ true, true, false, false, Collections.emptyList()),
|
|
|
+ smartDevice("FREE", "独立设备", 1, "GAS_SENSOR", "181", "28.4", true,
|
|
|
+ true, false, false, false, Collections.emptyList())));
|
|
|
+ when(adapter.load(null)).thenReturn(snapshot);
|
|
|
+ CockpitMonitoringDistributionResponse all = service.load("all", null, null, null, null, 1, 100, null);
|
|
|
+ assertEquals(2, all.getPagination().getTotal());
|
|
|
+ assertEquals(1, all.getUnassociatedEquipment().size());
|
|
|
+ assertEquals("FREE", all.getUnassociatedEquipment().get(0).getDeviceCode());
|
|
|
+ assertTrue(!all.getMonitoringPoints().get(0).getCoordinateValidation().isRenderable());
|
|
|
+ assertTrue(!all.getUnassociatedEquipment().get(0).getCoordinateValidation().isRenderable());
|
|
|
+ assertEquals(0, all.getExcluded().getInvalidCoordinateCount());
|
|
|
+ assertEquals("READY", all.getFreshness().getReason());
|
|
|
+ assertEquals(1, statusCount(all, CockpitMonitoringPointStatus.ALARM));
|
|
|
+ assertEquals(0, statusCount(all, CockpitMonitoringPointStatus.NORMAL));
|
|
|
+
|
|
|
+ CockpitMonitoringDistributionResponse normal = service.load("normal", null, null, "NORMAL", null, 1, 100, null);
|
|
|
+ assertEquals(Collections.singletonList("FREE"), normal.getMapFilter().getDeviceCodes());
|
|
|
+ assertTrue(normal.getMapFilter().getPointCodes().isEmpty());
|
|
|
+ CockpitMonitoringDistributionResponse district = service.load("district", null, null, null, "1", 1, 100, null);
|
|
|
+ assertEquals(1, district.getPagination().getTotal(), "被筛掉的点位不能让关联设备变成独立设备");
|
|
|
+ assertEquals(Collections.singletonList("FREE"), district.getMapFilter().getDeviceCodes());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void exclusionsCountEachRejectedObjectOnceRegardlessOfAssociatedDeviceCount() {
|
|
|
+ CockpitMonitoringPointDeviceSnapshot d = device("D", "设备", true, false, false, false, Collections.emptyList());
|
|
|
+ CockpitMonitoringDistributionSnapshot snapshot = new CockpitMonitoringDistributionSnapshot(
|
|
|
+ SNAPSHOT_AT, SNAPSHOT_AT, fixture().getTypes(), Arrays.asList(
|
|
|
+ point("EMPTY", "合法空点", null, null, "110.4", "28.4"),
|
|
|
+ point("UNKNOWN", "未知类型", 0, "LEGACY", "110.4", "28.4", d, d, d),
|
|
|
+ point("MISMATCH", "错种类", 0, "WATER_PLANT", "110.4", "28.4", d, d),
|
|
|
+ point("NONFORMAL", "无行业", 0, "SMART_MANHOLE", "110.4", "28.4", d)), Arrays.asList(
|
|
|
+ smartDevice("U", "未知", 0, "LEGACY", "110.4", "28.4", true, true, false, false, false, Collections.emptyList()),
|
|
|
+ smartDevice("M", "错种类", 0, "WATER_PLANT", "110.4", "28.4", true, true, false, false, false, Collections.emptyList()),
|
|
|
+ smartDevice("N", "无行业", 0, "SMART_MANHOLE", "110.4", "28.4", true, true, false, false, false, Collections.emptyList())));
|
|
|
+ when(adapter.load(null)).thenReturn(snapshot);
|
|
|
+ CockpitMonitoringDistributionResponse response = service.load("reconcile", null, null, null, null, 1, 100, null);
|
|
|
+ assertEquals(1, response.getPagination().getTotal());
|
|
|
+ assertEquals(1, statusCount(response, CockpitMonitoringPointStatus.EMPTY));
|
|
|
+ assertEquals(2, response.getExcluded().getUnknownTypeCount());
|
|
|
+ assertEquals(2, response.getExcluded().getTypeKindMismatchCount());
|
|
|
+ assertEquals(2, response.getExcluded().getNonFormalIndustryCount());
|
|
|
+ int excluded = response.getExcluded().getUnknownTypeCount() + response.getExcluded().getTypeKindMismatchCount()
|
|
|
+ + response.getExcluded().getNonFormalIndustryCount() + response.getExcluded().getInvalidCoordinateCount();
|
|
|
+ assertEquals(7, response.getPagination().getTotal() + excluded);
|
|
|
}
|
|
|
|
|
|
private int statusCount(CockpitMonitoringDistributionResponse response,
|