@Test public void test10deleteSecurityZoneByWrongName() throws Exception { XXSecurityZone xxSecurityZone = new XXSecurityZone(); xxSecurityZone.setId(2L); RangerSecurityZone securityZone = new RangerSecurityZone(); securityZone.setId(2L); securityZone.setName("sz1"); XXSecurityZoneDao xXSecurityZoneDao = Mockito.mock(XXSecurityZoneDao.class); Mockito.when(daoManager.getXXSecurityZoneDao()).thenReturn(xXSecurityZoneDao); Mockito.when(xXSecurityZoneDao.findByZoneName(securityZone.getName())).thenReturn(null); Mockito.when(restErrorUtil.createRESTException(Mockito.anyString())).thenThrow(new WebApplicationException()); thrown.expect(WebApplicationException.class); securityZoneDBStore.deleteSecurityZoneByName(securityZone.getName()); Mockito.verify(xXSecurityZoneDao, times(1)).findByZoneName(xxSecurityZone.getName()); }
@Override public void deleteSecurityZoneByName(String zoneName) throws Exception { XXSecurityZone xxSecurityZone = daoMgr.getXXSecurityZoneDao().findByZoneName(zoneName); if (xxSecurityZone == null) { throw restErrorUtil.createRESTException("security-zone with name: " + zoneName + " does not exist"); } RangerSecurityZone securityZone = securityZoneService.read(xxSecurityZone.getId()); daoMgr.getXXGlobalState().onGlobalStateChange(RANGER_GLOBAL_STATE_NAME); securityZoneRefUpdater.cleanupRefTables(securityZone); securityZoneService.delete(securityZone); List<XXTrxLog> trxLogList = securityZoneService.getTransactionLog(securityZone, null, "delete"); bizUtil.createTrxLog(trxLogList); }
SecurityZoneDBStore implements SecurityZoneStore { @Override public void deleteSecurityZoneByName(String zoneName) throws Exception { XXSecurityZone xxSecurityZone = daoMgr.getXXSecurityZoneDao().findByZoneName(zoneName); if (xxSecurityZone == null) { throw restErrorUtil.createRESTException("security-zone with name: " + zoneName + " does not exist"); } RangerSecurityZone securityZone = securityZoneService.read(xxSecurityZone.getId()); daoMgr.getXXGlobalState().onGlobalStateChange(RANGER_GLOBAL_STATE_NAME); securityZoneRefUpdater.cleanupRefTables(securityZone); securityZoneService.delete(securityZone); List<XXTrxLog> trxLogList = securityZoneService.getTransactionLog(securityZone, null, "delete"); bizUtil.createTrxLog(trxLogList); } }
SecurityZoneDBStore implements SecurityZoneStore { @Override public void deleteSecurityZoneByName(String zoneName) throws Exception { XXSecurityZone xxSecurityZone = daoMgr.getXXSecurityZoneDao().findByZoneName(zoneName); if (xxSecurityZone == null) { throw restErrorUtil.createRESTException("security-zone with name: " + zoneName + " does not exist"); } RangerSecurityZone securityZone = securityZoneService.read(xxSecurityZone.getId()); daoMgr.getXXGlobalState().onGlobalStateChange(RANGER_GLOBAL_STATE_NAME); securityZoneRefUpdater.cleanupRefTables(securityZone); securityZoneService.delete(securityZone); List<XXTrxLog> trxLogList = securityZoneService.getTransactionLog(securityZone, null, "delete"); bizUtil.createTrxLog(trxLogList); }  }
SecurityZoneDBStore implements SecurityZoneStore { @Override public void deleteSecurityZoneByName(String zoneName) throws Exception { XXSecurityZone xxSecurityZone = daoMgr.getXXSecurityZoneDao().findByZoneName(zoneName); if (xxSecurityZone == null) { throw restErrorUtil.createRESTException("security-zone with name: " + zoneName + " does not exist"); } RangerSecurityZone securityZone = securityZoneService.read(xxSecurityZone.getId()); 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); }
SecurityZoneDBStore implements SecurityZoneStore { @Override public void deleteSecurityZoneByName(String zoneName) throws Exception { XXSecurityZone xxSecurityZone = daoMgr.getXXSecurityZoneDao().findByZoneName(zoneName); if (xxSecurityZone == null) { throw restErrorUtil.createRESTException("security-zone with name: " + zoneName + " does not exist"); } RangerSecurityZone securityZone = securityZoneService.read(xxSecurityZone.getId()); 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);  }