Created
September 14, 2018 23:02
-
-
Save jnizet/de0f85574a118d48ddaa920b77ce84bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static org.junit.Assert.assertEquals; | |
import static org.mockito.ArgumentMatchers.anyList; | |
import static org.mockito.Mockito.mock; | |
import static org.mockito.Mockito.when; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.Collections; | |
import java.util.List; | |
import org.junit.Before; | |
import org.junit.Test; | |
public class SomeTest { | |
static class Employee {} | |
static class EmployeeService { | |
public List<Employee> getEntities(List<String> manager){ | |
//some processing, make db call and return entities | |
return new ArrayList<>(); | |
} | |
} | |
private EmployeeService employeeService = mock(EmployeeService.class); | |
@Before | |
public void setup(){ | |
Employee employee = new Employee(); | |
List<Employee> employees = new ArrayList<>(Arrays.asList(employee)); | |
when(employeeService.getEntities(anyList())).thenReturn(employees); | |
} | |
@Test | |
public void test() { | |
assertEquals(1, employeeService.getEntities(Collections.emptyList()).size()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment