package com.braintree.populators;

import com.braintree.command.result.BrainTreeRefundTransactionResult;
import com.braintreegateway.Transaction;
import de.hybris.bootstrap.annotations.UnitTest;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;

import java.math.BigDecimal;

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

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

    private static final String TRANSACTION_ID = "transactionId";
    private static final String GRAPHQL_ID = "GraphQLId";
    private static final BigDecimal AMOUNT = new BigDecimal(100);

    @InjectMocks
    private TransactionToBrainTreeRefundTransactionResultPopulator unit;

    @Mock
    private Transaction transaction;

    @Before
    public void setUp() {
        when(transaction.getAmount()).thenReturn(AMOUNT);
        when(transaction.getId()).thenReturn(TRANSACTION_ID);
        when(transaction.getGraphQLId()).thenReturn(GRAPHQL_ID);
    }

    @Test
    public void shouldPopulateTransactionToBraintreeRefundTransactionResult() {
        BrainTreeRefundTransactionResult brainTreeRefundTransactionResult = new BrainTreeRefundTransactionResult();

        unit.populate(transaction, brainTreeRefundTransactionResult);

        assertEquals(AMOUNT, brainTreeRefundTransactionResult.getAmount());
        assertEquals(TRANSACTION_ID, brainTreeRefundTransactionResult.getTransactionId());
        assertEquals(GRAPHQL_ID, brainTreeRefundTransactionResult.getTransactionGraphQLId());
    }
}
