package com.eactive.eai.transformer.layout.loader;

import static org.junit.Assert.assertNotNull;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.transaction.annotation.Transactional;

import com.eactive.eai.data.entity.onl.transformer.layout.LayoutEntity;
import com.eactive.eai.transformer.function.jpa.TransformJPATestConfiguration;

@DataJpaTest
@Transactional(readOnly = false)
@ContextConfiguration(classes = { TransformJPATestConfiguration.class})
@Sql({ "/com/eactive/eai/transformer/init_tseaitr06.sql", "/com/eactive/eai/transformer/init_tseaitr07.sql",
"/com/eactive/eai/transformer/init_tseaitr08.sql" })
class LayoutRepositoryTest {

	@Autowired
	LayoutLoaderRepository layoutLoaderRepository;

	@Test
	void testFindById() {
		LayoutEntity layoutEntity = layoutLoaderRepository.getReferenceById("TST_TTST00000002_RES");
		layoutEntity = layoutEntity.getLayoutItemEntities().stream().findAny().get().getLayoutEntity();
		assertNotNull(layoutEntity);
		System.out.println(layoutEntity);
	}

}
