package cn.novalon.manage.sys.config;

import cn.novalon.manage.common.handler.ExceptionLogService;
import cn.novalon.manage.sys.handler.ExceptionLogServiceImpl;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import static org.assertj.core.api.Assertions.assertThat;

@ExtendWith(MockitoExtension.class)
class ExceptionLogConfigTest {

    @Mock
    private ExceptionLogServiceImpl exceptionLogServiceImpl;

    private ExceptionLogConfig exceptionLogConfig;

    @BeforeEach
    void setUp() {
        exceptionLogConfig = new ExceptionLogConfig();
    }

    @Test
    void testExceptionLogService() {
        ExceptionLogService exceptionLogService = exceptionLogConfig.exceptionLogService(exceptionLogServiceImpl);
        
        assertThat(exceptionLogService).isNotNull();
        assertThat(exceptionLogService).isSameAs(exceptionLogServiceImpl);
    }

    @Test
    void testExceptionLogService_DifferentInstance() {
        ExceptionLogService exceptionLogService1 = exceptionLogConfig.exceptionLogService(exceptionLogServiceImpl);
        ExceptionLogService exceptionLogService2 = exceptionLogConfig.exceptionLogService(exceptionLogServiceImpl);
        
        assertThat(exceptionLogService1).isNotNull();
        assertThat(exceptionLogService2).isNotNull();
        assertThat(exceptionLogService1).isSameAs(exceptionLogServiceImpl);
        assertThat(exceptionLogService2).isSameAs(exceptionLogServiceImpl);
    }
}