view spring-boot-playground/src/test/java/de/comline/spring/service/RepositoryMocker.java @ 20:452cfefb0e1e default tip

Einfache Spring Application, die ihre config aus dem Spring Cloud Config Server liest
author Dirk Olmes <dirk.olmes@codedo.de>
date Thu, 17 Sep 2020 17:25:15 +0200
parents 4594ff529ab1
children
line wrap: on
line source

package de.comline.spring.service;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import de.comline.spring.repository.MovieRepository;

class RepositoryMocker {
	public static MovieRepository createMockRepository() {
		MovieRepository mockRepository = mock(MovieRepository.class);
		when(mockRepository.save(any())).thenAnswer(invocation -> {
			return invocation.getArgument(0);
		});
		return mockRepository;
	}
}