-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
AdrianBalunan
committed
Mar 16, 2026
1 parent
e0db729
commit ccf109b
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
helpmehelpapplication/src/test/java/ntnu/systemutvikling/team6/models/user/MessegeTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package ntnu.systemutvikling.team6.models.user; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.LocalDateTime; | ||
| import java.util.UUID; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.*; | ||
|
|
||
| public class MessegeTest { | ||
| @Test | ||
| void shouldThrowExceptionIfNameIsNullOrEmpty() { | ||
| assertThrows( | ||
| IllegalArgumentException.class, | ||
| () -> new Message(null, "Someone", "Something Somewhere Somehow")); | ||
| assertThrows( | ||
| IllegalArgumentException.class, | ||
| () -> new Message("", "Someone", "Something Somewhere Somehow")); | ||
| } | ||
|
|
||
| @Test | ||
| void shouldThrowExceptionIfFromIsNullOrEmpty() { | ||
| assertThrows( | ||
| IllegalArgumentException.class, | ||
| () -> new Message("Title", null, "Something Somewhere Somehow")); | ||
| assertThrows( | ||
| IllegalArgumentException.class, | ||
| () -> new Message("Title", "", "Something Somewhere Somehow")); | ||
| } | ||
| @Test | ||
| void shouldThrowExceptionIfContentIsNullOrEmpty() { | ||
| assertThrows( | ||
| IllegalArgumentException.class, | ||
| () -> new Message("Title", "Someone", null)); | ||
| assertThrows( | ||
| IllegalArgumentException.class, | ||
| () -> new Message("Title", "Someone", "")); | ||
| } | ||
|
|
||
| @Test | ||
| void GettersWork(){ | ||
| Message newMessage = new Message("Title", "Someone", "Somewhere"); | ||
| assertInstanceOf(UUID.class, newMessage.getId()); | ||
| assertEquals("Title", newMessage.getTitle()); | ||
| assertEquals("Someone", newMessage.getFrom()); | ||
| assertEquals("Somewhere", newMessage.getContent()); | ||
| assertEquals(LocalDate.now(), newMessage.getTimeAndDate().toLocalDate()); | ||
| } | ||
| } |