SteamWar/SpigotCore
Archiviert
13
0
Dieses Repository wurde am 2024-08-05 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
SpigotCore/SpigotCore_Main/testsrc/de/steamwar/command/SimpleCommandTest.java
yoyosource c0d3edd4b0
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Improve CommandFramework Exception readability
2022-01-03 00:42:00 +01:00

62 Zeilen
2.1 KiB
Java

/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.command;
import de.steamwar.TestCommandSender;
import org.junit.Before;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
public class SimpleCommandTest {
private SimpleCommand simpleCommand;
@Before
public void setUp() throws Exception {
simpleCommand = new SimpleCommand();
}
@Test
public void testCommandParsing() {
try {
simpleCommand.execute(new TestCommandSender(), "", new String[]{});
} catch (CommandFrameworkException commandFrameworkException) {
if (commandFrameworkException.getCause().getCause() instanceof ExecutionIdentifier) {
ExecutionIdentifier executionIdentifier = (ExecutionIdentifier) commandFrameworkException.getCause().getCause();
assertThat(executionIdentifier.getMessage(), is("Simple execute without any parameters"));
return;
}
}
assert false;
}
@Test
public void testUnknownCommandParsing() {
try {
simpleCommand.execute(new TestCommandSender(), "", new String[]{"unknown"});
} catch (SecurityException securityException) {
securityException.printStackTrace();
assert false;
}
}
}