@@ -0,0 +1,2332 @@
+package org.apollo.game.model.entity.attr;%0A%0Aimport java.nio.charset.StandardCharsets;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport com.google.common.primitives.Longs;%0A%0A/**%0A * Tests for different %7B@link Attribute%7Ds.%0A */%0Apublic final class AttributeTests %7B%0A%0A%09/**%0A%09 * Defines Attributes with their default values before any tests are run.%0A%09 */%0A%09@Before%0A%09public void setup() %7B%0A%09%09AttributeMap.define(%22string_test%22, AttributeDefinition.forString(%22Hello world%22, AttributePersistence.TRANSIENT));%0A%09%09AttributeMap.define(%22boolean_test%22, AttributeDefinition.forBoolean(true, AttributePersistence.TRANSIENT));%0A%09%09AttributeMap.define(%22int_test%22, AttributeDefinition.forInt(Integer.MAX_VALUE, AttributePersistence.TRANSIENT));%0A%09%09AttributeMap.define(%22long_test%22, AttributeDefinition.forLong(Long.MAX_VALUE, AttributePersistence.TRANSIENT));%0A%09%09AttributeMap.define(%22double_test%22, AttributeDefinition.forDouble(Double.MAX_VALUE, AttributePersistence.TRANSIENT));%0A%09%7D%0A%0A%09/**%0A%09 * Tests Attribute %3Ccode%3EString%3C/code%3E encoding.%0A%09 */%0A%09@Test%0A%09public void stringEncode() %7B%0A%09%09AttributeMap map = new AttributeMap();%0A%09%09byte%5B%5D expected = %22Hello world%5C0%22.getBytes(StandardCharsets.UTF_8);%0A%09%09Assert.assertArrayEquals(expected, map.get(%22string_test%22).encode());%0A%09%7D%0A%0A%09/**%0A%09 * Tests Attribute %3Ccode%3Eboolean%3C/code%3E encoding.%0A%09 */%0A%09@Test%0A%09public void booleanEncode() %7B%0A%09%09AttributeMap map = new AttributeMap();%0A%09%09byte%5B%5D expected = %7B 1 %7D;%0A%09%09Assert.assertArrayEquals(expected, map.get(%22boolean_test%22).encode());%0A%09%7D%0A%0A%09/**%0A%09 * Tests Attribute %3Ccode%3Eint%3C/code%3E encoding.%0A%09 */%0A%09@Test%0A%09public void intEncode() %7B%0A%09%09AttributeMap map = new AttributeMap();%0A%09%09byte%5B%5D expected = Longs.toByteArray(Integer.MAX_VALUE);%0A%09%09Assert.assertArrayEquals(expected, map.get(%22int_test%22).encode());%0A%09%7D%0A%0A%09/**%0A%09 * Tests Attribute %3Ccode%3Elong%3C/code%3E encoding.%0A%09 */%0A%09@Test%0A%09public void longEncode() %7B%0A%09%09AttributeMap map = new AttributeMap();%0A%09%09byte%5B%5D expected = Longs.toByteArray(Long.MAX_VALUE);%0A%09%09Assert.assertArrayEquals(expected, map.get(%22long_test%22).encode());%0A%09%7D%0A%0A%09/**%0A%09 * Tests Attribute %3Ccode%3Edouble%3C/code%3E encoding.%0A%09 */%0A%09@Test%0A%09public void doubleEncode() %7B%0A%09%09AttributeMap map = new AttributeMap();%0A%09%09byte%5B%5D expected = Longs.toByteArray(Double.doubleToLongBits(Double.MAX_VALUE));%0A%09%09Assert.assertArrayEquals(expected, map.get(%22double_test%22).encode());%0A%09%7D%0A%0A%7D%0A

Add unit test for Attribute#encode