package com.braintree.converters.populators;

import de.hybris.bootstrap.annotations.UnitTest;
import de.hybris.platform.ordermanagementfacades.payment.data.PaymentTransactionEntryData;
import de.hybris.platform.payment.model.PaymentTransactionEntryModel;
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.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

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

    private static final String ERROR_MESSAGE = "errorMessage";
    @Mock
    private PaymentTransactionEntryModel model;

    @InjectMocks
    private BrainTreePaymentTransactionEntryPopulator unit;

    @Test
    public void shouldPopulateErrorMessage() {
        PaymentTransactionEntryData data = new PaymentTransactionEntryData();

        when(model.getErrorMessage()).thenReturn(ERROR_MESSAGE);

        unit.populate(model, data);

        assertEquals(ERROR_MESSAGE, data.getErrorMessage());
    }

    @Test
    public void shouldNotPopulateErrorMessage() {
        PaymentTransactionEntryData data = null;

        unit.populate(model, data);

        verify(model, never()).getErrorMessage();
    }

}