Search in sources :

Example 11 with XXGlobalStateDao

use of org.apache.ranger.db.XXGlobalStateDao in project ranger by apache.

the class TestSecurityZoneDBStore method test2updateSecurityZoneById.

@Test
public void test2updateSecurityZoneById() throws Exception {
    XXSecurityZone xxSecurityZone = new XXSecurityZone();
    xxSecurityZone.setId(2L);
    RangerSecurityZone securityZone = new RangerSecurityZone();
    securityZone.setId(2L);
    RangerSecurityZone updateSecurityZone = new RangerSecurityZone();
    updateSecurityZone.setId(2L);
    XXSecurityZoneDao xXSecurityZoneDao = Mockito.mock(XXSecurityZoneDao.class);
    XXGlobalStateDao xXGlobalStateDao = Mockito.mock(XXGlobalStateDao.class);
    Mockito.when(daoManager.getXXSecurityZoneDao()).thenReturn(xXSecurityZoneDao);
    Mockito.when(xXSecurityZoneDao.findByZoneId(securityZone.getId())).thenReturn(xxSecurityZone);
    Mockito.when(daoManager.getXXGlobalState()).thenReturn(xXGlobalStateDao);
    Mockito.doNothing().when(xXGlobalStateDao).onGlobalStateChange(RANGER_GLOBAL_STATE_NAME);
    Mockito.when(securityZoneService.update(securityZone)).thenReturn(updateSecurityZone);
    Mockito.doNothing().when(securityZoneRefUpdater).createNewZoneMappingForRefTable(updateSecurityZone);
    List<XXTrxLog> trxLogList = new ArrayList<XXTrxLog>();
    Mockito.doNothing().when(bizUtil).createTrxLog(trxLogList);
    RangerSecurityZone expectedSecurityZone = securityZoneDBStore.updateSecurityZoneById(securityZone);
    Assert.assertNotNull(xxSecurityZone);
    Assert.assertEquals(updateSecurityZone.getId(), expectedSecurityZone.getId());
    Mockito.verify(daoManager).getXXSecurityZoneDao();
    Mockito.verify(daoManager).getXXGlobalState();
    Mockito.verify(securityZoneService).update(securityZone);
}
Also used : RangerSecurityZone(org.apache.ranger.plugin.model.RangerSecurityZone) XXSecurityZoneDao(org.apache.ranger.db.XXSecurityZoneDao) XXGlobalStateDao(org.apache.ranger.db.XXGlobalStateDao) ArrayList(java.util.ArrayList) XXTrxLog(org.apache.ranger.entity.XXTrxLog) XXSecurityZone(org.apache.ranger.entity.XXSecurityZone) Test(org.junit.Test)

Aggregations

XXGlobalStateDao (org.apache.ranger.db.XXGlobalStateDao)11 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)8 XXPortalUser (org.apache.ranger.entity.XXPortalUser)4 XXSecurityZone (org.apache.ranger.entity.XXSecurityZone)4 XXTrxLog (org.apache.ranger.entity.XXTrxLog)4 XXUserPermission (org.apache.ranger.entity.XXUserPermission)4 RangerSecurityZone (org.apache.ranger.plugin.model.RangerSecurityZone)4 VXPortalUser (org.apache.ranger.view.VXPortalUser)4 VXString (org.apache.ranger.view.VXString)4 VXUser (org.apache.ranger.view.VXUser)4 Date (java.util.Date)3 XXModuleDefDao (org.apache.ranger.db.XXModuleDefDao)3 XXSecurityZoneDao (org.apache.ranger.db.XXSecurityZoneDao)3 XXUserDao (org.apache.ranger.db.XXUserDao)3 XXUserPermissionDao (org.apache.ranger.db.XXUserPermissionDao)3 XXModuleDef (org.apache.ranger.entity.XXModuleDef)3 VXUserList (org.apache.ranger.view.VXUserList)3 HashSet (java.util.HashSet)2 UserSessionBase (org.apache.ranger.common.UserSessionBase)2