@Test public void test_should_delete_draft_when_present_on_update() { final ServiceRequest serviceRequest = mock(ServiceRequest.class); when(serviceRequest.getDraftId()).thenReturn(4L); when(serviceRequest.getAuthenticatedUser()).thenReturn(getCitizen()); when(serviceRequest.getTenantId()).thenReturn("tenantId"); final SevaRequest sevaRequest = getSevaRequest(); when(userRepository.getUserByUserName("anonymous", "tenantId")).thenReturn(populateUser()); when(employeeRepository.getEmployeeById(1L, "tenantId")).thenReturn(getEmployee()); when(submissionRepository.getPosition(serviceRequest.getCrn(), serviceRequest.getTenantId())) .thenReturn(1L); serviceRequestService.update(serviceRequest, sevaRequest); verify(draftService).delete(4L); }
public void update(ServiceRequest serviceRequest, SevaRequest contractSevaRequest) { validate(serviceRequest); setUserIdForAnonymousUser(contractSevaRequest); enrichWithComputedFields(serviceRequest, contractSevaRequest, serviceRequest.getServiceStatus()); serviceRequestRepository.update(contractSevaRequest); deleteDraft(serviceRequest); }
ServiceRequestService { public void update(ServiceRequest serviceRequest, SevaRequest contractSevaRequest) { validate(serviceRequest); setUserIdForAnonymousUser(contractSevaRequest); enrichWithComputedFields(serviceRequest, contractSevaRequest, serviceRequest.getServiceStatus()); serviceRequestRepository.update(contractSevaRequest); deleteDraft(serviceRequest); } }
ServiceRequestService { public void update(ServiceRequest serviceRequest, SevaRequest contractSevaRequest) { validate(serviceRequest); setUserIdForAnonymousUser(contractSevaRequest); enrichWithComputedFields(serviceRequest, contractSevaRequest, serviceRequest.getServiceStatus()); serviceRequestRepository.update(contractSevaRequest); deleteDraft(serviceRequest); } @Autowired  ServiceRequestService(ServiceRequestRepository serviceRequestRepository,
                                 SevaNumberGeneratorService sevaNumberGeneratorService,
                                 UserRepository userRepository,
                                 ServiceRequestTypeService serviceRequestTypeService,
                                 List<ServiceRequestValidator> validators,
                                 ServiceRequestCustomFieldService customFieldService,
                                 DraftService draftService, @Value("${postgres.enabled}") boolean postgresEnabled); }
ServiceRequestService { public void update(ServiceRequest serviceRequest, SevaRequest contractSevaRequest) { validate(serviceRequest); setUserIdForAnonymousUser(contractSevaRequest); enrichWithComputedFields(serviceRequest, contractSevaRequest, serviceRequest.getServiceStatus()); serviceRequestRepository.update(contractSevaRequest); deleteDraft(serviceRequest); } @Autowired  ServiceRequestService(ServiceRequestRepository serviceRequestRepository,
                                 SevaNumberGeneratorService sevaNumberGeneratorService,
                                 UserRepository userRepository,
                                 ServiceRequestTypeService serviceRequestTypeService,
                                 List<ServiceRequestValidator> validators,
                                 ServiceRequestCustomFieldService customFieldService,
                                 DraftService draftService, @Value("${postgres.enabled}") boolean postgresEnabled); List<ServiceRequest> findAll(ServiceRequestSearchCriteria serviceRequestSearchCriteria); Long getCount(ServiceRequestSearchCriteria searchCriteria); void save(ServiceRequest serviceRequest, SevaRequest contractSevaRequest); void update(ServiceRequest serviceRequest, SevaRequest contractSevaRequest); List<String> getCrnByAttributes(String receivingMode, Long locationId, String keyword); }
ServiceRequestService { public void update(ServiceRequest serviceRequest, SevaRequest contractSevaRequest) { validate(serviceRequest); setUserIdForAnonymousUser(contractSevaRequest); enrichWithComputedFields(serviceRequest, contractSevaRequest, serviceRequest.getServiceStatus()); serviceRequestRepository.update(contractSevaRequest); deleteDraft(serviceRequest); } @Autowired  ServiceRequestService(ServiceRequestRepository serviceRequestRepository,
                                 SevaNumberGeneratorService sevaNumberGeneratorService,
                                 UserRepository userRepository,
                                 ServiceRequestTypeService serviceRequestTypeService,
                                 List<ServiceRequestValidator> validators,
                                 ServiceRequestCustomFieldService customFieldService,
                                 DraftService draftService, @Value("${postgres.enabled}") boolean postgresEnabled); List<ServiceRequest> findAll(ServiceRequestSearchCriteria serviceRequestSearchCriteria); Long getCount(ServiceRequestSearchCriteria searchCriteria); void save(ServiceRequest serviceRequest, SevaRequest contractSevaRequest); void update(ServiceRequest serviceRequest, SevaRequest contractSevaRequest); List<String> getCrnByAttributes(String receivingMode, Long locationId, String keyword);  }