This repository has been archived by the owner on May 13, 2020. It is now read-only.
generated from cryptic-game/microservice-java-template
-
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
1 parent
e7bc787
commit 67b9254
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/test/java/net/cryptic_game/microservice/chat/channel/ChannelTests.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,56 @@ | ||
package net.cryptic_game.microservice.chat.channel; | ||
|
||
import net.cryptic_game.microservice.wrapper.User; | ||
import org.junit.Test; | ||
|
||
import java.util.Date; | ||
import java.util.UUID; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class ChannelTests { | ||
|
||
@Test | ||
public void testGetUuid() { | ||
final Channel channel = new Channel("test"); | ||
assertNotNull(channel.getUuid()); | ||
} | ||
|
||
@Test | ||
public void testGetName() { | ||
final Channel channel = new Channel("test"); | ||
assertEquals("test", channel.getName()); | ||
} | ||
|
||
@Test | ||
public void testSetName() { | ||
final Channel channel = new Channel("test"); | ||
channel.setName("test123"); | ||
|
||
assertEquals("test123", channel.getName()); | ||
} | ||
|
||
@Test | ||
public void testAddUser() { | ||
final Channel channel = new Channel("test"); | ||
final User testUser = new User(UUID.randomUUID(), "test", "test@test.test", new Date(), new Date()); | ||
channel.addUser(testUser); | ||
|
||
assertTrue(channel.getUsers().contains(testUser)); | ||
} | ||
|
||
@Test | ||
public void testRemoveUser() { | ||
final Channel channel = new Channel("test"); | ||
final User testUser = new User(UUID.randomUUID(), "test", "test@test.test", new Date(), new Date()); | ||
channel.addUser(testUser); | ||
|
||
if (!channel.getUsers().contains(testUser)) { | ||
fail(); | ||
} | ||
|
||
channel.removeUser(testUser); | ||
|
||
assertFalse(channel.getUsers().contains(testUser)); | ||
} | ||
} |