刘光辉
4 小时以前 06f314545ac3514d7ce28939920866ae8188d31c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
package jnpf.dmsService;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
import jnpf.base.UserInfo;
import jnpf.base.DictionaryDataApi;
import jnpf.base.entity.DictionaryDataEntity;
import jnpf.dmsEntity.watermark.DmsWatermarkParameters;
import jnpf.dmsEntity.permission.entity.DmsDocumentEntity;
import jnpf.dmsEntity.permission.entity.DmsFileVersionEntity;
import jnpf.dmsEntity.preview.model.DmsWatermarkSnapshot;
import jnpf.dmsEntity.watermark.DmsWatermarkConfigEntity;
import jnpf.dmsEntity.watermark.DmsWatermarkPositionEntity;
import jnpf.dmsIntegration.audit.DmsVersionStateAuditRow;
import jnpf.dmsMapper.DmsDocumentMapper;
import jnpf.dmsMapper.DmsVersionStateMapper;
import jnpf.dmsMapper.DmsWatermarkConfigMapper;
import jnpf.dmsMapper.DmsWatermarkPositionMapper;
import jnpf.permission.OrganizeApi;
import org.apache.ibatis.builder.MapperBuilderAssistant;
import org.apache.ibatis.session.Configuration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.ArgumentCaptor;
import org.mockito.junit.jupiter.MockitoExtension;
 
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
 
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.lenient;
 
@ExtendWith(MockitoExtension.class)
class DmsWatermarkPreviewResolverTest {
    private static final UUID VERSION_ID = UUID.fromString("0199d0e5-8e70-7000-8000-000000000010");
    private static final UUID DOCUMENT_ID = UUID.fromString("0199d0e5-8e70-7000-8000-000000000011");
    private static final UUID CONFIG_ID = UUID.fromString("0199d0e5-8e70-7000-8000-000000000012");
 
    @Mock private DmsWatermarkConfigMapper configMapper;
    @Mock private DmsWatermarkPositionMapper positionMapper;
    @Mock private DmsDocumentMapper documentMapper;
    @Mock private DmsVersionStateMapper versionStateMapper;
    @Mock private OrganizeApi organizeApi;
    @Mock private DictionaryDataApi dictionaryDataApi;
    private DmsWatermarkPreviewResolver resolver;
 
    @BeforeEach
    void setUp() {
        initTable(DmsWatermarkConfigEntity.class);
        initTable(DmsWatermarkPositionEntity.class);
        resolver = new DmsWatermarkPreviewResolver(configMapper, positionMapper, documentMapper,
                versionStateMapper, organizeApi, dictionaryDataApi);
        DictionaryDataEntity entry = new DictionaryDataEntity();
        entry.setDictionaryTypeId("879384732964547653");
        entry.setEnCode("RECORD");
        entry.setEnabledMark(1);
        lenient().when(dictionaryDataApi.getList("879384732964547653", "true")).thenReturn(List.of(entry));
        lenient().when(configMapper.selectMatchingConfigIds(any(), any(), any())).thenReturn(List.of(CONFIG_ID));
    }
 
    @Test
    void resolvesPreviewWatermarkForCurrentDocxAndReplacesTrustedVariables() {
        UserInfo user = user();
        user.setOrganizeIds(Collections.emptyList());
        DmsVersionStateAuditRow state = new DmsVersionStateAuditRow();
        state.setLifecycleStatus("EFFECTIVE");
        when(versionStateMapper.selectAuditState("tenant-1", VERSION_ID)).thenReturn(state);
        DmsWatermarkConfigEntity aligned = config();
        aligned.setHorizontalAlign("RIGHT");
        aligned.setVerticalAlign("MIDDLE");
        when(configMapper.selectList(any())).thenReturn(Collections.singletonList(aligned));
        when(positionMapper.selectList(any())).thenReturn(Collections.singletonList(position()));
        DmsDocumentEntity document = new DmsDocumentEntity();
        document.setDocumentNo("SOP-001");
        when(documentMapper.selectByTenantAndId("tenant-1", DOCUMENT_ID)).thenReturn(document);
 
        List<DmsWatermarkSnapshot> result = resolver.resolve(user, "tenant-1", version("manual.docx"), types());
 
        assertEquals(1, result.size());
        assertEquals("张三 / 质量部 / SOP-001 / V1.0 / 现行版本", result.get(0).getContent());
        assertEquals(1, result.get(0).getPositions().size());
        for (DmsWatermarkSnapshot snapshot : List.of(result.get(0),
                resolver.resolveDownload(user, "tenant-1", version("manual.docx"), types()).get(0),
                resolver.resolvePrint(user, "tenant-1", version("manual.docx"), types()).get(0))) {
            assertEquals("RIGHT", snapshot.getHorizontalAlign());
            assertEquals("MIDDLE", snapshot.getVerticalAlign());
        }
    }
 
