package com.eactive.eai.common.bizkey;

import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;
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.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.jdbc.Sql;

import com.eactive.eai.common.lifecycle.LifecycleException;
import com.eactive.eai.data.CommonJPATestConfiguration;
import com.eactive.eai.data.jpa.BaseRepositoryImpl;

@DataJpaTest
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
@ComponentScan({ "com.eactive.eai.common.bizkey" })
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
		"com.eactive.eai.common.bizkey" })
@EntityScan({ "com.eactive.eai.data.entity.onl.bizkey" })
@Sql({ "/com/eactive/eai/common/bizkey/init_tseaifr03.sql" })
class BizKeyManagerTest {
	@Autowired
	BizKeyManager bizKeyManager;

	@Test
	void testStart() throws LifecycleException {
		// given

		// when
		bizKeyManager.start();

		// then
		assertNotNull(bizKeyManager.getAllKeyNames());
		assertTrue(bizKeyManager.getAllKeyNames().length > 0);

	}

}
