Created
April 7, 2020 21:00
-
-
Save larsgroeber/93c5ef8fb94c0da88132d4e62b3c18ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@MockBean | |
private lateinit var mailSenderProxy: MailSenderProxyService; | |
@Test | |
@WithMockUser(authorities = ["SEND_MAIL"]) | |
@Throws(Exception::class) | |
fun shouldSendMail() { | |
val mockMessage = mock(MimeMessage::class.java) | |
Mockito.`when`(mailSenderProxy.createMimeMessage()).thenReturn(mockMessage) | |
val builder = MockMvcRequestBuilders.multipart("/email/sendMail") | |
.param("body", "body").param("toMail", "toMail").param("subject", "subject") | |
mockMvc.perform(builder).andExpect(MockMvcResultMatchers.status().isNoContent) | |
verify(mailSenderProxy).send(mockMessage) | |
val logs = mongoTemplate.findAll(EMailLogEntity::class.java) | |
assertThat(logs).hasSize(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment