| | |
| | | |
| | | 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()); |
| | | } |
| | | } |
| | | } |