@Test public void test_delete_with_kafka() { List<Instrument> expectedResult = getInstruments(); instrumentRepositoryWithKafka.delete(expectedResult, requestInfo); verify(instrumentQueueRepository).addToQue(captor.capture()); final InstrumentRequest actualRequest = captor.getValue(); assertEquals(expectedResult.get(0).getAmount(), actualRequest.getInstruments().get(0).getAmount()); assertEquals(expectedResult.get(0).getTransactionNumber(), actualRequest.getInstruments().get(0).getTransactionNumber()); assertEquals(expectedResult.get(0).getSerialNo(), actualRequest.getInstruments().get(0).getSerialNo()); assertEquals(expectedResult.get(0).getTransactionType().name(), actualRequest.getInstruments().get(0).getTransactionType().name()); assertEquals(expectedResult.get(0).getInstrumentType().getId(), actualRequest.getInstruments().get(0).getInstrumentType().getId()); }
@Transactional public List<Instrument> delete(List<Instrument> instruments, RequestInfo requestInfo) { InstrumentMapper mapper = new InstrumentMapper(); if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { InstrumentRequest request = new InstrumentRequest(); request.setRequestInfo(requestInfo); request.setInstruments(new ArrayList<>()); for (Instrument iac : instruments) request.getInstruments().add(mapper.toContract(iac)); instrumentQueueRepository.addToQue(request); return instruments; } else { List<Instrument> resultList = new ArrayList<Instrument>(); for (Instrument iac : instruments) resultList.add(delete(iac)); InstrumentRequest request = new InstrumentRequest(); request.setRequestInfo(requestInfo); request.setInstruments(new ArrayList<>()); for (Instrument iac : resultList) request.getInstruments().add(mapper.toContract(iac)); instrumentQueueRepository.addToSearchQue(request); return resultList; } }
InstrumentRepository { @Transactional public List<Instrument> delete(List<Instrument> instruments, RequestInfo requestInfo) { InstrumentMapper mapper = new InstrumentMapper(); if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { InstrumentRequest request = new InstrumentRequest(); request.setRequestInfo(requestInfo); request.setInstruments(new ArrayList<>()); for (Instrument iac : instruments) request.getInstruments().add(mapper.toContract(iac)); instrumentQueueRepository.addToQue(request); return instruments; } else { List<Instrument> resultList = new ArrayList<Instrument>(); for (Instrument iac : instruments) resultList.add(delete(iac)); InstrumentRequest request = new InstrumentRequest(); request.setRequestInfo(requestInfo); request.setInstruments(new ArrayList<>()); for (Instrument iac : resultList) request.getInstruments().add(mapper.toContract(iac)); instrumentQueueRepository.addToSearchQue(request); return resultList; } } }
InstrumentRepository { @Transactional public List<Instrument> delete(List<Instrument> instruments, RequestInfo requestInfo) { InstrumentMapper mapper = new InstrumentMapper(); if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { InstrumentRequest request = new InstrumentRequest(); request.setRequestInfo(requestInfo); request.setInstruments(new ArrayList<>()); for (Instrument iac : instruments) request.getInstruments().add(mapper.toContract(iac)); instrumentQueueRepository.addToQue(request); return instruments; } else { List<Instrument> resultList = new ArrayList<Instrument>(); for (Instrument iac : instruments) resultList.add(delete(iac)); InstrumentRequest request = new InstrumentRequest(); request.setRequestInfo(requestInfo); request.setInstruments(new ArrayList<>()); for (Instrument iac : resultList) request.getInstruments().add(mapper.toContract(iac)); instrumentQueueRepository.addToSearchQue(request); return resultList; } } @Autowired  InstrumentRepository(InstrumentJdbcRepository instrumentJdbcRepository,
            InstrumentQueueRepository instrumentQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka,
            InstrumentESRepository instrumentESRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            InstrumentVoucherJdbcRepository instrumentVoucherJdbcRepository); }
InstrumentRepository { @Transactional public List<Instrument> delete(List<Instrument> instruments, RequestInfo requestInfo) { InstrumentMapper mapper = new InstrumentMapper(); if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { InstrumentRequest request = new InstrumentRequest(); request.setRequestInfo(requestInfo); request.setInstruments(new ArrayList<>()); for (Instrument iac : instruments) request.getInstruments().add(mapper.toContract(iac)); instrumentQueueRepository.addToQue(request); return instruments; } else { List<Instrument> resultList = new ArrayList<Instrument>(); for (Instrument iac : instruments) resultList.add(delete(iac)); InstrumentRequest request = new InstrumentRequest(); request.setRequestInfo(requestInfo); request.setInstruments(new ArrayList<>()); for (Instrument iac : resultList) request.getInstruments().add(mapper.toContract(iac)); instrumentQueueRepository.addToSearchQue(request); return resultList; } } @Autowired  InstrumentRepository(InstrumentJdbcRepository instrumentJdbcRepository,
            InstrumentQueueRepository instrumentQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka,
            InstrumentESRepository instrumentESRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            InstrumentVoucherJdbcRepository instrumentVoucherJdbcRepository); Instrument findById(Instrument instrument); @Transactional List<Instrument> save(List<Instrument> instruments, RequestInfo requestInfo); @Transactional List<Instrument> update(List<Instrument> instruments, RequestInfo requestInfo); @Transactional List<Instrument> delete(List<Instrument> instruments, RequestInfo requestInfo); @Transactional Instrument save(Instrument instrument); @Transactional Instrument update(Instrument instrument); @Transactional Instrument delete(Instrument instrument); Pagination<Instrument> search(InstrumentSearch domain); boolean uniqueCheck(String fieldName, Instrument instrument); }
InstrumentRepository { @Transactional public List<Instrument> delete(List<Instrument> instruments, RequestInfo requestInfo) { InstrumentMapper mapper = new InstrumentMapper(); if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { InstrumentRequest request = new InstrumentRequest(); request.setRequestInfo(requestInfo); request.setInstruments(new ArrayList<>()); for (Instrument iac : instruments) request.getInstruments().add(mapper.toContract(iac)); instrumentQueueRepository.addToQue(request); return instruments; } else { List<Instrument> resultList = new ArrayList<Instrument>(); for (Instrument iac : instruments) resultList.add(delete(iac)); InstrumentRequest request = new InstrumentRequest(); request.setRequestInfo(requestInfo); request.setInstruments(new ArrayList<>()); for (Instrument iac : resultList) request.getInstruments().add(mapper.toContract(iac)); instrumentQueueRepository.addToSearchQue(request); return resultList; } } @Autowired  InstrumentRepository(InstrumentJdbcRepository instrumentJdbcRepository,
            InstrumentQueueRepository instrumentQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka,
            InstrumentESRepository instrumentESRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            InstrumentVoucherJdbcRepository instrumentVoucherJdbcRepository); Instrument findById(Instrument instrument); @Transactional List<Instrument> save(List<Instrument> instruments, RequestInfo requestInfo); @Transactional List<Instrument> update(List<Instrument> instruments, RequestInfo requestInfo); @Transactional List<Instrument> delete(List<Instrument> instruments, RequestInfo requestInfo); @Transactional Instrument save(Instrument instrument); @Transactional Instrument update(Instrument instrument); @Transactional Instrument delete(Instrument instrument); Pagination<Instrument> search(InstrumentSearch domain); boolean uniqueCheck(String fieldName, Instrument instrument);  }