mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 10:58:42 +00:00
4709922f11
* feat: create page controller * add test * add documentation * fix: delete img file * fix: modify App, SignupMode, UserController, pom.xml, and Readme * fix: modify MVC files on page controller * fix: modify readme file
37 lines
1.3 KiB
Java
37 lines
1.3 KiB
Java
package com.iluwatar.page.controller;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
import org.junit.jupiter.api.extension.ExtendWith;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
|
import org.springframework.test.web.servlet.MockMvc;
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
|
|
|
@ExtendWith(SpringExtension.class)
|
|
@SpringBootTest
|
|
@AutoConfigureMockMvc
|
|
public class UserControllerTest {
|
|
private UserController userController;
|
|
|
|
@Autowired
|
|
MockMvc mockMvc;
|
|
|
|
/**
|
|
* Verify if view and model are directed properly
|
|
*/
|
|
@Test
|
|
void testGetUserPath () throws Exception {
|
|
this.mockMvc.perform(get("/user")
|
|
.param("name", "Lily")
|
|
.param("email", "Lily@email.com"))
|
|
.andExpect(status().isOk())
|
|
.andExpect(model().attribute("name", "Lily"))
|
|
.andExpect(model().attribute("email", "Lily@email.com"))
|
|
.andReturn();
|
|
}
|
|
}
|