/*
 * Copyright 2019 MovingBlocks
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.destinationsol.game.console.commands;

import org.destinationsol.game.Console;
import org.destinationsol.game.Hero;
import org.destinationsol.game.SolGame;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;

public class DieCommandHandlerTest {

    private DieCommandHandler commandHandler;
    private Hero hero;
    private Console console;

    @Before
    public void init() {
        SolGame game = Mockito.mock(SolGame.class);
        hero = Mockito.mock(Hero.class, Mockito.RETURNS_DEEP_STUBS);
        commandHandler = new DieCommandHandler(hero, game);
        console = Mockito.mock(Console.class);
    }

    @Test
    public void shouldKillWhenAliveAndNotTranscendent() {
        Mockito.when(hero.isTranscendent()).thenReturn(false);
        Mockito.when(hero.isAlive()).thenReturn(true);
        Mockito.verify(hero, Mockito.never()).getShip();
    }

    @Test
    public void shouldNotKillWhenTranscendent() {
        Mockito.when(hero.isTranscendent()).thenReturn(true);
        commandHandler.handle("respawn", console);
        Mockito.verify(hero, Mockito.never()).getShip();
    }

    @Test
    public void shouldNotKillWhenAlreadyDead() {
        Mockito.when(hero.isAlive()).thenReturn(false);
        commandHandler.handle("respawn", console);
        Mockito.verify(hero, Mockito.never()).getShip();
    }

}

@@ -821,109 +821,398 @@
 org.
-mockito.Mockito;%0A%0Apublic class DieCommandHandlerTest %7B%0A%0A    private DieCommandHandler commandHandler;
+junit.runner.RunWith;%0Aimport org.mockito.Answers;%0Aimport org.mockito.Mock;%0Aimport org.mockito.Mockito;%0Aimport org.mockito.junit.MockitoJUnitRunner;%0A%0Aimport static org.mockito.Mockito.*;%0A%0A@RunWith(MockitoJUnitRunner.class)%0Apublic class DieCommandHandlerTest %7B%0A%0A    private DieCommandHandler commandHandler;%0A%0A    @Mock%0A    private SolGame game;%0A%0A    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
 %0A   
@@ -1230,16 +1230,27 @@
 ro hero;
+%0A%0A    @Mock
 %0A    pri
@@ -1313,129 +1313,8 @@
 ) %7B%0A
-        SolGame game = Mockito.mock(SolGame.class);%0A        hero = Mockito.mock(Hero.class, Mockito.RETURNS_DEEP_STUBS);%0A
     
@@ -1373,55 +1373,8 @@
 e);%0A
-        console = Mockito.mock(Console.class);%0A
     
@@ -1448,32 +1448,24 @@
 ) %7B%0A        
-Mockito.
 when(hero.is
@@ -1503,32 +1503,24 @@
 e);%0A        
-Mockito.
 when(hero.is
@@ -1550,32 +1550,71 @@
 e);%0A        
-Mockito.
+commandHandler.handle(%22die%22, console);%0A        
 verify(hero,
@@ -1614,38 +1614,39 @@
 y(hero, Mockito.
-never(
+times(1
 )).getShip();%0A  
@@ -1714,32 +1714,24 @@
 ) %7B%0A        
-Mockito.
 when(hero.is
@@ -1787,39 +1787,35 @@
 Handler.handle(%22
-respawn
+die
 %22, console);%0A   
@@ -1815,32 +1815,77 @@
 e);%0A        
-Mockito.
+verify(console, times(1)).warn(anyString());%0A        
 verify(hero,
@@ -1881,32 +1881,24 @@
 erify(hero, 
-Mockito.
 never()).get
@@ -1979,24 +1979,16 @@
         
-Mockito.
 when(her
@@ -2054,15 +2054,11 @@
 le(%22
-respawn
+die
 %22, c
@@ -2074,24 +2074,69 @@
         
-Mockito.
+verify(console, times(1)).warn(anyString());%0A        
 verify(h
@@ -2140,24 +2140,16 @@
 y(hero, 
-Mockito.
 never())

Fix 'die' command tests