package com.braintree.translator;

import de.hybris.bootstrap.annotations.UnitTest;
import de.hybris.platform.jalo.Item;
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.junit.Assert.assertNotNull;

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

    private static final String PASSWORD = "password";
    private static final String MASKED_PASSWORD = "********";
    private static final String EMPTY_STRING = "";

    @InjectMocks
    private BraintreeSensitiveDataTranslator sensitiveDataTranslator;
    @Mock
    private Item item;


    @Test
    public void shouldMaskExportedValue() {
        String maskedValue = sensitiveDataTranslator.exportValue(PASSWORD);

        assertNotNull(maskedValue);
        assertEquals(maskedValue, MASKED_PASSWORD);
    }

    @Test
    public void shouldReturnEmptyStringWhenValueIsNull() {
        String maskedValue = sensitiveDataTranslator.exportValue(null);

        assertNotNull(maskedValue);
        assertEquals(maskedValue, EMPTY_STRING);
    }

    @Test
    public void shouldImportValueAsItIs() {
        String actualValue = (String) sensitiveDataTranslator.importValue(PASSWORD, item);

        assertNotNull(actualValue);
        assertEquals(actualValue, PASSWORD);
    }
}
