@Test(expected = InvalidDataException.class) public final void test_update_with_null_req() { List<Instrument> expextedResult = getInstruments(); when(instrumentRepository.uniqueCheck(any(String.class), any(Instrument.class))).thenReturn(true); when(instrumentRepository.update(any(List.class), any(RequestInfo.class))).thenReturn(expextedResult); List<Instrument> actualResult = instrumentService.update(null, errors, requestInfo); assertEquals(expextedResult, actualResult); }
@Transactional public List<Instrument> update(List<Instrument> instruments, BindingResult errors, RequestInfo requestInfo) { try { instruments = fetchRelated(instruments, requestInfo); validate(instruments, ACTION_UPDATE, errors); if (errors.hasErrors()) throw new CustomBindException(errors); } catch (CustomBindException e) { throw new CustomBindException(errors); } return instrumentRepository.update(instruments, requestInfo); }
InstrumentService { @Transactional public List<Instrument> update(List<Instrument> instruments, BindingResult errors, RequestInfo requestInfo) { try { instruments = fetchRelated(instruments, requestInfo); validate(instruments, ACTION_UPDATE, errors); if (errors.hasErrors()) throw new CustomBindException(errors); } catch (CustomBindException e) { throw new CustomBindException(errors); } return instrumentRepository.update(instruments, requestInfo); } }
InstrumentService { @Transactional public List<Instrument> update(List<Instrument> instruments, BindingResult errors, RequestInfo requestInfo) { try { instruments = fetchRelated(instruments, requestInfo); validate(instruments, ACTION_UPDATE, errors); if (errors.hasErrors()) throw new CustomBindException(errors); } catch (CustomBindException e) { throw new CustomBindException(errors); } return instrumentRepository.update(instruments, requestInfo); } @Autowired  InstrumentService(SmartValidator validator, InstrumentRepository instrumentRepository, BankContractRepository bankContractRepository,
            FinancialStatusContractRepository financialStatusContractRepository,
            BankAccountContractRepository bankAccountContractRepository,
            InstrumentTypeRepository instrumentTypeRepository); }
InstrumentService { @Transactional public List<Instrument> update(List<Instrument> instruments, BindingResult errors, RequestInfo requestInfo) { try { instruments = fetchRelated(instruments, requestInfo); validate(instruments, ACTION_UPDATE, errors); if (errors.hasErrors()) throw new CustomBindException(errors); } catch (CustomBindException e) { throw new CustomBindException(errors); } return instrumentRepository.update(instruments, requestInfo); } @Autowired  InstrumentService(SmartValidator validator, InstrumentRepository instrumentRepository, BankContractRepository bankContractRepository,
            FinancialStatusContractRepository financialStatusContractRepository,
            BankAccountContractRepository bankAccountContractRepository,
            InstrumentTypeRepository instrumentTypeRepository); @Transactional List<Instrument> create(List<Instrument> instruments, BindingResult errors, RequestInfo requestInfo); @Transactional List<Instrument> update(List<Instrument> instruments, BindingResult errors, RequestInfo requestInfo); @Transactional List<Instrument> delete(List<Instrument> instruments, BindingResult errors, RequestInfo requestInfo); List<Instrument> fetchRelated(List<Instrument> instruments, RequestInfo requestInfo); Pagination<Instrument> search(InstrumentSearch instrumentSearch); @Transactional Instrument save(Instrument instrument); @Transactional Instrument update(Instrument instrument); @Transactional Instrument delete(Instrument instrument); List<Instrument> deposit(InstrumentRequest instrumentDepositRequest, BindingResult errors,
            RequestInfo requestInfo); List<Instrument> dishonor(InstrumentRequest instrumentDepositRequest, BindingResult errors,
            RequestInfo requestInfo); }
InstrumentService { @Transactional public List<Instrument> update(List<Instrument> instruments, BindingResult errors, RequestInfo requestInfo) { try { instruments = fetchRelated(instruments, requestInfo); validate(instruments, ACTION_UPDATE, errors); if (errors.hasErrors()) throw new CustomBindException(errors); } catch (CustomBindException e) { throw new CustomBindException(errors); } return instrumentRepository.update(instruments, requestInfo); } @Autowired  InstrumentService(SmartValidator validator, InstrumentRepository instrumentRepository, BankContractRepository bankContractRepository,
            FinancialStatusContractRepository financialStatusContractRepository,
            BankAccountContractRepository bankAccountContractRepository,
            InstrumentTypeRepository instrumentTypeRepository); @Transactional List<Instrument> create(List<Instrument> instruments, BindingResult errors, RequestInfo requestInfo); @Transactional List<Instrument> update(List<Instrument> instruments, BindingResult errors, RequestInfo requestInfo); @Transactional List<Instrument> delete(List<Instrument> instruments, BindingResult errors, RequestInfo requestInfo); List<Instrument> fetchRelated(List<Instrument> instruments, RequestInfo requestInfo); Pagination<Instrument> search(InstrumentSearch instrumentSearch); @Transactional Instrument save(Instrument instrument); @Transactional Instrument update(Instrument instrument); @Transactional Instrument delete(Instrument instrument); List<Instrument> deposit(InstrumentRequest instrumentDepositRequest, BindingResult errors,
            RequestInfo requestInfo); List<Instrument> dishonor(InstrumentRequest instrumentDepositRequest, BindingResult errors,
            RequestInfo requestInfo); static final String ACTION_CREATE; static final String ACTION_UPDATE; static final String ACTION_DELETE; static final String ACTION_VIEW; static final String ACTION_EDIT; static final String ACTION_SEARCH; }