class Chatroom extends AbstractActor {

    public List<Messages.PostToChatroom> joinChatroom(Messages.JoinChatroom msg) {
        joinedUsers.add(msg.userRef);
        return chatHistory;
    }

}

class ChatroomTest extends AbstractActor {

    static ActorSystem system;

    @Test
    public void testShouldAddUserToJoinedUsersWhenJoiningUnitTest() {

        Props props = Props.create(Chatroom.class);
        TestActorRef<Chatroom> ref = TestActorRef.create(system, props);
        Chatroom chatroom = ref.underlyingActor();

        UserRef userRef = new UserRef(system.deadLetters(), "user");
        Messages.JoinChatroom request = new Messages.JoinChatroom(userRef);
        chatroom.joinChatroom(request);

        assertEquals(chatroom.joinedUsers.get(0), userRef);
    }

}