package com.braintree.customersupportbackoffice.services.impl;

import com.braintree.command.request.BrainTreeFindTransactionRequest;
import com.braintree.command.result.BrainTreeFindTransactionResult;
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;

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

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

    @Mock
    private BrainTreePaymentService brainTreePaymentService;
    @Mock
    private BrainTreeFindTransactionRequest request;
    @Mock
    private BrainTreeFindTransactionResult expected;
    @InjectMocks
    private BraintreeTransactionSearchServiceImpl searchService;

    @Test
    public void shouldFindTransactions() throws AdapterException {
        when(brainTreePaymentService.findTransactions(request)).thenReturn(expected);
        BrainTreeFindTransactionResult result = searchService.findTransactions(request);
        verify(brainTreePaymentService).findTransactions(request);
        assertEquals(expected, result);
    }

}

