package com.braintree.facade.impl;

import de.hybris.bootstrap.annotations.UnitTest;
import de.hybris.platform.acceleratorservices.urlresolver.SiteBaseUrlResolutionService;
import de.hybris.platform.basecommerce.model.site.BaseSiteModel;
import de.hybris.platform.site.BaseSiteService;
import org.apache.commons.lang.StringUtils;
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 DefaultBraintreeUrlResolutionFacadeTest {

    public static final String TEST_URL = "testUrl";
    public static final String CONNECT = "/connect";

    @Mock
    private SiteBaseUrlResolutionService siteBaseUrlResolutionService;
    @Mock
    private BaseSiteService baseSiteService;
    @Mock
    private BaseSiteModel baseSiteModel;

    @InjectMocks
    DefaultBraintreeUrlResolutionFacade unit;

    @Test
    public void buildReturnUrlTest(){
        when(baseSiteService.getCurrentBaseSite()).thenReturn(baseSiteModel);
        when(siteBaseUrlResolutionService.getWebsiteUrlForSite(baseSiteModel, StringUtils.EMPTY, true, CONNECT)).thenReturn(TEST_URL);

        String actual = unit.buildReturnUrl(CONNECT);

        assertEquals(TEST_URL, actual);

    }
}
