Java Code Examples for org.apache.kylin.common.util.LocalFileMetadataTestCase

The following examples show how to use org.apache.kylin.common.util.LocalFileMetadataTestCase. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Test
public void testGoodDesc() throws IOException {
    AggregationGroupRule rule = getAggregationGroupRule();

    for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/").listFiles()) {
        if (!f.getName().endsWith("json")) {
            continue;
        }
        CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
        desc.init(getTestConfig());
        ValidateContext vContext = new ValidateContext();
        rule.validate(desc, vContext);
        //vContext.print(System.out);
        assertTrue(vContext.getResults().length == 0);
    }
}
 
Example 2
@Test
public void testGoodBecomeBadDesc() throws IOException {
    AggregationGroupRule rule = new AggregationGroupRule() {
        @Override
        protected long getMaxCombinations(CubeDesc cubeDesc) {
            return 2;
        }
    };

    for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/").listFiles()) {
        System.out.println(f.getName());
        CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
        try {
            desc.init(getTestConfig());
        } catch (Exception e) {
            // Ignore any exception here, validation may fail for bad json
        }
        ValidateContext vContext = new ValidateContext();
        rule.validate(desc, vContext);
        //vContext.print(System.out);
        assertTrue(vContext.getResults().length > 0);
        assertTrue(vContext.getResults()[0].getMessage().startsWith("Aggregation group 1 has too many combinations"));
    }
}
 
Example 3
@Test
public void testCombinationIntOverflow() throws IOException {
    for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/").listFiles()) {
        if (f.getName().endsWith("bad")) {
            String path = f.getPath();
            f.renameTo(new File(path.substring(0, path.length() - 4)));
        }
    }

    ValidateContext vContext = new ValidateContext();
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/ut_cube_desc_combination_int_overflow.json"), CubeDesc.class);

    IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
    try {
        desc.init(getTestConfig());
    } catch (Exception ex) {
        // as it's a failure case, it should throw exception
    }
    rule.validate(desc, vContext);
    assertEquals(1, vContext.getResults().length);
}
 
Example 4
Source Project: kylin-on-parquet-v2   Source File: DictionaryRuleTest.java    License: Apache License 2.0 6 votes vote down vote up
private void testDictionaryDesc(String expectMessage, DictionaryDesc... descs) throws IOException {
    DictionaryRule rule = new DictionaryRule();
    File f = new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/test_kylin_cube_without_slr_left_join_desc.json");
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);

    List<DictionaryDesc> newDicts = Lists.newArrayList(desc.getDictionaries());
    for (DictionaryDesc dictDesc : descs) {
        newDicts.add(dictDesc);
    }
    desc.setDictionaries(newDicts);

    desc.init(config);
    ValidateContext vContext = new ValidateContext();
    rule.validate(desc, vContext);

    if (expectMessage == null) {
        assertTrue(vContext.getResults().length == 0);
    } else {
        assertTrue(vContext.getResults().length == 1);
        String actualMessage = vContext.getResults()[0].getMessage();
        assertTrue(actualMessage.startsWith(expectMessage));
    }
}
 
Example 5
Source Project: kylin-on-parquet-v2   Source File: CuboidSchedulerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCuboid_onlyBaseCuboid() {
    for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA, "cube_desc").listFiles()) {
        if (f.getName().endsWith(".bad")) {
            String path = f.getPath();
            f.renameTo(new File(path.substring(0, path.length() - 4)));
        }
    }
    getTestConfig().clearManagers();
    CubeDesc cube = getCubeDescManager().getCubeDesc("ut_large_dimension_number");
    CuboidScheduler scheduler = cube.getInitialCuboidScheduler();

    Cuboid baseCuboid = Cuboid.getBaseCuboid(cube);
    assertTrue(scheduler.isValid(baseCuboid.getId()));

    List<Long> spanningChild = scheduler.getSpanningCuboid(baseCuboid.getId());
    assertTrue(spanningChild.size() > 0);
}
 
Example 6
Source Project: kylin   Source File: AggregationGroupRuleTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testGoodDesc() throws IOException {
    AggregationGroupRule rule = getAggregationGroupRule();

    for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/").listFiles()) {
        if (!f.getName().endsWith("json")) {
            continue;
        }
        CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
        desc.init(getTestConfig());
        ValidateContext vContext = new ValidateContext();
        rule.validate(desc, vContext);
        //vContext.print(System.out);
        assertTrue(vContext.getResults().length == 0);
    }
}
 
