package com.eactive.eai.common.b2bextractor;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.boot.test.mock.mockito.SpyBean;
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.b2bextractor" })
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
		"com.eactive.eai.common.b2bextractor" })
@EntityScan({ "com.eactive.eai.data.entity.onl.b2bextractor" })
@Sql({ "/com/eactive/eai/common/b2bextractor/init_tseaifr06.sql" })
class B2BExtractManagerTest {

	@SpyBean
	B2BExtractManager b2bExtractManager;

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

		// when
		b2bExtractManager.start();

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

}
