package test.test;

import java.util.ArrayList;

import org.mockito.Mockito;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.thymeleaf.spring4.SpringTemplateEngine;
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
import org.thymeleaf.templateresolver.ServletContextTemplateResolver;

import test.model.jpa.Message;
import test.model.mongo.Post;
import test.service.MessageService;
import test.service.PostService;

@Configuration
@EnableWebMvc
@ComponentScan(basePackages={"test.controller"})
public class MvcConfig {

	private static String[] messageSourceBasenames = { "applicationResources" };

	@Bean
	public ResourceBundleMessageSource messageSource() {
		ResourceBundleMessageSource ms = new ResourceBundleMessageSource();
		ms.setBasenames(messageSourceBasenames);
		ms.setFallbackToSystemLocale(false);
		return ms;
	}

	@Bean
	public ServletContextTemplateResolver templateResolver() {
		ServletContextTemplateResolver resolver = new ServletContextTemplateResolver();
		resolver.setPrefix("/WEB-INF/thymeleaf");
		resolver.setTemplateMode("HTML5");
		return resolver;
	}

	@Bean
	public SpringTemplateEngine templateEngine() {
		SpringTemplateEngine templateEngine = new SpringTemplateEngine();
		templateEngine.setTemplateResolver(templateResolver());
		return templateEngine;
	}

	@Bean
	public ThymeleafViewResolver viewResolver() {
		ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
		viewResolver.setTemplateEngine(templateEngine());
		viewResolver.setOrder(1);
		viewResolver.setViewNames(new String[] {"*.html"});
		return viewResolver;
	}

	// service mocks

	@Bean
	public MessageService messageService() {
		MessageService impl = Mockito.mock(MessageService.class);
		Mockito.when(impl.findImportantMessages()).thenReturn(new ArrayList<Message>(0));
		return impl;
	}
	
	@Bean
	public PostService postService() {
		PostService impl = Mockito.mock(PostService.class);
		Mockito.when(impl.findLatestPosts()).thenReturn(new ArrayList<Post>(0));
		return impl;
	}

}

@@ -659,22 +659,89 @@
 est.
-service.Messag
+model.neo4j.Movie;%0D%0Aimport test.service.MessageService;%0D%0Aimport test.service.Movi
 eSer
@@ -2420,11 +2420,213 @@
 %0D%0A%09%7D%0D%0A%0D%0A
+%09@Bean%0D%0A%09public MovieService movieService() %7B%0D%0A%09%09MovieService impl = Mockito.mock(MovieService.class);%0D%0A%09%09Mockito.when(impl.findTestMovies()).thenReturn(new ArrayList%3CMovie%3E(0));%0D%0A%09%09return impl;%0D%0A%09%7D%0D%0A%0D%0A
 %7D%0D%0A

Fix missing mock in mvc test config