package com.braintree.converters.populators.configuration;

import com.braintree.enums.BraintreePaymentMethodLimit;
import com.braintree.enums.BraintreePaymentMethodLimitData;
import com.braintree.hybris.data.BraintreeSRCConfigurationData;
import de.hybris.bootstrap.annotations.UnitTest;
import de.hybris.platform.core.model.BraintreeSRCConfigurationModel;
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.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;

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

    @Mock
    private BraintreeSRCConfigurationModel model;
    @InjectMocks
    private BraintreeSRCConfigurationPopulator unit;

    @Test
    public void shouldPopulateSRCConfiguration() {
        BraintreeSRCConfigurationData data = new BraintreeSRCConfigurationData();
        when(model.isEnabled()).thenReturn(true);
        when(model.getSavedSRCAccountLimit()).thenReturn(BraintreePaymentMethodLimit.ONE);

        unit.populate(model, data);

        assertTrue(data.isEnabled());
        assertEquals(BraintreePaymentMethodLimitData.ONE, data.getSavedSRCAccountLimit());
    }

}