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

Add sendMail

parent b6a2fbc9
No related branches found
No related tags found
3 merge requests!31M2,!28M2 user,!27Draft: M2 user
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