mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-10-06 11:37:46 +02:00
Add some more tests for WrappedGameProfile
This commit is contained in:
parent
39998eedf8
commit
c368251954
@ -604,7 +604,6 @@ public class FuzzyReflection {
|
|||||||
// Prevent duplicate fields
|
// Prevent duplicate fields
|
||||||
|
|
||||||
// @SafeVarargs
|
// @SafeVarargs
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private static <T> Set<T> setUnion(T[]... array) {
|
private static <T> Set<T> setUnion(T[]... array) {
|
||||||
Set<T> result = new LinkedHashSet<T>();
|
Set<T> result = new LinkedHashSet<T>();
|
||||||
|
|
||||||
|
@ -67,7 +67,6 @@ public class Util {
|
|||||||
* @return The list
|
* @return The list
|
||||||
*/
|
*/
|
||||||
// @SafeVarargs
|
// @SafeVarargs
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static <E> List<E> asList(E... elements) {
|
public static <E> List<E> asList(E... elements) {
|
||||||
List<E> list = new ArrayList<E>(elements.length);
|
List<E> list = new ArrayList<E>(elements.length);
|
||||||
for (E element : elements) {
|
for (E element : elements) {
|
||||||
|
@ -250,6 +250,7 @@ public class WrappedGameProfile extends AbstractWrapper {
|
|||||||
*
|
*
|
||||||
* @return Property map.
|
* @return Property map.
|
||||||
*/
|
*/
|
||||||
|
// In the protocol hack and 1.8 it is a ForwardingMultimap
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public Multimap<String, WrappedSignedProperty> getProperties() {
|
public Multimap<String, WrappedSignedProperty> getProperties() {
|
||||||
Multimap<String, WrappedSignedProperty> result = propertyMap;
|
Multimap<String, WrappedSignedProperty> result = propertyMap;
|
||||||
|
@ -450,7 +450,6 @@ public class NbtFactory {
|
|||||||
* @return The new filled NBT list.
|
* @return The new filled NBT list.
|
||||||
*/
|
*/
|
||||||
// @SafeVarargs
|
// @SafeVarargs
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static <T> NbtList<T> ofList(String name, T... elements) {
|
public static <T> NbtList<T> ofList(String name, T... elements) {
|
||||||
return WrappedList.fromArray(name, elements);
|
return WrappedList.fromArray(name, elements);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,10 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import com.comphenix.protocol.BukkitInitialization;
|
import com.comphenix.protocol.BukkitInitialization;
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import com.mojang.authlib.properties.Property;
|
||||||
|
import com.mojang.authlib.properties.PropertyMap;
|
||||||
|
|
||||||
public class WrappedGameProfileTest {
|
public class WrappedGameProfileTest {
|
||||||
|
|
||||||
@ -16,9 +20,18 @@ public class WrappedGameProfileTest {
|
|||||||
public static void initializeBukkit() {
|
public static void initializeBukkit() {
|
||||||
BukkitInitialization.initializePackage();
|
BukkitInitialization.initializePackage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Test
|
@Test
|
||||||
|
public void testWrapper() {
|
||||||
|
GameProfile profile = new GameProfile(UUID.nameUUIDFromBytes("ProtocolLib".getBytes(Charsets.UTF_8)), "ProtocolLib");
|
||||||
|
WrappedGameProfile wrapper = WrappedGameProfile.fromHandle(profile);
|
||||||
|
|
||||||
|
assertEquals(profile.getId(), wrapper.getUUID());
|
||||||
|
assertEquals(profile.getName(), wrapper.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public void testSkinUpdate() {
|
public void testSkinUpdate() {
|
||||||
final UUID uuid = UUID.nameUUIDFromBytes("123".getBytes(Charsets.UTF_8));
|
final UUID uuid = UUID.nameUUIDFromBytes("123".getBytes(Charsets.UTF_8));
|
||||||
|
|
||||||
@ -31,4 +44,41 @@ public class WrappedGameProfileTest {
|
|||||||
public void testNullFailure() {
|
public void testNullFailure() {
|
||||||
new WrappedGameProfile((String)null, null);
|
new WrappedGameProfile((String)null, null);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
|
public void testGetProperties() {
|
||||||
|
GameProfile profile = new GameProfile(UUID.nameUUIDFromBytes("ProtocolLib".getBytes(Charsets.UTF_8)), "ProtocolLib");
|
||||||
|
|
||||||
|
String name = "test";
|
||||||
|
String value = "test";
|
||||||
|
String signature = null;
|
||||||
|
|
||||||
|
profile.getProperties().put(name, new Property(name, value, signature));
|
||||||
|
|
||||||
|
WrappedGameProfile wrapper = WrappedGameProfile.fromHandle(profile);
|
||||||
|
Multimap<String, WrappedSignedProperty> properties = wrapper.getProperties();
|
||||||
|
WrappedSignedProperty property = properties.get(name).iterator().next();
|
||||||
|
|
||||||
|
assertEquals(property.getName(), name);
|
||||||
|
assertEquals(property.getValue(), value);
|
||||||
|
assertEquals(property.getSignature(), signature);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddProperties() {
|
||||||
|
String name = "test";
|
||||||
|
String value = "test";
|
||||||
|
String signature = null;
|
||||||
|
|
||||||
|
WrappedGameProfile wrapper = new WrappedGameProfile(UUID.nameUUIDFromBytes("ProtocolLib".getBytes(Charsets.UTF_8)), "ProtocolLib");
|
||||||
|
wrapper.getProperties().put(name, new WrappedSignedProperty(name, value, signature));
|
||||||
|
|
||||||
|
GameProfile profile = (GameProfile) wrapper.getHandle();
|
||||||
|
PropertyMap properties = profile.getProperties();
|
||||||
|
Property property = properties.get(name).iterator().next();
|
||||||
|
|
||||||
|
assertEquals(property.getName(), name);
|
||||||
|
assertEquals(property.getValue(), value);
|
||||||
|
assertEquals(property.getSignature(), signature);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user