Skip to content
Snippets Groups Projects
Commit 80dc8a9c authored by Dominika Zemanovičová's avatar Dominika Zemanovičová
Browse files

Send mail mock

parent aa37d856
No related branches found
No related tags found
1 merge request!12Mail module
Pipeline #
This commit is part of merge request !12. Comments created here will be created in the context of that merge request.
...@@ -7,10 +7,11 @@ import org.junit.jupiter.api.Test; ...@@ -7,10 +7,11 @@ 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;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
...@@ -35,10 +36,12 @@ class MailControllerTest { ...@@ -35,10 +36,12 @@ class MailControllerTest {
@Test @Test
void sendMail() throws Exception { void sendMail() throws Exception {
// TODO use mocks var mailDto = new MailDto("user@example.com", "Hello");
MailController mailController = mock(MailController.class);
when(mailController.sendMail(mailDto)).thenReturn("Success, you have sent: " + mailDto.getContent());
mockMvc.perform(post("/mail") mockMvc.perform(post("/mail")
.content(asJsonString(new MailDto("12marting02@gmail.com", "Hello"))) .content(asJsonString(mailDto))
.contentType(MediaType.APPLICATION_JSON)) .contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()); .andExpect(status().isOk());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment