package com.braintree.converters.populators.configuration;

import com.braintree.hybris.data.BraintreeApplePayConfigurationData;
import de.hybris.bootstrap.annotations.UnitTest;
import de.hybris.platform.core.model.BraintreeApplePayConfigurationModel;
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.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;

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

    @Mock
    private BraintreeApplePayConfigurationModel model;

    @InjectMocks
    private BraintreeApplePayConfigurationPopulator unit;

    @Test
    public void shouldPopulateApplePayConfiguration() {
        BraintreeApplePayConfigurationData data = new BraintreeApplePayConfigurationData();
        when(model.isEnabled()).thenReturn(true);
        when(model.isExpressCheckout()).thenReturn(true);

        unit.populate(model, data);

        assertTrue(data.isEnabled());
        assertTrue(data.isExpressCheckout());
    }

    @Test
    public void shouldPopulateExpressCheckoutFalseIfEnableFalse() {
        BraintreeApplePayConfigurationData data = new BraintreeApplePayConfigurationData();
        when(model.isEnabled()).thenReturn(false);

        unit.populate(model, data);

        assertFalse(data.isEnabled());
        assertFalse(data.isExpressCheckout());
    }

}