Unable to save email send to WebWolf #419
This commit is contained in:
parent
ae92ac6808
commit
e801b0917d
@ -78,6 +78,13 @@
|
|||||||
<artifactId>hsqldb</artifactId>
|
<artifactId>hsqldb</artifactId>
|
||||||
<version>${hsqldb.version}</version>
|
<version>${hsqldb.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- ************* START: Dependencies for Unit and Integration Testing ************** -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -6,6 +6,8 @@ import lombok.Data;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -23,7 +25,8 @@ import java.time.format.DateTimeFormatter;
|
|||||||
public class Email implements Serializable {
|
public class Email implements Serializable {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
private String id;
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
private LocalDateTime time;
|
private LocalDateTime time;
|
||||||
private String contents;
|
private String contents;
|
||||||
private String sender;
|
private String sender;
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
package org.owasp.webwolf.mailbox;
|
||||||
|
|
||||||
|
import org.hamcrest.CoreMatchers;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
@DataJpaTest
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
public class MailboxRepositoryTest {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MailboxRepository mailboxRepository;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void emailShouldBeSaved() {
|
||||||
|
Email email = new Email();
|
||||||
|
email.setTime(LocalDateTime.now());
|
||||||
|
email.setTitle("test");
|
||||||
|
email.setSender("test@test.com");
|
||||||
|
email.setContents("test");
|
||||||
|
email.setRecipient("someone@webwolf.org");
|
||||||
|
mailboxRepository.save(email);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void savedEmailShouldBeFoundByReceipient() {
|
||||||
|
Email email = new Email();
|
||||||
|
email.setTime(LocalDateTime.now());
|
||||||
|
email.setTitle("test");
|
||||||
|
email.setSender("test@test.com");
|
||||||
|
email.setContents("test");
|
||||||
|
email.setRecipient("someone@webwolf.org");
|
||||||
|
mailboxRepository.saveAndFlush(email);
|
||||||
|
|
||||||
|
List<Email> emails = mailboxRepository.findByRecipientOrderByTimeDesc("someone@webwolf.org");
|
||||||
|
|
||||||
|
assertThat(emails.size(), CoreMatchers.is(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user