Skip to content

Commit c368251

Browse files
committed
Add some more tests for WrappedGameProfile
1 parent 39998ee commit c368251

File tree

5 files changed

+54
-6
lines changed

5 files changed

+54
-6
lines changed

ProtocolLib/src/main/java/com/comphenix/protocol/reflect/FuzzyReflection.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,6 @@ public Set<Constructor<?>> getConstructors() {
604604
// Prevent duplicate fields
605605

606606
// @SafeVarargs
607-
@SuppressWarnings("unchecked")
608607
private static <T> Set<T> setUnion(T[]... array) {
609608
Set<T> result = new LinkedHashSet<T>();
610609

ProtocolLib/src/main/java/com/comphenix/protocol/utility/Util.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public static List<Player> getOnlinePlayers() {
6767
* @return The list
6868
*/
6969
// @SafeVarargs
70-
@SuppressWarnings("unchecked")
7170
public static <E> List<E> asList(E... elements) {
7271
List<E> list = new ArrayList<E>(elements.length);
7372
for (E element : elements) {

ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedGameProfile.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ public String getName() {
250250
*
251251
* @return Property map.
252252
*/
253+
// In the protocol hack and 1.8 it is a ForwardingMultimap
253254
@SuppressWarnings({ "unchecked", "rawtypes" })
254255
public Multimap<String, WrappedSignedProperty> getProperties() {
255256
Multimap<String, WrappedSignedProperty> result = propertyMap;

ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtFactory.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,6 @@ public static NbtCompound ofCompound(String name) {
450450
* @return The new filled NBT list.
451451
*/
452452
// @SafeVarargs
453-
@SuppressWarnings("unchecked")
454453
public static <T> NbtList<T> ofList(String name, T... elements) {
455454
return WrappedList.fromArray(name, elements);
456455
}

ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedGameProfileTest.java

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,29 @@
99

1010
import com.comphenix.protocol.BukkitInitialization;
1111
import com.google.common.base.Charsets;
12+
import com.google.common.collect.Multimap;
13+
import com.mojang.authlib.GameProfile;
14+
import com.mojang.authlib.properties.Property;
15+
import com.mojang.authlib.properties.PropertyMap;
1216

1317
public class WrappedGameProfileTest {
1418

1519
@BeforeClass
1620
public static void initializeBukkit() {
1721
BukkitInitialization.initializePackage();
1822
}
19-
20-
@SuppressWarnings("deprecation")
23+
2124
@Test
25+
public void testWrapper() {
26+
GameProfile profile = new GameProfile(UUID.nameUUIDFromBytes("ProtocolLib".getBytes(Charsets.UTF_8)), "ProtocolLib");
27+
WrappedGameProfile wrapper = WrappedGameProfile.fromHandle(profile);
28+
29+
assertEquals(profile.getId(), wrapper.getUUID());
30+
assertEquals(profile.getName(), wrapper.getName());
31+
}
32+
33+
@Test
34+
@SuppressWarnings("deprecation")
2235
public void testSkinUpdate() {
2336
final UUID uuid = UUID.nameUUIDFromBytes("123".getBytes(Charsets.UTF_8));
2437

@@ -31,4 +44,41 @@ public void testSkinUpdate() {
3144
public void testNullFailure() {
3245
new WrappedGameProfile((String)null, null);
3346
}
34-
}
47+
48+
@Test
49+
public void testGetProperties() {
50+
GameProfile profile = new GameProfile(UUID.nameUUIDFromBytes("ProtocolLib".getBytes(Charsets.UTF_8)), "ProtocolLib");
51+
52+
String name = "test";
53+
String value = "test";
54+
String signature = null;
55+
56+
profile.getProperties().put(name, new Property(name, value, signature));
57+
58+
WrappedGameProfile wrapper = WrappedGameProfile.fromHandle(profile);
59+
Multimap<String, WrappedSignedProperty> properties = wrapper.getProperties();
60+
WrappedSignedProperty property = properties.get(name).iterator().next();
61+
62+
assertEquals(property.getName(), name);
63+
assertEquals(property.getValue(), value);
64+
assertEquals(property.getSignature(), signature);
65+
}
66+
67+
@Test
68+
public void testAddProperties() {
69+
String name = "test";
70+
String value = "test";
71+
String signature = null;
72+
73+
WrappedGameProfile wrapper = new WrappedGameProfile(UUID.nameUUIDFromBytes("ProtocolLib".getBytes(Charsets.UTF_8)), "ProtocolLib");
74+
wrapper.getProperties().put(name, new WrappedSignedProperty(name, value, signature));
75+
76+
GameProfile profile = (GameProfile) wrapper.getHandle();
77+
PropertyMap properties = profile.getProperties();
78+
Property property = properties.get(name).iterator().next();
79+
80+
assertEquals(property.getName(), name);
81+
assertEquals(property.getValue(), value);
82+
assertEquals(property.getSignature(), signature);
83+
}
84+
}

0 commit comments

Comments
 (0)