@Test
lic final void test_isValidResourceGraph() {

ject[][] data_bad = new Object[][] {
/  { name,  excludesSupported, recursiveSupported, mandatory, reg-exp, parent-level, level }
{ "db",            null, null, null, null, "" ,             10 },
{ "table",         null, null, null, null, "db",            20 },   // same as db's level
{ "column-family", null, null, null, null, "table",         null }, // level is null!
{ "column",        null, null, null, null, "column-family", 20 },   // level is duplicate for [db->table->column-family-> column] hierarchy
{ "udf",           null, null, null, null, "db",            10 },   // udf's id conflicts with that of db in the [db->udf] hierarchy

st<RangerResourceDef> resourceDefs = _utils.createResourceDefs(data_bad);
en(_serviceDef.getResources()).thenReturn(resourceDefs);
en(_serviceDef.getName()).thenReturn("service-name");
en(_serviceDef.getUpdateTime()).thenReturn(new Date());
ailures.clear(); assertFalse(_validator.isValidResourceGraph(_serviceDef, _failures));
tils.checkFailureForMissingValue(_failures, "resource level");
tils.checkFailureForSemanticError(_failures, "resource level", "20"); // level 20 is duplicate for 1 hierarchy
tils.checkFailureForSemanticError(_failures, "resource level", "10"); // level 10 is duplicate for another hierarchy
    data_bad = new Object[][] {
            //  { name,  excludesSupported, recursiveSupported, mandatory, reg-exp, parent-level, level }
            { "db",            null, null, null, null, "" ,             10 },
            { "table",         null, null, null, null, "db",            20 },
            { "column-family", null, null, null, null, "table",         15 }, // level is smaller than table!
            { "column",        null, null, null, null, "column-family", 30 },
            { "udf",           null, null, null, null, "db",            15 },
    };
    resourceDefs = _utils.createResourceDefs(data_bad);
    when(_serviceDef.getResources()).thenReturn(resourceDefs);
    when(_serviceDef.getName()).thenReturn("service-name");
    when(_serviceDef.getUpdateTime()).thenReturn(new Date());
    _failures.clear(); assertFalse(_validator.isValidResourceGraph(_serviceDef, _failures));
    _utils.checkFailureForSemanticError(_failures, "resource level", "15"); // level 20 is duplicate for 1 hierarchy
    Object[][] data_good = new Object[][] {
/  { name,  excludesSupported, recursiveSupported, mandatory, reg-exp, parent-level, level }
{ "db",     null, null, null, null, "" ,     -10 }, // -ve level is ok
{ "table",  null, null, null, null, "db",    0 },   // 0 level is ok
{ "column", null, null, null, null, "table", 10 },  // level is null!
{ "udf",    null, null, null, null, "db",    0 },   // should not conflict as it belong to a different hierarchy

sourceDefs = _utils.createResourceDefs(data_good);
en(_serviceDef.getResources()).thenReturn(resourceDefs);
ailures.clear(); assertTrue(_validator.isValidResourceGraph(_serviceDef, _failures));
sertTrue(_failures.isEmpty());
    Object[][] data_cycles = new Object[][] {
            //  { name,  excludesSupported, recursiveSupported, mandatory, reg-exp, parent-level, level }
            { "db",     null, null, null, null, "column" ,     -10 }, // -ve level is ok
            { "table",  null, null, null, null, "db",    0 },   // 0 level is ok
            { "column", null, null, null, null, "table", 10 },  // level is null!
            { "udf",    null, null, null, null, "db",    -5 },   // should not conflict as it belong to a different hierarchy
    };
    resourceDefs = _utils.createResourceDefs(data_cycles);
    when(_serviceDef.getResources()).thenReturn(resourceDefs);
    _failures.clear(); assertFalse("Graph was valid!", _validator.isValidResourceGraph(_serviceDef, _failures));
    assertFalse(_failures.isEmpty());
    _utils.checkFailureForSemanticError(_failures, "resource graph");
    data_bad = new Object[][] {
            //  { name,  excludesSupported, recursiveSupported, mandatory, reg-exp, parent-level, level }
            { "db",     null, null, null, null, "" ,     -10 }, // -ve level is ok
            { "table",  null, null, true, null, "db",    0 },   // 0 level is ok; mandatory true here, but not at parent level?
            { "column", null, null, null, null, "table", 10 },  // level is null!
            { "udf",    null, null, null, null, "db",    0 },   // should not conflict as it belong to a different hierarchy
    };
    resourceDefs = _utils.createResourceDefs(data_bad);
    when(_serviceDef.getResources()).thenReturn(resourceDefs);
    _failures.clear(); assertFalse(_validator.isValidResourceGraph(_serviceDef, _failures));
    assertFalse(_failures.isEmpty());
    data_good = new Object[][] {
            //  { name,  excludesSupported, recursiveSupported, mandatory, reg-exp, parent-level, level }
            { "db",     null, null, true, null, "" ,     -10 }, // -ve level is ok
            { "table",  null, null, null, null, "db",    0 },   // 0 level is ok; mandatory true here, but not at parent level?
            { "column", null, null, null, null, "table", 10 },  // level is null!
            { "udf",    null, null, true, null, "db",    0 },   // should not conflict as it belong to a different hierarchy
    };
    resourceDefs = _utils.createResourceDefs(data_good);
    when(_serviceDef.getResources()).thenReturn(resourceDefs);
    _failures.clear(); assertTrue(_validator.isValidResourceGraph(_serviceDef, _failures));
    assertTrue(_failures.isEmpty());
}