view spring-boot-playground/src/main/java/de/comline/spring/controller/MovieController.java @ 5:227f3105fedd

Erster Unit Test, der das repository einfach nur mockt
author Dirk Olmes <dirk.olmes@codedo.de>
date Thu, 13 Aug 2020 15:58:57 +0200
parents 92d52e4ac567
children d57d0c6a841b
line wrap: on
line source

package de.comline.spring.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import de.comline.spring.service.MovieService;

@RestController
public class MovieController {
	@Autowired
	private MovieService service;
	
	@PostMapping("/movie/{title}")
	public String index(@PathVariable(name = "title") String title) {
		service.createMovie(title);
		return "Successfully created movie " + title + ".\n";
	}
}