SecurityZoneREST { @DELETE @Path("/zones/name/{name}") public void deleteSecurityZone(@PathParam("name") String zoneName) { if (LOG.isDebugEnabled()) { LOG.debug("==> deleteSecurityZone(name=" + zoneName + ")"); } try { ensureAdminAccess(); RangerSecurityZoneValidator validator = validatorFactory.getSecurityZoneValidator(svcStore, securityZoneStore); validator.validate(zoneName, RangerValidator.Action.DELETE); securityZoneStore.deleteSecurityZoneByName(zoneName); } catch(WebApplicationException excp) { throw excp; } catch(Throwable excp) { LOG.error("deleteSecurityZone(" + zoneName + ") failed", excp); throw restErrorUtil.createRESTException(excp.getMessage()); } if (LOG.isDebugEnabled()) { LOG.debug("<== deleteSecurityZone(name=" + zoneName + ")"); } }  @POST @Path("/zones") RangerSecurityZone createSecurityZone(RangerSecurityZone securityZone); @PUT @Path("/zones/{id}") RangerSecurityZone updateSecurityZone(@PathParam("id") Long zoneId,
                                                 RangerSecurityZone securityZone); @DELETE @Path("/zones/name/{name}") void deleteSecurityZone(@PathParam("name") String zoneName); @DELETE @Path("/zones/{id}") void deleteSecurityZone(@PathParam("id") Long zoneId); @GET @Path("/zones/name/{name}") RangerSecurityZone getSecurityZone(@PathParam("name") String zoneName); @GET @Path("/zones/{id}") RangerSecurityZone getSecurityZone(@PathParam("id") Long id); @GET @Path("/zones") RangerSecurityZoneList getAllZones(@Context HttpServletRequest request);  }
@Test public void testDeleteSecurityZoneById() throws Exception { RangerSecurityZone securityZone = createRangerSecurityZone(); Long securityZoneId = 2L; securityZone.setId(securityZoneId); when(rangerBizUtil.isAdmin()).thenReturn(true); when(validatorFactory.getSecurityZoneValidator(svcStore, securityZoneStore)).thenReturn(validator); doNothing().when(validator).validate(securityZoneId, RangerValidator.Action.DELETE); securityZoneREST.deleteSecurityZone(securityZoneId); verify(securityZoneStore, times(1)).deleteSecurityZoneById(securityZoneId); }
@Test public void testDeleteSecurityZoneByName() throws Exception { RangerSecurityZone securityZone = createRangerSecurityZone(); Long securityZoneId = 2L; securityZone.setId(securityZoneId); String securityZoneName = securityZone.getName(); when(rangerBizUtil.isAdmin()).thenReturn(true); when(validatorFactory.getSecurityZoneValidator(svcStore, securityZoneStore)).thenReturn(validator); doNothing().when(validator).validate(securityZoneName, RangerValidator.Action.DELETE); securityZoneREST.deleteSecurityZone(securityZoneName); verify(securityZoneStore, times(1)).deleteSecurityZoneByName(securityZoneName); }