    @Test
    void copiesBarcodeTextDisplayIntoPreviewSnapshot() {
        DmsVersionStateAuditRow state = new DmsVersionStateAuditRow();
        state.setLifecycleStatus("EFFECTIVE");
        when(versionStateMapper.selectAuditState("tenant-1", VERSION_ID)).thenReturn(state);
        DmsWatermarkConfigEntity config = config();
        config.setWatermarkType("BARCODE");
        config.setBarcodeFormat("QR_CODE");
        config.setContentTemplate("{/FILENO}");
        config.setShowBarcodeText(true);
        when(configMapper.selectList(any())).thenReturn(Collections.singletonList(config));
        when(positionMapper.selectList(any())).thenReturn(Collections.singletonList(position()));
        DmsDocumentEntity document = new DmsDocumentEntity();
        document.setDocumentNo("SOP-001");
        when(documentMapper.selectByTenantAndId("tenant-1", DOCUMENT_ID)).thenReturn(document);
 
        List<DmsWatermarkSnapshot> result = resolver.resolve(user(), "tenant-1", version("manual.docx"), types());
 
        assertEquals(Boolean.TRUE, result.get(0).getShowBarcodeText());
        assertEquals("SOP-001", result.get(0).getContent());
    }
 
    @Test
    void downloadUsesDownloadSceneConfiguration() {
        DmsVersionStateAuditRow state = new DmsVersionStateAuditRow();
        state.setLifecycleStatus("EFFECTIVE");
        when(versionStateMapper.selectAuditState("tenant-1", VERSION_ID)).thenReturn(state);
        when(configMapper.selectList(any())).thenReturn(Collections.singletonList(config()));
        when(positionMapper.selectList(any())).thenReturn(Collections.singletonList(position()));
 
        resolver.resolveDownload(user(), "tenant-1", version("manual.docx"), types());
 
        @SuppressWarnings("unchecked")
        ArgumentCaptor<LambdaQueryWrapper<DmsWatermarkConfigEntity>> captor =
                ArgumentCaptor.forClass(LambdaQueryWrapper.class);
        verify(configMapper).selectList(captor.capture());
        String sql = captor.getValue().getSqlSegment();
        assertTrue(sql.contains("load_download"));
        assertTrue(!sql.contains("load_preview"));
    }
 
    @Test
    void printUsesPrintSceneConfiguration() {
        DmsVersionStateAuditRow state = new DmsVersionStateAuditRow();
        state.setLifecycleStatus("EFFECTIVE");
        when(versionStateMapper.selectAuditState("tenant-1", VERSION_ID)).thenReturn(state);
        when(configMapper.selectList(any())).thenReturn(Collections.singletonList(config()));
        when(positionMapper.selectList(any())).thenReturn(Collections.singletonList(position()));
 
        resolver.resolvePrint(user(), "tenant-1", version("manual.docx"), types());
 
        @SuppressWarnings("unchecked")
        ArgumentCaptor<LambdaQueryWrapper<DmsWatermarkConfigEntity>> captor =
                ArgumentCaptor.forClass(LambdaQueryWrapper.class);
        verify(configMapper).selectList(captor.capture());
        String sql = captor.getValue().getSqlSegment();
        assertTrue(sql.contains("load_print"));
        assertTrue(!sql.contains("load_preview"));
        assertTrue(!sql.contains("load_download"));
    }
 
    @Test
    void rejectsChineseFileNameInCode128BeforeIssuingPreview() {
        DmsVersionStateAuditRow state = new DmsVersionStateAuditRow();
        state.setLifecycleStatus("EFFECTIVE");
        when(versionStateMapper.selectAuditState("tenant-1", VERSION_ID)).thenReturn(state);
        DmsWatermarkConfigEntity config = config();
        config.setName("测试2");
        config.setWatermarkType("BARCODE");
        config.setBarcodeFormat("CODE_128");
        config.setContentTemplate("{/FILENAME}-{/VERSION}");
        when(configMapper.selectList(any())).thenReturn(Collections.singletonList(config));
        when(positionMapper.selectList(any())).thenReturn(Collections.singletonList(position()));
        jnpf.exception.DataException error = assertThrows(jnpf.exception.DataException.class,
                () -> resolver.resolve(user(), "tenant-1", version("玻思韬.docx"), types()));
        assertTrue(error.getMessage().contains("测试2"));
        assertTrue(error.getMessage().contains("请将条码格式改为二维码"));
    }
 
