@Test public void shouldThrowExceptionIfShipmentFileHasIncorrectDataLength() throws Exception { ShipmentLineItem shipmentLineItem = new ShipmentLineItem(); shipmentLineItem.setProductCode("R10"); doThrow(new DataIntegrityViolationException("Incorrect data length")).when(shipmentMapper).insertShippedLineItem(shipmentLineItem); expectedException.expect(dataExceptionMatcher("error.incorrect.length")); shipmentRepository.save(shipmentLineItem); }
public void save(ShipmentLineItem shipmentLineItem) { try { shipmentMapper.insertShippedLineItem(shipmentLineItem); } catch (DataIntegrityViolationException exception) { throw new DataException("error.incorrect.length"); } }
ShipmentRepository { public void save(ShipmentLineItem shipmentLineItem) { try { shipmentMapper.insertShippedLineItem(shipmentLineItem); } catch (DataIntegrityViolationException exception) { throw new DataException("error.incorrect.length"); } } }
ShipmentRepository { public void save(ShipmentLineItem shipmentLineItem) { try { shipmentMapper.insertShippedLineItem(shipmentLineItem); } catch (DataIntegrityViolationException exception) { throw new DataException("error.incorrect.length"); } } @Autowired  ShipmentRepository(ShipmentMapper shipmentMapper); }
ShipmentRepository { public void save(ShipmentLineItem shipmentLineItem) { try { shipmentMapper.insertShippedLineItem(shipmentLineItem); } catch (DataIntegrityViolationException exception) { throw new DataException("error.incorrect.length"); } } @Autowired  ShipmentRepository(ShipmentMapper shipmentMapper); void insertShipmentFileInfo(ShipmentFileInfo shipmentFileInfo); void save(ShipmentLineItem shipmentLineItem); List<ShipmentLineItem> getLineItems(Long orderId); }
ShipmentRepository { public void save(ShipmentLineItem shipmentLineItem) { try { shipmentMapper.insertShippedLineItem(shipmentLineItem); } catch (DataIntegrityViolationException exception) { throw new DataException("error.incorrect.length"); } } @Autowired  ShipmentRepository(ShipmentMapper shipmentMapper); void insertShipmentFileInfo(ShipmentFileInfo shipmentFileInfo); void save(ShipmentLineItem shipmentLineItem); List<ShipmentLineItem> getLineItems(Long orderId);  }