yangys
2025-08-07 bc4056543fdbef38ac8bf1648df934d5bc8e5bde
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
package org.springblade.mdm.flow.service;
 
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import org.springblade.core.log.exception.ServiceException;
 
public class FlowProgramFileServiceTest {
 
    @Test
    public void testCheckFilename() {
        FlowProgramFileService service = new FlowProgramFileService();
 
        String drawingNo = "零件号";
        String processNo = "10";
        String craftEdition = "A";//工艺版次
 
        String progName = drawingNo+"-"+processNo;
 
 
        FlowProgramProperties programProperties = new FlowProgramProperties();
        programProperties.setDrawingNo(drawingNo);
        programProperties.setProcessNo(processNo);
        programProperties.setCraftEdition(craftEdition);
        try {
            service.checkFilename("abc.txt", programProperties);
        }catch(ServiceException e){
            Assertions.assertEquals(1,e.getResultCode().getCode());
        }
 
        String filename = progName+"-"+craftEdition+"-4-1.txt";//4段第一段
        try {
            service.checkFilename(filename, programProperties);
 
        }catch(ServiceException e){
            Assertions.fail("应该验证通过,实际code="+e.getResultCode().getCode());
        }
 
        filename = progName+"-"+craftEdition+"-101-1.txt";//段数超2位数测试
        try {
            service.checkFilename(filename, programProperties);
        }catch(ServiceException e){
            Assertions.assertEquals(3,e.getResultCode().getCode());
        }
 
        filename = progName+"-"+craftEdition+"-3-5.txt";//段号超过总段数
        try {
            service.checkFilename(filename, programProperties);
        }catch(ServiceException e){
            Assertions.assertEquals(4,e.getResultCode().getCode());
        }
    }
 
 
    @Test
    public void getProgramSegCount(){
        FlowProgramFileService service = new FlowProgramFileService();
        String filename = "YZL4-1100-01-50-A-5-1.TXT";
 
        Assertions.assertEquals(5,  service.getProgramSegCount(filename));
    }
}