package com.braintree.strategy.impl;

import de.hybris.bootstrap.annotations.UnitTest;
import de.hybris.platform.core.model.order.AbstractOrderEntryModel;
import de.hybris.platform.ordersplitting.model.ConsignmentModel;
import de.hybris.platform.storelocator.model.PointOfServiceModel;
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.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

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

    @InjectMocks
    private BrainTreeSplitByPoS unit;

    @Mock
    private AbstractOrderEntryModel orderEntry;
    @Mock
    private PointOfServiceModel pointOfServiceModel;
    @Mock
    private ConsignmentModel consignmentModel;

    @Test
    public void shouldGetGroupingObject() {
        //given
        when(orderEntry.getDeliveryPointOfService()).thenReturn(pointOfServiceModel);

        //when
        Object result = unit.getGroupingObject(orderEntry);

        //then
        assertEquals(pointOfServiceModel, result);
    }

    @Test
    public void shouldExecuteAfterSplitting() {
        //when
        unit.afterSplitting(pointOfServiceModel, consignmentModel);

        //then
        verify(consignmentModel).setDeliveryPointOfService(pointOfServiceModel);
    }

}
