DisplayName in EmailController

This commit is contained in:
2025-06-11 18:27:54 +02:00
parent 5addf38127
commit 5d7ab8d45d

View File

@@ -1,6 +1,7 @@
package _11.asktpk.artisanconnectbackend; package _11.asktpk.artisanconnectbackend;
import _11.asktpk.artisanconnectbackend.security.JwtUtil; import _11.asktpk.artisanconnectbackend.security.JwtUtil;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
@@ -24,8 +25,9 @@ class EmailControllerIntegrationTest {
private JwtUtil jwtUtil; private JwtUtil jwtUtil;
@Test @Test
@DisplayName("Wysyłanie Maila z waznym tokenem")
void testSendEmailWithValidAuthToken() throws Exception { void testSendEmailWithValidAuthToken() throws Exception {
System.out.println("Starting testSendEmailWithValidAuthToken"); System.out.println("Startowanie testSendEmailWithValidAuthToken");
String jsonPayload = """ String jsonPayload = """
{ {
"to": "test@example.com", "to": "test@example.com",
@@ -33,7 +35,7 @@ class EmailControllerIntegrationTest {
"body": "Test Body" "body": "Test Body"
} }
"""; """;
System.out.println("Sending JSON payload: " + jsonPayload); System.out.println("Wysyłanie JSON payload: " + jsonPayload);
String jwtToken = "Bearer " + jwtUtil.generateToken("test@example.com", "USER", 1L); String jwtToken = "Bearer " + jwtUtil.generateToken("test@example.com", "USER", 1L);
@@ -45,13 +47,14 @@ class EmailControllerIntegrationTest {
.andExpect(content().string("Email wysłany pomyślnie")) .andExpect(content().string("Email wysłany pomyślnie"))
.andReturn(); .andReturn();
System.out.println("Response status: " + result.getResponse().getStatus()); System.out.println("Status odpowiedzi: " + result.getResponse().getStatus());
System.out.println("Response content: " + result.getResponse().getContentAsString()); System.out.println("Treść odpowiedzi: " + result.getResponse().getContentAsString());
} }
@Test @Test
@DisplayName("Wysyłanie Maila bez tokena")
void testSendEmailWithoutAuthToken() throws Exception { void testSendEmailWithoutAuthToken() throws Exception {
System.out.println("Starting testSendEmailWithoutAuthToken"); System.out.println("Startowanie testSendEmailWithoutAuthToken");
String jsonPayload = """ String jsonPayload = """
{ {
"to": "test@example.com", "to": "test@example.com",
@@ -59,7 +62,7 @@ class EmailControllerIntegrationTest {
"body": "Test Body" "body": "Test Body"
} }
"""; """;
System.out.println("Sending JSON payload: " + jsonPayload); System.out.println("Wysyłanie JSON payload: " + jsonPayload);
MvcResult result = mockMvc.perform(post("/api/v1/email/send") MvcResult result = mockMvc.perform(post("/api/v1/email/send")
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
@@ -67,7 +70,7 @@ class EmailControllerIntegrationTest {
.andExpect(status().isForbidden()) .andExpect(status().isForbidden())
.andReturn(); .andReturn();
System.out.println("Response status: " + result.getResponse().getStatus()); System.out.println("Status odpowiedzi: " + result.getResponse().getStatus());
System.out.println("Response content: " + result.getResponse().getContentAsString()); System.out.println("Treść odpowiedzi: " + result.getResponse().getContentAsString());
} }
} }