This repository has been archived on 2021-12-05. You can view files and clone it, but cannot push or open issues or pull requests.
envoy/common/src/test/java/envoy/data/UserTest.java

36 lines
1.0 KiB
Java

package envoy.data;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.util.Set;
import org.junit.jupiter.api.Test;
import envoy.data.User.UserStatus;
import envoy.util.SerializationUtils;
/**
* Project: <strong>envoy-common</strong><br>
* File: <strong>UserTest.java</strong><br>
* Created: <strong>31 Mar 2020</strong><br>
*
* @author Leon Hofmeister
* @since Envoy Common v0.1-beta
*/
public class UserTest {
@Test
public void test() throws IOException, ClassNotFoundException {
User user2 = new User(2, "kai");
User user3 = new User(3, "ai");
User user4 = new User(4, "ki", Set.of(user2, user3));
User user5 = new User(5, "ka", Set.of(user2, user3, user4));
User user =
new User(1, "maxi", UserStatus.AWAY, Set.of(user2, user3, user4, user5));
var serializedUser = SerializationUtils.writeToByteArray(user);
var deserializedUser = SerializationUtils.read(serializedUser, User.class);
assertEquals(user.getContacts(), deserializedUser.getContacts());
}
}