CustomerServiceImpl implements CustomerService { @Override @Transactional(readOnly = true) public List<Customer> getCustomers() { LOGGER.info("Retrieving customers list"); return customerRepository.findAll(); }  @Override Customer addCustomer(Customer customer); @Override @Transactional(readOnly = true) List<Customer> getCustomers(); @Override Customer findCustomerByCustomerName(String customerName); @Override @Transactional(readOnly = true) Customer findCustomerByCustomerId(int customerId);  }
@Test public void testGetCustomers() { Customer testCustomer = new Customer(); testCustomer.setFirstName("Johny"); testCustomer.setLastName("Rainbow"); List<Customer> customerList = Arrays.asList(testCustomer); Mockito.when(customerRepository.findAll()).thenReturn(customerList); List<Customer> customers = customerService.getCustomers(); assertThat(customers).isNotEmpty(); assertThat(customers).extracting(Customer::getFirstName).contains("Johny"); }