Add more unit tests

This commit is contained in:
William committed 2023-03-22 00:31:02 +00:00
1 parent 8923b44c92
commit 0d358989dc
8 files changed
+368 -18

No files matched your search

@@ -35,10 +35,12 @@ public class Manager {
// Update caches on all servers
protected void propagateCacheUpdate() {
plugin.getOnlineUsers().stream().findAny().ifPresent(user -> Message.builder()
.type(Message.Type.UPDATE_CACHES)
.scope(Message.Scope.SERVER)
.target(Message.TARGET_ALL)
.build().send(plugin.getMessenger(), user));
if (plugin.getSettings().isCrossServer()) {
plugin.getOnlineUsers().stream().findAny().ifPresent(user -> Message.builder()
.type(Message.Type.UPDATE_CACHES)
.scope(Message.Scope.SERVER)
.target(Message.TARGET_ALL)
.build().send(plugin.getMessenger(), user));
}
}
}
@@ -137,16 +137,16 @@ public class WarpsManager {
this.cacheWarp(warp, true);
}
public void renameWarp(@NotNull String name, @NotNull String newName) throws ValidationException {
public void setWarpName(@NotNull String name, @NotNull String newName) throws ValidationException {
final Optional<Warp> optionalWarp = plugin.getDatabase().getWarp(name);
if (optionalWarp.isEmpty()) {
throw new ValidationException(ValidationException.Type.NOT_FOUND);
}
this.renameWarp(optionalWarp.get(), newName);
this.setWarpName(optionalWarp.get(), newName);
}
public void renameWarp(@NotNull Warp warp, @NotNull String newName) throws ValidationException {
public void setWarpName(@NotNull Warp warp, @NotNull String newName) throws ValidationException {
if (!plugin.getValidator().isValidName(newName)) {
throw new ValidationException(ValidationException.Type.NAME_INVALID);
}