@Test public void test11getSecurityZoneByWrongName() throws Exception { 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.getSecurityZoneByName(securityZone.getName()); Mockito.verify(xXSecurityZoneDao, times(1)).findByZoneName(securityZone.getName()); }
@Override public RangerSecurityZone getSecurityZoneByName(String name) throws Exception { XXSecurityZone xxSecurityZone = daoMgr.getXXSecurityZoneDao().findByZoneName(name); if (xxSecurityZone == null) { throw restErrorUtil.createRESTException("security-zone with name: " + name + " does not exist"); } return securityZoneService.read(xxSecurityZone.getId()); }
SecurityZoneDBStore implements SecurityZoneStore { @Override public RangerSecurityZone getSecurityZoneByName(String name) throws Exception { XXSecurityZone xxSecurityZone = daoMgr.getXXSecurityZoneDao().findByZoneName(name); if (xxSecurityZone == null) { throw restErrorUtil.createRESTException("security-zone with name: " + name + " does not exist"); } return securityZoneService.read(xxSecurityZone.getId()); } }
SecurityZoneDBStore implements SecurityZoneStore { @Override public RangerSecurityZone getSecurityZoneByName(String name) throws Exception { XXSecurityZone xxSecurityZone = daoMgr.getXXSecurityZoneDao().findByZoneName(name); if (xxSecurityZone == null) { throw restErrorUtil.createRESTException("security-zone with name: " + name + " does not exist"); } return securityZoneService.read(xxSecurityZone.getId()); }  }
SecurityZoneDBStore implements SecurityZoneStore { @Override public RangerSecurityZone getSecurityZoneByName(String name) throws Exception { XXSecurityZone xxSecurityZone = daoMgr.getXXSecurityZoneDao().findByZoneName(name); if (xxSecurityZone == null) { throw restErrorUtil.createRESTException("security-zone with name: " + name + " does not exist"); } return securityZoneService.read(xxSecurityZone.getId()); }  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 RangerSecurityZone getSecurityZoneByName(String name) throws Exception { XXSecurityZone xxSecurityZone = daoMgr.getXXSecurityZoneDao().findByZoneName(name); if (xxSecurityZone == null) { throw restErrorUtil.createRESTException("security-zone with name: " + name + " does not exist"); } return securityZoneService.read(xxSecurityZone.getId()); }  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);  }