@Test public final void test_fetch_surrenderreason() { List<Instrument> instruments = getInstrumentss(); SurrenderReason expextedResult = SurrenderReason.builder().name("name").description("description").id("1") .build(); instruments.get(0).setSurrenderReason(expextedResult); when(surrenderReasonRepository.findById(any(SurrenderReason.class))).thenReturn(expextedResult); List<Instrument> actualResult = instrumentService.fetchRelated(instruments, new RequestInfo()); assertEquals(expextedResult, actualResult.get(0).getSurrenderReason()); }
public List<Instrument> fetchRelated(List<Instrument> instruments, RequestInfo requestInfo) { if (instruments != null) for (Instrument instrument : instruments) { if ("create".equalsIgnoreCase(requestInfo.getAction())) instrument.setId(UUID.randomUUID().toString().replace("-", "")); if (instrument.getInstrumentType() != null && instrument.getInstrumentType().getName() != null) { InstrumentTypeSearch instrumentTypeSearch = new InstrumentTypeSearch(); instrumentTypeSearch.setName(instrument.getInstrumentType().getName()); instrumentTypeSearch.setTenantId(instrument.getTenantId()); Pagination<InstrumentType> response = instrumentTypeRepository.search(instrumentTypeSearch); if (response == null || response.getPagedData() == null || response.getPagedData().isEmpty()) throw new InvalidDataException("instrumentType", "instrumentType.invalid", " Invalid instrumentType"); instrument.setInstrumentType(response.getPagedData().get(0)); } bankContractRepository.getClass(); bankAccountContractRepository.getClass(); } return instruments; }
InstrumentService { public List<Instrument> fetchRelated(List<Instrument> instruments, RequestInfo requestInfo) { if (instruments != null) for (Instrument instrument : instruments) { if ("create".equalsIgnoreCase(requestInfo.getAction())) instrument.setId(UUID.randomUUID().toString().replace("-", "")); if (instrument.getInstrumentType() != null && instrument.getInstrumentType().getName() != null) { InstrumentTypeSearch instrumentTypeSearch = new InstrumentTypeSearch(); instrumentTypeSearch.setName(instrument.getInstrumentType().getName()); instrumentTypeSearch.setTenantId(instrument.getTenantId()); Pagination<InstrumentType> response = instrumentTypeRepository.search(instrumentTypeSearch); if (response == null || response.getPagedData() == null || response.getPagedData().isEmpty()) throw new InvalidDataException("instrumentType", "instrumentType.invalid", " Invalid instrumentType"); instrument.setInstrumentType(response.getPagedData().get(0)); } bankContractRepository.getClass(); bankAccountContractRepository.getClass(); } return instruments; } }
InstrumentService { public List<Instrument> fetchRelated(List<Instrument> instruments, RequestInfo requestInfo) { if (instruments != null) for (Instrument instrument : instruments) { if ("create".equalsIgnoreCase(requestInfo.getAction())) instrument.setId(UUID.randomUUID().toString().replace("-", "")); if (instrument.getInstrumentType() != null && instrument.getInstrumentType().getName() != null) { InstrumentTypeSearch instrumentTypeSearch = new InstrumentTypeSearch(); instrumentTypeSearch.setName(instrument.getInstrumentType().getName()); instrumentTypeSearch.setTenantId(instrument.getTenantId()); Pagination<InstrumentType> response = instrumentTypeRepository.search(instrumentTypeSearch); if (response == null || response.getPagedData() == null || response.getPagedData().isEmpty()) throw new InvalidDataException("instrumentType", "instrumentType.invalid", " Invalid instrumentType"); instrument.setInstrumentType(response.getPagedData().get(0)); } bankContractRepository.getClass(); bankAccountContractRepository.getClass(); } return instruments; } @Autowired  InstrumentService(SmartValidator validator, InstrumentRepository instrumentRepository, BankContractRepository bankContractRepository,
            FinancialStatusContractRepository financialStatusContractRepository,
            BankAccountContractRepository bankAccountContractRepository,
            InstrumentTypeRepository instrumentTypeRepository); }
InstrumentService { public List<Instrument> fetchRelated(List<Instrument> instruments, RequestInfo requestInfo) { if (instruments != null) for (Instrument instrument : instruments) { if ("create".equalsIgnoreCase(requestInfo.getAction())) instrument.setId(UUID.randomUUID().toString().replace("-", "")); if (instrument.getInstrumentType() != null && instrument.getInstrumentType().getName() != null) { InstrumentTypeSearch instrumentTypeSearch = new InstrumentTypeSearch(); instrumentTypeSearch.setName(instrument.getInstrumentType().getName()); instrumentTypeSearch.setTenantId(instrument.getTenantId()); Pagination<InstrumentType> response = instrumentTypeRepository.search(instrumentTypeSearch); if (response == null || response.getPagedData() == null || response.getPagedData().isEmpty()) throw new InvalidDataException("instrumentType", "instrumentType.invalid", " Invalid instrumentType"); instrument.setInstrumentType(response.getPagedData().get(0)); } bankContractRepository.getClass(); bankAccountContractRepository.getClass(); } return instruments; } @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 { public List<Instrument> fetchRelated(List<Instrument> instruments, RequestInfo requestInfo) { if (instruments != null) for (Instrument instrument : instruments) { if ("create".equalsIgnoreCase(requestInfo.getAction())) instrument.setId(UUID.randomUUID().toString().replace("-", "")); if (instrument.getInstrumentType() != null && instrument.getInstrumentType().getName() != null) { InstrumentTypeSearch instrumentTypeSearch = new InstrumentTypeSearch(); instrumentTypeSearch.setName(instrument.getInstrumentType().getName()); instrumentTypeSearch.setTenantId(instrument.getTenantId()); Pagination<InstrumentType> response = instrumentTypeRepository.search(instrumentTypeSearch); if (response == null || response.getPagedData() == null || response.getPagedData().isEmpty()) throw new InvalidDataException("instrumentType", "instrumentType.invalid", " Invalid instrumentType"); instrument.setInstrumentType(response.getPagedData().get(0)); } bankContractRepository.getClass(); bankAccountContractRepository.getClass(); } return instruments; } @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; }