package com.braintree.converters.populators.configuration;

import com.braintree.enums.BraintreePaymentMethodLimit;
import com.braintree.enums.BraintreePaymentMethodLimitData;
import com.braintree.hybris.data.BraintreeVenmoConfigurationData;
import de.hybris.bootstrap.annotations.UnitTest;
import de.hybris.platform.core.model.BraintreeVenmoConfigurationModel;
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 BraintreeVenmoConfigurationPopulatorTest {

    private static final String PROFILE_ID = "profileId";

    @Mock
    private BraintreeVenmoConfigurationModel model;
    @InjectMocks
    private BraintreeVenmoConfigurationPopulator unit;

    @Test
    public void shouldPopulateVenmoConfiguration() {
        BraintreeVenmoConfigurationData data = new BraintreeVenmoConfigurationData();

        when(model.isEnabled()).thenReturn(true);
        when(model.getProfileId()).thenReturn(PROFILE_ID);
        when(model.getSavedVenmoAccountLimit()).thenReturn(BraintreePaymentMethodLimit.ONE);

        unit.populate(model, data);

        assertTrue(data.isEnabled());
        assertEquals(PROFILE_ID, data.getProfileId());
        assertEquals(BraintreePaymentMethodLimitData.ONE, data.getSavedVenmoAccountLimit());
    }

}