package com.braintree.actions.consignment;

import de.hybris.bootstrap.annotations.UnitTest;
import de.hybris.platform.ordersplitting.model.ConsignmentModel;
import de.hybris.platform.ordersplitting.model.ConsignmentProcessModel;
import de.hybris.platform.servicelayer.model.ModelService;
import de.hybris.platform.warehouse.Process2WarehouseAdapter;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@UnitTest
@RunWith(MockitoJUnitRunner.class)
public class BrainTreeSendConsignmentToWarehouseActionTest {

    @Mock
    private Process2WarehouseAdapter process2WarehouseAdapter;
    @Mock
    private ModelService modelService;

    @InjectMocks
    private BrainTreeSendConsignmentToWarehouseAction unit;

    @Mock
    private ConsignmentProcessModel process;
    @Mock
    private ConsignmentModel consignment;

    @Test
    public void shouldExecuteAction() {
        //given
        when(process.getConsignment()).thenReturn(consignment);

        //when
        unit.executeAction(process);

        //then
        verify(process2WarehouseAdapter).prepareConsignment(consignment);
        verify(process).setWaitingForConsignment(true);
        verify(modelService).save(process);
    }

}
