@Test public void testSave() { MarriageRegnRequest marriageRegnRequest = new MarriageRegnRequest(); RequestInfo requestInfo = new RequestInfo(); List<MarriageRegn> marriageRegns = getMarriageRegnFromDB(); marriageRegnRequest.setMarriageRegn(marriageRegns.get(0)); marriageRegnRequest.setRequestInfo(requestInfo); when(jdbcTemplate.update(any(String.class), any(Object[].class))).thenReturn(1); Mockito.doNothing().when(witnessRepository).save(Matchers.anyString(), Matchers.anyString(), Matchers.any(Witness.class)); marriageRegnRepository.save(marriageRegns.get(0)); }
public void save(MarriageRegn marriageRegn) { jdbcTemplate.update(INSERT_MARRIAGE_REGN_QUERY, new PreparedStatementSetter(){ @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, marriageRegn.getId()); ps.setLong(2, marriageRegn.getRegnUnit().getId()); ps.setLong(3, marriageRegn.getMarriageDate()); ps.setString(4, marriageRegn.getVenue().toString()); ps.setString(5, marriageRegn.getStreet()); ps.setString(6, marriageRegn.getPlaceOfMarriage()); ps.setString(7, marriageRegn.getLocality()); ps.setString(8, marriageRegn.getCity()); ps.setString(9, marriageRegn.getMarriagePhoto()); ps.setLong(10, marriageRegn.getBridegroom().getId()); ps.setLong(11, marriageRegn.getBride().getId()); ps.setString(12, marriageRegn.getPriest().getName()); ps.setLong(13, marriageRegn.getPriest().getReligion()); ps.setString(14, marriageRegn.getPriest().getAddress()); ps.setString(15, marriageRegn.getPriest().getAadhaar()); ps.setString(16, marriageRegn.getPriest().getMobileNo()); ps.setString(17, marriageRegn.getPriest().getEmail()); ps.setString(18, marriageRegn.getSerialNo()); ps.setString(19, marriageRegn.getVolumeNo()); ps.setString(20, marriageRegn.getApplicationNumber()); ps.setString(21, marriageRegn.getRegnNumber()); ps.setLong(22, marriageRegn.getRegnDate()); ps.setString(23, marriageRegn.getStatus().toString()); ps.setString(24, marriageRegn.getSource().toString()); ps.setString(25, marriageRegn.getStateId()); ps.setBoolean(26, marriageRegn.getIsActive()); ps.setString(27, marriageRegn.getTenantId()); ps.setString(28, marriageRegn.getFee().getId()); ps.setString(29, marriageRegn.getDemands().get(0).getId()); ps.setLong(30, marriageRegn.getApprovalDetails().getDepartment()); ps.setLong(31, marriageRegn.getApprovalDetails().getDesignation()); ps.setLong(32, marriageRegn.getApprovalDetails().getAssignee()); ps.setString(33, marriageRegn.getApprovalDetails().getAction()); ps.setString(34, marriageRegn.getApprovalDetails().getStatus()); ps.setString(35, marriageRegn.getApprovalDetails().getComments()); ps.setString(36,marriageRegn.getAuditDetails().getCreatedBy()); ps.setString(37, marriageRegn.getAuditDetails().getLastModifiedBy()); ps.setLong(38,marriageRegn.getAuditDetails().getCreatedTime()); ps.setLong(39, marriageRegn.getAuditDetails().getLastModifiedTime()); } }); if (marriageRegn.getWitnesses() != null) marriageRegn.getWitnesses().forEach(witness -> { witnessRepository.save(marriageRegn.getApplicationNumber(), marriageRegn.getTenantId(), witness); }); }
MarriageRegnRepository { public void save(MarriageRegn marriageRegn) { jdbcTemplate.update(INSERT_MARRIAGE_REGN_QUERY, new PreparedStatementSetter(){ @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, marriageRegn.getId()); ps.setLong(2, marriageRegn.getRegnUnit().getId()); ps.setLong(3, marriageRegn.getMarriageDate()); ps.setString(4, marriageRegn.getVenue().toString()); ps.setString(5, marriageRegn.getStreet()); ps.setString(6, marriageRegn.getPlaceOfMarriage()); ps.setString(7, marriageRegn.getLocality()); ps.setString(8, marriageRegn.getCity()); ps.setString(9, marriageRegn.getMarriagePhoto()); ps.setLong(10, marriageRegn.getBridegroom().getId()); ps.setLong(11, marriageRegn.getBride().getId()); ps.setString(12, marriageRegn.getPriest().getName()); ps.setLong(13, marriageRegn.getPriest().getReligion()); ps.setString(14, marriageRegn.getPriest().getAddress()); ps.setString(15, marriageRegn.getPriest().getAadhaar()); ps.setString(16, marriageRegn.getPriest().getMobileNo()); ps.setString(17, marriageRegn.getPriest().getEmail()); ps.setString(18, marriageRegn.getSerialNo()); ps.setString(19, marriageRegn.getVolumeNo()); ps.setString(20, marriageRegn.getApplicationNumber()); ps.setString(21, marriageRegn.getRegnNumber()); ps.setLong(22, marriageRegn.getRegnDate()); ps.setString(23, marriageRegn.getStatus().toString()); ps.setString(24, marriageRegn.getSource().toString()); ps.setString(25, marriageRegn.getStateId()); ps.setBoolean(26, marriageRegn.getIsActive()); ps.setString(27, marriageRegn.getTenantId()); ps.setString(28, marriageRegn.getFee().getId()); ps.setString(29, marriageRegn.getDemands().get(0).getId()); ps.setLong(30, marriageRegn.getApprovalDetails().getDepartment()); ps.setLong(31, marriageRegn.getApprovalDetails().getDesignation()); ps.setLong(32, marriageRegn.getApprovalDetails().getAssignee()); ps.setString(33, marriageRegn.getApprovalDetails().getAction()); ps.setString(34, marriageRegn.getApprovalDetails().getStatus()); ps.setString(35, marriageRegn.getApprovalDetails().getComments()); ps.setString(36,marriageRegn.getAuditDetails().getCreatedBy()); ps.setString(37, marriageRegn.getAuditDetails().getLastModifiedBy()); ps.setLong(38,marriageRegn.getAuditDetails().getCreatedTime()); ps.setLong(39, marriageRegn.getAuditDetails().getLastModifiedTime()); } }); if (marriageRegn.getWitnesses() != null) marriageRegn.getWitnesses().forEach(witness -> { witnessRepository.save(marriageRegn.getApplicationNumber(), marriageRegn.getTenantId(), witness); }); } }
MarriageRegnRepository { public void save(MarriageRegn marriageRegn) { jdbcTemplate.update(INSERT_MARRIAGE_REGN_QUERY, new PreparedStatementSetter(){ @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, marriageRegn.getId()); ps.setLong(2, marriageRegn.getRegnUnit().getId()); ps.setLong(3, marriageRegn.getMarriageDate()); ps.setString(4, marriageRegn.getVenue().toString()); ps.setString(5, marriageRegn.getStreet()); ps.setString(6, marriageRegn.getPlaceOfMarriage()); ps.setString(7, marriageRegn.getLocality()); ps.setString(8, marriageRegn.getCity()); ps.setString(9, marriageRegn.getMarriagePhoto()); ps.setLong(10, marriageRegn.getBridegroom().getId()); ps.setLong(11, marriageRegn.getBride().getId()); ps.setString(12, marriageRegn.getPriest().getName()); ps.setLong(13, marriageRegn.getPriest().getReligion()); ps.setString(14, marriageRegn.getPriest().getAddress()); ps.setString(15, marriageRegn.getPriest().getAadhaar()); ps.setString(16, marriageRegn.getPriest().getMobileNo()); ps.setString(17, marriageRegn.getPriest().getEmail()); ps.setString(18, marriageRegn.getSerialNo()); ps.setString(19, marriageRegn.getVolumeNo()); ps.setString(20, marriageRegn.getApplicationNumber()); ps.setString(21, marriageRegn.getRegnNumber()); ps.setLong(22, marriageRegn.getRegnDate()); ps.setString(23, marriageRegn.getStatus().toString()); ps.setString(24, marriageRegn.getSource().toString()); ps.setString(25, marriageRegn.getStateId()); ps.setBoolean(26, marriageRegn.getIsActive()); ps.setString(27, marriageRegn.getTenantId()); ps.setString(28, marriageRegn.getFee().getId()); ps.setString(29, marriageRegn.getDemands().get(0).getId()); ps.setLong(30, marriageRegn.getApprovalDetails().getDepartment()); ps.setLong(31, marriageRegn.getApprovalDetails().getDesignation()); ps.setLong(32, marriageRegn.getApprovalDetails().getAssignee()); ps.setString(33, marriageRegn.getApprovalDetails().getAction()); ps.setString(34, marriageRegn.getApprovalDetails().getStatus()); ps.setString(35, marriageRegn.getApprovalDetails().getComments()); ps.setString(36,marriageRegn.getAuditDetails().getCreatedBy()); ps.setString(37, marriageRegn.getAuditDetails().getLastModifiedBy()); ps.setLong(38,marriageRegn.getAuditDetails().getCreatedTime()); ps.setLong(39, marriageRegn.getAuditDetails().getLastModifiedTime()); } }); if (marriageRegn.getWitnesses() != null) marriageRegn.getWitnesses().forEach(witness -> { witnessRepository.save(marriageRegn.getApplicationNumber(), marriageRegn.getTenantId(), witness); }); }  }
MarriageRegnRepository { public void save(MarriageRegn marriageRegn) { jdbcTemplate.update(INSERT_MARRIAGE_REGN_QUERY, new PreparedStatementSetter(){ @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, marriageRegn.getId()); ps.setLong(2, marriageRegn.getRegnUnit().getId()); ps.setLong(3, marriageRegn.getMarriageDate()); ps.setString(4, marriageRegn.getVenue().toString()); ps.setString(5, marriageRegn.getStreet()); ps.setString(6, marriageRegn.getPlaceOfMarriage()); ps.setString(7, marriageRegn.getLocality()); ps.setString(8, marriageRegn.getCity()); ps.setString(9, marriageRegn.getMarriagePhoto()); ps.setLong(10, marriageRegn.getBridegroom().getId()); ps.setLong(11, marriageRegn.getBride().getId()); ps.setString(12, marriageRegn.getPriest().getName()); ps.setLong(13, marriageRegn.getPriest().getReligion()); ps.setString(14, marriageRegn.getPriest().getAddress()); ps.setString(15, marriageRegn.getPriest().getAadhaar()); ps.setString(16, marriageRegn.getPriest().getMobileNo()); ps.setString(17, marriageRegn.getPriest().getEmail()); ps.setString(18, marriageRegn.getSerialNo()); ps.setString(19, marriageRegn.getVolumeNo()); ps.setString(20, marriageRegn.getApplicationNumber()); ps.setString(21, marriageRegn.getRegnNumber()); ps.setLong(22, marriageRegn.getRegnDate()); ps.setString(23, marriageRegn.getStatus().toString()); ps.setString(24, marriageRegn.getSource().toString()); ps.setString(25, marriageRegn.getStateId()); ps.setBoolean(26, marriageRegn.getIsActive()); ps.setString(27, marriageRegn.getTenantId()); ps.setString(28, marriageRegn.getFee().getId()); ps.setString(29, marriageRegn.getDemands().get(0).getId()); ps.setLong(30, marriageRegn.getApprovalDetails().getDepartment()); ps.setLong(31, marriageRegn.getApprovalDetails().getDesignation()); ps.setLong(32, marriageRegn.getApprovalDetails().getAssignee()); ps.setString(33, marriageRegn.getApprovalDetails().getAction()); ps.setString(34, marriageRegn.getApprovalDetails().getStatus()); ps.setString(35, marriageRegn.getApprovalDetails().getComments()); ps.setString(36,marriageRegn.getAuditDetails().getCreatedBy()); ps.setString(37, marriageRegn.getAuditDetails().getLastModifiedBy()); ps.setLong(38,marriageRegn.getAuditDetails().getCreatedTime()); ps.setLong(39, marriageRegn.getAuditDetails().getLastModifiedTime()); } }); if (marriageRegn.getWitnesses() != null) marriageRegn.getWitnesses().forEach(witness -> { witnessRepository.save(marriageRegn.getApplicationNumber(), marriageRegn.getTenantId(), witness); }); }  @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 { public void save(MarriageRegn marriageRegn) { jdbcTemplate.update(INSERT_MARRIAGE_REGN_QUERY, new PreparedStatementSetter(){ @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, marriageRegn.getId()); ps.setLong(2, marriageRegn.getRegnUnit().getId()); ps.setLong(3, marriageRegn.getMarriageDate()); ps.setString(4, marriageRegn.getVenue().toString()); ps.setString(5, marriageRegn.getStreet()); ps.setString(6, marriageRegn.getPlaceOfMarriage()); ps.setString(7, marriageRegn.getLocality()); ps.setString(8, marriageRegn.getCity()); ps.setString(9, marriageRegn.getMarriagePhoto()); ps.setLong(10, marriageRegn.getBridegroom().getId()); ps.setLong(11, marriageRegn.getBride().getId()); ps.setString(12, marriageRegn.getPriest().getName()); ps.setLong(13, marriageRegn.getPriest().getReligion()); ps.setString(14, marriageRegn.getPriest().getAddress()); ps.setString(15, marriageRegn.getPriest().getAadhaar()); ps.setString(16, marriageRegn.getPriest().getMobileNo()); ps.setString(17, marriageRegn.getPriest().getEmail()); ps.setString(18, marriageRegn.getSerialNo()); ps.setString(19, marriageRegn.getVolumeNo()); ps.setString(20, marriageRegn.getApplicationNumber()); ps.setString(21, marriageRegn.getRegnNumber()); ps.setLong(22, marriageRegn.getRegnDate()); ps.setString(23, marriageRegn.getStatus().toString()); ps.setString(24, marriageRegn.getSource().toString()); ps.setString(25, marriageRegn.getStateId()); ps.setBoolean(26, marriageRegn.getIsActive()); ps.setString(27, marriageRegn.getTenantId()); ps.setString(28, marriageRegn.getFee().getId()); ps.setString(29, marriageRegn.getDemands().get(0).getId()); ps.setLong(30, marriageRegn.getApprovalDetails().getDepartment()); ps.setLong(31, marriageRegn.getApprovalDetails().getDesignation()); ps.setLong(32, marriageRegn.getApprovalDetails().getAssignee()); ps.setString(33, marriageRegn.getApprovalDetails().getAction()); ps.setString(34, marriageRegn.getApprovalDetails().getStatus()); ps.setString(35, marriageRegn.getApprovalDetails().getComments()); ps.setString(36,marriageRegn.getAuditDetails().getCreatedBy()); ps.setString(37, marriageRegn.getAuditDetails().getLastModifiedBy()); ps.setLong(38,marriageRegn.getAuditDetails().getCreatedTime()); ps.setLong(39, marriageRegn.getAuditDetails().getLastModifiedTime()); } }); if (marriageRegn.getWitnesses() != null) marriageRegn.getWitnesses().forEach(witness -> { witnessRepository.save(marriageRegn.getApplicationNumber(), marriageRegn.getTenantId(), witness); }); }  @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; }