package com.eactive.eai.rms.data.entity.onl.transform;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.test.context.ContextConfiguration;

import com.eactive.eai.data.jpa.BaseRepositoryImpl;
import com.eactive.eai.rms.common.login.LoginVo;
import com.eactive.eai.rms.common.login.SessionManager;

@DataJpaTest
@ContextConfiguration(classes = { TransformServiceTestConfig.class })
@ComponentScan({ "com.eactive.eai.data.entity.onl.message", "com.eactive.eai.rms.data.entity.onl.transform" })
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
		"com.eactive.eai.data.entity.onl.message", "com.eactive.eai.rms.data.entity.onl.transform" })
@EntityScan({ "com.eactive.eai.data.entity.onl.message", "com.eactive.eai.data.entity.onl.transformer",
		"com.eactive.eai.rms.data.entity.onl.bzwkdstcd", "com.eactive.eai.data.entity.onl.unifbwk" })

class TransformServiceTest {

	@Autowired
	private TransformService transformService;

	@Mock
	private SessionManager sessionManager;

	@Test
	void testFindAll() {
		LoginVo loginVo = new LoginVo();
		loginVo.setUserId("admin");
		SessionManager.setLoginVo(loginVo);

		Page<TransformEaiMessage> page = transformService.findAll(Pageable.ofSize(20), null, null, null, null);

		Assertions.assertNotNull(page);
	}

}

@Configuration
class TransformServiceTestConfig {
}
