@Test public void test_save() { VoucherSubTypeEntity entity = getVoucherSubTypeEntity(); VoucherSubType expectedResult = entity.toDomain(); when(voucherSubTypeJdbcRepository.create(any(VoucherSubTypeEntity.class))).thenReturn(entity); VoucherSubType actualResult = voucherSubTypeRepositoryWithKafka.save(getVoucherSubTypeDomin()); assertEquals(expectedResult.getId(), actualResult.getId()); assertEquals(expectedResult.getVoucherName(), actualResult.getVoucherName()); assertEquals(expectedResult.getVoucherType(), actualResult.getVoucherType()); }
@Transactional public List<VoucherSubType> save(List<VoucherSubType> voucherSubTypes, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); VoucherSubTypeContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : voucherSubTypes) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToQue(request); return voucherSubTypes; } else { List<VoucherSubType> resultList = new ArrayList<VoucherSubType>(); for (VoucherSubType f : voucherSubTypes) { resultList.add(save(f)); } VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : resultList) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToSearchQueue(request); return resultList; } }
VoucherSubTypeRepository { @Transactional public List<VoucherSubType> save(List<VoucherSubType> voucherSubTypes, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); VoucherSubTypeContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : voucherSubTypes) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToQue(request); return voucherSubTypes; } else { List<VoucherSubType> resultList = new ArrayList<VoucherSubType>(); for (VoucherSubType f : voucherSubTypes) { resultList.add(save(f)); } VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : resultList) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToSearchQueue(request); return resultList; } } }
VoucherSubTypeRepository { @Transactional public List<VoucherSubType> save(List<VoucherSubType> voucherSubTypes, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); VoucherSubTypeContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : voucherSubTypes) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToQue(request); return voucherSubTypes; } else { List<VoucherSubType> resultList = new ArrayList<VoucherSubType>(); for (VoucherSubType f : voucherSubTypes) { resultList.add(save(f)); } VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : resultList) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  VoucherSubTypeRepository(
            VoucherSubTypeJdbcRepository voucherSubTypeJdbcRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            VoucherSubTypeESRepository voucherSubTypeESRepository,
            VoucherSubTypeQueueRepository voucherSubTypeQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka); }
VoucherSubTypeRepository { @Transactional public List<VoucherSubType> save(List<VoucherSubType> voucherSubTypes, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); VoucherSubTypeContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : voucherSubTypes) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToQue(request); return voucherSubTypes; } else { List<VoucherSubType> resultList = new ArrayList<VoucherSubType>(); for (VoucherSubType f : voucherSubTypes) { resultList.add(save(f)); } VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : resultList) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  VoucherSubTypeRepository(
            VoucherSubTypeJdbcRepository voucherSubTypeJdbcRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            VoucherSubTypeESRepository voucherSubTypeESRepository,
            VoucherSubTypeQueueRepository voucherSubTypeQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<VoucherSubType> save(List<VoucherSubType> voucherSubTypes,
            RequestInfo requestInfo); @Transactional List<VoucherSubType> update(List<VoucherSubType> voucherSubTypes,
            RequestInfo requestInfo); @Transactional VoucherSubType save(VoucherSubType voucherSubType); @Transactional VoucherSubType update(VoucherSubType voucherSubType); void addToQue(VoucherSubTypeRequest request); void addToSearchQueue(VoucherSubTypeRequest request); Pagination<VoucherSubType> search(VoucherSubTypeSearch domain); }
VoucherSubTypeRepository { @Transactional public List<VoucherSubType> save(List<VoucherSubType> voucherSubTypes, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); VoucherSubTypeContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : voucherSubTypes) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToQue(request); return voucherSubTypes; } else { List<VoucherSubType> resultList = new ArrayList<VoucherSubType>(); for (VoucherSubType f : voucherSubTypes) { resultList.add(save(f)); } VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : resultList) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  VoucherSubTypeRepository(
            VoucherSubTypeJdbcRepository voucherSubTypeJdbcRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            VoucherSubTypeESRepository voucherSubTypeESRepository,
            VoucherSubTypeQueueRepository voucherSubTypeQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<VoucherSubType> save(List<VoucherSubType> voucherSubTypes,
            RequestInfo requestInfo); @Transactional List<VoucherSubType> update(List<VoucherSubType> voucherSubTypes,
            RequestInfo requestInfo); @Transactional VoucherSubType save(VoucherSubType voucherSubType); @Transactional VoucherSubType update(VoucherSubType voucherSubType); void addToQue(VoucherSubTypeRequest request); void addToSearchQueue(VoucherSubTypeRequest request); Pagination<VoucherSubType> search(VoucherSubTypeSearch domain);  }