package com.braintree.converters.populators;

import com.braintree.hybris.data.BraintreeLocalPaymentMethodData;
import com.braintree.model.BraintreeLocalPaymentMethodsModel;
import de.hybris.bootstrap.annotations.UnitTest;
import de.hybris.platform.core.model.media.MediaModel;
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.when;

@UnitTest
@RunWith(MockitoJUnitRunner.class)
public class BrainTreeLocalPaymentsPopulatorTest {
    private static final String CODE = "code";
    private static final String NAME = "name";
    private static final String URL = "url";
    private static final String ALT_TEXT = "altText";
    private static final boolean IS_ENABLED = true;

    @Mock
    private BraintreeLocalPaymentMethodsModel model;
    @Mock
    private MediaModel mediaModel;

    @InjectMocks
    private BrainTreeLocalPaymentsPopulator unit;

    @Test
    public void shouldPopulateLocalPaymentsData() {
        final BraintreeLocalPaymentMethodData data = new BraintreeLocalPaymentMethodData();

        when(mediaModel.getURL()).thenReturn(URL);
        when(mediaModel.getAltText()).thenReturn(ALT_TEXT);
        when(model.getCode()).thenReturn(CODE);
        when(model.getName()).thenReturn(NAME);
        when(model.getImage()).thenReturn(mediaModel);
        when(model.isIsEnabled()).thenReturn(IS_ENABLED);

        unit.populate(model, data);

        assertEquals(CODE, data.getCode());
        assertEquals(NAME, data.getName());
        assertEquals(IS_ENABLED, data.getIsEnabled());
        assertEquals(URL, data.getPathToImage());
        assertEquals(ALT_TEXT, data.getAltText());
    }
}