Example 7
Source Project: kylin   Source File: AggregationGroupRuleTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testGoodBecomeBadDesc() throws IOException {
    AggregationGroupRule rule = new AggregationGroupRule() {
        @Override
        protected long getMaxCombinations(CubeDesc cubeDesc) {
            return 2;
        }
    };

    for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/").listFiles()) {
        System.out.println(f.getName());
        CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
        try {
            desc.init(getTestConfig());
        } catch (Exception e) {
            // Ignore any exception here, validation may fail for bad json
        }
        ValidateContext vContext = new ValidateContext();
        rule.validate(desc, vContext);
        //vContext.print(System.out);
        assertTrue(vContext.getResults().length > 0);
        assertTrue(vContext.getResults()[0].getMessage().startsWith("Aggregation group 1 has too many combinations"));
    }
}
 
Example 8
Source Project: kylin   Source File: AggregationGroupRuleTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCombinationIntOverflow() throws IOException {
    for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/").listFiles()) {
        if (f.getName().endsWith("bad")) {
            String path = f.getPath();
            f.renameTo(new File(path.substring(0, path.length() - 4)));
        }
    }

    ValidateContext vContext = new ValidateContext();
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/ut_cube_desc_combination_int_overflow.json"), CubeDesc.class);

    IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
    try {
        desc.init(getTestConfig());
    } catch (Exception ex) {
        // as it's a failure case, it should throw exception
    }
    rule.validate(desc, vContext);
    assertEquals(1, vContext.getResults().length);
}
 
Example 9
Source Project: kylin   Source File: DictionaryRuleTest.java    License: Apache License 2.0 6 votes vote down vote up
private void testDictionaryDesc(String expectMessage, DictionaryDesc... descs) throws IOException {
    DictionaryRule rule = new DictionaryRule();
    File f = new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/test_kylin_cube_without_slr_left_join_desc.json");
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);

    List<DictionaryDesc> newDicts = Lists.newArrayList(desc.getDictionaries());
    for (DictionaryDesc dictDesc : descs) {
        newDicts.add(dictDesc);
    }
    desc.setDictionaries(newDicts);

    desc.init(config);
    ValidateContext vContext = new ValidateContext();
    rule.validate(desc, vContext);

    if (expectMessage == null) {
        assertTrue(vContext.getResults().length == 0);
    } else {
        assertTrue(vContext.getResults().length == 1);
        String actualMessage = vContext.getResults()[0].getMessage();
        assertTrue(actualMessage.startsWith(expectMessage));
    }
}
 
Example 10
Source Project: kylin   Source File: CuboidSchedulerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCuboid_onlyBaseCuboid() {
    for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA, "cube_desc").listFiles()) {
        if (f.getName().endsWith(".bad")) {
            String path = f.getPath();
            f.renameTo(new File(path.substring(0, path.length() - 4)));
        }
    }
    getTestConfig().clearManagers();
    CubeDesc cube = getCubeDescManager().getCubeDesc("ut_large_dimension_number");
    CuboidScheduler scheduler = cube.getInitialCuboidScheduler();

    Cuboid baseCuboid = Cuboid.getBaseCuboid(cube);
    assertTrue(scheduler.isValid(baseCuboid.getId()));

    List<Long> spanningChild = scheduler.getSpanningCuboid(baseCuboid.getId());
    assertTrue(spanningChild.size() > 0);
}
 
Example 11
Source Project: kylin-on-parquet-v2   Source File: ResourceToolTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
    FileUtils.forceMkdir(DIR_1);
    FileUtils.forceMkdir(DIR_2);
    FileUtils.write(new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + FILE_1), "");
    FileUtils.write(new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + FILE_2), "");
    FileUtils.forceMkdir(new File(dstPath));
    FileUtils.cleanDirectory(new File(dstPath));
    this.createTestMetadata();
}
 
Example 12
Source Project: kylin-on-parquet-v2   Source File: ResourceToolTest.java    License: Apache License 2.0 5 votes vote down vote up
@After
public void after() throws Exception {
    FileUtils.deleteQuietly(new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + FILE_1));
    FileUtils.deleteQuietly(new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + FILE_2));
    File directory = new File(dstPath);
    try {
        FileUtils.deleteDirectory(directory);
    } catch (IOException e) {
        if (directory.exists() && directory.list().length > 0)
            throw new IllegalStateException("Can't delete directory " + directory, e);
    }
    this.cleanupTestMetadata();
}
 
Example 13
@BeforeClass
public static void before() throws IOException {
    staticCreateTestMetadata();

    KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv();
    CubeManager cubeManager = CubeManager.getInstance(kylinConfig);

    cube = cubeManager.getCube("ssb");
    flatTable = LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/data/" + kylinConfig.getHiveIntermediateTablePrefix()
            + "ssb_19920101000000_19920201000000.csv";
    dictionaryMap = ITInMemCubeBuilderTest.getDictionaryMap(cube, flatTable);
}
 