    @Test
    void historicalVersionUsesAllScopeWatermarksAndHistoricalStateText() {
        DmsVersionStateAuditRow state = new DmsVersionStateAuditRow();
        state.setLifecycleStatus("SUPERSEDED");
        when(versionStateMapper.selectAuditState("tenant-1", VERSION_ID)).thenReturn(state);
        DmsWatermarkConfigEntity allVersions = config();
        allVersions.setVersionScope("ALL");
        when(configMapper.selectList(any())).thenReturn(Collections.singletonList(allVersions));
        when(positionMapper.selectList(any())).thenReturn(Collections.singletonList(position()));
 
        List<DmsWatermarkSnapshot> result = resolver.resolve(user(), "tenant-1", version("manual.docx"), types());
 
        assertEquals(1, result.size());
        assertTrue(result.get(0).getContent().contains("历史版本"));
        @SuppressWarnings("unchecked")
        ArgumentCaptor<LambdaQueryWrapper<DmsWatermarkConfigEntity>> captor =
                ArgumentCaptor.forClass(LambdaQueryWrapper.class);
        verify(configMapper).selectList(captor.capture());
        String sql = captor.getValue().getSqlSegment();
        assertTrue(sql.contains("version_scope"), sql);
        assertTrue(!sql.contains("version_scope IN"), sql);
    }
 
    @Test
    void pendingVersionDoesNotResolveWatermarks() {
        DmsVersionStateAuditRow state = new DmsVersionStateAuditRow();
        state.setLifecycleStatus("PENDING");
        when(versionStateMapper.selectAuditState("tenant-1", VERSION_ID)).thenReturn(state);
 
        assertEquals(0, resolver.resolve(user(), "tenant-1", version("manual.docx"), types()).size());
        verify(configMapper, never()).selectList(any());
    }
 
    @Test
    void resolvesPreviewWatermarkForSupportedImages() {
        DmsVersionStateAuditRow state = new DmsVersionStateAuditRow();
        state.setLifecycleStatus("EFFECTIVE");
        when(versionStateMapper.selectAuditState("tenant-1", VERSION_ID)).thenReturn(state);
        when(configMapper.selectList(any())).thenReturn(Collections.singletonList(config()));
        when(positionMapper.selectList(any())).thenReturn(Collections.singletonList(position()));
 
        assertEquals(1, resolver.resolve(user(), "tenant-1", version("diagram.PNG"), types()).size());
        assertEquals(1, resolver.resolve(user(), "tenant-1", version("photo.jpg"), types()).size());
        DmsFileVersionEntity mimeOnlyImage = version("diagram");
        mimeOnlyImage.setMimeType("image/png");
        assertEquals(1, resolver.resolve(user(), "tenant-1", mimeOnlyImage, types()).size());
    }
 
    @Test
    void resolvesWatermarksForPdfInEveryScene() {
        DmsVersionStateAuditRow state = new DmsVersionStateAuditRow();
        state.setLifecycleStatus("EFFECTIVE");
        when(versionStateMapper.selectAuditState("tenant-1", VERSION_ID)).thenReturn(state);
        when(configMapper.selectList(any())).thenReturn(Collections.singletonList(config()));
        when(positionMapper.selectList(any())).thenReturn(Collections.singletonList(position()));
 
        DmsFileVersionEntity pdf = version("manual.pdf");
        assertEquals(1, resolver.resolve(user(), "tenant-1", pdf, types()).size());
        assertEquals(1, resolver.resolveDownload(user(), "tenant-1", pdf, types()).size());
        assertEquals(1, resolver.resolvePrint(user(), "tenant-1", pdf, types()).size());
    }
 
