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
|
// when / then
|
||||||
for (MessageKey messageKey : messageKeys) {
|
for (MessageKey messageKey : messageKeys) {
|
||||||
String key = messageKey.getKey();
|
String key = messageKey.getKey();
|
||||||
if (keys.contains(key)) {
|
if (!keys.add(key)) {
|
||||||
fail("Found key '" + messageKey.getKey() + "' twice!");
|
fail("Found key '" + messageKey.getKey() + "' twice!");
|
||||||
} else if (StringUtils.isEmpty(key)) {
|
} else if (StringUtils.isEmpty(key)) {
|
||||||
fail("Key for message key '" + messageKey + "' is empty");
|
fail("Key for message key '" + messageKey + "' is empty");
|
||||||
}
|
}
|
||||||
keys.add(key);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,10 +33,9 @@ public class AdminPermissionTest {
|
|||||||
|
|
||||||
// when/then
|
// when/then
|
||||||
for (AdminPermission permission : AdminPermission.values()) {
|
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() + "'");
|
fail("More than one enum value defines the node '" + permission.getNode() + "'");
|
||||||
}
|
}
|
||||||
nodes.add(permission.getNode());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,10 +33,9 @@ public class PlayerPermissionTest {
|
|||||||
|
|
||||||
// when/then
|
// when/then
|
||||||
for (PlayerPermission permission : PlayerPermission.values()) {
|
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() + "'");
|
fail("More than one enum value defines the node '" + permission.getNode() + "'");
|
||||||
}
|
}
|
||||||
nodes.add(permission.getNode());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,10 +37,9 @@ public class PlayerStatePermissionTest {
|
|||||||
|
|
||||||
// when/then
|
// when/then
|
||||||
for (PlayerStatePermission permission : PlayerStatePermission.values()) {
|
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() + "'");
|
fail("More than one enum value defines the node '" + permission.getNode() + "'");
|
||||||
}
|
}
|
||||||
nodes.add(permission.getNode());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -43,10 +43,9 @@ public class HashAlgorithmIntegrationTest {
|
|||||||
// when / then
|
// when / then
|
||||||
for (HashAlgorithm algorithm : HashAlgorithm.values()) {
|
for (HashAlgorithm algorithm : HashAlgorithm.values()) {
|
||||||
if (!HashAlgorithm.CUSTOM.equals(algorithm)) {
|
if (!HashAlgorithm.CUSTOM.equals(algorithm)) {
|
||||||
if (classes.contains(algorithm.getClazz())) {
|
if (!classes.add(algorithm.getClazz())) {
|
||||||
fail("Found class '" + algorithm.getClazz() + "' twice!");
|
fail("Found class '" + algorithm.getClazz() + "' twice!");
|
||||||
}
|
}
|
||||||
classes.add(algorithm.getClazz());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,10 +74,9 @@ public class SettingsClassConsistencyTest {
|
|||||||
if (Property.class.isAssignableFrom(field.getType())) {
|
if (Property.class.isAssignableFrom(field.getType())) {
|
||||||
Property<?> property =
|
Property<?> property =
|
||||||
(Property<?>) ReflectionTestUtils.getFieldValue(clazz, null, field.getName());
|
(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");
|
fail("Path '" + property.getPath() + "' should be used by only one constant");
|
||||||
}
|
}
|
||||||
paths.add(property.getPath());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user