/**
 *
 */
package com.braintree.converters.populators;

import de.hybris.bootstrap.annotations.UnitTest;
import de.hybris.platform.commercefacades.user.data.AddressData;
import de.hybris.platform.core.model.user.AddressModel;
import de.hybris.platform.servicelayer.dto.converter.Converter;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;

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

    private static final String BRAINTREE_ADDRESS_ID = "testId";
    private static final String COMA = ", ";

    @Mock
    private AddressModel model;
    @Mock
    private Map<String, Converter<AddressModel, StringBuilder>> addressFormatConverterMap;
    @Mock
    private Converter<AddressModel, StringBuilder> defaultAddressFormatConverter;

    @InjectMocks
    private BrainTreeAddressPopulator unit;

    @Test
    public void shouldPopulateBraintreeAddressId() {
        AddressData data = new AddressData();

        when(model.getBrainTreeAddressId()).thenReturn(BRAINTREE_ADDRESS_ID);
        when(defaultAddressFormatConverter.convert(any())).thenReturn(new StringBuilder());

        unit.populate(model, data);

        assertEquals(BRAINTREE_ADDRESS_ID, data.getBrainTreeAddressId());
    }
}
