Skip to content

Commit

Permalink
Feat: Message Class test
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianBalunan committed Mar 16, 2026
1 parent e0db729 commit ccf109b
Showing 1 changed file with 50 additions and 0 deletions.
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());
}
}

0 comments on commit ccf109b

Please sign in to comment.