| | |
| | | } |
| | | } |
| | | |
| | | /** 验证旧登记记录缺少厂商身份时仍可按稳定设备编码同步并补齐身份。 */ |
| | | @Test |
| | | void registeredObservationSqlShouldRepairLegacyVendorIdentity() throws IOException |
| | | { |
| | | try (InputStream input = getClass().getResourceAsStream( |
| | | "/mapper/system/TDetectionCabinetMapper.xml")) |
| | | { |
| | | assertNotNull(input); |
| | | String mapperXml = new String(input.readAllBytes(), StandardCharsets.UTF_8); |
| | | int start = mapperXml.indexOf("<update id=\"updateRegisteredCabinetObservation\""); |
| | | int end = mapperXml.indexOf("</update>", start); |
| | | String updateSql = mapperXml.substring(start, end); |
| | | |
| | | assertTrue(updateSql.contains("vendor_device_type = coalesce(vendor_device_type, #{devtype})")); |
| | | assertTrue(updateSql.contains("cabinet_code = concat(#{adapterCode}, '-', #{devtype}, '-', #{devid})")); |
| | | } |
| | | } |
| | | |
| | | private String sqlFragment(String mapperXml, String id) |
| | | { |
| | | int start = mapperXml.indexOf("<sql id=\"" + id + "\""); |