Java Code Examples for org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege#setHiveObject()
The following examples show how to use
org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege#setHiveObject() .
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
Source File: FederatedHMSHandlerTest.java From waggle-dance with Apache License 2.0 | 6 votes |
@Test public void grant_revoke_privileges() throws TException { HiveObjectRef hiveObjectRef = new HiveObjectRef(); hiveObjectRef.setDbName(DB_P); HiveObjectPrivilege hiveObjectPrivilege = new HiveObjectPrivilege(); hiveObjectPrivilege.setHiveObject(hiveObjectRef); PrivilegeBag privileges = new PrivilegeBag(Collections.singletonList((hiveObjectPrivilege))); GrantRevokeType grantRevokeType = GrantRevokeType.GRANT; GrantRevokePrivilegeRequest request = new GrantRevokePrivilegeRequest(grantRevokeType, privileges); GrantRevokePrivilegeRequest inboundRequest = new GrantRevokePrivilegeRequest(); GrantRevokePrivilegeResponse expected = new GrantRevokePrivilegeResponse(); when(primaryMapping.transformInboundGrantRevokePrivilegesRequest(request)).thenReturn(inboundRequest); when(primaryClient.grant_revoke_privileges(inboundRequest)).thenReturn(expected); GrantRevokePrivilegeResponse response = handler.grant_revoke_privileges(request); assertThat(response, is(expected)); verify(primaryMapping).checkWritePermissions(DB_P); }
Example 2
Source File: DatabaseMappingImpl.java From waggle-dance with Apache License 2.0 | 5 votes |
@Override public List<HiveObjectPrivilege> transformOutboundHiveObjectPrivileges(List<HiveObjectPrivilege> privileges) { for (HiveObjectPrivilege privilege : privileges) { privilege.setHiveObject(transformOutboundHiveObjectRef(privilege.getHiveObject())); } return privileges; }
Example 3
Source File: DatabaseMappingImpl.java From waggle-dance with Apache License 2.0 | 5 votes |
@Override public PrivilegeBag transformInboundPrivilegeBag(PrivilegeBag privilegeBag) { if (privilegeBag.isSetPrivileges()) { for (HiveObjectPrivilege privilege : privilegeBag.getPrivileges()) { privilege.setHiveObject(transformInboundHiveObjectRef(privilege.getHiveObject())); } } return privilegeBag; }
Example 4
Source File: DatabaseMappingImplTest.java From waggle-dance with Apache License 2.0 | 5 votes |
@Before public void setUp() { databaseMapping = new DatabaseMappingImpl(metastoreMapping, queryMapping); database = new Database(); database.setName(DB_NAME); partition = new Partition(); partition.setDbName(DB_NAME); partitions = Lists.newArrayList(partition); index = new Index(); index.setDbName(DB_NAME); hiveObjectRef = new HiveObjectRef(); hiveObjectRef.setDbName(DB_NAME); hiveObjectRef.setObjectType(HiveObjectType.DATABASE); hiveObjectRef.setObjectName(DB_NAME); hiveObjectPrivileges = new ArrayList<>(); HiveObjectPrivilege hiveObjectPrivilege = new HiveObjectPrivilege(); hiveObjectPrivilege.setHiveObject(hiveObjectRef); hiveObjectPrivileges.add(hiveObjectPrivilege); partitionSpec = new PartitionSpec(); partitionSpec.setDbName(DB_NAME); when(metastoreMapping.transformInboundDatabaseName(anyString())).thenReturn(IN_DB_NAME); when(metastoreMapping.transformOutboundDatabaseName(anyString())).thenReturn(OUT_DB_NAME); when(queryMapping.transformOutboundDatabaseName(metastoreMapping, VIEW_EXPANDED_TEXT)) .thenReturn(VIEW_EXPANDED_TEXT_TRANSFORMED); when(queryMapping.transformOutboundDatabaseName(metastoreMapping, VIEW_ORIGINAL_TEXT)) .thenReturn(VIEW_ORIGINAL_TEXT_TRANSFORMED); }
Example 5
Source File: FederatedHMSHandlerTest.java From waggle-dance with Apache License 2.0 | 5 votes |
@Test public void grant_privileges() throws TException { HiveObjectRef hiveObjectRef = new HiveObjectRef(); hiveObjectRef.setDbName(DB_P); HiveObjectPrivilege hiveObjectPrivilege = new HiveObjectPrivilege(); hiveObjectPrivilege.setHiveObject(hiveObjectRef); PrivilegeBag privileges = new PrivilegeBag(Collections.singletonList((hiveObjectPrivilege))); PrivilegeBag inboundPrivileges = new PrivilegeBag(); when(primaryMapping.transformInboundPrivilegeBag(privileges)).thenReturn(inboundPrivileges); handler.grant_privileges(privileges); verify(primaryMapping).checkWritePermissions(DB_P); verify(primaryClient).grant_privileges(inboundPrivileges); }
Example 6
Source File: FederatedHMSHandlerTest.java From waggle-dance with Apache License 2.0 | 5 votes |
@Test public void revoke_privileges() throws TException { HiveObjectRef hiveObjectRef = new HiveObjectRef(); hiveObjectRef.setDbName(DB_P); HiveObjectPrivilege hiveObjectPrivilege = new HiveObjectPrivilege(); hiveObjectPrivilege.setHiveObject(hiveObjectRef); PrivilegeBag privileges = new PrivilegeBag(Collections.singletonList((hiveObjectPrivilege))); PrivilegeBag inboundPrivileges = new PrivilegeBag(); when(primaryMapping.transformInboundPrivilegeBag(privileges)).thenReturn(inboundPrivileges); handler.revoke_privileges(privileges); verify(primaryMapping).checkWritePermissions(DB_P); verify(primaryClient).revoke_privileges(inboundPrivileges); }