@Test public void shouldGetPositiveAdjustmentReasons() { when(mapper.getAll()).thenReturn(allReasons); List<StockAdjustmentReason> reasons = repository.getAdjustmentReasons(true, null, null); verify(mapper).getAll(); assertEquals(reasons, positiveReasons); }
public List<StockAdjustmentReason> getAdjustmentReasons(final Boolean additive, final Long programId, final StockAdjustmentReason.Category category) { List<StockAdjustmentReason> reasons; if (programId != null) { reasons = adjustmentReasonMapper.getAllByProgram(programId); } else { reasons = adjustmentReasonMapper.getAllDefault(); } CollectionUtils.filter(reasons, new Predicate<StockAdjustmentReason>() { @Override public boolean evaluate(StockAdjustmentReason reason) { if(null != category && false == reason.inCategory(category)) return false; if(null != additive && reason.getAdditive() != additive) return false; return true; } }); return reasons; }
StockAdjustmentReasonRepository { public List<StockAdjustmentReason> getAdjustmentReasons(final Boolean additive, final Long programId, final StockAdjustmentReason.Category category) { List<StockAdjustmentReason> reasons; if (programId != null) { reasons = adjustmentReasonMapper.getAllByProgram(programId); } else { reasons = adjustmentReasonMapper.getAllDefault(); } CollectionUtils.filter(reasons, new Predicate<StockAdjustmentReason>() { @Override public boolean evaluate(StockAdjustmentReason reason) { if(null != category && false == reason.inCategory(category)) return false; if(null != additive && reason.getAdditive() != additive) return false; return true; } }); return reasons; } }
StockAdjustmentReasonRepository { public List<StockAdjustmentReason> getAdjustmentReasons(final Boolean additive, final Long programId, final StockAdjustmentReason.Category category) { List<StockAdjustmentReason> reasons; if (programId != null) { reasons = adjustmentReasonMapper.getAllByProgram(programId); } else { reasons = adjustmentReasonMapper.getAllDefault(); } CollectionUtils.filter(reasons, new Predicate<StockAdjustmentReason>() { @Override public boolean evaluate(StockAdjustmentReason reason) { if(null != category && false == reason.inCategory(category)) return false; if(null != additive && reason.getAdditive() != additive) return false; return true; } }); return reasons; }  }
StockAdjustmentReasonRepository { public List<StockAdjustmentReason> getAdjustmentReasons(final Boolean additive, final Long programId, final StockAdjustmentReason.Category category) { List<StockAdjustmentReason> reasons; if (programId != null) { reasons = adjustmentReasonMapper.getAllByProgram(programId); } else { reasons = adjustmentReasonMapper.getAllDefault(); } CollectionUtils.filter(reasons, new Predicate<StockAdjustmentReason>() { @Override public boolean evaluate(StockAdjustmentReason reason) { if(null != category && false == reason.inCategory(category)) return false; if(null != additive && reason.getAdditive() != additive) return false; return true; } }); return reasons; }  List<StockAdjustmentReason> getAdjustmentReasons(final Boolean additive,
                                                          final Long programId,
                                                          final StockAdjustmentReason.Category category); StockAdjustmentReason getAdjustmentReasonByName(String name); void insertAdjustmentReason(StockAdjustmentReason reason); StockAdjustmentReasonProgram getAdjustmentReasonProgram(String programCode, String reasonName); void insertAdjustmentReasonProgram(StockAdjustmentReasonProgram entry); void updateAdjustmentReasonProgram(StockAdjustmentReasonProgram entry); }
StockAdjustmentReasonRepository { public List<StockAdjustmentReason> getAdjustmentReasons(final Boolean additive, final Long programId, final StockAdjustmentReason.Category category) { List<StockAdjustmentReason> reasons; if (programId != null) { reasons = adjustmentReasonMapper.getAllByProgram(programId); } else { reasons = adjustmentReasonMapper.getAllDefault(); } CollectionUtils.filter(reasons, new Predicate<StockAdjustmentReason>() { @Override public boolean evaluate(StockAdjustmentReason reason) { if(null != category && false == reason.inCategory(category)) return false; if(null != additive && reason.getAdditive() != additive) return false; return true; } }); return reasons; }  List<StockAdjustmentReason> getAdjustmentReasons(final Boolean additive,
                                                          final Long programId,
                                                          final StockAdjustmentReason.Category category); StockAdjustmentReason getAdjustmentReasonByName(String name); void insertAdjustmentReason(StockAdjustmentReason reason); StockAdjustmentReasonProgram getAdjustmentReasonProgram(String programCode, String reasonName); void insertAdjustmentReasonProgram(StockAdjustmentReasonProgram entry); void updateAdjustmentReasonProgram(StockAdjustmentReasonProgram entry);  }