package com.braintree.customersupportbackoffice.populators.transaction;

import com.braintree.command.result.BrainTreeAbstractTransactionResult;
import com.braintree.hybris.data.BrainTreeResponseResultData;
import de.hybris.bootstrap.annotations.UnitTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.runners.MockitoJUnitRunner;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

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

    private static final String ERROR_MSG = "errorMsg";
    private static final String ERROR_CODE = "errorCode";
    private static final String TRANSACTION_ID = "transactionId";
    @InjectMocks
    private BrainTreeTransactionMainPopulator unit;

    @Test
    public void shouldPopulateResponseResultData() {
        BrainTreeResponseResultData target = new BrainTreeResponseResultData();
        BrainTreeAbstractTransactionResult source = new BrainTreeAbstractTransactionResult();
        source.setSuccess(true);
        source.setErrorMessage(ERROR_MSG);
        source.setErrorCode(ERROR_CODE);
        source.setTransactionId(TRANSACTION_ID);

        unit.populate(source, target);

        assertTrue(target.isSuccess());
        assertEquals(ERROR_MSG, target.getErrorMessage());
        assertEquals(ERROR_CODE, target.getErrorCode());
        assertEquals(TRANSACTION_ID, target.getTransactionId());

    }
}