Skip to content
Snippets Groups Projects
Commit 6632f036 authored by Dominika Zemanovičová's avatar Dominika Zemanovičová Committed by Martin Gargalovič
Browse files

Send mail mock

parent f41bc944
No related branches found
No related tags found
3 merge requests!31M2,!28M2 user,!27Draft: M2 user
......@@ -7,10 +7,11 @@ import org.junit.jupiter.api.Test;
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.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
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.result.MockMvcResultMatchers.status;
......@@ -35,10 +36,12 @@ class MailControllerTest {
@Test
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")
.content(asJsonString(new MailDto("12marting02@gmail.com", "Hello")))
.content(asJsonString(mailDto))
.contentType(MediaType.APPLICATION_JSON))
.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