@Test(expected = Exception.class) public void test_should_persist_service_type() { when(grievanceTypeQueryBuilder.insertComplaintTypeQuery()).thenReturn("FirstQuery"); when(jdbcTemplate.update(any(String.class), anyListOf(Object.class))).thenReturn(1); when(grievanceTypeQueryBuilder.insertServiceTypeQuery()).thenReturn("SecondQuery"); when(jdbcTemplate.update(any(String.class), anyListOf(Object.class))).thenReturn(1); grievanceTypeRepository.persistServiceType(any(ServiceRequest.class)); verify(jdbcTemplate, times(2)).update(any(String.class), anyListOf(Object.class)); }
public ServiceRequest persistServiceType(final ServiceRequest serviceRequest) { LOGGER.info("Service Type Request::" + serviceRequest); final String complaintInsert = grievanceTypeQueryBuilder.insertComplaintTypeQuery(); boolean active = (null != serviceRequest.getService().getActive() ? serviceRequest.getService().getActive() : true); boolean days = (null != serviceRequest.getService().getDays() ? serviceRequest.getService().getDays() : false); final Object[] object = new Object[]{serviceRequest.getService().getServiceName(), serviceRequest.getService().getServiceCode(), serviceRequest.getService().getDescription(), active, serviceRequest.getService().getSlaHours(), serviceRequest.getService().getTenantId(), serviceRequest.getService().getType(), serviceRequest.getRequestInfo().getUserInfo().getId(), new Date(new java.util.Date().getTime()), serviceRequest.getService().getCategory(), days, serviceRequest.getService().getLocalName() }; jdbcTemplate.update(complaintInsert, object); final String serviceInsert = grievanceTypeQueryBuilder.insertServiceTypeQuery(); final Object[] obj = new Object[]{serviceRequest.getService().getServiceCode(), serviceRequest.getService().getTenantId(), serviceRequest.getRequestInfo().getUserInfo().getId(), new Date(new java.util.Date().getTime())}; jdbcTemplate.update(serviceInsert, obj); if (serviceRequest.getService().isMetadata()) { persistAttributeValues(serviceRequest); } if (null != serviceRequest.getService().getKeywords()) { if (serviceRequest.getService().getKeywords().size() > 0) { persistKeywordServiceCodeMapping(serviceRequest); } } return serviceRequest; }
GrievanceTypeRepository { public ServiceRequest persistServiceType(final ServiceRequest serviceRequest) { LOGGER.info("Service Type Request::" + serviceRequest); final String complaintInsert = grievanceTypeQueryBuilder.insertComplaintTypeQuery(); boolean active = (null != serviceRequest.getService().getActive() ? serviceRequest.getService().getActive() : true); boolean days = (null != serviceRequest.getService().getDays() ? serviceRequest.getService().getDays() : false); final Object[] object = new Object[]{serviceRequest.getService().getServiceName(), serviceRequest.getService().getServiceCode(), serviceRequest.getService().getDescription(), active, serviceRequest.getService().getSlaHours(), serviceRequest.getService().getTenantId(), serviceRequest.getService().getType(), serviceRequest.getRequestInfo().getUserInfo().getId(), new Date(new java.util.Date().getTime()), serviceRequest.getService().getCategory(), days, serviceRequest.getService().getLocalName() }; jdbcTemplate.update(complaintInsert, object); final String serviceInsert = grievanceTypeQueryBuilder.insertServiceTypeQuery(); final Object[] obj = new Object[]{serviceRequest.getService().getServiceCode(), serviceRequest.getService().getTenantId(), serviceRequest.getRequestInfo().getUserInfo().getId(), new Date(new java.util.Date().getTime())}; jdbcTemplate.update(serviceInsert, obj); if (serviceRequest.getService().isMetadata()) { persistAttributeValues(serviceRequest); } if (null != serviceRequest.getService().getKeywords()) { if (serviceRequest.getService().getKeywords().size() > 0) { persistKeywordServiceCodeMapping(serviceRequest); } } return serviceRequest; } }
GrievanceTypeRepository { public ServiceRequest persistServiceType(final ServiceRequest serviceRequest) { LOGGER.info("Service Type Request::" + serviceRequest); final String complaintInsert = grievanceTypeQueryBuilder.insertComplaintTypeQuery(); boolean active = (null != serviceRequest.getService().getActive() ? serviceRequest.getService().getActive() : true); boolean days = (null != serviceRequest.getService().getDays() ? serviceRequest.getService().getDays() : false); final Object[] object = new Object[]{serviceRequest.getService().getServiceName(), serviceRequest.getService().getServiceCode(), serviceRequest.getService().getDescription(), active, serviceRequest.getService().getSlaHours(), serviceRequest.getService().getTenantId(), serviceRequest.getService().getType(), serviceRequest.getRequestInfo().getUserInfo().getId(), new Date(new java.util.Date().getTime()), serviceRequest.getService().getCategory(), days, serviceRequest.getService().getLocalName() }; jdbcTemplate.update(complaintInsert, object); final String serviceInsert = grievanceTypeQueryBuilder.insertServiceTypeQuery(); final Object[] obj = new Object[]{serviceRequest.getService().getServiceCode(), serviceRequest.getService().getTenantId(), serviceRequest.getRequestInfo().getUserInfo().getId(), new Date(new java.util.Date().getTime())}; jdbcTemplate.update(serviceInsert, obj); if (serviceRequest.getService().isMetadata()) { persistAttributeValues(serviceRequest); } if (null != serviceRequest.getService().getKeywords()) { if (serviceRequest.getService().getKeywords().size() > 0) { persistKeywordServiceCodeMapping(serviceRequest); } } return serviceRequest; }  }
GrievanceTypeRepository { public ServiceRequest persistServiceType(final ServiceRequest serviceRequest) { LOGGER.info("Service Type Request::" + serviceRequest); final String complaintInsert = grievanceTypeQueryBuilder.insertComplaintTypeQuery(); boolean active = (null != serviceRequest.getService().getActive() ? serviceRequest.getService().getActive() : true); boolean days = (null != serviceRequest.getService().getDays() ? serviceRequest.getService().getDays() : false); final Object[] object = new Object[]{serviceRequest.getService().getServiceName(), serviceRequest.getService().getServiceCode(), serviceRequest.getService().getDescription(), active, serviceRequest.getService().getSlaHours(), serviceRequest.getService().getTenantId(), serviceRequest.getService().getType(), serviceRequest.getRequestInfo().getUserInfo().getId(), new Date(new java.util.Date().getTime()), serviceRequest.getService().getCategory(), days, serviceRequest.getService().getLocalName() }; jdbcTemplate.update(complaintInsert, object); final String serviceInsert = grievanceTypeQueryBuilder.insertServiceTypeQuery(); final Object[] obj = new Object[]{serviceRequest.getService().getServiceCode(), serviceRequest.getService().getTenantId(), serviceRequest.getRequestInfo().getUserInfo().getId(), new Date(new java.util.Date().getTime())}; jdbcTemplate.update(serviceInsert, obj); if (serviceRequest.getService().isMetadata()) { persistAttributeValues(serviceRequest); } if (null != serviceRequest.getService().getKeywords()) { if (serviceRequest.getService().getKeywords().size() > 0) { persistKeywordServiceCodeMapping(serviceRequest); } } return serviceRequest; }  ServiceRequest persistServiceType(final ServiceRequest serviceRequest); ServiceRequest persistModifyServiceType(final ServiceRequest serviceRequest); boolean checkServiceByNameAndCode(final String code, final String name, final String tenantId); boolean checkServiceCodeIfExists(final String serviceCode, final String tenantId); boolean checkComplaintNameIfExists(final String serviceName, final String tenantId, final String serviceCode, String mode); boolean checkComplaintCodeNameIfExists(final String serviceName, final String tenantId, final String serviceCode, String mode); List<GrievanceType> findForCriteria(final ServiceGetRequest serviceTypeGetRequest); }
GrievanceTypeRepository { public ServiceRequest persistServiceType(final ServiceRequest serviceRequest) { LOGGER.info("Service Type Request::" + serviceRequest); final String complaintInsert = grievanceTypeQueryBuilder.insertComplaintTypeQuery(); boolean active = (null != serviceRequest.getService().getActive() ? serviceRequest.getService().getActive() : true); boolean days = (null != serviceRequest.getService().getDays() ? serviceRequest.getService().getDays() : false); final Object[] object = new Object[]{serviceRequest.getService().getServiceName(), serviceRequest.getService().getServiceCode(), serviceRequest.getService().getDescription(), active, serviceRequest.getService().getSlaHours(), serviceRequest.getService().getTenantId(), serviceRequest.getService().getType(), serviceRequest.getRequestInfo().getUserInfo().getId(), new Date(new java.util.Date().getTime()), serviceRequest.getService().getCategory(), days, serviceRequest.getService().getLocalName() }; jdbcTemplate.update(complaintInsert, object); final String serviceInsert = grievanceTypeQueryBuilder.insertServiceTypeQuery(); final Object[] obj = new Object[]{serviceRequest.getService().getServiceCode(), serviceRequest.getService().getTenantId(), serviceRequest.getRequestInfo().getUserInfo().getId(), new Date(new java.util.Date().getTime())}; jdbcTemplate.update(serviceInsert, obj); if (serviceRequest.getService().isMetadata()) { persistAttributeValues(serviceRequest); } if (null != serviceRequest.getService().getKeywords()) { if (serviceRequest.getService().getKeywords().size() > 0) { persistKeywordServiceCodeMapping(serviceRequest); } } return serviceRequest; }  ServiceRequest persistServiceType(final ServiceRequest serviceRequest); ServiceRequest persistModifyServiceType(final ServiceRequest serviceRequest); boolean checkServiceByNameAndCode(final String code, final String name, final String tenantId); boolean checkServiceCodeIfExists(final String serviceCode, final String tenantId); boolean checkComplaintNameIfExists(final String serviceName, final String tenantId, final String serviceCode, String mode); boolean checkComplaintCodeNameIfExists(final String serviceName, final String tenantId, final String serviceCode, String mode); List<GrievanceType> findForCriteria(final ServiceGetRequest serviceTypeGetRequest); static final Logger LOGGER; static final String COMPLAINT; }