    @Test
    void eachRuntimeEntryProducesItsOwnBarcodeWithIndependentPayloadAndLabelInEveryScene() {
        customAndOrdinaryConfigurations();
        jnpf.dmsEntity.watermark.DmsWatermarkParameters parameters = new jnpf.dmsEntity.watermark.DmsWatermarkParameters();
        parameters.setCustomBarcode(List.of(entry(5, "REC-005", "第五页"),
                entry(4, "记录 {/CUN} <&>", "文字 {/CDN} <&>"),
                entry(4, "REC-SECOND-004", "同页第二条"), entry(null, "EVERY-PAGE", "每页")));
        parameters.setWatermarkBusinessTypes(List.of("RECORD"));
        for (List<DmsWatermarkSnapshot> snapshots : List.of(
                resolver.resolve(user(), "tenant-1", version("manual.docx"), parameters),
                resolver.resolveDownload(user(), "tenant-1", version("manual.docx"), parameters),
                resolver.resolvePrint(user(), "tenant-1", version("manual.docx"), parameters))) {
            assertEquals(5, snapshots.size());
            assertEquals("REC-005", snapshots.get(0).getContent());
            assertEquals("第五页", snapshots.get(0).getBarcodeText());
            assertEquals(List.of(5), snapshots.get(0).getRenderPages());
            assertEquals(Boolean.TRUE, snapshots.get(0).getShowBarcodeText());
            assertEquals("记录 {/CUN} <&>", snapshots.get(1).getContent());
            assertEquals("文字 {/CDN} <&>", snapshots.get(1).getBarcodeText());
            assertEquals(List.of(4), snapshots.get(1).getRenderPages());
            assertEquals("REC-SECOND-004", snapshots.get(2).getContent());
            assertEquals(List.of(4), snapshots.get(2).getRenderPages());
            org.junit.jupiter.api.Assertions.assertNull(snapshots.get(3).getRenderPages());
            org.junit.jupiter.api.Assertions.assertNull(snapshots.get(4).getRenderPages());
            assertTrue(snapshots.get(4).getContent().contains("张三"));
        }
    }
 
    @Test
    void frozenCopySerialUsesExistingCustomBarcodeSourceWithOrWithoutRequiredGuard() {
        customAndOrdinaryConfigurations();
        var request = new jnpf.dmsEntity.print.form.DmsFilePrintTicketRequest();
        request.setCustomBarcode(List.of(entry(null, "20261003000001",
                "打印流水号: 20261003000001  计数流水号: 20260001")));
        request.setWatermarkBusinessTypes(List.of("RECORD"));
        for (boolean required : List.of(false, true)) {
            request.setRequireSerialWatermark(required);
            var result = resolver.resolvePrint(user(), "tenant-1", version("manual.docx"), request);
            assertEquals(2, result.size());
            assertEquals(Boolean.TRUE, result.getFirst().getCustomBarcode());
            assertEquals("20261003000001", result.getFirst().getContent());
            assertEquals("打印流水号: 20261003000001  计数流水号: 20260001", result.getFirst().getBarcodeText());
            org.junit.jupiter.api.Assertions.assertNull(result.getFirst().getRenderPages());
            assertEquals(1, result.getFirst().getPositions().size());
            assertEquals("TEXT", result.get(1).getWatermarkType());
        }
    }
 
    @Test
    void absentRuntimeTextSkipsCustomConfigurationAndPreservesOrdinaryWatermarks() {
        customAndOrdinaryConfigurations();
        List<DmsWatermarkSnapshot> snapshots = resolver.resolve(user(), "tenant-1", version("manual.docx"), types());
        assertEquals(1, snapshots.size());
        assertEquals("TEXT", snapshots.get(0).getWatermarkType());
    }
 
    @Test
    void entryWithoutPageProducesEveryPageSnapshot() {
        customAndOrdinaryConfigurations();
        jnpf.dmsEntity.watermark.DmsWatermarkParameters parameters = new jnpf.dmsEntity.watermark.DmsWatermarkParameters();
        parameters.setCustomBarcode(List.of(entry(null, "REC-001", "Independent label")));
        parameters.setWatermarkBusinessTypes(List.of("RECORD"));
        List<DmsWatermarkSnapshot> snapshots = resolver.resolve(user(), "tenant-1", version("manual.docx"), parameters);
        assertEquals("REC-001", snapshots.get(0).getContent());
        assertEquals("Independent label", snapshots.get(0).getBarcodeText());
        org.junit.jupiter.api.Assertions.assertNull(snapshots.get(0).getRenderPages());
    }
 
    private jnpf.dmsEntity.watermark.DmsWatermarkParameters.CustomBarcode entry(Integer page, String value, String text) {
        jnpf.dmsEntity.watermark.DmsWatermarkParameters.CustomBarcode entry = new jnpf.dmsEntity.watermark.DmsWatermarkParameters.CustomBarcode();
        entry.setPage(page);
        entry.setBarValue(value);
        entry.setBarText(text);
        return entry;
    }
 
    private DmsWatermarkParameters types() {
        DmsWatermarkParameters parameters = new DmsWatermarkParameters();
        parameters.setWatermarkBusinessTypes(List.of("RECORD"));
        return parameters;
    }
 
