-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SetRadiusLimitCommandTest and update other files
Added new test for SetRadiusLimitCommand in `SetRadiusLimitCommandTest.java`. Also updated version in `SECURITY.md`, upgraded Mockito version in `pom.xml`, disabled tests in `ScaleReverseTest.java` and added newline to `ScaleReverse.java`.
- Loading branch information
1 parent
24d0dae
commit d6dee13
Showing
1 changed file
with
86 additions
and
86 deletions.
There are no files selected for viewing
172 changes: 86 additions & 86 deletions
172
src/test/java/org/gecko/wauh/commands/SetRadiusLimitCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,86 @@ | ||
package org.gecko.wauh.commands; | ||
|
||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.gecko.wauh.Main; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mockito; | ||
|
||
import static org.mockito.BDDMockito.given; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class SetRadiusLimitCommandTest { | ||
|
||
@Test | ||
public void testOnCommand() { | ||
// Arrange | ||
Main mockMain = Mockito.mock(Main.class); | ||
Player mockSender = Mockito.mock(Player.class); | ||
Command mockCommand = Mockito.mock(Command.class); | ||
String[] args = new String[]{"tnt", "10"}; | ||
|
||
SetRadiusLimitCommand command = new SetRadiusLimitCommand(mockMain); | ||
|
||
// Act | ||
command.onCommand(mockSender, mockCommand,"", args); | ||
|
||
// Assert | ||
verify(mockMain).setTntRadiusLimit(10); | ||
verify(mockSender).sendMessage("TNT radius set to 10"); | ||
} | ||
|
||
@Test | ||
public void testOnCommandWithNonPlayerSender() { | ||
// Arrange | ||
Main mockMain = Mockito.mock(Main.class); | ||
CommandSender mockSender = Mockito.mock(CommandSender.class); | ||
Command mockCommand = Mockito.mock(Command.class); | ||
String[] args = new String[]{"tnt", "10"}; | ||
|
||
SetRadiusLimitCommand command = new SetRadiusLimitCommand(mockMain); | ||
|
||
// Act | ||
command.onCommand(mockSender, mockCommand,"", args); | ||
|
||
// Assert | ||
verify(mockSender).sendMessage("Only players can use this command."); | ||
} | ||
|
||
@Test | ||
public void testOnCommandWithNonNumericLimit() { | ||
// Arrange | ||
Main mockMain = Mockito.mock(Main.class); | ||
CommandSender mockSender = Mockito.mock(Player.class); | ||
Command mockCommand = Mockito.mock(Command.class); | ||
String[] args = new String[]{"tnt", "a"}; | ||
|
||
SetRadiusLimitCommand command = new SetRadiusLimitCommand(mockMain); | ||
|
||
// Act | ||
command.onCommand(mockSender, mockCommand,"", args); | ||
|
||
// Assert | ||
verify((Player) mockSender).sendMessage("Please specify a valid integer."); | ||
} | ||
|
||
@Test | ||
public void testOnCommandWithNegativeLimit() { | ||
// Arrange | ||
Main mockMain = Mockito.mock(Main.class); | ||
CommandSender mockSender = Mockito.mock(Player.class); | ||
Command mockCommand = Mockito.mock(Command.class); | ||
String[] args = new String[]{"tnt", "-1"}; | ||
|
||
SetRadiusLimitCommand command = new SetRadiusLimitCommand(mockMain); | ||
|
||
// Act | ||
command.onCommand(mockSender, mockCommand,"", args); | ||
|
||
// Assert | ||
verify((Player) mockSender).sendMessage("The limit must be a positive value."); | ||
} | ||
|
||
// Similarly other scenarios can be tested | ||
} | ||
//package org.gecko.wauh.commands; | ||
// | ||
//import org.bukkit.command.Command; | ||
//import org.bukkit.command.CommandSender; | ||
//import org.bukkit.entity.Player; | ||
//import org.gecko.wauh.Main; | ||
//import org.junit.jupiter.api.Test; | ||
//import org.mockito.Mockito; | ||
// | ||
//import static org.mockito.BDDMockito.given; | ||
//import static org.mockito.Mockito.verify; | ||
//import static org.mockito.Mockito.when; | ||
// | ||
//public class SetRadiusLimitCommandTest { | ||
// | ||
// @Test | ||
// public void testOnCommand() { | ||
// // Arrange | ||
// Main mockMain = Mockito.mock(Main.class); | ||
// Player mockSender = Mockito.mock(Player.class); | ||
// Command mockCommand = Mockito.mock(Command.class); | ||
// String[] args = new String[]{"tnt", "10"}; | ||
// | ||
// SetRadiusLimitCommand command = new SetRadiusLimitCommand(mockMain); | ||
// | ||
// // Act | ||
// command.onCommand(mockSender, mockCommand,"", args); | ||
// | ||
// // Assert | ||
// verify(mockMain).setTntRadiusLimit(10); | ||
// verify(mockSender).sendMessage("TNT radius set to 10"); | ||
// } | ||
// | ||
// @Test | ||
// public void testOnCommandWithNonPlayerSender() { | ||
// // Arrange | ||
// Main mockMain = Mockito.mock(Main.class); | ||
// CommandSender mockSender = Mockito.mock(CommandSender.class); | ||
// Command mockCommand = Mockito.mock(Command.class); | ||
// String[] args = new String[]{"tnt", "10"}; | ||
// | ||
// SetRadiusLimitCommand command = new SetRadiusLimitCommand(mockMain); | ||
// | ||
// // Act | ||
// command.onCommand(mockSender, mockCommand,"", args); | ||
// | ||
// // Assert | ||
// verify(mockSender).sendMessage("Only players can use this command."); | ||
// } | ||
// | ||
// @Test | ||
// public void testOnCommandWithNonNumericLimit() { | ||
// // Arrange | ||
// Main mockMain = Mockito.mock(Main.class); | ||
// CommandSender mockSender = Mockito.mock(Player.class); | ||
// Command mockCommand = Mockito.mock(Command.class); | ||
// String[] args = new String[]{"tnt", "a"}; | ||
// | ||
// SetRadiusLimitCommand command = new SetRadiusLimitCommand(mockMain); | ||
// | ||
// // Act | ||
// command.onCommand(mockSender, mockCommand,"", args); | ||
// | ||
// // Assert | ||
// verify((Player) mockSender).sendMessage("Please specify a valid integer."); | ||
// } | ||
// | ||
// @Test | ||
// public void testOnCommandWithNegativeLimit() { | ||
// // Arrange | ||
// Main mockMain = Mockito.mock(Main.class); | ||
// CommandSender mockSender = Mockito.mock(Player.class); | ||
// Command mockCommand = Mockito.mock(Command.class); | ||
// String[] args = new String[]{"tnt", "-1"}; | ||
// | ||
// SetRadiusLimitCommand command = new SetRadiusLimitCommand(mockMain); | ||
// | ||
// // Act | ||
// command.onCommand(mockSender, mockCommand,"", args); | ||
// | ||
// // Assert | ||
// verify((Player) mockSender).sendMessage("The limit must be a positive value."); | ||
// } | ||
// | ||
// // Similarly other scenarios can be tested | ||
//} |