-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from s-chepurnov/test-utf8
кодировка UTF-8 в тестах
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson; | ||
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.jwt; | ||
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
|
@@ -20,12 +21,19 @@ | |
import io.hexlet.blog.util.ModelGenerator; | ||
import io.hexlet.blog.util.UserUtils; | ||
import jakarta.transaction.Transactional; | ||
import org.springframework.test.web.servlet.setup.MockMvcBuilders; | ||
import org.springframework.web.context.WebApplicationContext; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
||
@SpringBootTest | ||
@Transactional | ||
@AutoConfigureMockMvc | ||
public class PostsCommentsControllerTest { | ||
|
||
@Autowired | ||
private WebApplicationContext wac; | ||
|
||
@Autowired | ||
private MockMvc mockMvc; | ||
|
||
|
@@ -47,7 +55,13 @@ public class PostsCommentsControllerTest { | |
|
||
@BeforeEach | ||
public void setUp() { | ||
mockMvc = MockMvcBuilders.webAppContextSetup(wac) | ||
.defaultResponseCharacterEncoding(StandardCharsets.UTF_8) | ||
.apply(springSecurity()) | ||
.build(); | ||
|
||
token = jwt().jwt(builder -> builder.subject("[email protected]")); | ||
|
||
testPost = Instancio.of(modelGenerator.getPostModel()) | ||
.create(); | ||
testPost.setAuthor(userUtils.getTestUser()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.jwt; | ||
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; | ||
|
@@ -29,11 +30,18 @@ | |
import io.hexlet.blog.repository.PostRepository; | ||
import io.hexlet.blog.util.ModelGenerator; | ||
import io.hexlet.blog.util.UserUtils; | ||
import org.springframework.test.web.servlet.setup.MockMvcBuilders; | ||
import org.springframework.web.context.WebApplicationContext; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
||
@SpringBootTest | ||
@AutoConfigureMockMvc | ||
public class PostsControllerTest { | ||
|
||
@Autowired | ||
private WebApplicationContext wac; | ||
|
||
@Autowired | ||
private MockMvc mockMvc; | ||
|
||
|
@@ -58,7 +66,13 @@ public class PostsControllerTest { | |
|
||
@BeforeEach | ||
public void setUp() { | ||
mockMvc = MockMvcBuilders.webAppContextSetup(wac) | ||
.defaultResponseCharacterEncoding(StandardCharsets.UTF_8) | ||
.apply(springSecurity()) | ||
.build(); | ||
|
||
token = jwt().jwt(builder -> builder.subject("[email protected]")); | ||
|
||
testPost = Instancio.of(modelGenerator.getPostModel()) | ||
.create(); | ||
testPost.setAuthor(userUtils.getTestUser()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,13 @@ | |
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.jwt; | ||
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import java.util.HashMap; | ||
|
||
import org.instancio.Instancio; | ||
|
@@ -26,11 +28,16 @@ | |
import io.hexlet.blog.repository.UserRepository; | ||
import io.hexlet.blog.util.ModelGenerator; | ||
import net.datafaker.Faker; | ||
import org.springframework.test.web.servlet.setup.MockMvcBuilders; | ||
import org.springframework.web.context.WebApplicationContext; | ||
|
||
@SpringBootTest | ||
@AutoConfigureMockMvc | ||
public class UsersControllerTest { | ||
|
||
@Autowired | ||
private WebApplicationContext wac; | ||
|
||
@Autowired | ||
private MockMvc mockMvc; | ||
|
||
|
@@ -52,7 +59,13 @@ public class UsersControllerTest { | |
|
||
@BeforeEach | ||
public void setUp() { | ||
mockMvc = MockMvcBuilders.webAppContextSetup(wac) | ||
.defaultResponseCharacterEncoding(StandardCharsets.UTF_8) | ||
.apply(springSecurity()) | ||
.build(); | ||
|
||
token = jwt().jwt(builder -> builder.subject("[email protected]")); | ||
|
||
testUser = Instancio.of(modelGenerator.getUserModel()) | ||
.create(); | ||
userRepository.save(testUser); | ||
|