package com.braintree.customersupportbackoffice.services.impl;

import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.junit.Assert.assertEquals;

import com.braintree.command.request.BrainTreeCustomerRequest;
import com.braintree.command.result.BrainTreeFindCustomersResult;
import com.braintree.method.BrainTreePaymentService;
import de.hybris.bootstrap.annotations.UnitTest;
import de.hybris.platform.payment.AdapterException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

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

    @Mock
    private BrainTreePaymentService brainTreePaymentService;
    @Mock
    private BrainTreeCustomerRequest request;
    @Mock
    private BrainTreeFindCustomersResult expected;
    @InjectMocks
    private BraintreeCustomerSearchServiceImpl customerSearchService;

    @Test
    public void shouldFindCustomers() throws AdapterException {
        when(brainTreePaymentService.findCustomers(request)).thenReturn(expected);
        BrainTreeFindCustomersResult result = customerSearchService.findCustomers(request);
        verify(brainTreePaymentService).findCustomers(request);
        assertEquals(expected, result);
    }
}
