SecurityZoneDBStore implements SecurityZoneStore { @Override public void deleteSecurityZoneById(Long zoneId) throws Exception { RangerSecurityZone securityZone = securityZoneService.read(zoneId); daoMgr.getXXGlobalState().onGlobalStateChange(RANGER_GLOBAL_STATE_NAME); securityZoneRefUpdater.cleanupRefTables(securityZone); securityZoneService.delete(securityZone); List<XXTrxLog> trxLogList = securityZoneService.getTransactionLog(securityZone, null, "delete"); bizUtil.createTrxLog(trxLogList); }  void init(); @PostConstruct void initStore(); @Override RangerSecurityZone createSecurityZone(RangerSecurityZone securityZone); @Override RangerSecurityZone updateSecurityZoneById(RangerSecurityZone securityZone); @Override void deleteSecurityZoneByName(String zoneName); @Override void deleteSecurityZoneById(Long zoneId); @Override RangerSecurityZone getSecurityZone(Long id); @Override RangerSecurityZone getSecurityZoneByName(String name); @Override List<RangerSecurityZone> getSecurityZones(SearchFilter filter); @Override Map<String, RangerSecurityZone.RangerSecurityZoneService> getSecurityZonesForService(String serviceName);  }
@Test public void test4deleteSecurityZoneById() throws Exception { XXSecurityZone xxSecurityZone = new XXSecurityZone(); xxSecurityZone.setId(2L); RangerSecurityZone securityZone = new RangerSecurityZone(); securityZone.setId(2L); securityZone.setName("sz1"); XXGlobalStateDao xXGlobalStateDao = Mockito.mock(XXGlobalStateDao.class); Mockito.when(securityZoneService.read(securityZone.getId())).thenReturn(securityZone); Mockito.when(daoManager.getXXGlobalState()).thenReturn(xXGlobalStateDao); Mockito.doNothing().when(xXGlobalStateDao).onGlobalStateChange(RANGER_GLOBAL_STATE_NAME); Mockito.when(securityZoneRefUpdater.cleanupRefTables(securityZone)).thenReturn(true); Mockito.when(securityZoneService.delete(securityZone)).thenReturn(true); List<XXTrxLog> trxLogList = new ArrayList<XXTrxLog>(); Mockito.doNothing().when(bizUtil).createTrxLog(trxLogList); securityZoneDBStore.deleteSecurityZoneById(securityZone.getId()); }