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

Add sendMail

parent 2b698701
No related branches found
No related tags found
2 merge requests!15Mail module test,!12Mail module
Pipeline #
package org.fuseri.modulemail.service;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.fuseri.model.dto.mail.MailDto;
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.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.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@SpringBootTest
......@@ -29,4 +33,18 @@ class MailControllerTest {
.andExpect(status().isOk());
}
@Test
void sendMail() throws Exception {
// TODO use mocks
mockMvc.perform(post("/mail")
.content(asJsonString(new MailDto("12marting02@gmail.com", "Hello")))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
}
private static String asJsonString(final Object obj) throws JsonProcessingException {
return new ObjectMapper().writeValueAsString(obj);
}
}
\ No newline at end of file
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