mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-07 11:10:14 +01:00
Testing - check return value of Set#add instead of separately checking Set#contains
This commit is contained in:
parent
2420a83ec3
commit
8f5817883e
@ -22,12 +22,11 @@ public class MessageKeyTest {
|
||||
// when / then
|
||||
for (MessageKey messageKey : messageKeys) {
|
||||
String key = messageKey.getKey();
|
||||
if (keys.contains(key)) {
|
||||
if (!keys.add(key)) {
|
||||
fail("Found key '" + messageKey.getKey() + "' twice!");
|
||||
} else if (StringUtils.isEmpty(key)) {
|
||||
fail("Key for message key '" + messageKey + "' is empty");
|
||||
}
|
||||
keys.add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,10 +33,9 @@ public class AdminPermissionTest {
|
||||
|
||||
// when/then
|
||||
for (AdminPermission permission : AdminPermission.values()) {
|
||||
if (nodes.contains(permission.getNode())) {
|
||||
if (!nodes.add(permission.getNode())) {
|
||||
fail("More than one enum value defines the node '" + permission.getNode() + "'");
|
||||
}
|
||||
nodes.add(permission.getNode());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,10 +33,9 @@ public class PlayerPermissionTest {
|
||||
|
||||
// when/then
|
||||
for (PlayerPermission permission : PlayerPermission.values()) {
|
||||
if (nodes.contains(permission.getNode())) {
|
||||
if (!nodes.add(permission.getNode())) {
|
||||
fail("More than one enum value defines the node '" + permission.getNode() + "'");
|
||||
}
|
||||
nodes.add(permission.getNode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,10 +37,9 @@ public class PlayerStatePermissionTest {
|
||||
|
||||
// when/then
|
||||
for (PlayerStatePermission permission : PlayerStatePermission.values()) {
|
||||
if (nodes.contains(permission.getNode())) {
|
||||
if (!nodes.add(permission.getNode())) {
|
||||
fail("More than one enum value defines the node '" + permission.getNode() + "'");
|
||||
}
|
||||
nodes.add(permission.getNode());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,10 +43,9 @@ public class HashAlgorithmIntegrationTest {
|
||||
// when / then
|
||||
for (HashAlgorithm algorithm : HashAlgorithm.values()) {
|
||||
if (!HashAlgorithm.CUSTOM.equals(algorithm)) {
|
||||
if (classes.contains(algorithm.getClazz())) {
|
||||
if (!classes.add(algorithm.getClazz())) {
|
||||
fail("Found class '" + algorithm.getClazz() + "' twice!");
|
||||
}
|
||||
classes.add(algorithm.getClazz());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,10 +74,9 @@ public class SettingsClassConsistencyTest {
|
||||
if (Property.class.isAssignableFrom(field.getType())) {
|
||||
Property<?> property =
|
||||
(Property<?>) ReflectionTestUtils.getFieldValue(clazz, null, field.getName());
|
||||
if (paths.contains(property.getPath())) {
|
||||
if (!paths.add(property.getPath())) {
|
||||
fail("Path '" + property.getPath() + "' should be used by only one constant");
|
||||
}
|
||||
paths.add(property.getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user