package com.example;

import org.easymock.EasyMockExtension;
import org.easymock.Mock;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import static org.easymock.EasyMock.*;
import static org.junit.jupiter.api.Assertions.assertEquals;

@ExtendWith(EasyMockExtension.class)
public class ShipServiceTest {

    ShipService shipService;

    @Mock
    ShipTracker shipTrackerMock;

    @BeforeEach
    public void setUp() {
        shipService = new ShipService(this.shipTrackerMock);
    }

    @Test
    public void testGetShipWithCurrentPosition() {

        //given
        String shipName = "Titanic";
        expect(shipTrackerMock.getPositionForShipName(shipName))
                .andReturn(new Position());
        replay(shipTrackerMock);

        //when
        Ship titanic = this.shipService.getShipWithCurrentPosition(shipName);

        //then
        assertEquals(shipName, titanic.getName());

        verify(shipTrackerMock);
    }

}
