Add two modules for BAEL-4688
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package com.baeldung.boot.mvc;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class MvcApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MvcApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.baeldung.boot.mvc.controllers;
|
||||
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/hello")
|
||||
public class HelloController {
|
||||
|
||||
@GetMapping(value = "/{name}", produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
public ResponseEntity<?> hello(@PathVariable String name) {
|
||||
return new ResponseEntity<>("Hello, " + name, HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.baeldung.boot.mvc;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class MvcApplicationIntegrationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.baeldung.boot.mvc.controllers;
|
||||
|
||||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
@Import(HelloController.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
public class HelloControllerUnitTest {
|
||||
|
||||
@Autowired
|
||||
private HelloController helloController;
|
||||
|
||||
@Test
|
||||
public void helloTest() {
|
||||
ResponseEntity response = this.helloController.hello("Caio");
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(response.getBody()).isEqualTo("Hello, Caio");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user