@Test public void getRentIncrementsTest() { List<RentIncrementType> rentIncrements = new ArrayList<>(); RentIncrementType rentIncrementType = new RentIncrementType(); rentIncrementType.setId(1l); rentIncrementType.setTenantId("1"); rentIncrements.add(rentIncrementType); when(namedParameterJdbcTemplate.query(any(String.class),any(Map.class), Matchers.<BeanPropertyRowMapper>any())).thenReturn(rentIncrements); assertTrue(rentIncrements.equals(rentIncrementRepository.getRentIncrements(rentIncrementType.getTenantId(), null))); }
public List<RentIncrementType> getRentIncrements(String tenantId, String basisOfAllotment) { Map params = new HashMap(); String query = "select * from eglams_rentincrementtype rentincrement where rentincrement.tenant_id=:tenantId"; params.put("tenantId", tenantId); if(StringUtils.isNotBlank(basisOfAllotment)){ query = query.concat(" and rentincrement.type=:type "); params.put("type", basisOfAllotment); } List<RentIncrementType> rentIncrements = null; try { rentIncrements = namedParameterJdbcTemplate.query(query, params, new BeanPropertyRowMapper<>(RentIncrementType.class)); } catch (Exception ex) { logger.info(ex.getMessage(), ex); throw new RuntimeException("No records found for given criteria"); } return rentIncrements; }
RentIncrementRepository { public List<RentIncrementType> getRentIncrements(String tenantId, String basisOfAllotment) { Map params = new HashMap(); String query = "select * from eglams_rentincrementtype rentincrement where rentincrement.tenant_id=:tenantId"; params.put("tenantId", tenantId); if(StringUtils.isNotBlank(basisOfAllotment)){ query = query.concat(" and rentincrement.type=:type "); params.put("type", basisOfAllotment); } List<RentIncrementType> rentIncrements = null; try { rentIncrements = namedParameterJdbcTemplate.query(query, params, new BeanPropertyRowMapper<>(RentIncrementType.class)); } catch (Exception ex) { logger.info(ex.getMessage(), ex); throw new RuntimeException("No records found for given criteria"); } return rentIncrements; } }
RentIncrementRepository { public List<RentIncrementType> getRentIncrements(String tenantId, String basisOfAllotment) { Map params = new HashMap(); String query = "select * from eglams_rentincrementtype rentincrement where rentincrement.tenant_id=:tenantId"; params.put("tenantId", tenantId); if(StringUtils.isNotBlank(basisOfAllotment)){ query = query.concat(" and rentincrement.type=:type "); params.put("type", basisOfAllotment); } List<RentIncrementType> rentIncrements = null; try { rentIncrements = namedParameterJdbcTemplate.query(query, params, new BeanPropertyRowMapper<>(RentIncrementType.class)); } catch (Exception ex) { logger.info(ex.getMessage(), ex); throw new RuntimeException("No records found for given criteria"); } return rentIncrements; }  }
RentIncrementRepository { public List<RentIncrementType> getRentIncrements(String tenantId, String basisOfAllotment) { Map params = new HashMap(); String query = "select * from eglams_rentincrementtype rentincrement where rentincrement.tenant_id=:tenantId"; params.put("tenantId", tenantId); if(StringUtils.isNotBlank(basisOfAllotment)){ query = query.concat(" and rentincrement.type=:type "); params.put("type", basisOfAllotment); } List<RentIncrementType> rentIncrements = null; try { rentIncrements = namedParameterJdbcTemplate.query(query, params, new BeanPropertyRowMapper<>(RentIncrementType.class)); } catch (Exception ex) { logger.info(ex.getMessage(), ex); throw new RuntimeException("No records found for given criteria"); } return rentIncrements; }  List<RentIncrementType> getRentIncrements(String tenantId, String basisOfAllotment); List<RentIncrementType> getRentIncrementById(Long rentID); }
RentIncrementRepository { public List<RentIncrementType> getRentIncrements(String tenantId, String basisOfAllotment) { Map params = new HashMap(); String query = "select * from eglams_rentincrementtype rentincrement where rentincrement.tenant_id=:tenantId"; params.put("tenantId", tenantId); if(StringUtils.isNotBlank(basisOfAllotment)){ query = query.concat(" and rentincrement.type=:type "); params.put("type", basisOfAllotment); } List<RentIncrementType> rentIncrements = null; try { rentIncrements = namedParameterJdbcTemplate.query(query, params, new BeanPropertyRowMapper<>(RentIncrementType.class)); } catch (Exception ex) { logger.info(ex.getMessage(), ex); throw new RuntimeException("No records found for given criteria"); } return rentIncrements; }  List<RentIncrementType> getRentIncrements(String tenantId, String basisOfAllotment); List<RentIncrementType> getRentIncrementById(Long rentID); static final Logger logger; }