if (agg.getSelectRule() == null) { context.addResult(ResultLevel.ERROR, AGGREGATION_GROUP + index + " 'select rule' field not set"); continue; if (agg.getSelectRule().mandatoryDims != null) { for (String m : agg.getSelectRule().mandatoryDims) { mandatoryDims.add(m); if (agg.getSelectRule().hierarchyDims != null) { for (String[] ss : agg.getSelectRule().hierarchyDims) { for (String s : ss) { hierarchyDims.add(s); if (agg.getSelectRule().jointDims != null) { for (String[] ss : agg.getSelectRule().jointDims) { for (String s : ss) { jointDims.add(s); if (agg.getSelectRule().jointDims != null) { for (String[] joints : agg.getSelectRule().jointDims) { if (agg.getSelectRule().hierarchyDims != null) { for (String[] oneHierarchy : agg.getSelectRule().hierarchyDims) { Set<String> share = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); share.addAll(CollectionUtils.intersection(oneJoint, Arrays.asList(oneHierarchy))); for (String[] joints : agg.getSelectRule().jointDims) { Set<String> oneJoint = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); for (String s : joints) {
if (agg.getSelectRule() == null) { logger.error("Aggregation group " + index + " 'select_rule' field not set"); throw new IllegalStateException("Aggregation group " + index + " select rule field not set"); getDims(mandatoryDims, agg.getSelectRule().mandatoryDims); getDims(hierarchyDimsList, hierarchyDims, agg.getSelectRule().hierarchyDims); getDims(jointDimsList, jointDims, agg.getSelectRule().jointDims);
@Test public void testBadInit9() throws Exception { String[] strs = new String[] { LSTG_FORMAT_NAME, META_CATEG_NAME }; thrown.expect(IllegalStateException.class); thrown.expectMessage( "Aggregation group 1 hierarchy dimensions overlap with joint dimensions: " + sortStrs(strs)); CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC); cubeDesc.getAggregationGroups().get(0).getSelectRule().hierarchyDims = new String[][] { new String[] { META_CATEG_NAME, CATEG_LVL2_NAME, CATEG_LVL3_NAME }, new String[] { LSTG_FORMAT_NAME, LSTG_SITE_ID } }; cubeDesc.getAggregationGroups().get(0).getSelectRule().jointDims = new String[][] { new String[] { META_CATEG_NAME, LSTG_FORMAT_NAME } }; cubeDesc.init(getTestConfig()); }
@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); }
@Test public void testBadInit5() throws Exception { CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC); cubeDesc.getAggregationGroups().get(0).getSelectRule().mandatoryDims = new String[] { SELLER_ID, META_CATEG_NAME }; cubeDesc.init(getTestConfig()); }
@Test public void testBadInit6() throws Exception { CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC); cubeDesc.getAggregationGroups().get(0).getSelectRule().mandatoryDims = new String[] { SELLER_ID, LSTG_FORMAT_NAME }; cubeDesc.init(getTestConfig()); }
@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())); }
@Test public void testBadInit7() throws Exception { thrown.expect(IllegalStateException.class); thrown.expectMessage("Aggregation group 1 require at least 2 dimensions in a joint"); CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC); cubeDesc.getAggregationGroups().get(0).getSelectRule().jointDims = new String[][] { new String[] { LSTG_FORMAT_NAME } }; cubeDesc.init(getTestConfig()); }
@Test public void testBadInit11() throws Exception { thrown.expect(IllegalStateException.class); thrown.expectMessage("Aggregation group 1 require at least 2 dimensions in a hierarchy."); CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC); cubeDesc.getAggregationGroups().get(0).getSelectRule().hierarchyDims = new String[][] { new String[] { META_CATEG_NAME } }; cubeDesc.init(getTestConfig()); }
@Test public void testBadInit10() throws Exception { String[] strs = new String[] { LSTG_FORMAT_NAME, LSTG_SITE_ID }; thrown.expect(IllegalStateException.class); thrown.expectMessage("Aggregation group 1 a dimension exist in more than one joint: " + sortStrs(strs)); CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC); cubeDesc.getAggregationGroups().get(0).getSelectRule().jointDims = new String[][] { new String[] { LSTG_FORMAT_NAME, LSTG_SITE_ID, SLR_SEGMENT_CD }, new String[] { LSTG_FORMAT_NAME, LSTG_SITE_ID, LEAF_CATEG_ID } }; cubeDesc.init(getTestConfig()); }
@Test public void testBadInit8() throws Exception { String[] strs = new String[] { CATEG_LVL2_NAME, META_CATEG_NAME }; thrown.expect(IllegalStateException.class); thrown.expectMessage( "Aggregation group 1 hierarchy dimensions overlap with joint dimensions: " + sortStrs(strs)); CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC); cubeDesc.getAggregationGroups().get(0).getSelectRule().jointDims = new String[][] { new String[] { META_CATEG_NAME, CATEG_LVL2_NAME } }; cubeDesc.init(getTestConfig()); }
@Test public void testBadInit12() throws Exception { String[] strs = new String[] { CATEG_LVL2_NAME, META_CATEG_NAME }; thrown.expect(IllegalStateException.class); thrown.expectMessage("Aggregation group 1 a dimension exist in more than one hierarchy: " + sortStrs(strs)); CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC); cubeDesc.getAggregationGroups().get(0).getSelectRule().hierarchyDims = new String[][] { new String[] { META_CATEG_NAME, CATEG_LVL2_NAME, CATEG_LVL3_NAME }, new String[] { META_CATEG_NAME, CATEG_LVL2_NAME } }; cubeDesc.init(getTestConfig()); }
AggregationGroup iag = ic.getAggregationGroups().get(i); assertArrayEquals(lag.getIncludes(), iag.getIncludes()); assertArrayEquals(lag.getSelectRule().mandatoryDims, iag.getSelectRule().mandatoryDims); assertArrayEquals(lag.getSelectRule().hierarchyDims, iag.getSelectRule().hierarchyDims); assertArrayEquals(lag.getSelectRule().jointDims, iag.getSelectRule().jointDims);
if (agg.getSelectRule() == null) { context.addResult(ResultLevel.ERROR, AGGREGATION_GROUP + index + " 'select rule' field not set"); continue; if (agg.getSelectRule().mandatoryDims != null) { for (String m : agg.getSelectRule().mandatoryDims) { mandatoryDims.add(m); if (agg.getSelectRule().hierarchyDims != null) { for (String[] ss : agg.getSelectRule().hierarchyDims) { for (String s : ss) { hierarchyDims.add(s); if (agg.getSelectRule().jointDims != null) { for (String[] ss : agg.getSelectRule().jointDims) { for (String s : ss) { jointDims.add(s); if (agg.getSelectRule().jointDims != null) { for (String[] joints : agg.getSelectRule().jointDims) { if (agg.getSelectRule().hierarchyDims != null) { for (String[] oneHierarchy : agg.getSelectRule().hierarchyDims) { Set<String> share = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); share.addAll(CollectionUtils.intersection(oneJoint, Arrays.asList(oneHierarchy))); for (String[] joints : agg.getSelectRule().jointDims) { Set<String> oneJoint = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); for (String s : joints) {
if (agg.getSelectRule() == null) { logger.error("Aggregation group " + index + " 'select_rule' field not set"); throw new IllegalStateException("Aggregation group " + index + " select rule field not set"); getDims(mandatoryDims, agg.getSelectRule().mandatoryDims); getDims(hierarchyDimsList, hierarchyDims, agg.getSelectRule().hierarchyDims); getDims(jointDimsList, jointDims, agg.getSelectRule().jointDims);