CustomerServiceImpl implements CustomerService { @Override public Customer findOne(String customerCode) { return customerRepository.findById(customerCode).orElse(null); }  @Override Customer findOne(String customerCode); @Override Customer register(Customer customer, String rawPassword);  }
@Test public void testFindOne01() { Customer c = new Customer(); when(customerRepository.findById("xxx")).thenReturn(Optional.of(c)); Customer result = customerService.findOne("xxx"); assertThat(result, is(c)); }
@Test public void testFindOne02() { when(customerRepository.findById("xxx")).thenReturn(Optional.empty()); Customer result = customerService.findOne("xxx"); assertThat(result, is(nullValue())); }