puzhibing
2026-09-14 34e836924716843f64a6c68442e5fb297d0e25e4
ruoyi-service/ruoyi-account/src/test/java/com/ruoyi/account/controller/TVinManagementControllerTest.java
@@ -215,6 +215,37 @@
        assertEquals(Arrays.asList(1L, 2L), controller.getVinIdsByAppUserId(88L).getData());
    }
    @Test
    void innerListByIdsDelegatesDistinctIds() {
        TVinManagementService service = mock(TVinManagementService.class);
        TVinManagement record = new TVinManagement();
        record.setId(1L);
        when(service.listByIds(Arrays.asList(1L, 2L))).thenReturn(Collections.singletonList(record));
        TVinManagementController controller = buildController(service);
        R<List<TVinManagement>> result = controller.listByIds(Arrays.asList(1L, 1L, null, 2L));
        assertEquals(200, result.getCode());
        assertEquals(1, result.getData().size());
        assertEquals(Long.valueOf(1L), result.getData().get(0).getId());
        verify(service).listByIds(Arrays.asList(1L, 2L));
    }
    @Test
    void innerListByIdsReturnsEmptyWhenIdsBlank() {
        TVinManagementService service = mock(TVinManagementService.class);
        TVinManagementController controller = buildController(service);
        R<List<TVinManagement>> emptyResult = controller.listByIds(Collections.emptyList());
        R<List<TVinManagement>> nullResult = controller.listByIds(null);
        assertEquals(200, emptyResult.getCode());
        assertTrue(emptyResult.getData().isEmpty());
        assertEquals(200, nullResult.getCode());
        assertTrue(nullResult.getData().isEmpty());
        verifyNoInteractions(service);
    }
    private MockMultipartFile vinExcelFile() throws Exception {
        try (XSSFWorkbook workbook = new XSSFWorkbook(); ByteArrayOutputStream output = new ByteArrayOutputStream()) {
            Sheet sheet = workbook.createSheet("VIN码数据");