package com.eactive.eai.httpouttlsinfo;

import com.eactive.eai.common.lifecycle.LifecycleException;
import com.eactive.eai.data.CommonJPATestConfiguration;
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
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 static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

@DataJpaTest
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
@ComponentScan({ "com.eactive.eai.httpouttlsinfo" })
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
		"com.eactive.eai.httpouttlsinfo" })
@EntityScan({ "com.eactive.eai.data.entity.onl.httpouttlsinfo" })
@Sql({ "/com/eactive/eai/httpouttlsinfo/init_http_tls_client_info.sql" })
class HttpOutTlsInfoManagerTest {

	@Autowired
	HttpOutTlsInfoManager httpOutTlsInfoManager;

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

		// when
		httpOutTlsInfoManager.start();

		// then
		assertNotNull(httpOutTlsInfoManager.getAllClientIds());
		assertTrue(httpOutTlsInfoManager.getAllClientIds().length > 0);
	}

}
