package com.braintree.commands.impl;

import de.hybris.bootstrap.annotations.UnitTest;
import de.hybris.platform.payment.dto.TransactionStatusDetails;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.runners.MockitoJUnitRunner;
import org.junit.Test;

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

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

    private static final String REASON_CODE_100 = "100";
    private static final String REASON_CODE_101 = "101";
    private static final String REASON_CODE_999 = "999";

    @InjectMocks
    private DefaultBraintreeCodeTranslator codeTranslator;


    @Test
    public void shouldTestTranslateReasonCodeWhenSuccessful() {
        TransactionStatusDetails result = codeTranslator.translateReasonCode(REASON_CODE_100);

        assertEquals(TransactionStatusDetails.SUCCESFULL, result);
    }

    @Test
    public void shouldTestTranslateReasonCodeWhenInvalidRequest() {
        TransactionStatusDetails result = codeTranslator.translateReasonCode(REASON_CODE_101);

        assertEquals(TransactionStatusDetails.INVALID_REQUEST, result);
    }

    @Test
    public void shouldTestTranslateReasonCodeWhenUnknownCode() {
        TransactionStatusDetails result = codeTranslator.translateReasonCode(REASON_CODE_999);

        assertEquals(TransactionStatusDetails.UNKNOWN_CODE, result);
    }

    @Test
    public void shouldTestTranslateReasonCodeWhenCodeNull() {
        TransactionStatusDetails result = codeTranslator.translateReasonCode(null);

        assertNull(result);
    }
}