    @Test
    void emptyBusinessTypesDoNotQueryWatermarkConfigurations() {
        assertTrue(resolver.resolve(user(), "tenant-1", version("manual.docx")).isEmpty());
        DmsWatermarkParameters empty = new DmsWatermarkParameters();
        empty.setWatermarkBusinessTypes(List.of());
        assertTrue(resolver.resolveDownload(user(), "tenant-1", version("manual.docx"), empty).isEmpty());
        verify(configMapper, never()).selectList(any());
    }
 
    @Test
    void multipleBusinessTypesSelectEachConfigurationOnce() {
        DictionaryDataEntity second = new DictionaryDataEntity();
        second.setDictionaryTypeId("879384732964547653");
        second.setEnCode("REPORT");
        second.setEnabledMark(1);
        DictionaryDataEntity first = new DictionaryDataEntity();
        first.setDictionaryTypeId("879384732964547653");
        first.setEnCode("RECORD");
        first.setEnabledMark(1);
        when(dictionaryDataApi.getList("879384732964547653", "true")).thenReturn(List.of(first, second));
        DmsVersionStateAuditRow state = new DmsVersionStateAuditRow();
        state.setLifecycleStatus("EFFECTIVE");
        when(versionStateMapper.selectAuditState("tenant-1", VERSION_ID)).thenReturn(state);
        when(configMapper.selectList(any())).thenReturn(List.of(config()));
        when(positionMapper.selectList(any())).thenReturn(List.of(position()));
        DmsWatermarkParameters parameters = new DmsWatermarkParameters();
        parameters.setWatermarkBusinessTypes(List.of("RECORD", "REPORT"));
 
        assertEquals(1, resolver.resolve(user(), "tenant-1", version("manual.docx"), parameters).size());
        verify(configMapper).selectMatchingConfigIds(any(), any(), any());
    }
 
    private void customAndOrdinaryConfigurations() {
        DmsVersionStateAuditRow state = new DmsVersionStateAuditRow();
        state.setLifecycleStatus("EFFECTIVE");
        when(versionStateMapper.selectAuditState("tenant-1", VERSION_ID)).thenReturn(state);
        DmsWatermarkConfigEntity custom = config();
        custom.setWatermarkType("BARCODE");
        custom.setBarcodeFormat("QR_CODE");
        custom.setShowBarcodeText(false);
        custom.setContentTemplate(jnpf.dmsEntity.watermark.DmsWatermarkParameters.CUSTOM_BARCODE_TEMPLATE);
        when(configMapper.selectList(any())).thenReturn(List.of(custom, config()));
        when(positionMapper.selectList(any())).thenReturn(List.of(position()));
    }
 
    private UserInfo user() {
        UserInfo user = new UserInfo();
        user.setUserId("user-1");
        user.setUserName("张三");
        user.setOrganize("质量部");
        user.setOrganizeIds(Collections.singletonList("department-1"));
        return user;
    }
 
    private DmsFileVersionEntity version(String fileName) {
        DmsFileVersionEntity version = new DmsFileVersionEntity();
        version.setId(VERSION_ID);
        version.setDocumentId(DOCUMENT_ID);
        version.setFileName(fileName);
        version.setVersionLabel("V1.0");
        return version;
    }
 
    private DmsWatermarkConfigEntity config() {
        DmsWatermarkConfigEntity config = new DmsWatermarkConfigEntity();
        config.setId(CONFIG_ID);
        config.setWatermarkType("TEXT");
        config.setContentTemplate("{/CUN} / {/CDN} / {/FILENO} / {/VERSION} / {/FILESTATE}");
        config.setFontFamily("SimHei");
        config.setFontColor("#666666");
        config.setFontSize(24);
        config.setRotationAngle(-30);
        config.setOpacity(30);
        config.setLayoutMode("POSITION");
        config.setMarkWidthMm(new BigDecimal("80"));
        config.setMarkHeightMm(new BigDecimal("20"));
        return config;
    }
 
    private DmsWatermarkPositionEntity position() {
        DmsWatermarkPositionEntity position = new DmsWatermarkPositionEntity();
        position.setConfigId(CONFIG_ID);
        position.setPaperType("A4");
        position.setPaperWidthMm(new BigDecimal("210"));
        position.setPaperHeightMm(new BigDecimal("297"));
        position.setPortraitXMm(new BigDecimal("65"));
        position.setPortraitYMm(new BigDecimal("138"));
        position.setLandscapeXMm(new BigDecimal("108"));
        position.setLandscapeYMm(new BigDecimal("95"));
        return position;
    }
 
    private void initTable(Class<?> type) {
        if (TableInfoHelper.getTableInfo(type) == null) {
            TableInfoHelper.initTableInfo(new MapperBuilderAssistant(new Configuration(), ""), type);
        }
    }
}