Skip to content
Snippets Groups Projects

Mail module

Merged Martin Gargalovič requested to merge Mail-Module into main
1 file
+ 6
3
Compare changes
  • Side-by-side
  • Inline
@@ -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());
}
Loading