@Test public void test_should_search_Disposals() { final List<Disposal> disposals = new ArrayList<>(); final Disposal disposal = getDisposalFromDB(); disposals.add(disposal); when(disposalQueryBuilder.getQuery(any(DisposalCriteria.class), any(List.class))).thenReturn(StringUtils.EMPTY); when(jdbcTemplate.query(any(String.class), any(Object[].class), any(DisposalRowMapper.class))) .thenReturn(disposals); assertTrue(disposals.equals(disposalRepository.search(new DisposalCriteria()))); }
public List<Disposal> search(final DisposalCriteria disposalCriteria) { final List<Object> preparedStatementValues = new ArrayList<>(); final String queryStr = disposalQueryBuilder.getQuery(disposalCriteria, preparedStatementValues); List<Disposal> disposals = null; try { log.info("queryStr::" + queryStr + "preparedStatementValues::" + preparedStatementValues.toString()); disposals = jdbcTemplate.query(queryStr, preparedStatementValues.toArray(), disposalRowMapper); log.info("DisposalRepository::" + disposals); } catch (final Exception ex) { log.info("the exception from findforcriteria : " + ex); throw new RuntimeException("the exception from find for disposal criteria : " + ex.getMessage()); } return disposals; }
DisposalRepository { public List<Disposal> search(final DisposalCriteria disposalCriteria) { final List<Object> preparedStatementValues = new ArrayList<>(); final String queryStr = disposalQueryBuilder.getQuery(disposalCriteria, preparedStatementValues); List<Disposal> disposals = null; try { log.info("queryStr::" + queryStr + "preparedStatementValues::" + preparedStatementValues.toString()); disposals = jdbcTemplate.query(queryStr, preparedStatementValues.toArray(), disposalRowMapper); log.info("DisposalRepository::" + disposals); } catch (final Exception ex) { log.info("the exception from findforcriteria : " + ex); throw new RuntimeException("the exception from find for disposal criteria : " + ex.getMessage()); } return disposals; } }
DisposalRepository { public List<Disposal> search(final DisposalCriteria disposalCriteria) { final List<Object> preparedStatementValues = new ArrayList<>(); final String queryStr = disposalQueryBuilder.getQuery(disposalCriteria, preparedStatementValues); List<Disposal> disposals = null; try { log.info("queryStr::" + queryStr + "preparedStatementValues::" + preparedStatementValues.toString()); disposals = jdbcTemplate.query(queryStr, preparedStatementValues.toArray(), disposalRowMapper); log.info("DisposalRepository::" + disposals); } catch (final Exception ex) { log.info("the exception from findforcriteria : " + ex); throw new RuntimeException("the exception from find for disposal criteria : " + ex.getMessage()); } return disposals; }  }
DisposalRepository { public List<Disposal> search(final DisposalCriteria disposalCriteria) { final List<Object> preparedStatementValues = new ArrayList<>(); final String queryStr = disposalQueryBuilder.getQuery(disposalCriteria, preparedStatementValues); List<Disposal> disposals = null; try { log.info("queryStr::" + queryStr + "preparedStatementValues::" + preparedStatementValues.toString()); disposals = jdbcTemplate.query(queryStr, preparedStatementValues.toArray(), disposalRowMapper); log.info("DisposalRepository::" + disposals); } catch (final Exception ex) { log.info("the exception from findforcriteria : " + ex); throw new RuntimeException("the exception from find for disposal criteria : " + ex.getMessage()); } return disposals; }  List<Disposal> search(final DisposalCriteria disposalCriteria); void create(final DisposalRequest disposalRequest); }
DisposalRepository { public List<Disposal> search(final DisposalCriteria disposalCriteria) { final List<Object> preparedStatementValues = new ArrayList<>(); final String queryStr = disposalQueryBuilder.getQuery(disposalCriteria, preparedStatementValues); List<Disposal> disposals = null; try { log.info("queryStr::" + queryStr + "preparedStatementValues::" + preparedStatementValues.toString()); disposals = jdbcTemplate.query(queryStr, preparedStatementValues.toArray(), disposalRowMapper); log.info("DisposalRepository::" + disposals); } catch (final Exception ex) { log.info("the exception from findforcriteria : " + ex); throw new RuntimeException("the exception from find for disposal criteria : " + ex.getMessage()); } return disposals; }  List<Disposal> search(final DisposalCriteria disposalCriteria); void create(final DisposalRequest disposalRequest);  }