@Test public void shouldInsert() throws Exception { Product product = new Product(); product.setId(20L); OrderQuantityAdjustmentProduct adjustmentProduct = new OrderQuantityAdjustmentProduct(); adjustmentProduct.setAdjustmentFactor(new OrderQuantityAdjustmentFactor("adj-factor","adj-factor",1,true)); adjustmentProduct.setAdjustmentType(new OrderQuantityAdjustmentType("adj-type","adj-type",1)); adjustmentProduct.setFacility(new Facility(10L)); adjustmentProduct.setProduct(product); adjustmentProduct.setMinMOS(5L); adjustmentProduct.setMaxMOS(15L); adjustmentProductRepository.insert(adjustmentProduct); verify(adjustmentProductMapper).insert(adjustmentProduct); }
public void insert(OrderQuantityAdjustmentProduct adjustmentProduct) { try { orderQuantityAdjustmentProductMapper.insert(adjustmentProduct); } catch (DuplicateKeyException duplicateKeyException) { throw new DataException("error.duplicate.product.code"); } catch (DataIntegrityViolationException dataIntegrityViolationException) { String errorMessage = dataIntegrityViolationException.getMessage().toLowerCase(); if (errorMessage.contains("foreign key") || errorMessage.contains("violates not-null constraint")) { throw new DataException("error.reference.data.missing"); } else { throw new DataException("error.incorrect.length"); } } }
OrderQuantityAdjustmentProductRepository { public void insert(OrderQuantityAdjustmentProduct adjustmentProduct) { try { orderQuantityAdjustmentProductMapper.insert(adjustmentProduct); } catch (DuplicateKeyException duplicateKeyException) { throw new DataException("error.duplicate.product.code"); } catch (DataIntegrityViolationException dataIntegrityViolationException) { String errorMessage = dataIntegrityViolationException.getMessage().toLowerCase(); if (errorMessage.contains("foreign key") || errorMessage.contains("violates not-null constraint")) { throw new DataException("error.reference.data.missing"); } else { throw new DataException("error.incorrect.length"); } } } }
OrderQuantityAdjustmentProductRepository { public void insert(OrderQuantityAdjustmentProduct adjustmentProduct) { try { orderQuantityAdjustmentProductMapper.insert(adjustmentProduct); } catch (DuplicateKeyException duplicateKeyException) { throw new DataException("error.duplicate.product.code"); } catch (DataIntegrityViolationException dataIntegrityViolationException) { String errorMessage = dataIntegrityViolationException.getMessage().toLowerCase(); if (errorMessage.contains("foreign key") || errorMessage.contains("violates not-null constraint")) { throw new DataException("error.reference.data.missing"); } else { throw new DataException("error.incorrect.length"); } } }  }
OrderQuantityAdjustmentProductRepository { public void insert(OrderQuantityAdjustmentProduct adjustmentProduct) { try { orderQuantityAdjustmentProductMapper.insert(adjustmentProduct); } catch (DuplicateKeyException duplicateKeyException) { throw new DataException("error.duplicate.product.code"); } catch (DataIntegrityViolationException dataIntegrityViolationException) { String errorMessage = dataIntegrityViolationException.getMessage().toLowerCase(); if (errorMessage.contains("foreign key") || errorMessage.contains("violates not-null constraint")) { throw new DataException("error.reference.data.missing"); } else { throw new DataException("error.incorrect.length"); } } }  List<OrderQuantityAdjustmentProduct> getAll(); void insert(OrderQuantityAdjustmentProduct adjustmentProduct); OrderQuantityAdjustmentProduct getByProductAndFacility(Long productId, Long facilityId); }
OrderQuantityAdjustmentProductRepository { public void insert(OrderQuantityAdjustmentProduct adjustmentProduct) { try { orderQuantityAdjustmentProductMapper.insert(adjustmentProduct); } catch (DuplicateKeyException duplicateKeyException) { throw new DataException("error.duplicate.product.code"); } catch (DataIntegrityViolationException dataIntegrityViolationException) { String errorMessage = dataIntegrityViolationException.getMessage().toLowerCase(); if (errorMessage.contains("foreign key") || errorMessage.contains("violates not-null constraint")) { throw new DataException("error.reference.data.missing"); } else { throw new DataException("error.incorrect.length"); } } }  List<OrderQuantityAdjustmentProduct> getAll(); void insert(OrderQuantityAdjustmentProduct adjustmentProduct); OrderQuantityAdjustmentProduct getByProductAndFacility(Long productId, Long facilityId);  }