|
|
@@ -18,7 +18,6 @@ import java.time.Clock;
|
|
|
import java.time.Instant;
|
|
|
import java.time.ZoneOffset;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -33,6 +32,9 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
|
|
|
|
|
+/**
|
|
|
+ * 管理信息契约:**片区 × 行业**计数,组织/权属视图已按决策票 06 删除。
|
|
|
+ */
|
|
|
class CockpitInfrastructureManagementInformationControllerTest {
|
|
|
|
|
|
private static final String ENDPOINT = "/api/cockpit/v1/infrastructure/management-information";
|
|
|
@@ -53,7 +55,7 @@ class CockpitInfrastructureManagementInformationControllerTest {
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void managementInformationGroupsOrganizationsAndOwnershipDistribution() throws Exception {
|
|
|
+ void managementInformationGroupsCountsByDistrictAndIndustry() throws Exception {
|
|
|
when(adapter.load()).thenReturn(fixture());
|
|
|
|
|
|
mockMvc.perform(get(ENDPOINT).header("X-Request-Id", "management-information-001"))
|
|
|
@@ -69,41 +71,37 @@ class CockpitInfrastructureManagementInformationControllerTest {
|
|
|
.andExpect(jsonPath("$.data.freshness.status").value("CURRENT"))
|
|
|
.andExpect(jsonPath("$.data.freshness.reason").value("READY"))
|
|
|
.andExpect(jsonPath("$.data.selectedFilters.industry").value(nullValue()))
|
|
|
- .andExpect(jsonPath("$.data.selectedFilters.organizationCode").value(nullValue()))
|
|
|
- .andExpect(jsonPath("$.data.totals.organizationCount").value(5))
|
|
|
- .andExpect(jsonPath("$.data.totals.facilityCount").value(6))
|
|
|
- .andExpect(jsonPath("$.data.totals.equipmentCount").value(4))
|
|
|
- .andExpect(jsonPath("$.data.totals.unmaintainedCount").value(2))
|
|
|
- .andExpect(jsonPath("$.data.organizations", hasSize(5)))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].organizationCode").value("ORG-WS-A"))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].organizationName").value("供水一公司"))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].industry").value("WATER_SUPPLY"))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].facilityCount").value(2))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].equipmentCount").value(1))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].unmaintained").value(false))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].ownershipDistribution", hasSize(2)))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].ownershipDistribution[0].ownershipType").value("OWNED"))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].ownershipDistribution[0].facilityCount").value(2))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].ownershipDistribution[0].equipmentCount").value(0))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].ownershipDistribution[0].total").value(2))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].ownershipDistribution[1].ownershipType").value("LEASED"))
|
|
|
- .andExpect(jsonPath("$.data.organizations[1].organizationCode").value("ORG-GAS-A"))
|
|
|
- .andExpect(jsonPath("$.data.organizations[2].organizationCode").value("ORG-WS-B"))
|
|
|
- .andExpect(jsonPath("$.data.organizations[2].ownershipDistribution[0].ownershipType").value("ENTRUSTED"))
|
|
|
- .andExpect(jsonPath("$.data.organizations[2].ownershipDistribution[1].ownershipType").value("UNKNOWN"))
|
|
|
- .andExpect(jsonPath("$.data.ownershipDistribution", hasSize(4)))
|
|
|
- .andExpect(jsonPath("$.data.ownershipDistribution[0].ownershipType").value("OWNED"))
|
|
|
- .andExpect(jsonPath("$.data.ownershipDistribution[0].facilityCount").value(5))
|
|
|
- .andExpect(jsonPath("$.data.ownershipDistribution[0].equipmentCount").value(1))
|
|
|
- .andExpect(jsonPath("$.data.ownershipDistribution[0].total").value(6))
|
|
|
- .andExpect(jsonPath("$.data.ownershipDistribution[1].ownershipType").value("UNKNOWN"))
|
|
|
- .andExpect(jsonPath("$.data.ownershipDistribution[1].total").value(2))
|
|
|
- .andExpect(jsonPath("$.data.ownershipDistribution[2].ownershipType").value("ENTRUSTED"))
|
|
|
- .andExpect(jsonPath("$.data.ownershipDistribution[3].ownershipType").value("LEASED"))
|
|
|
- .andExpect(jsonPath("$.data.mapFilter.organizationCodes", hasSize(5)))
|
|
|
- .andExpect(jsonPath("$.data.mapFilter.organizationCodes[0]").value("ORG-WS-A"))
|
|
|
- .andExpect(jsonPath("$.data.mapFilter.organizationCodes[3]").value("UNMAINTAINED"))
|
|
|
- .andExpect(jsonPath("$.data.mapFilter.organizationCodes[4]").value("ORG-MH-A"))
|
|
|
+ .andExpect(jsonPath("$.data.selectedFilters.district").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.selectedFilters.districtFilter").value("NONE"))
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.district").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.districtFilter").value("NONE"))
|
|
|
+ // 片区升序、未分区最后;未分区内部按行业排序。
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry", hasSize(5)))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[0].district").value(0))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[0].districtName").value("城南"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[0].industry").value("WATER_SUPPLY"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[0].facilityCount").value(2))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[0].equipmentCount").value(1))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[1].district").value(1))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[1].districtName").value("城北"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[1].industry").value("GAS"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[1].facilityCount").value(1))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[1].equipmentCount").value(1))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[2].district").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[2].districtName").value("未分区"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[2].industry").value("DRAINAGE"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[2].facilityCount").value(1))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[2].equipmentCount").value(1))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[3].district").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[3].districtName").value("未分区"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[3].industry").value("GAS"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[3].facilityCount").value(0))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[3].equipmentCount").value(1))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[4].district").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[4].districtName").value("未分区"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[4].industry").value("MANHOLE"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[4].facilityCount").value(1))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[4].equipmentCount").value(0))
|
|
|
.andExpect(jsonPath("$.data.excluded.duplicateRelationCount").value(1))
|
|
|
.andExpect(jsonPath("$.data.excluded.unknownIndustryCount").value(1))
|
|
|
.andExpect(jsonPath("$.data.excluded.nonFormalIndustryCount").value(0))
|
|
|
@@ -111,101 +109,112 @@ class CockpitInfrastructureManagementInformationControllerTest {
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void missingOrganizationFallsIntoExplicitUnmaintainedBucket() throws Exception {
|
|
|
+ void removedOrganizationAndOwnershipFieldsAreGoneFromTheResponse() throws Exception {
|
|
|
when(adapter.load()).thenReturn(fixture());
|
|
|
|
|
|
mockMvc.perform(get(ENDPOINT))
|
|
|
.andExpect(status().isOk())
|
|
|
- .andExpect(jsonPath("$.data.organizations[3].organizationCode").value("UNMAINTAINED"))
|
|
|
- .andExpect(jsonPath("$.data.organizations[3].organizationName").value("未维护"))
|
|
|
- .andExpect(jsonPath("$.data.organizations[3].unmaintained").value(true))
|
|
|
- .andExpect(jsonPath("$.data.organizations[3].industry").value("DRAINAGE"))
|
|
|
- .andExpect(jsonPath("$.data.organizations[3].facilityCount").value(1))
|
|
|
- .andExpect(jsonPath("$.data.organizations[3].equipmentCount").value(1))
|
|
|
- .andExpect(jsonPath("$.data.organizations[3].ownershipDistribution[0].ownershipType").value("OWNED"))
|
|
|
- .andExpect(jsonPath("$.data.organizations[3].ownershipDistribution[1].ownershipType").value("UNKNOWN"))
|
|
|
- .andExpect(jsonPath("$.data.totals.unmaintainedCount").value(2));
|
|
|
+ .andExpect(jsonPath("$.data.organizations").doesNotExist())
|
|
|
+ .andExpect(jsonPath("$.data.ownershipDistribution").doesNotExist())
|
|
|
+ .andExpect(jsonPath("$.data.totals.unmaintainedCount").doesNotExist())
|
|
|
+ .andExpect(jsonPath("$.data.totals.organizationCount").doesNotExist())
|
|
|
+ .andExpect(jsonPath("$.data.selectedFilters.organizationCode").doesNotExist())
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.organizationCode").doesNotExist())
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.organizationCodes").doesNotExist());
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void duplicateRelationsAreCountedOnceAndReportedAsExcluded() throws Exception {
|
|
|
+ void facilitiesAndEquipmentAreCountedSeparatelyAndNeverMerged() throws Exception {
|
|
|
when(adapter.load()).thenReturn(fixture());
|
|
|
|
|
|
mockMvc.perform(get(ENDPOINT))
|
|
|
.andExpect(status().isOk())
|
|
|
- .andExpect(jsonPath("$.data.totals.facilityCount").value(6))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].facilityCount").value(2))
|
|
|
- .andExpect(jsonPath("$.data.excluded.duplicateRelationCount").value(1));
|
|
|
+ .andExpect(jsonPath("$.data.totals.facilityCount").value(5))
|
|
|
+ .andExpect(jsonPath("$.data.totals.equipmentCount").value(4))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[0].facilityCount").value(2))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[0].equipmentCount").value(1));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void facilitiesAndEquipmentAreCountedSeparatelyAndNeverMerged() throws Exception {
|
|
|
+ void industryFilterRestrictsDistrictIndustryRowsToTheFormalIndustry() throws Exception {
|
|
|
when(adapter.load()).thenReturn(fixture());
|
|
|
|
|
|
- mockMvc.perform(get(ENDPOINT))
|
|
|
+ mockMvc.perform(get(ENDPOINT).queryParam("industry", "WATER_SUPPLY"))
|
|
|
.andExpect(status().isOk())
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].facilityCount").value(2))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].equipmentCount").value(1))
|
|
|
- .andExpect(jsonPath("$.data.totals.facilityCount").value(6))
|
|
|
- .andExpect(jsonPath("$.data.totals.equipmentCount").value(4));
|
|
|
+ .andExpect(jsonPath("$.data.selectedFilters.industry").value("WATER_SUPPLY"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry", hasSize(1)))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[0].district").value(0))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[0].districtName").value("城南"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[0].industry").value("WATER_SUPPLY"))
|
|
|
+ .andExpect(jsonPath("$.data.totals.facilityCount").value(2))
|
|
|
+ .andExpect(jsonPath("$.data.totals.equipmentCount").value(1));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void industryFilterRestrictsOrganizationsToTheFormalIndustry() throws Exception {
|
|
|
+ void districtFilterSelectsOnlyTheRequestedDistrict() throws Exception {
|
|
|
when(adapter.load()).thenReturn(fixture());
|
|
|
|
|
|
- mockMvc.perform(get(ENDPOINT).queryParam("industry", "WATER_SUPPLY"))
|
|
|
+ mockMvc.perform(get(ENDPOINT).queryParam("district", "1"))
|
|
|
.andExpect(status().isOk())
|
|
|
- .andExpect(jsonPath("$.data.selectedFilters.industry").value("WATER_SUPPLY"))
|
|
|
- .andExpect(jsonPath("$.data.organizations", hasSize(2)))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].organizationCode").value("ORG-WS-A"))
|
|
|
- .andExpect(jsonPath("$.data.organizations[1].organizationCode").value("ORG-WS-B"))
|
|
|
- .andExpect(jsonPath("$.data.totals.facilityCount").value(3))
|
|
|
- .andExpect(jsonPath("$.data.totals.equipmentCount").value(2));
|
|
|
+ .andExpect(jsonPath("$.data.selectedFilters.district").value(1))
|
|
|
+ .andExpect(jsonPath("$.data.selectedFilters.districtName").value("城北"))
|
|
|
+ .andExpect(jsonPath("$.data.selectedFilters.districtFilter").value("ASSIGNED"))
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.district").value(1))
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.districtFilter").value("ASSIGNED"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry", hasSize(1)))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[0].industry").value("GAS"))
|
|
|
+ .andExpect(jsonPath("$.data.totals.facilityCount").value(1))
|
|
|
+ .andExpect(jsonPath("$.data.totals.equipmentCount").value(1));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void organizationCodeFilterSelectsSingleUnit() throws Exception {
|
|
|
+ void unassignedDistrictFilterSelectsOnlyUnassignedRows() throws Exception {
|
|
|
when(adapter.load()).thenReturn(fixture());
|
|
|
|
|
|
- mockMvc.perform(get(ENDPOINT).queryParam("organizationCode", "ORG-GAS-A"))
|
|
|
+ mockMvc.perform(get(ENDPOINT).queryParam("district", "UNASSIGNED"))
|
|
|
.andExpect(status().isOk())
|
|
|
- .andExpect(jsonPath("$.data.selectedFilters.organizationCode").value("ORG-GAS-A"))
|
|
|
- .andExpect(jsonPath("$.data.organizations", hasSize(1)))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].organizationCode").value("ORG-GAS-A"))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].organizationName").value("燃气公司"))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].industry").value("GAS"))
|
|
|
- .andExpect(jsonPath("$.data.totals.facilityCount").value(1))
|
|
|
- .andExpect(jsonPath("$.data.totals.equipmentCount").value(1))
|
|
|
- .andExpect(jsonPath("$.data.mapFilter.organizationCodes[0]").value("ORG-GAS-A"));
|
|
|
+ .andExpect(jsonPath("$.data.selectedFilters.district").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.selectedFilters.districtName").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.selectedFilters.districtFilter").value("UNASSIGNED"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry", hasSize(3)))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[0].districtName").value("未分区"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[0].industry").value("DRAINAGE"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[1].districtName").value("未分区"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[1].industry").value("GAS"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[2].districtName").value("未分区"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[2].industry").value("MANHOLE"))
|
|
|
+ .andExpect(jsonPath("$.data.totals.facilityCount").value(2))
|
|
|
+ .andExpect(jsonPath("$.data.totals.equipmentCount").value(2));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void unmaintainedCodeFilterSelectsOnlyTheUnmaintainedBucket() throws Exception {
|
|
|
+ void dirtyDistrictValuesAreNormalizedToUnassignedInsteadOfInventingDistricts() throws Exception {
|
|
|
when(adapter.load()).thenReturn(fixture());
|
|
|
|
|
|
- mockMvc.perform(get(ENDPOINT).queryParam("organizationCode", "UNMAINTAINED"))
|
|
|
+ mockMvc.perform(get(ENDPOINT))
|
|
|
.andExpect(status().isOk())
|
|
|
- .andExpect(jsonPath("$.data.organizations", hasSize(1)))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].organizationCode").value("UNMAINTAINED"))
|
|
|
- .andExpect(jsonPath("$.data.organizations[0].unmaintained").value(true))
|
|
|
- .andExpect(jsonPath("$.data.totals.facilityCount").value(1))
|
|
|
- .andExpect(jsonPath("$.data.totals.equipmentCount").value(1));
|
|
|
+ // 片区 99 是脏值 → 与 null 合并进同一「未分区 GAS」桶,不得冒充第 4 个片区。
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[3].district").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[3].districtName").value("未分区"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[3].industry").value("GAS"))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[3].equipmentCount").value(1))
|
|
|
+ // 合法片区只有 0/1 两行,没有 99。
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry[?(@.district == 99)]", hasSize(0)));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void unknownOrganizationCodeReturnsExplicitEmptyResult() throws Exception {
|
|
|
+ void unknownIndustryCombinationReturnsExplicitEmptyResult() throws Exception {
|
|
|
when(adapter.load()).thenReturn(fixture());
|
|
|
|
|
|
- mockMvc.perform(get(ENDPOINT).queryParam("organizationCode", "ORG-MISSING"))
|
|
|
+ mockMvc.perform(get(ENDPOINT)
|
|
|
+ .queryParam("industry", "MANHOLE")
|
|
|
+ .queryParam("district", "0"))
|
|
|
.andExpect(status().isOk())
|
|
|
- .andExpect(jsonPath("$.data.organizations", hasSize(0)))
|
|
|
- .andExpect(jsonPath("$.data.totals.organizationCount").value(0))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry", hasSize(0)))
|
|
|
.andExpect(jsonPath("$.data.totals.facilityCount").value(0))
|
|
|
.andExpect(jsonPath("$.data.totals.equipmentCount").value(0))
|
|
|
- .andExpect(jsonPath("$.data.mapFilter.organizationCodes", hasSize(0)))
|
|
|
.andExpect(jsonPath("$.data.freshness.status").value("EMPTY"))
|
|
|
- .andExpect(jsonPath("$.data.freshness.reason").value("NO_ORGANIZATIONS"));
|
|
|
+ .andExpect(jsonPath("$.data.freshness.reason").value("NO_RELATIONS"));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
@@ -215,11 +224,11 @@ class CockpitInfrastructureManagementInformationControllerTest {
|
|
|
|
|
|
mockMvc.perform(get(ENDPOINT))
|
|
|
.andExpect(status().isOk())
|
|
|
- .andExpect(jsonPath("$.data.organizations", hasSize(0)))
|
|
|
- .andExpect(jsonPath("$.data.ownershipDistribution", hasSize(0)))
|
|
|
- .andExpect(jsonPath("$.data.totals.organizationCount").value(0))
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry", hasSize(0)))
|
|
|
+ .andExpect(jsonPath("$.data.totals.facilityCount").value(0))
|
|
|
+ .andExpect(jsonPath("$.data.totals.equipmentCount").value(0))
|
|
|
.andExpect(jsonPath("$.data.freshness.status").value("EMPTY"))
|
|
|
- .andExpect(jsonPath("$.data.freshness.reason").value("NO_ORGANIZATIONS"));
|
|
|
+ .andExpect(jsonPath("$.data.freshness.reason").value("NO_RELATIONS"));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
@@ -233,6 +242,32 @@ class CockpitInfrastructureManagementInformationControllerTest {
|
|
|
verifyNoInteractions(adapter);
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ void invalidDistrictReturnsTypedBadRequestBeforeReadAdapterIsCalled() throws Exception {
|
|
|
+ mockMvc.perform(get(ENDPOINT).queryParam("district", "城区A"))
|
|
|
+ .andExpect(status().isBadRequest())
|
|
|
+ .andExpect(jsonPath("$.code").value(400))
|
|
|
+ .andExpect(jsonPath("$.data.category").value("INVALID_REQUEST"))
|
|
|
+ .andExpect(jsonPath("$.data.message").value("district must be 0, 1, 2 or UNASSIGNED"));
|
|
|
+
|
|
|
+ mockMvc.perform(get(ENDPOINT).queryParam("district", "3"))
|
|
|
+ .andExpect(status().isBadRequest())
|
|
|
+ .andExpect(jsonPath("$.data.message").value("district must be 0, 1, 2 or UNASSIGNED"));
|
|
|
+
|
|
|
+ verifyNoInteractions(adapter);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void legacyOrganizationCodeParameterIsNoLongerAContract() throws Exception {
|
|
|
+ when(adapter.load()).thenReturn(fixture());
|
|
|
+
|
|
|
+ // 旧组织入参已删除:不再被当成筛选条件(绑定层忽略未知入参),响应里也没有组织字段。
|
|
|
+ mockMvc.perform(get(ENDPOINT).queryParam("organizationCode", "ORG-GAS-A"))
|
|
|
+ .andExpect(status().isOk())
|
|
|
+ .andExpect(jsonPath("$.data.districtIndustry", hasSize(5)))
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.organizationCodes").doesNotExist());
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
void mutatingRequestIsRejectedBeforeReadAdapterIsCalled() throws Exception {
|
|
|
mockMvc.perform(post(ENDPOINT))
|
|
|
@@ -266,21 +301,30 @@ class CockpitInfrastructureManagementInformationControllerTest {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 片区×行业用例:
|
|
|
+ * 城南 WSS 设施2/设备1;城北 GAS 设施1/设备1;未分区 DRAINAGE 设施1/设备1、
|
|
|
+ * MANHOLE 设施1/设备0;脏值片区 99 的 GAS 设备1 归一为未分区 GAS。
|
|
|
+ */
|
|
|
private static CockpitInfrastructureManagementInformationSnapshot fixture() {
|
|
|
- List<CockpitInfrastructureManagementInformationSnapshot.SourceRelation> relations = new ArrayList<>();
|
|
|
- relations.add(relation("F-WS-001", "FACILITY", "WATER_SUPPLY", "ORG-WS-A", "供水一公司", "OWNED"));
|
|
|
- relations.add(relation("F-WS-002", "FACILITY", "WATER_SUPPLY", "ORG-WS-A", "供水一公司", "OWNED"));
|
|
|
- relations.add(relation("E-WS-001", "SMART_DEVICE", "WATER_SUPPLY", "ORG-WS-A", "供水一公司", "LEASED"));
|
|
|
- relations.add(relation("F-WS-003", "FACILITY", "WATER_SUPPLY", "ORG-WS-B", "供水二公司", "ENTRUSTED"));
|
|
|
- relations.add(relation("E-WS-002", "SMART_DEVICE", "WATER_SUPPLY", "ORG-WS-B", "供水二公司", null));
|
|
|
- relations.add(relation("F-GAS-001", "FACILITY", "GAS", "ORG-GAS-A", "燃气公司", "OWNED"));
|
|
|
- relations.add(relation("E-GAS-001", "SMART_DEVICE", "GAS", "ORG-GAS-A", "燃气公司", "OWNED"));
|
|
|
- relations.add(relation("F-DR-001", "FACILITY", "DRAINAGE", null, null, "OWNED"));
|
|
|
- relations.add(relation("E-DR-001", "SMART_DEVICE", "DRAINAGE", " ", null, null));
|
|
|
- relations.add(relation("F-WS-001", "FACILITY", "WATER_SUPPLY", "ORG-WS-A", "供水一公司", "OWNED"));
|
|
|
- relations.add(relation("F-MH-001", "FACILITY", "MANHOLE", "ORG-MH-A", "井盖公司", "OWNED"));
|
|
|
- relations.add(relation("E-XX-001", "SMART_DEVICE", null, "ORG-WS-A", "供水一公司", "OWNED"));
|
|
|
- relations.add(relation("E-XX-002", "SENSOR", "WATER_SUPPLY", "ORG-WS-A", "供水一公司", "OWNED"));
|
|
|
+ List<CockpitInfrastructureManagementInformationSnapshot.SourceRelation> relations =
|
|
|
+ new ArrayList<>();
|
|
|
+ relations.add(relation("F-WS-001", "FACILITY", "WATER_SUPPLY", 0));
|
|
|
+ relations.add(relation("F-WS-002", "FACILITY", "WATER_SUPPLY", 0));
|
|
|
+ relations.add(relation("E-WS-001", "SMART_DEVICE", "WATER_SUPPLY", 0));
|
|
|
+ relations.add(relation("F-GAS-001", "FACILITY", "GAS", 1));
|
|
|
+ relations.add(relation("E-GAS-001", "SMART_DEVICE", "GAS", 1));
|
|
|
+ relations.add(relation("F-DR-001", "FACILITY", "DRAINAGE", null));
|
|
|
+ relations.add(relation("E-DR-001", "SMART_DEVICE", "DRAINAGE", null));
|
|
|
+ relations.add(relation("F-MH-001", "FACILITY", "MANHOLE", null));
|
|
|
+ // 重复对象:只应计一次,并计入 duplicateRelationCount。
|
|
|
+ relations.add(relation("F-WS-001", "FACILITY", "WATER_SUPPLY", 0));
|
|
|
+ // 行业缺失:计入 unknownIndustryCount。
|
|
|
+ relations.add(relation("E-XX-001", "SMART_DEVICE", null, 0));
|
|
|
+ // 对象类型不识别:计入 unknownObjectKindCount。
|
|
|
+ relations.add(relation("E-XX-002", "SENSOR", "WATER_SUPPLY", 0));
|
|
|
+ // 库中脏片区值:归一为未分区,不得冒充第 4 个片区。
|
|
|
+ relations.add(relation("E-GAS-DIRTY", "SMART_DEVICE", "GAS", 99));
|
|
|
return new CockpitInfrastructureManagementInformationSnapshot(
|
|
|
"2026-09-02T09:59:50+08:00", relations);
|
|
|
}
|
|
|
@@ -289,10 +333,8 @@ class CockpitInfrastructureManagementInformationControllerTest {
|
|
|
String objectCode,
|
|
|
String objectKind,
|
|
|
String industry,
|
|
|
- String organizationCode,
|
|
|
- String organizationName,
|
|
|
- String ownershipType) {
|
|
|
+ Integer district) {
|
|
|
return new CockpitInfrastructureManagementInformationSnapshot.SourceRelation(
|
|
|
- objectCode, objectKind, industry, organizationCode, organizationName, ownershipType);
|
|
|
+ objectCode, objectKind, industry, district);
|
|
|
}
|
|
|
}
|