package com.njcn.gather.tool.adddata.component;

import com.njcn.gather.tool.adddata.pojo.bo.AddDataTableDefinition;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.List;

/**
 * 表定义注册测试。
 */
class AddDataTableRegistryTest {

    @Test
    void shouldLoadAllThirteenTablesFromSchema() throws Exception {
        AddDataTableRegistry registry = new AddDataTableRegistry();
        registry.afterPropertiesSet();

        List<AddDataTableDefinition> definitions = registry.getTableDefinitions();

        Assertions.assertEquals(13, definitions.size());
        Assertions.assertEquals("data_flicker", definitions.get(0).getTableName());
        Assertions.assertEquals("data_v", definitions.get(definitions.size() - 1).getTableName());
        Assertions.assertTrue(registry.getDefinition("data_v").getColumns().contains("V_THD"));
        Assertions.assertEquals(4, registry.getDefinition("data_v").getPhaseCodes().size());
        Assertions.assertTrue(registry.getDefinition("data_v").getPhaseCodes().contains("T"));
    }
}