Example 14
@Test
public void testGoodDesc2() throws IOException {

    ValidateContext vContext = new ValidateContext();
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
    desc.getAggregationGroups().get(0).getSelectRule().jointDims = new String[][] { //
            new String[] { "lstg_format_name", "lstg_site_id", "slr_segment_cd", "CATEG_LVL2_NAME" } };

    IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
    rule.validate(desc, vContext);
    //vContext.print(System.out);
    assertEquals(1, vContext.getResults().length);
}
 
Example 15
@Test
public void testBadDesc1() throws IOException {

    ValidateContext vContext = new ValidateContext();
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
    String[] temp = Arrays.asList(desc.getAggregationGroups().get(0).getIncludes()).subList(0, 3).toArray(new String[3]);

    desc.getAggregationGroups().get(0).setIncludes(temp);
    IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
    rule.validate(desc, vContext);
    //vContext.print(System.out);
    assertEquals(1, vContext.getResults().length);
    assertEquals("Aggregation group 1 'includes' dimensions not include all the dimensions:[seller_id, META_CATEG_NAME, lstg_format_name, lstg_site_id, slr_segment_cd]", (vContext.getResults()[0].getMessage()));
}
 
Example 16
@Test
public void testBadDesc2() throws IOException {

    ValidateContext vContext = new ValidateContext();
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
    desc.getAggregationGroups().get(0).getSelectRule().jointDims = new String[][] { //
            new String[] { "lstg_format_name", "lstg_site_id", "slr_segment_cd", "META_CATEG_NAME", "CATEG_LVL2_NAME" } };

    IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
    rule.validate(desc, vContext);
    //vContext.print(System.out);
    assertEquals(2, vContext.getResults().length);
    assertEquals("Aggregation group 1 joint dimensions has overlap with more than 1 dimensions in same hierarchy: [CATEG_LVL2_NAME, META_CATEG_NAME]", (vContext.getResults()[0].getMessage()));
}
 
Example 17
Source Project: kylin-on-parquet-v2   Source File: DictionaryRuleTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testGoodDesc() throws IOException {
    DictionaryRule rule = new DictionaryRule();

    for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/").listFiles()) {
        if (!f.getName().endsWith("json")) {
            continue;
        }
        CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
        desc.init(config);
        ValidateContext vContext = new ValidateContext();
        rule.validate(desc, vContext);
        assertTrue(vContext.getResults().length == 0);
    }
}
 
Example 18
Source Project: kylin-on-parquet-v2   Source File: FunctionRuleTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testGoodDesc() throws IOException {
    FunctionRule rule = new FunctionRule();

    File f = new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/ssb.json");
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
    desc.init(config);
    ValidateContext vContext = new ValidateContext();
    rule.validate(desc, vContext);
    vContext.print(System.out);
    assertTrue(vContext.getResults().length == 0);
}
 
Example 19
Source Project: kylin-on-parquet-v2   Source File: FunctionRuleTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalStateException.class)
public void testValidateMeasureNamesDuplicated() throws IOException {
    File f = new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/ssb.json");
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);

    MeasureDesc measureDescDuplicated = desc.getMeasures().get(1);
    List<MeasureDesc> newMeasures = Lists.newArrayList(desc.getMeasures());
    newMeasures.add(measureDescDuplicated);
    desc.setMeasures(newMeasures);

    desc.init(config);
}
 
Example 20
Source Project: kylin-on-parquet-v2   Source File: CubeDescTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testCombinationIntOverflow() throws Exception {
    for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA, "cube_desc").listFiles()) {
        if (f.getName().endsWith(".bad")) {
            String path = f.getPath();
            f.renameTo(new File(path.substring(0, path.length() - 4)));
        }
    }

    thrown.expect(TooManyCuboidException.class);
    getTestConfig().clearManagers();
    CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig())
            .getCubeDesc("ut_cube_desc_combination_int_overflow");
    cubeDesc.init(getTestConfig());
}
 
Example 21
Source Project: kylin-on-parquet-v2   Source File: CubeDescTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testTooManyRowkeys() throws Exception {
    File metaFile = new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA, "cube_desc/ut_78_rowkeys.json.bad");
    Assert.assertTrue(metaFile.exists());
    String path = metaFile.getPath();
    metaFile.renameTo(new File(path.substring(0, path.length() - 4)));

    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage(
            "Too many rowkeys (78) in CubeDesc, please try to reduce dimension number or adopt derived dimensions");
    getTestConfig().clearManagers();
    CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("ut_78_rowkeys");
    cubeDesc.init(getTestConfig());
}
 
Example 22
Source Project: kylin-on-parquet-v2   Source File: CuboidSchedulerTest.java    License: Apache License 2.0 5 votes vote down vote up
private CubeDesc getFiftyDimFiveCapCubeDesc() {
    File metaFile = new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA, "cube_desc/fifty_dim_five_cap.json.bad");
    assertTrue(metaFile.exists());
    String path = metaFile.getPath();
    metaFile.renameTo(new File(path.substring(0, path.length() - 4)));
    return CubeDescManager.getInstance(getTestConfig()).getCubeDesc("fifty_dim_five_cap");
}
 
Example 23
Source Project: kylin-on-parquet-v2   Source File: CuboidSchedulerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test(expected=RuntimeException.class)
public void testTooManyCombination() {
    File twentyFile = new File(new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA, "cube_desc"), "twenty_dim");
    twentyFile.renameTo(new File(twentyFile.getPath().substring(0, twentyFile.getPath().length() - 4)));
    CubeDesc cube = getTwentyDimCubeDesc();
    CuboidScheduler cuboidScheduler = cube.getInitialCuboidScheduler();
    cuboidScheduler.getCuboidCount();
    twentyFile.renameTo(new File(twentyFile.getPath() + ".bad"));
}
 
Example 24
Source Project: kylin-on-parquet-v2   Source File: RowKeyAttrRuleTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testGoodDesc() throws IOException {
    for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/").listFiles()) {
        CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
        ValidateContext vContext = new ValidateContext();
        IValidatorRule<CubeDesc> rule = new RowKeyAttrRule();
        rule.validate(desc, vContext);
        vContext.print(System.out);
        assertTrue(vContext.getResults().length == 0);
    }
}
 
Example 25
Source Project: kylin-on-parquet-v2   Source File: RowKeyAttrRuleTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testBadDesc() throws IOException {
    ValidateContext vContext = new ValidateContext();
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
    desc.getRowkey().getRowKeyColumns()[2].setColumn("");
    IValidatorRule<CubeDesc> rule = new RowKeyAttrRule();
    rule.validate(desc, vContext);
    vContext.print(System.out);
    assertTrue(vContext.getResults().length == 1);
    assertTrue("Rowkey column empty".equalsIgnoreCase(vContext.getResults()[0].getMessage()));
}
 
Example 26
Source Project: kylin   Source File: ResourceToolTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
    FileUtils.forceMkdir(DIR_1);
    FileUtils.forceMkdir(DIR_2);
    FileUtils.write(new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + FILE_1), "");
    FileUtils.write(new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + FILE_2), "");
    FileUtils.forceMkdir(new File(dstPath));
    FileUtils.cleanDirectory(new File(dstPath));
    this.createTestMetadata();
}
 
Example 27
Source Project: kylin   Source File: ResourceToolTest.java    License: Apache License 2.0 5 votes vote down vote up
@After
public void after() throws Exception {
    FileUtils.deleteQuietly(new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + FILE_1));
    FileUtils.deleteQuietly(new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + FILE_2));
    File directory = new File(dstPath);
    try {
        FileUtils.deleteDirectory(directory);
    } catch (IOException e) {
        if (directory.exists() && directory.list().length > 0)
            throw new IllegalStateException("Can't delete directory " + directory, e);
    }
    this.cleanupTestMetadata();
}
 
Example 28
Source Project: kylin   Source File: ITDoggedCubeBuilderTest.java    License: Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void before() throws IOException {
    staticCreateTestMetadata();

    KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv();
    CubeManager cubeManager = CubeManager.getInstance(kylinConfig);

    cube = cubeManager.getCube("ssb");
    flatTable = LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/data/" + kylinConfig.getHiveIntermediateTablePrefix()
            + "ssb_19920101000000_19920201000000.csv";
    dictionaryMap = ITInMemCubeBuilderTest.getDictionaryMap(cube, flatTable);
}
 
Example 29
Source Project: kylin   Source File: AggregationGroupRuleTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testGoodDesc2() throws IOException {

    ValidateContext vContext = new ValidateContext();
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
    desc.getAggregationGroups().get(0).getSelectRule().jointDims = new String[][] { //
            new String[] { "lstg_format_name", "lstg_site_id", "slr_segment_cd", "CATEG_LVL2_NAME" } };

    IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
    rule.validate(desc, vContext);
    //vContext.print(System.out);
    assertEquals(1, vContext.getResults().length);
}
 
Example 30
Source Project: kylin   Source File: AggregationGroupRuleTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testBadDesc1() throws IOException {

    ValidateContext vContext = new ValidateContext();
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
    String[] temp = Arrays.asList(desc.getAggregationGroups().get(0).getIncludes()).subList(0, 3).toArray(new String[3]);

    desc.getAggregationGroups().get(0).setIncludes(temp);
    IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
    rule.validate(desc, vContext);
    //vContext.print(System.out);
    assertEquals(1, vContext.getResults().length);
    assertEquals("Aggregation group 1 'includes' dimensions not include all the dimensions:[seller_id, META_CATEG_NAME, lstg_format_name, lstg_site_id, slr_segment_cd]", (vContext.getResults()[0].getMessage()));
}