13b6dcd74b
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Add CommandRegistering Add initial implementation for CommandPart
61 Zeilen
2.0 KiB
Java
61 Zeilen
2.0 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 (SecurityException securityException) {
|
|
if (securityException.getCause().getCause() instanceof ExecutionIdentifier) {
|
|
ExecutionIdentifier executionIdentifier = (ExecutionIdentifier) securityException.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) {
|
|
assert false;
|
|
}
|
|
}
|
|
}
|