Skip to content

Instantly share code, notes, and snippets.

@mauricioaniche
Created January 9, 2017 14:48
Show Gist options
  • Save mauricioaniche/98dddad147104aa8223688de32250445 to your computer and use it in GitHub Desktop.
Save mauricioaniche/98dddad147104aa8223688de32250445 to your computer and use it in GitHub Desktop.
public class CustomerServiceTest{
@Test
public void shouldGenerateInvoices() {
// mocking CustomerDAO
CustomerDAO customerDao = Mockito.mock(CustomerDAO.class);
Mockito.when(
customerDao.findCustomerById(1))
.thenReturn(new Customer(1, "Customer1"));
// instantiating the CUT, and passing
// a mock as dependency
CustomerService cut = new CustomerService(customerDao);
cut.generateInvoices();
// asserts here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment