CustomerServiceImpl implements CustomerService { @Override public Customer register(Customer customer, String rawPassword) { String customerCode = customerCodeSeq.getNext(); String password = passwordEncoder.encode(rawPassword); customer.setCustomerCode(customerCode); customer.setCustomerPass(password); return customerRepository.save(customer); }  @Override Customer findOne(String customerCode); @Override Customer register(Customer customer, String rawPassword);  }
@Test public void testRegister01() { Customer c = new Customer(); when(sequencer.getNext()).thenReturn("12345678"); customerService.register(c, "foo"); ArgumentCaptor<Customer> customerArg = ArgumentCaptor.forClass( Customer.class); verify(customerRepository, times(1)).save(customerArg.capture()); assertThat(customerArg.getValue(), is(c)); assertThat(customerArg.getValue().getCustomerCode(), is("12345678")); }