| | |
| | | verify(batteryGroupFieldMapper).deleteBatteryGroupFieldById(2L, "admin"); |
| | | } |
| | | |
| | | @Test |
| | | void deleteByIdsShouldRejectReferencedField() |
| | | { |
| | | when(batteryGroupFieldMapper.selectBatteryGroupFieldById(1L)).thenReturn(field); |
| | | when(batteryGroupFieldMapper.countFieldReferences(1L)).thenReturn(1); |
| | | |
| | | ServiceException exception = assertThrows(ServiceException.class, |
| | | () -> batteryGroupFieldService.deleteBatteryGroupFieldByIds(new Long[] { 1L }, "admin")); |
| | | |
| | | assertEquals("字段已被模板或电池组引用,不能删除", exception.getMessage()); |
| | | verify(batteryGroupFieldMapper, never()).deleteBatteryGroupFieldById(anyLong(), any(String.class)); |
| | | } |
| | | |
| | | private TBatteryGroupField statusCommand(String status) |
| | | { |
| | | TBatteryGroupField command = new TBatteryGroupField(); |