/* * 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 . */ 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; } } }