package com.cf.imes.module.system.service.application;

import com.cf.imes.framework.test.core.ut.BaseMockitoUnitTest;
import com.cf.imes.module.system.dal.dataobject.application.ApplicationDO;
import com.cf.imes.module.system.dal.mysql.application.ApplicationMapper;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;

import static com.cf.imes.framework.test.core.util.RandomUtils.randomPojo;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.when;


class ApplicationServiceImplTest extends BaseMockitoUnitTest {

    @InjectMocks
    private ApplicationServiceImpl applicationService;

    @Mock
    private ApplicationMapper applicationMapper;

    @Test
    void getApplicationByOrganId() {
        Long organId = 1L;
        ApplicationDO applicationDO = randomPojo(ApplicationDO.class);
        applicationMapper.insert(applicationDO);
        when(applicationMapper.selectByOrganId(organId)).thenReturn(applicationDO);

        ApplicationDO applicationByOrganId = applicationService.getApplicationByOrganId(organId);
        assertNotNull(applicationByOrganId);
        assertEquals(applicationDO.getId(), applicationByOrganId.getId());
    }
}
