package com.ruoyi.web.modules.openstats.support;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import static org.mockito.Mockito.when;

@ExtendWith(MockitoExtension.class)
class OpenStatsTokenSupportTest
{
    @Mock
    private OpenStatsTokenCryptoSupport tokenCryptoSupport;

    @InjectMocks
    private OpenStatsTokenSupport tokenSupport;

    @Test
    void isValidToken_delegatesToCrypto()
    {
        when(tokenCryptoSupport.validateEncryptedToken("cipher")).thenReturn(true);
        assertTrue(tokenSupport.isValidToken("cipher"));
    }

    @Test
    void isValidToken_blankRejected()
    {
        assertFalse(tokenSupport.isValidToken(null));
        assertFalse(tokenSupport.isValidToken(""));
        assertFalse(tokenSupport.isValidToken("   "));
    }
}
