@Test public void testFindForCriteria() { List<MarriageRegn> marriageRegns = getMarriageRegnFromDB(); when(marriageRegnQueryBuilder.getQueryForListOfMarriageRegnIds(any(MarriageRegnCriteria.class), any(List.class))).thenReturn(StringUtils.EMPTY); when(jdbcTemplate.query(any(String.class), any(Object[].class), any(MarriageRegnIdsRowMapper.class))) .thenReturn(getApplicationnumbers()); when(marriageRegnQueryBuilder.getQuery(any(MarriageRegnCriteria.class), any(List.class), any(List.class))) .thenReturn(StringUtils.EMPTY); when(jdbcTemplate.query(any(String.class), any(Object[].class), any(MarriageRegnRowMapper.class))) .thenReturn(marriageRegns); assertTrue(marriageRegns.equals(marriageRegnRepository.findForCriteria(new MarriageRegnCriteria()))); }
@SuppressWarnings("unchecked") public List<MarriageRegn> findForCriteria(MarriageRegnCriteria marriageRegnCriteria) { List<Object> preparedStatementValuesForListOfMarriageRegnIds = new ArrayList<Object>(); String queryStrForListOfMarriageRegnIds = marriageRegnQueryBuilder.getQueryForListOfMarriageRegnIds( marriageRegnCriteria, preparedStatementValuesForListOfMarriageRegnIds); List<String> listOfApplNos = jdbcTemplate.query(queryStrForListOfMarriageRegnIds, preparedStatementValuesForListOfMarriageRegnIds.toArray(), marriageRegnIdsRowMapper); System.out.println("queryStrForListOfMarriageRegnIds " + queryStrForListOfMarriageRegnIds); System.out.println("listOfApplNos " + listOfApplNos); if (listOfApplNos.isEmpty()) { return Collections.EMPTY_LIST; } List<Object> preparedStatementValues = new ArrayList<Object>(); String queryStr = marriageRegnQueryBuilder.getQuery(marriageRegnCriteria, preparedStatementValues, listOfApplNos); List<MarriageRegn> marriageRegn = jdbcTemplate.query(queryStr, preparedStatementValues.toArray(), marriageRegnRowMapper); return marriageRegn; }
MarriageRegnRepository { @SuppressWarnings("unchecked") public List<MarriageRegn> findForCriteria(MarriageRegnCriteria marriageRegnCriteria) { List<Object> preparedStatementValuesForListOfMarriageRegnIds = new ArrayList<Object>(); String queryStrForListOfMarriageRegnIds = marriageRegnQueryBuilder.getQueryForListOfMarriageRegnIds( marriageRegnCriteria, preparedStatementValuesForListOfMarriageRegnIds); List<String> listOfApplNos = jdbcTemplate.query(queryStrForListOfMarriageRegnIds, preparedStatementValuesForListOfMarriageRegnIds.toArray(), marriageRegnIdsRowMapper); System.out.println("queryStrForListOfMarriageRegnIds " + queryStrForListOfMarriageRegnIds); System.out.println("listOfApplNos " + listOfApplNos); if (listOfApplNos.isEmpty()) { return Collections.EMPTY_LIST; } List<Object> preparedStatementValues = new ArrayList<Object>(); String queryStr = marriageRegnQueryBuilder.getQuery(marriageRegnCriteria, preparedStatementValues, listOfApplNos); List<MarriageRegn> marriageRegn = jdbcTemplate.query(queryStr, preparedStatementValues.toArray(), marriageRegnRowMapper); return marriageRegn; } }
MarriageRegnRepository { @SuppressWarnings("unchecked") public List<MarriageRegn> findForCriteria(MarriageRegnCriteria marriageRegnCriteria) { List<Object> preparedStatementValuesForListOfMarriageRegnIds = new ArrayList<Object>(); String queryStrForListOfMarriageRegnIds = marriageRegnQueryBuilder.getQueryForListOfMarriageRegnIds( marriageRegnCriteria, preparedStatementValuesForListOfMarriageRegnIds); List<String> listOfApplNos = jdbcTemplate.query(queryStrForListOfMarriageRegnIds, preparedStatementValuesForListOfMarriageRegnIds.toArray(), marriageRegnIdsRowMapper); System.out.println("queryStrForListOfMarriageRegnIds " + queryStrForListOfMarriageRegnIds); System.out.println("listOfApplNos " + listOfApplNos); if (listOfApplNos.isEmpty()) { return Collections.EMPTY_LIST; } List<Object> preparedStatementValues = new ArrayList<Object>(); String queryStr = marriageRegnQueryBuilder.getQuery(marriageRegnCriteria, preparedStatementValues, listOfApplNos); List<MarriageRegn> marriageRegn = jdbcTemplate.query(queryStr, preparedStatementValues.toArray(), marriageRegnRowMapper); return marriageRegn; }  }
MarriageRegnRepository { @SuppressWarnings("unchecked") public List<MarriageRegn> findForCriteria(MarriageRegnCriteria marriageRegnCriteria) { List<Object> preparedStatementValuesForListOfMarriageRegnIds = new ArrayList<Object>(); String queryStrForListOfMarriageRegnIds = marriageRegnQueryBuilder.getQueryForListOfMarriageRegnIds( marriageRegnCriteria, preparedStatementValuesForListOfMarriageRegnIds); List<String> listOfApplNos = jdbcTemplate.query(queryStrForListOfMarriageRegnIds, preparedStatementValuesForListOfMarriageRegnIds.toArray(), marriageRegnIdsRowMapper); System.out.println("queryStrForListOfMarriageRegnIds " + queryStrForListOfMarriageRegnIds); System.out.println("listOfApplNos " + listOfApplNos); if (listOfApplNos.isEmpty()) { return Collections.EMPTY_LIST; } List<Object> preparedStatementValues = new ArrayList<Object>(); String queryStr = marriageRegnQueryBuilder.getQuery(marriageRegnCriteria, preparedStatementValues, listOfApplNos); List<MarriageRegn> marriageRegn = jdbcTemplate.query(queryStr, preparedStatementValues.toArray(), marriageRegnRowMapper); return marriageRegn; }  @SuppressWarnings("unchecked") List<MarriageRegn> findForCriteria(MarriageRegnCriteria marriageRegnCriteria); void save(MarriageRegn marriageRegn); String generateApplicationNumber(); void update(MarriageRegn marriageRegn); void saveJson(String applicationNumber, String marriageRegnJson, String tenantId); }
MarriageRegnRepository { @SuppressWarnings("unchecked") public List<MarriageRegn> findForCriteria(MarriageRegnCriteria marriageRegnCriteria) { List<Object> preparedStatementValuesForListOfMarriageRegnIds = new ArrayList<Object>(); String queryStrForListOfMarriageRegnIds = marriageRegnQueryBuilder.getQueryForListOfMarriageRegnIds( marriageRegnCriteria, preparedStatementValuesForListOfMarriageRegnIds); List<String> listOfApplNos = jdbcTemplate.query(queryStrForListOfMarriageRegnIds, preparedStatementValuesForListOfMarriageRegnIds.toArray(), marriageRegnIdsRowMapper); System.out.println("queryStrForListOfMarriageRegnIds " + queryStrForListOfMarriageRegnIds); System.out.println("listOfApplNos " + listOfApplNos); if (listOfApplNos.isEmpty()) { return Collections.EMPTY_LIST; } List<Object> preparedStatementValues = new ArrayList<Object>(); String queryStr = marriageRegnQueryBuilder.getQuery(marriageRegnCriteria, preparedStatementValues, listOfApplNos); List<MarriageRegn> marriageRegn = jdbcTemplate.query(queryStr, preparedStatementValues.toArray(), marriageRegnRowMapper); return marriageRegn; }  @SuppressWarnings("unchecked") List<MarriageRegn> findForCriteria(MarriageRegnCriteria marriageRegnCriteria); void save(MarriageRegn marriageRegn); String generateApplicationNumber(); void update(MarriageRegn marriageRegn); void saveJson(String applicationNumber, String marriageRegnJson, String tenantId); static final String INSERT_JSON_QUERY; static final String INSERT_MARRIAGE_REGN_QUERY; static final String UPDATE_MARRIAGE_REGN_QUERY; }