view spring-boot-playground/src/test/java/de/comline/spring/service/RepositoryMocker.java @ 18:8504317b9a09

Erweiterung um Sleuth, manuelle Konfiguration von Spring
author Dirk Olmes <dirk.olmes@codedo.de>
date Thu, 17 Sep 2020 09:03:11 +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;
	}
}