@Test public void testFindForCriteria() { final List<Asset> assets = new ArrayList<>(); assets.add(getAsset()); when(assetQueryBuilder.getQuery(any(AssetCriteria.class), any(List.class))).thenReturn(StringUtils.EMPTY); when(jdbcTemplate.query(any(String.class), any(Object[].class), any(AssetRowMapper.class))).thenReturn(assets); assertTrue(assets.equals(assetRepository.findForCriteria(new AssetCriteria()))); }
public List<Asset> findForCriteria(final AssetCriteria assetCriteria) { final List<Object> preparedStatementValues = new ArrayList<>(); final String queryStr = assetQueryBuilder.getQuery(assetCriteria, preparedStatementValues); List<Asset> assets = new ArrayList<>(); try { log.debug("queryStr::" + queryStr + "preparedStatementValues::" + preparedStatementValues.toString()); assets = jdbcTemplate.query(queryStr, preparedStatementValues.toArray(), assetRowMapper); log.debug("Assets From Criteria::" + assets); } catch (final Exception ex) { log.debug("the exception from findforcriteria : " + ex); throw new RuntimeException("the exception from find for asset criteria"); } return assets; }
AssetRepository { public List<Asset> findForCriteria(final AssetCriteria assetCriteria) { final List<Object> preparedStatementValues = new ArrayList<>(); final String queryStr = assetQueryBuilder.getQuery(assetCriteria, preparedStatementValues); List<Asset> assets = new ArrayList<>(); try { log.debug("queryStr::" + queryStr + "preparedStatementValues::" + preparedStatementValues.toString()); assets = jdbcTemplate.query(queryStr, preparedStatementValues.toArray(), assetRowMapper); log.debug("Assets From Criteria::" + assets); } catch (final Exception ex) { log.debug("the exception from findforcriteria : " + ex); throw new RuntimeException("the exception from find for asset criteria"); } return assets; } }
AssetRepository { public List<Asset> findForCriteria(final AssetCriteria assetCriteria) { final List<Object> preparedStatementValues = new ArrayList<>(); final String queryStr = assetQueryBuilder.getQuery(assetCriteria, preparedStatementValues); List<Asset> assets = new ArrayList<>(); try { log.debug("queryStr::" + queryStr + "preparedStatementValues::" + preparedStatementValues.toString()); assets = jdbcTemplate.query(queryStr, preparedStatementValues.toArray(), assetRowMapper); log.debug("Assets From Criteria::" + assets); } catch (final Exception ex) { log.debug("the exception from findforcriteria : " + ex); throw new RuntimeException("the exception from find for asset criteria"); } return assets; }  }
AssetRepository { public List<Asset> findForCriteria(final AssetCriteria assetCriteria) { final List<Object> preparedStatementValues = new ArrayList<>(); final String queryStr = assetQueryBuilder.getQuery(assetCriteria, preparedStatementValues); List<Asset> assets = new ArrayList<>(); try { log.debug("queryStr::" + queryStr + "preparedStatementValues::" + preparedStatementValues.toString()); assets = jdbcTemplate.query(queryStr, preparedStatementValues.toArray(), assetRowMapper); log.debug("Assets From Criteria::" + assets); } catch (final Exception ex) { log.debug("the exception from findforcriteria : " + ex); throw new RuntimeException("the exception from find for asset criteria"); } return assets; }  List<Asset> findForCriteria(final AssetCriteria assetCriteria); Map<Long, List<TransactionHistory>> getTransactionHistory(final List<Long> assetids, final String tenantId); List<Asset> findAssetByCode(final String code, final String tenantId); @Transactional Asset create(final AssetRequest assetRequest); Asset update(final AssetRequest assetRequest); Integer getTotalDBRecords(final AssetCriteria assetCriteria); }
AssetRepository { public List<Asset> findForCriteria(final AssetCriteria assetCriteria) { final List<Object> preparedStatementValues = new ArrayList<>(); final String queryStr = assetQueryBuilder.getQuery(assetCriteria, preparedStatementValues); List<Asset> assets = new ArrayList<>(); try { log.debug("queryStr::" + queryStr + "preparedStatementValues::" + preparedStatementValues.toString()); assets = jdbcTemplate.query(queryStr, preparedStatementValues.toArray(), assetRowMapper); log.debug("Assets From Criteria::" + assets); } catch (final Exception ex) { log.debug("the exception from findforcriteria : " + ex); throw new RuntimeException("the exception from find for asset criteria"); } return assets; }  List<Asset> findForCriteria(final AssetCriteria assetCriteria); Map<Long, List<TransactionHistory>> getTransactionHistory(final List<Long> assetids, final String tenantId); List<Asset> findAssetByCode(final String code, final String tenantId); @Transactional Asset create(final AssetRequest assetRequest); Asset update(final AssetRequest assetRequest); Integer getTotalDBRecords(final AssetCriteria assetCriteria);  }