CommonPrivilege implements Privilege { @Override public List<KeyValue> getParts() { return parts; } CommonPrivilege(String privilegeStr); @Override boolean implies(Privilege privilege, Model model); @Override List<KeyValue> getAuthorizable(); @Override String toString(); @Override List<KeyValue> getParts(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testCreateCommonPrivilege() throws Exception { String privilegeHiveStr = "server=server1->db=db1->table=table1->column=column1->action=select"; String privilegeSolrStr = "server=server1->collection=col1->action=update"; String privilegeSqoopStr = "server=server1->link=link1->action=read"; CommonPrivilege privilegeHive = new CommonPrivilege(privilegeHiveStr); CommonPrivilege privilegeSolr = new CommonPrivilege(privilegeSolrStr); CommonPrivilege privilegeSqoop = new CommonPrivilege(privilegeSqoopStr); List<KeyValue> keyValues = privilegeHive.getParts(); assertEquals(5, keyValues.size()); assertEquals("server", keyValues.get(0).getKey()); assertEquals("server1", keyValues.get(0).getValue()); assertEquals("db", keyValues.get(1).getKey()); assertEquals("db1", keyValues.get(1).getValue()); assertEquals("table", keyValues.get(2).getKey()); assertEquals("table1", keyValues.get(2).getValue()); assertEquals("column", keyValues.get(3).getKey()); assertEquals("column1", keyValues.get(3).getValue()); assertEquals("action", keyValues.get(4).getKey()); assertEquals("select", keyValues.get(4).getValue()); keyValues = privilegeSolr.getParts(); assertEquals(3, keyValues.size()); assertEquals("server", keyValues.get(0).getKey()); assertEquals("server1", keyValues.get(0).getValue()); assertEquals("collection", keyValues.get(1).getKey()); assertEquals("col1", keyValues.get(1).getValue()); assertEquals("action", keyValues.get(2).getKey()); assertEquals("update", keyValues.get(2).getValue()); keyValues = privilegeSqoop.getParts(); assertEquals(3, keyValues.size()); assertEquals("server", keyValues.get(0).getKey()); assertEquals("server1", keyValues.get(0).getValue()); assertEquals("link", keyValues.get(1).getKey()); assertEquals("link1", keyValues.get(1).getValue()); assertEquals("action", keyValues.get(2).getKey()); assertEquals("read", keyValues.get(2).getValue()); }