@Test public void testSavee() { FunctionEntity functionEntity = getFunctionEntity(); Function expectedResult = functionEntity.toDomain(); when(functionJdbcRepository.create(any(FunctionEntity.class))).thenReturn(functionEntity); Function actualResult = functionRepository.save(getFunctionDomain()); assertEquals(expectedResult, actualResult); }
@Transactional public List<Function> save(List<Function> functions, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); FunctionContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { FunctionRequest request = new FunctionRequest(); request.setRequestInfo(requestInfo); request.setFunctions(new ArrayList<>()); for (Function f : functions) { contract = new FunctionContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getFunctions().add(contract); } addToQue(request); return functions; } else { List<Function> resultList = new ArrayList<Function>(); for (Function f : functions) { resultList.add(save(f)); } FunctionRequest request = new FunctionRequest(); request.setRequestInfo(requestInfo); request.setFunctions(new ArrayList<>()); for (Function f : resultList) { contract = new FunctionContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getFunctions().add(contract); } addToSearchQueue(request); return resultList; } }
FunctionRepository { @Transactional public List<Function> save(List<Function> functions, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); FunctionContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { FunctionRequest request = new FunctionRequest(); request.setRequestInfo(requestInfo); request.setFunctions(new ArrayList<>()); for (Function f : functions) { contract = new FunctionContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getFunctions().add(contract); } addToQue(request); return functions; } else { List<Function> resultList = new ArrayList<Function>(); for (Function f : functions) { resultList.add(save(f)); } FunctionRequest request = new FunctionRequest(); request.setRequestInfo(requestInfo); request.setFunctions(new ArrayList<>()); for (Function f : resultList) { contract = new FunctionContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getFunctions().add(contract); } addToSearchQueue(request); return resultList; } } }
FunctionRepository { @Transactional public List<Function> save(List<Function> functions, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); FunctionContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { FunctionRequest request = new FunctionRequest(); request.setRequestInfo(requestInfo); request.setFunctions(new ArrayList<>()); for (Function f : functions) { contract = new FunctionContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getFunctions().add(contract); } addToQue(request); return functions; } else { List<Function> resultList = new ArrayList<Function>(); for (Function f : functions) { resultList.add(save(f)); } FunctionRequest request = new FunctionRequest(); request.setRequestInfo(requestInfo); request.setFunctions(new ArrayList<>()); for (Function f : resultList) { contract = new FunctionContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getFunctions().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  FunctionRepository(FunctionJdbcRepository functionJdbcRepository,
			MastersQueueRepository functionQueueRepository, FinancialConfigurationService financialConfigurationService,
			FunctionESRepository functionESRepository, @Value("${persist.through.kafka}") String persistThroughKafka); }
FunctionRepository { @Transactional public List<Function> save(List<Function> functions, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); FunctionContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { FunctionRequest request = new FunctionRequest(); request.setRequestInfo(requestInfo); request.setFunctions(new ArrayList<>()); for (Function f : functions) { contract = new FunctionContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getFunctions().add(contract); } addToQue(request); return functions; } else { List<Function> resultList = new ArrayList<Function>(); for (Function f : functions) { resultList.add(save(f)); } FunctionRequest request = new FunctionRequest(); request.setRequestInfo(requestInfo); request.setFunctions(new ArrayList<>()); for (Function f : resultList) { contract = new FunctionContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getFunctions().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  FunctionRepository(FunctionJdbcRepository functionJdbcRepository,
			MastersQueueRepository functionQueueRepository, FinancialConfigurationService financialConfigurationService,
			FunctionESRepository functionESRepository, @Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<Function> save(List<Function> functions, RequestInfo requestInfo); @Transactional List<Function> update(List<Function> functions, RequestInfo requestInfo); String getNextSequence(); Function findById(Function function); @Transactional Function save(Function function); @Transactional Function update(Function function); void addToQue(FunctionRequest request); void addToSearchQueue(FunctionRequest request); Pagination<Function> search(FunctionSearch domain); boolean uniqueCheck(String fieldName, Function function); }
FunctionRepository { @Transactional public List<Function> save(List<Function> functions, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); FunctionContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { FunctionRequest request = new FunctionRequest(); request.setRequestInfo(requestInfo); request.setFunctions(new ArrayList<>()); for (Function f : functions) { contract = new FunctionContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getFunctions().add(contract); } addToQue(request); return functions; } else { List<Function> resultList = new ArrayList<Function>(); for (Function f : functions) { resultList.add(save(f)); } FunctionRequest request = new FunctionRequest(); request.setRequestInfo(requestInfo); request.setFunctions(new ArrayList<>()); for (Function f : resultList) { contract = new FunctionContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getFunctions().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  FunctionRepository(FunctionJdbcRepository functionJdbcRepository,
			MastersQueueRepository functionQueueRepository, FinancialConfigurationService financialConfigurationService,
			FunctionESRepository functionESRepository, @Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<Function> save(List<Function> functions, RequestInfo requestInfo); @Transactional List<Function> update(List<Function> functions, RequestInfo requestInfo); String getNextSequence(); Function findById(Function function); @Transactional Function save(Function function); @Transactional Function update(Function function); void addToQue(FunctionRequest request); void addToSearchQueue(FunctionRequest request); Pagination<Function> search(FunctionSearch domain); boolean uniqueCheck(String fieldName, Function function);  }