mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-27 21:26:17 +01: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
|
||||
|
||||
// @SafeVarargs
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> Set<T> setUnion(T[]... array) {
|
||||
Set<T> result = new LinkedHashSet<T>();
|
||||
|
||||
|
@ -67,7 +67,6 @@ public class Util {
|
||||
* @return The list
|
||||
*/
|
||||
// @SafeVarargs
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <E> List<E> asList(E... elements) {
|
||||
List<E> list = new ArrayList<E>(elements.length);
|
||||
for (E element : elements) {
|
||||
|
@ -250,6 +250,7 @@ public class WrappedGameProfile extends AbstractWrapper {
|
||||
*
|
||||
* @return Property map.
|
||||
*/
|
||||
// In the protocol hack and 1.8 it is a ForwardingMultimap
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public Multimap<String, WrappedSignedProperty> getProperties() {
|
||||
Multimap<String, WrappedSignedProperty> result = propertyMap;
|
||||
|
@ -450,7 +450,6 @@ public class NbtFactory {
|
||||
* @return The new filled NBT list.
|
||||
*/
|
||||
// @SafeVarargs
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> NbtList<T> ofList(String name, T... elements) {
|
||||
return WrappedList.fromArray(name, elements);
|
||||
}
|
||||
|
@ -9,6 +9,10 @@ import org.junit.Test;
|
||||
|
||||
import com.comphenix.protocol.BukkitInitialization;
|
||||
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 {
|
||||
|
||||
@ -17,8 +21,17 @@ public class WrappedGameProfileTest {
|
||||
BukkitInitialization.initializePackage();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@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() {
|
||||
final UUID uuid = UUID.nameUUIDFromBytes("123".getBytes(Charsets.UTF_8));
|
||||
|
||||
@ -31,4 +44,41 @@ public class WrappedGameProfileTest {
|
||||
public void testNullFailure() {
|
||||
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