@@ -0,0 +1,3355 @@
+/*%0A * Copyright 2019 MovingBlocks%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.destinationsol.game.console.commands;%0A%0Aimport com.badlogic.gdx.math.Vector2;%0Aimport org.destinationsol.game.Console;%0Aimport org.destinationsol.game.Hero;%0Aimport org.destinationsol.game.SolGame;%0Aimport org.destinationsol.game.ship.SolShip;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.Answers;%0Aimport org.mockito.Mock;%0Aimport org.mockito.junit.MockitoJUnitRunner;%0A%0Aimport static org.mockito.Mockito.*;%0A%0A@RunWith(MockitoJUnitRunner.class)%0Apublic class PositionCommandHandlerTest %7B%0A%0A    private PositionCommandHandler commandHandler;%0A%0A    @Mock(answer = Answers.RETURNS_DEEP_STUBS)%0A    private SolGame game;%0A%0A    @Mock%0A    private SolShip ship;%0A%0A    @Mock%0A    private Console console;%0A%0A    @Before%0A    public void init() %7B%0A        when(ship.getPosition()).thenReturn(new Vector2(1f, 2f));%0A        Hero hero = new Hero(ship, game);%0A        commandHandler = new PositionCommandHandler(hero);%0A    %7D%0A%0A    @Test%0A    public void shouldPrintErrorOnUnknownFormat() %7B%0A        commandHandler.handle(%22position xyz%22, console);%0A        verify(console, never()).info(anyString());%0A        verify(console, times(1)).warn(%22Invalid position format: %5C%22xyz%5C%22!%22);%0A    %7D%0A%0A    @Test%0A    public void shouldPrintAvailableFormatsOnUnknownFormat() %7B%0A        int formatsCount = PositionCommandHandler.PositionFormat.values().length;%0A        int additionalLines = 2; //one for warning about unsupported format, one for list header%0A        int totalLines = formatsCount + additionalLines;%0A        commandHandler.handle(%22position xyz%22, console);%0A        verify(console, times(totalLines)).warn(anyString());%0A    %7D%0A%0A    @Test%0A    public void checkTerseOutput() %7B%0A        commandHandler.handle(%22position terse%22, console);%0A        verify(console, only()).info(%22X: %22 + ship.getPosition().x + %22   Y: %22 + ship.getPosition().y);%0A    %7D%0A%0A    @Test%0A    public void checkVerboseOutput() %7B%0A        commandHandler.handle(%22position verbose%22, console);%0A        verify(console, times(1)).info(%22The hero's X co-ordinate is: %22 + ship.getPosition().x);%0A        verify(console, times(1)).info(%22The hero's Y co-ordinate is: %22 + ship.getPosition().y);%0A    %7D%0A%0A    @Test%0A    public void checkBoldOutput() %7B%0A        commandHandler.handle(%22position bold%22, console);%0A        //Size of wanted message is known for test coordinates as well for the separator%0A        verify(console, times(2)).info(%22************%22);%0A        verify(console, times(1)).info(%22X: %22 + ship.getPosition().x);%0A        verify(console, times(1)).info(%22Y: %22 + ship.getPosition().y);%0A    %7D%0A%0A    @Test%0A    public void checkInternalOutput() %7B%0A        commandHandler.handle(%22position internal%22, console);%0A        verify(console, times(1)).info(ship.getPosition().toString());%0A    %7D%0A%0A%0A%7D%0A

Create test for position command handler