@Test public void test5getSecurityZoneByName() throws Exception { XXSecurityZone xxSecurityZone = new XXSecurityZone(); xxSecurityZone.setId(2L); xxSecurityZone.setName("sz1"); RangerSecurityZone securityZone = new RangerSecurityZone(); securityZone.setId(2L); securityZone.setName("sz1"); RangerSecurityZone createdSecurityZone = new RangerSecurityZone(); createdSecurityZone.setId(2L); createdSecurityZone.setName("sz1"); XXSecurityZoneDao xXSecurityZoneDao = Mockito.mock(XXSecurityZoneDao.class); Mockito.when(daoManager.getXXSecurityZoneDao()).thenReturn(xXSecurityZoneDao); Mockito.when(xXSecurityZoneDao.findByZoneName(securityZone.getName())).thenReturn(xxSecurityZone); Mockito.when(securityZoneService.read(securityZone.getId())).thenReturn(createdSecurityZone); RangerSecurityZone expectedSecurityZone = securityZoneDBStore.getSecurityZoneByName(securityZone.getName()); Assert.assertNotNull(xxSecurityZone); Assert.assertEquals(createdSecurityZone.getName(), expectedSecurityZone.getName()); Mockito.verify(securityZoneService).read(securityZone.getId()); }
@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);  }