Monday, August 22, 2022

How to Mock Specifications Spring Data JPA

How to Mock Specifications Spring Data JPA in Junit 5

@Test
public void getUserTest() {
	User user = new User();
	user.setId(105);
	user.setName("Ram");
	user.setEmailId("ram@javaiq.in");
	Mockito.when(userRepository.findAll(Mockito.any(Specifications.class))).thenReturn(user);
}

No comments:

Post a Comment