daily pastebin goal
31%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 57 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. import static org.junit.Assert.assertEquals;
  2. import static org.mockito.ArgumentMatchers.anyList;
  3. import static org.mockito.Mockito.mock;
  4. import static org.mockito.Mockito.when;
  5.  
  6. import java.util.ArrayList;
  7. import java.util.Arrays;
  8. import java.util.Collections;
  9. import java.util.List;
  10.  
  11. import org.junit.Before;
  12. import org.junit.Test;
  13.  
  14. public class SomeTest {
  15.  
  16.     static class Employee {}
  17.  
  18.     static class EmployeeService {
  19.         public List<Employee> getEntities(List<String> manager){
  20.             //some processing, make db call and return entities
  21.             return new ArrayList<>();
  22.         }
  23.     }
  24.  
  25.     private EmployeeService employeeService = mock(EmployeeService.class);
  26.  
  27.     @Before
  28.     public void setup(){
  29.         Employee employee = new Employee();
  30.         List<Employee> employees = new ArrayList<>(Arrays.asList(employee));
  31.         when(employeeService.getEntities(anyList())).thenReturn(employees);
  32.     }
  33.  
  34.     @Test
  35.     public void test() {
  36.         assertEquals(1, employeeService.getEntities(Collections.emptyList()).size());
  37.     }
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top