ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sneet...@apache.org
Subject [2/2] git commit: ARGUS-102:Add JUnit Test Cases
Date Sun, 12 Oct 2014 16:51:22 GMT
ARGUS-102:Add JUnit Test Cases

Signed-off-by: sneethiraj <sneethir@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-argus/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-argus/commit/65b6d83d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/65b6d83d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/65b6d83d

Branch: refs/heads/master
Commit: 65b6d83d993980dc46037a0078d8368d08026bca
Parents: 38ed203
Author: vperiasamy <vperiasamy@hortonworks.com>
Authored: Sat Oct 11 12:49:42 2014 -0400
Committer: sneethiraj <sneethir@apache.org>
Committed: Sun Oct 12 12:42:38 2014 -0400

----------------------------------------------------------------------
 pom.xml                                         |    4 +-
 security-admin/pom.xml                          |   11 +-
 .../java/com/xasecure/biz/TestAssetMgr.java     |  723 +++++++++++++
 .../test/java/com/xasecure/biz/TestUserMgr.java |  557 ++++++++++
 .../java/com/xasecure/biz/TestXABizUtil.java    |  530 ++++++++++
 .../java/com/xasecure/biz/TestXUserMgr.java     |  382 +++++++
 .../java/com/xasecure/common/TestDateUtil.java  |   64 ++
 .../java/com/xasecure/common/TestJSONUtil.java  |   55 +
 .../com/xasecure/common/TestPropertiesUtil.java |   96 ++
 .../com/xasecure/common/TestStringUtil.java     |  177 ++++
 .../com/xasecure/common/TestXAConfigUtil.java   |   38 +
 .../java/com/xasecure/rest/TestPublicAPIs.java  | 1000 ++++--------------
 .../java/com/xasecure/util/TestXAEnumUtil.java  |  108 ++
 13 files changed, 2938 insertions(+), 807 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/65b6d83d/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 97c0801..df72528 100644
--- a/pom.xml
+++ b/pom.xml
@@ -80,6 +80,7 @@
 		<jericho.html.version>3.3</jericho.html.version>
 		<jersey-bundle.version>1.17.1</jersey-bundle.version>
 		<junit.version>4.11</junit.version>
+		<mockito.version>1.8.4</mockito.version>
 		<knox.gateway.version>0.5.0-SNAPSHOT</knox.gateway.version>
 		<local.lib.dir>${project.basedir}/../lib/local</local.lib.dir>
 		<log4j.version>1.2.17</log4j.version>
@@ -105,6 +106,7 @@
 		<distMgmtStagingId>apache.staging.https</distMgmtStagingId>
     	<distMgmtStagingName>Apache Release Distribution Repository</distMgmtStagingName>
     	<distMgmtStagingUrl>https://repository.apache.org/service/local/staging/deploy/maven2</distMgmtStagingUrl>
+        <skipTests>true</skipTests>
   </properties>
   <profiles>
      <profile>
@@ -168,7 +170,7 @@
         <artifactId>maven-surefire-plugin</artifactId>
         <version>2.17</version>
         <configuration>
-          <skipTests>true</skipTests>
+          <skipTests>${skipTests}</skipTests>
         </configuration>
       </plugin>
 <!--

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/65b6d83d/security-admin/pom.xml
----------------------------------------------------------------------
diff --git a/security-admin/pom.xml b/security-admin/pom.xml
index 6ee7e9a..474098f 100644
--- a/security-admin/pom.xml
+++ b/security-admin/pom.xml
@@ -236,6 +236,11 @@
 		    <version>${junit.version}</version>
 		</dependency>
 		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-all</artifactId>
+			<version>${mockito.version}</version>
+		</dependency>
+		<dependency>
 		    <groupId>com.googlecode.log4jdbc</groupId>
 		    <artifactId>log4jdbc</artifactId>
 		    <version>${googlecode.log4jdbc.version}</version>
@@ -419,12 +424,12 @@
 			</configuration>
 		</plugin>
 
-		<!-- <plugin>
+		<plugin>
 			<groupId>org.apache.maven.plugins</groupId>
 			<artifactId>maven-surefire-plugin</artifactId>
 			<version>2.9</version>
 			<configuration>
-				<skipTests>false</skipTests>
+				<skipTests>${skipTests}</skipTests>
 				<additionalClasspathElements>
 					<additionalClasspathElement>${project.basedir}/src/main/webapp/WEB-INF</additionalClasspathElement>
 					<additionalClasspathElement>${project.basedir}/src/main/webapp/META-INF</additionalClasspathElement>
@@ -437,7 +442,7 @@
 					<version>2.17</version>
 				</dependency>
 			</dependencies>
-		</plugin> -->
+		</plugin>
 
 	</plugins>
 </pluginManagement>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/65b6d83d/security-admin/src/test/java/com/xasecure/biz/TestAssetMgr.java
----------------------------------------------------------------------
diff --git a/security-admin/src/test/java/com/xasecure/biz/TestAssetMgr.java b/security-admin/src/test/java/com/xasecure/biz/TestAssetMgr.java
new file mode 100644
index 0000000..59e127d
--- /dev/null
+++ b/security-admin/src/test/java/com/xasecure/biz/TestAssetMgr.java
@@ -0,0 +1,723 @@
+package com.xasecure.biz;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.WebApplicationException;
+
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import com.xasecure.common.AppConstants;
+import com.xasecure.common.ContextUtil;
+import com.xasecure.common.JSONUtil;
+import com.xasecure.common.MessageEnums;
+import com.xasecure.common.RESTErrorUtil;
+import com.xasecure.common.SearchCriteria;
+import com.xasecure.common.StringUtil;
+import com.xasecure.common.UserSessionBase;
+import com.xasecure.common.XACommonEnums;
+import com.xasecure.db.XADaoManager;
+import com.xasecure.db.XXAssetDao;
+import com.xasecure.db.XXResourceDao;
+import com.xasecure.db.XXUserDao;
+import com.xasecure.entity.XXAsset;
+import com.xasecure.entity.XXPortalUser;
+import com.xasecure.entity.XXResource;
+import com.xasecure.entity.XXUser;
+import com.xasecure.security.context.XAContextHolder;
+import com.xasecure.security.context.XASecurityContext;
+import com.xasecure.service.XAssetService;
+import com.xasecure.service.XAuditMapService;
+import com.xasecure.service.XPermMapService;
+import com.xasecure.service.XPolicyService;
+import com.xasecure.service.XResourceService;
+import com.xasecure.service.XUserService;
+import com.xasecure.view.VXAsset;
+import com.xasecure.view.VXAuditMap;
+import com.xasecure.view.VXAuditMapList;
+import com.xasecure.view.VXPermMap;
+import com.xasecure.view.VXPermMapList;
+import com.xasecure.view.VXResource;
+import com.xasecure.view.VXResponse;
+import com.xasecure.view.VXUser;
+
+@RunWith(MockitoJUnitRunner.class)
+public class TestAssetMgr {
+	
+	private Long id = 1L;
+	private static Long  hiveAssetId, knoxAssetId, hbaseAssetId, stormAssetId ;
+	
+	@InjectMocks
+	AssetMgr assetMgr = new AssetMgr();
+	
+	@Mock
+	RESTErrorUtil restErrorUtil;
+	
+	@Mock
+	XAssetService xAssetService;
+	
+	@Mock
+	JSONUtil jsonUtil;
+	
+	@Mock
+	StringUtil stringUtil;
+	
+	@Mock
+	XADaoManager xADaoManager;
+	
+	@Mock
+	XResourceService xResourceService;
+	
+	@Mock
+	XUserService xUserService;
+	
+	@Mock
+	XPermMapService xPermMapService;
+	
+	@Mock
+	XAuditMapService xAuditMapService;
+	
+	@Mock
+	XABizUtil xaBizUtil;
+	
+	@Mock 
+	AssetConnectionMgr assetConnectionMgr;
+	
+	@Mock
+	XPolicyService xPolicyService;
+	
+	@Rule
+	public ExpectedException thrown = ExpectedException.none();
+	
+	public void setup(){
+		XASecurityContext context = new XASecurityContext();
+		context.setUserSession(new UserSessionBase());
+		XAContextHolder.setSecurityContext(context);		
+		UserSessionBase currentUserSession = ContextUtil.getCurrentUserSession();
+		currentUserSession.setUserAdmin(true);
+	}
+	
+	@Test
+	public void testCreateXAssetForNoUserSession(){
+		XASecurityContext context = new XASecurityContext();
+		context.setUserSession(new UserSessionBase());
+		XAContextHolder.setSecurityContext(context);		
+		XXPortalUser portalUser = new XXPortalUser();
+		portalUser.setId(id);
+		UserSessionBase currentUserSession = ContextUtil.getCurrentUserSession();
+		currentUserSession.setXXPortalUser(portalUser);
+		currentUserSession.setUserAdmin(false);
+		WebApplicationException webApplicationException = new WebApplicationException();
+		
+		Mockito.when(restErrorUtil.createRESTException("Sorry, you don't have permission to perform the operation",MessageEnums.OPER_NOT_ALLOWED_FOR_ENTITY)).thenThrow(webApplicationException);
+		
+		thrown.expect(WebApplicationException.class);
+		String config = "{\"username\":\"admin\",\"password\":\"admin\",\"jdbc.driverClassName\":\"jdbcdrivernamefieldvalue\",\"jdbc.url\":\"jdbcurlfieldvalue\",\"commonNameForCertificate\":\"commonnameforcertification\"}";
+		VXAsset vXAsset = createVXAsset("Hdfs",1,config);
+		assetMgr.createXAsset(vXAsset);		
+		Mockito.verify(restErrorUtil).createRESTException("Sorry, you don't have permission to perform the operation",MessageEnums.OPER_NOT_ALLOWED_FOR_ENTITY);
+	}
+	
+	@Test	
+	public void testCreateXAssetForHdfs(){
+		setup();
+		String config = "{\"username\":\"admin\",\"password\":\"admin\",\"fs.default.name\":\"defaultnamevalue\",\"hadoop.security.authorization\":\"authvalue\",\"hadoop.security.authentication\":\"authenticationvalue\",\"hadoop.security.auth_to_local\":\"localvalue\",\"dfs.datanode.kerberos.principal\":\"principalvalue\",\"dfs.namenode.kerberos.principal\":\"namenodeprincipalvalue\",\"dfs.secondary.namenode.kerberos.principal\":\"secprincipalvalue\",\"commonNameForCertificate\":\"certificatevalue\"}";
+		VXAsset vXAsset = createVXAsset("Hdfs",1,config);
+		
+		String userName = "Test";
+		XXUser xxUser = new XXUser();
+		Mockito.when(xAssetService.getConfigWithEncryptedPassword(config,false)).thenReturn(config);
+		Mockito.when(xAssetService.createResource(vXAsset)).thenReturn(vXAsset);
+		Map<String,String> mapValue = new HashMap<String, String>();
+		mapValue.put("username", userName);
+		Mockito.when(jsonUtil.jsonToMap(config)).thenReturn(mapValue);
+		Mockito.when(stringUtil.getValidUserName(mapValue.get("username"))).thenReturn(userName);
+		VXResource vXResource = new VXResource();
+		vXResource.setPermMapList(new ArrayList<VXPermMap>());
+		vXResource.setAuditList(new ArrayList<VXAuditMap>());
+		Mockito.when(xResourceService.createResource((VXResource)Mockito.anyObject())).thenReturn(vXResource);
+		XXUserDao xxUserDao = Mockito.mock(XXUserDao.class);
+		Mockito.when(xADaoManager.getXXUser()).thenReturn(xxUserDao);
+		Mockito.when(xxUserDao.findByUserName(userName)).thenReturn(xxUser);
+		VXUser vxUser = new VXUser(); 
+		Mockito.when(xUserService.populateViewBean(xxUser)).thenReturn(vxUser);
+		Mockito.when(xPermMapService.createResource((VXPermMap)Mockito.anyObject())).thenReturn(null);
+		VXAuditMap vXAuditMap = new VXAuditMap();
+		Mockito.when(xAuditMapService.createResource((VXAuditMap)Mockito.anyObject())).thenReturn(vXAuditMap);
+		Mockito.when(xResourceService.readResource(vXResource.getId())).thenReturn(vXResource);
+		
+		VXAsset vXAssetChk = assetMgr.createXAsset(vXAsset);		
+		Assert.assertNotNull(vXAssetChk);
+		Assert.assertEquals(vXAsset.getName(), vXAssetChk.getName());	
+		
+		Mockito.when(xAssetService.readResource(vXAssetChk.getId())).thenReturn(vXAsset);
+		
+		VXAsset vXAssetDB = assetMgr.getXAsset(vXAssetChk.getId());
+		Assert.assertNotNull(vXAssetDB);
+		Assert.assertEquals(vXAssetDB.getName(), vXAssetChk.getName());
+		Assert.assertEquals(vXAssetDB.getAssetType(), vXAssetChk.getAssetType());
+		Assert.assertEquals(vXAssetDB.getActiveStatus(), vXAssetChk.getActiveStatus());
+		Assert.assertEquals(vXAssetDB.getDescription(), vXAssetChk.getDescription());
+		
+		String strUpd = "HdfsUpd"+getDateTimeForFileName();
+		vXAssetDB.setName(strUpd);
+		vXAssetDB.setDescription(strUpd);
+		vXAssetDB.setActiveStatus(0);
+		
+		XXAsset xxAsset = new XXAsset();
+		XXResourceDao xxResourceDao = Mockito.mock(XXResourceDao.class);
+		XXAssetDao xxAssetDao = Mockito.mock(XXAssetDao.class);
+		Mockito.when(xADaoManager.getXXAsset()).thenReturn(xxAssetDao);
+		Mockito.when(xxAssetDao.getById(vXAsset.getId())).thenReturn(xxAsset);
+		Mockito.when(xAssetService.updateResource((VXAsset)Mockito.anyObject())).thenReturn(vXAssetDB);
+		Mockito.when(xADaoManager.getXXResource()).thenReturn(xxResourceDao);
+		List<XXResource> lst = new ArrayList<XXResource>();
+		Mockito.when(xxResourceDao.findByResourceNameAndAssetIdAndRecursiveFlag(Mockito.anyString(),Mockito.anyLong(), Mockito.anyInt())).thenReturn(lst );
+		
+		VXAsset vxAssetUpd = assetMgr.updateXAsset(vXAssetDB);
+		Assert.assertEquals(vxAssetUpd.getName(), strUpd);
+		Assert.assertEquals(vxAssetUpd.getDescription(), strUpd);
+		Assert.assertEquals(0, vxAssetUpd.getActiveStatus());		
+		Assert.assertEquals(vxAssetUpd.getDescription(), strUpd);
+		hiveAssetId = vxAssetUpd.getId();
+	}
+	
+	@Test	
+	public void testCreateXAssetForHive(){
+		setup();
+		String config = "{\"username\":\"admin\",\"password\":\"admin\",\"jdbc.driverClassName\":\"jdbcdrivernamefieldvalue\",\"jdbc.url\":\"jdbcurlfieldvalue\",\"commonNameForCertificate\":\"commonnameforcertification\"}";
+		VXAsset vXAsset = createVXAsset("Hive",3,config);
+		
+		String userName = "Test";
+		XXUser xxUser = new XXUser();
+		Mockito.when(xAssetService.getConfigWithEncryptedPassword(config,false)).thenReturn(config);
+		Mockito.when(xAssetService.createResource(vXAsset)).thenReturn(vXAsset);
+		Map<String,String> mapValue = new HashMap<String, String>();
+		mapValue.put("username", userName);
+		Mockito.when(jsonUtil.jsonToMap(config)).thenReturn(mapValue);
+		Mockito.when(stringUtil.getValidUserName(mapValue.get("username"))).thenReturn(userName);
+		VXResource vXResource = new VXResource();
+		vXResource.setPermMapList(new ArrayList<VXPermMap>());
+		vXResource.setAuditList(new ArrayList<VXAuditMap>());
+		Mockito.when(xResourceService.createResource((VXResource)Mockito.anyObject())).thenReturn(vXResource);
+		XXUserDao xxUserDao = Mockito.mock(XXUserDao.class);
+		Mockito.when(xADaoManager.getXXUser()).thenReturn(xxUserDao);
+		Mockito.when(xxUserDao.findByUserName(userName)).thenReturn(xxUser);
+		VXUser vxUser = new VXUser(); 
+		Mockito.when(xUserService.populateViewBean(xxUser)).thenReturn(vxUser);
+		Mockito.when(xPermMapService.createResource((VXPermMap)Mockito.anyObject())).thenReturn(null);
+		VXAuditMap vXAuditMap = new VXAuditMap();
+		Mockito.when(xAuditMapService.createResource((VXAuditMap)Mockito.anyObject())).thenReturn(vXAuditMap);
+		Mockito.when(xResourceService.readResource(vXResource.getId())).thenReturn(vXResource);
+		
+		VXAsset vXAssetChk = assetMgr.createXAsset(vXAsset);
+		Assert.assertNotNull(vXAssetChk);
+		Assert.assertEquals(vXAsset.getName(), vXAssetChk.getName());
+		
+		Mockito.when(xAssetService.readResource(vXAssetChk.getId())).thenReturn(vXAsset);
+		
+		VXAsset vXAssetDB = assetMgr.getXAsset(vXAssetChk.getId());
+		Assert.assertNotNull(vXAssetDB);
+		Assert.assertEquals(vXAssetDB.getName(), vXAssetChk.getName());
+		Assert.assertEquals(vXAssetDB.getAssetType(), vXAssetChk.getAssetType());
+		Assert.assertEquals(vXAssetDB.getActiveStatus(), vXAssetChk.getActiveStatus());
+		Assert.assertEquals(vXAssetDB.getDescription(), vXAssetChk.getDescription());
+		hiveAssetId = vXAssetChk.getId();
+	}
+	
+	@Test
+	public void testCreateXAssetForHBase(){
+		setup();
+		String config = "{\"username\":\"admin\",\"password\":\"admin\",\"fs.default.name\":\"asdefaultnamevalue\",\"hadoop.security.authorization\":\"authvalue\",\"hadoop.security.authentication\":\"authenticationvalue\",\"hadoop.security.auth_to_local\":\"localvalue\",\"dfs.datanode.kerberos.principal\":\"principalvalue\",\"dfs.namenode.kerberos.principal\":\"namenodeprincipalvalue\",\"dfs.secondary.namenode.kerberos.principal\":\"secprincipalvalue\",\"hbase.master.kerberos.principal\":\"principalvalue\",\"hbase.rpc.engine\":\"enginevalue\",\"hbase.rpc.protection\":\"protectionvalue\",\"hbase.security.authentication\":\"authenvalue\",\"hbase.zookeeper.property.clientPort\":\"clientportvalue\",\"hbase.zookeeper.quorum\":\"quorumvalue\",\"zookeeper.znode.parent\":\"/hbase\",\"commonNameForCertificate\":\"certivalue\"}";
+		VXAsset vXAsset = createVXAsset("HBase",2,config);
+		
+		String userName = "Test";
+		XXUser xxUser = new XXUser();
+		Mockito.when(xAssetService.getConfigWithEncryptedPassword(config,false)).thenReturn(config);
+		Mockito.when(xAssetService.createResource(vXAsset)).thenReturn(vXAsset);
+		Map<String,String> mapValue = new HashMap<String, String>();
+		mapValue.put("username", userName);
+		Mockito.when(jsonUtil.jsonToMap(config)).thenReturn(mapValue);
+		Mockito.when(stringUtil.getValidUserName(mapValue.get("username"))).thenReturn(userName);
+		VXResource vXResource = new VXResource();
+		vXResource.setPermMapList(new ArrayList<VXPermMap>());
+		vXResource.setAuditList(new ArrayList<VXAuditMap>());
+		Mockito.when(xResourceService.createResource((VXResource)Mockito.anyObject())).thenReturn(vXResource);
+		XXUserDao xxUserDao = Mockito.mock(XXUserDao.class);
+		Mockito.when(xADaoManager.getXXUser()).thenReturn(xxUserDao);
+		Mockito.when(xxUserDao.findByUserName(userName)).thenReturn(xxUser);
+		VXUser vxUser = new VXUser(); 
+		Mockito.when(xUserService.populateViewBean(xxUser)).thenReturn(vxUser);
+		Mockito.when(xPermMapService.createResource((VXPermMap)Mockito.anyObject())).thenReturn(null);
+		VXAuditMap vXAuditMap = new VXAuditMap();
+		Mockito.when(xAuditMapService.createResource((VXAuditMap)Mockito.anyObject())).thenReturn(vXAuditMap);
+		Mockito.when(xResourceService.readResource(vXResource.getId())).thenReturn(vXResource);
+		
+		VXAsset vXAssetChk = assetMgr.createXAsset(vXAsset);
+		Assert.assertNotNull(vXAssetChk);
+		Assert.assertEquals(vXAsset.getName(), vXAssetChk.getName());
+		
+		Mockito.when(xAssetService.readResource(vXAssetChk.getId())).thenReturn(vXAsset);
+		
+		VXAsset vXAssetDB = assetMgr.getXAsset(vXAssetChk.getId());
+		Assert.assertNotNull(vXAssetDB);
+		Assert.assertEquals(vXAssetDB.getName(), vXAssetChk.getName());
+		Assert.assertEquals(vXAssetDB.getAssetType(), vXAssetChk.getAssetType());
+		Assert.assertEquals(vXAssetDB.getActiveStatus(), vXAssetChk.getActiveStatus());
+		Assert.assertEquals(vXAssetDB.getDescription(), vXAssetChk.getDescription());
+		hbaseAssetId = vXAssetChk.getId();
+	}
+	
+	@Test
+	public void testCreateXAssetForKnox(){
+		setup();
+		String config = "{\"username\":\"admin\",\"password\":\"admin\",\"knox.url\":\"urltest\",\"commonNameForCertificate\":\"certvalue\"}";
+		VXAsset vXAsset = createVXAsset("Knox",5,config);
+		
+		String userName = "Test";
+		XXUser xxUser = new XXUser();
+		Mockito.when(xAssetService.getConfigWithEncryptedPassword(config,false)).thenReturn(config);
+		Mockito.when(xAssetService.createResource(vXAsset)).thenReturn(vXAsset);
+		Map<String,String> mapValue = new HashMap<String, String>();
+		mapValue.put("username", userName);
+		Mockito.when(jsonUtil.jsonToMap(config)).thenReturn(mapValue);
+		Mockito.when(stringUtil.getValidUserName(mapValue.get("username"))).thenReturn(userName);
+		VXResource vXResource = new VXResource();
+		vXResource.setPermMapList(new ArrayList<VXPermMap>());
+		vXResource.setAuditList(new ArrayList<VXAuditMap>());
+		Mockito.when(xResourceService.createResource((VXResource)Mockito.anyObject())).thenReturn(vXResource);
+		XXUserDao xxUserDao = Mockito.mock(XXUserDao.class);
+		Mockito.when(xADaoManager.getXXUser()).thenReturn(xxUserDao);
+		Mockito.when(xxUserDao.findByUserName(userName)).thenReturn(xxUser);
+		VXUser vxUser = new VXUser(); 
+		Mockito.when(xUserService.populateViewBean(xxUser)).thenReturn(vxUser);
+		Mockito.when(xPermMapService.createResource((VXPermMap)Mockito.anyObject())).thenReturn(null);
+		VXAuditMap vXAuditMap = new VXAuditMap();
+		Mockito.when(xAuditMapService.createResource((VXAuditMap)Mockito.anyObject())).thenReturn(vXAuditMap);
+		Mockito.when(xResourceService.readResource(vXResource.getId())).thenReturn(vXResource);
+		
+		VXAsset vXAssetChk = assetMgr.createXAsset(vXAsset);
+		Assert.assertNotNull(vXAssetChk);
+		Assert.assertEquals(vXAsset.getName(), vXAssetChk.getName());
+		
+		Mockito.when(xAssetService.readResource(vXAssetChk.getId())).thenReturn(vXAsset);
+		
+		VXAsset vXAssetDB = assetMgr.getXAsset(vXAssetChk.getId());
+		Assert.assertNotNull(vXAssetDB);
+		Assert.assertEquals(vXAssetDB.getName(), vXAssetChk.getName());
+		Assert.assertEquals(vXAssetDB.getAssetType(), vXAssetChk.getAssetType());
+		Assert.assertEquals(vXAssetDB.getActiveStatus(), vXAssetChk.getActiveStatus());
+		Assert.assertEquals(vXAssetDB.getDescription(), vXAssetChk.getDescription());
+		knoxAssetId = vXAssetChk.getId();
+	}
+	
+	@Test
+	public void testCreateXAssetForStorm(){
+		setup();
+		String config = "{\"username\":\"admin\",\"password\":\"admin\",\"nimbus.url\":\"urlvalue\",\"commonNameForCertificate\":\"certvalue\"}";
+		VXAsset vXAsset = createVXAsset("Storm",6,config);
+		
+		String userName = "Test";
+		XXUser xxUser = new XXUser();
+		Mockito.when(xAssetService.getConfigWithEncryptedPassword(config,false)).thenReturn(config);
+		Mockito.when(xAssetService.createResource(vXAsset)).thenReturn(vXAsset);
+		Map<String,String> mapValue = new HashMap<String, String>();
+		mapValue.put("username", userName);
+		Mockito.when(jsonUtil.jsonToMap(config)).thenReturn(mapValue);
+		Mockito.when(stringUtil.getValidUserName(mapValue.get("username"))).thenReturn(userName);
+		VXResource vXResource = new VXResource();
+		vXResource.setPermMapList(new ArrayList<VXPermMap>());
+		vXResource.setAuditList(new ArrayList<VXAuditMap>());
+		Mockito.when(xResourceService.createResource((VXResource)Mockito.anyObject())).thenReturn(vXResource);
+		XXUserDao xxUserDao = Mockito.mock(XXUserDao.class);
+		Mockito.when(xADaoManager.getXXUser()).thenReturn(xxUserDao);
+		Mockito.when(xxUserDao.findByUserName(userName)).thenReturn(xxUser);
+		VXUser vxUser = new VXUser(); 
+		Mockito.when(xUserService.populateViewBean(xxUser)).thenReturn(vxUser);
+		Mockito.when(xPermMapService.createResource((VXPermMap)Mockito.anyObject())).thenReturn(null);
+		VXAuditMap vXAuditMap = new VXAuditMap();
+		Mockito.when(xAuditMapService.createResource((VXAuditMap)Mockito.anyObject())).thenReturn(vXAuditMap);
+		Mockito.when(xResourceService.readResource(vXResource.getId())).thenReturn(vXResource);
+		
+		VXAsset vXAssetChk = assetMgr.createXAsset(vXAsset);
+		Assert.assertNotNull(vXAssetChk);
+		Assert.assertEquals(vXAsset.getName(), vXAssetChk.getName());
+		
+		Mockito.when(xAssetService.readResource(vXAssetChk.getId())).thenReturn(vXAsset);
+		
+		VXAsset vXAssetDB = assetMgr.getXAsset(vXAssetChk.getId());
+		Assert.assertNotNull(vXAssetDB);
+		Assert.assertEquals(vXAssetDB.getName(), vXAssetChk.getName());
+		Assert.assertEquals(vXAssetDB.getAssetType(), vXAssetChk.getAssetType());
+		Assert.assertEquals(vXAssetDB.getActiveStatus(), vXAssetChk.getActiveStatus());
+		Assert.assertEquals(vXAssetDB.getDescription(), vXAssetChk.getDescription());
+		stormAssetId = vXAssetChk.getId();
+	}
+	
+	@Test
+	public void testXResourceCRUDForHive() throws JsonGenerationException, JsonMappingException, IOException{
+		setup();
+		Long assetId = hiveAssetId;
+		int assetType = AppConstants.ASSET_HIVE;
+		int resourceType = AppConstants.RESOURCE_COLUMN;
+		VXResource vXResource = createVXResource("Hive", assetId, assetType, resourceType);
+		
+		vXResource.setPermMapList(new ArrayList<VXPermMap>());
+		vXResource.setAuditList(new ArrayList<VXAuditMap>());
+		XXAssetDao xxAssetDao = Mockito.mock(XXAssetDao.class);
+		XXAsset xxAsset = new XXAsset();
+				
+		VXResponse vXResponse = new VXResponse();
+		Mockito.when(xADaoManager.getXXAsset()).thenReturn(xxAssetDao);
+		Mockito.when(xxAssetDao.getById(assetId)).thenReturn(xxAsset);
+		Mockito.when(stringUtil.split(vXResource.getName(), ",")).thenReturn(new String[0]);
+		Mockito.when(xaBizUtil.hasPermission(vXResource,AppConstants.XA_PERM_TYPE_ADMIN)).thenReturn(vXResponse);
+		Mockito.when(xResourceService.createResource(vXResource)).thenReturn(vXResource);
+		
+		VXResource vXResourceChk = assetMgr.createXResource(vXResource);
+		Assert.assertNotNull(vXResourceChk);
+		Assert.assertEquals(vXResourceChk.getAssetType(), AppConstants.ASSET_HIVE);
+		
+		Mockito.when(xResourceService.readResource(vXResourceChk.getId())).thenReturn(vXResource);
+		
+		VXResource vXResourceChkDb = assetMgr.getXResource(vXResourceChk.getId());
+		Assert.assertNotNull(vXResourceChkDb);
+		Assert.assertEquals(vXResourceChkDb.getAssetType(), AppConstants.ASSET_HIVE);
+		Assert.assertEquals(vXResourceChkDb.getResourceType(), resourceType);
+		Assert.assertEquals(vXResourceChkDb.getPolicyName(), vXResourceChk.getPolicyName());
+		Assert.assertEquals(vXResourceChkDb.getAssetName(), vXResourceChk.getAssetName());
+		Assert.assertEquals(vXResourceChkDb.getResourceStatus(), vXResourceChk.getResourceStatus());
+				
+		Mockito.when(xResourceService.readResource(vXResourceChk.getId())).thenReturn(vXResource);
+		Mockito.when(jsonUtil.writeJsonToFile(vXResource, vXResource.getName())).thenReturn(new File(vXResource.getName()));
+		
+		File fileChk = assetMgr.getXResourceFile(vXResourceChk.getId(),"json");
+		Assert.assertNotNull(fileChk);
+		
+		String policyNameUpd = "HiveUpd_"+getDateTimeForFileName();
+		vXResourceChkDb.setPolicyName(policyNameUpd);
+		vXResourceChkDb.setDatabases(policyNameUpd);
+		
+		XXResourceDao xxResourceDao = Mockito.mock(XXResourceDao.class);
+		XXResource xxResource = new XXResource();
+		Mockito.when(xResourceService.updateResource(vXResourceChkDb)).thenReturn(vXResourceChkDb);
+		Mockito.when(xADaoManager.getXXResource()).thenReturn(xxResourceDao);
+		Mockito.when(xxResourceDao.getById(vXResource.getId())).thenReturn(xxResource);
+		
+		VXResource vXResourceUpd = assetMgr.updateXResource(vXResourceChkDb);
+		Assert.assertNotNull(vXResourceUpd);
+		Assert.assertEquals(vXResourceUpd.getPolicyName(), policyNameUpd);
+		Assert.assertEquals(vXResourceUpd.getDatabases(), policyNameUpd);
+		
+		VXPermMapList vXPermMapList = new VXPermMapList();
+		Mockito.when(xPermMapService.searchXPermMaps((SearchCriteria)Mockito.anyObject())).thenReturn(vXPermMapList);
+		VXAuditMapList vXAuditMapsList = new VXAuditMapList(); 
+		Mockito.when(xAuditMapService.searchXAuditMaps((SearchCriteria)Mockito.anyObject())).thenReturn(vXAuditMapsList);
+		
+		assetMgr.deleteXResource(vXResourceChkDb.getId(), true);				
+	}
+	
+	@Test
+	public void testXResourceCRUDForHbase() throws JsonGenerationException, JsonMappingException, IOException{
+		setup();
+		Long assetId = hbaseAssetId;
+		int assetType = AppConstants.ASSET_HBASE;
+		int resourceType = AppConstants.RESOURCE_TABLE;
+		VXResource vXResource = createVXResource("Hbase", assetId, assetType, resourceType);
+		
+		vXResource.setPermMapList(new ArrayList<VXPermMap>());
+		vXResource.setAuditList(new ArrayList<VXAuditMap>());
+		XXAssetDao xxAssetDao = Mockito.mock(XXAssetDao.class);
+		XXAsset xxAsset = new XXAsset();
+		
+		xxAsset.setAssetType(AppConstants.ASSET_HBASE);
+		Mockito.when(xPolicyService.getResourceType(vXResource)).thenReturn(AppConstants.RESOURCE_PATH);
+		Mockito.when(stringUtil.split(vXResource.getTopologies(), ",")).thenReturn(new String[0]);
+		Mockito.when(xPolicyService.getResourceType(vXResource)).thenReturn(AppConstants.RESOURCE_TABLE);
+		Mockito.when(stringUtil.split(vXResource.getTables(), ",")).thenReturn(new String[0]);
+		Mockito.when(stringUtil.split("", ",")).thenReturn(new String[0]);
+		
+		VXResponse vXResponse = new VXResponse();
+		Mockito.when(xADaoManager.getXXAsset()).thenReturn(xxAssetDao);
+		Mockito.when(xxAssetDao.getById(assetId)).thenReturn(xxAsset);
+		Mockito.when(stringUtil.split(vXResource.getName(), ",")).thenReturn(new String[0]);
+		Mockito.when(xaBizUtil.hasPermission(vXResource,AppConstants.XA_PERM_TYPE_ADMIN)).thenReturn(vXResponse);
+		Mockito.when(xResourceService.createResource(vXResource)).thenReturn(vXResource);
+		
+		VXResource vXResourceChk = assetMgr.createXResource(vXResource);
+		Assert.assertNotNull(vXResourceChk);
+		Assert.assertEquals(vXResourceChk.getAssetType(), AppConstants.ASSET_HBASE);
+		
+		Mockito.when(xResourceService.readResource(vXResourceChk.getId())).thenReturn(vXResource);
+		
+		VXResource vXResourceChkDb = assetMgr.getXResource(vXResourceChk.getId());
+		Assert.assertNotNull(vXResourceChkDb);
+		Assert.assertEquals(vXResourceChkDb.getAssetType(), AppConstants.ASSET_HBASE);
+		Assert.assertEquals(vXResourceChkDb.getResourceType(), resourceType);
+		Assert.assertEquals(vXResourceChkDb.getPolicyName(), vXResourceChk.getPolicyName());
+		Assert.assertEquals(vXResourceChkDb.getAssetName(), vXResourceChk.getAssetName());
+		Assert.assertEquals(vXResourceChkDb.getResourceStatus(), vXResourceChk.getResourceStatus());
+		
+		Mockito.when(xResourceService.readResource(vXResourceChk.getId())).thenReturn(vXResource);
+		Mockito.when(jsonUtil.writeJsonToFile(vXResource, vXResource.getName())).thenReturn(new File(vXResource.getName()));
+		
+		File fileChk = assetMgr.getXResourceFile(vXResourceChk.getId(),"json");
+		Assert.assertNotNull(fileChk);
+		
+		String policyNameUpd = "HbaseUpd_"+getDateTimeForFileName();
+		vXResourceChkDb.setPolicyName(policyNameUpd);
+		vXResourceChkDb.setDatabases(policyNameUpd);
+		
+		XXResourceDao xxResourceDao = Mockito.mock(XXResourceDao.class);
+		XXResource xxResource = new XXResource();
+		Mockito.when(xResourceService.updateResource(vXResourceChkDb)).thenReturn(vXResourceChkDb);
+		Mockito.when(xADaoManager.getXXResource()).thenReturn(xxResourceDao);
+		Mockito.when(xxResourceDao.getById(vXResource.getId())).thenReturn(xxResource);
+		
+		VXResource vXResourceUpd = assetMgr.updateXResource(vXResourceChkDb);
+		Assert.assertNotNull(vXResourceUpd);
+		Assert.assertEquals(vXResourceUpd.getPolicyName(), policyNameUpd);
+		Assert.assertEquals(vXResourceUpd.getDatabases(), policyNameUpd);
+		
+		VXPermMapList vXPermMapList = new VXPermMapList();
+		Mockito.when(xPermMapService.searchXPermMaps((SearchCriteria)Mockito.anyObject())).thenReturn(vXPermMapList);
+		VXAuditMapList vXAuditMapsList = new VXAuditMapList(); 
+		Mockito.when(xAuditMapService.searchXAuditMaps((SearchCriteria)Mockito.anyObject())).thenReturn(vXAuditMapsList);
+		
+		assetMgr.deleteXResource(vXResourceChkDb.getId(), true);
+	}
+	
+	@Test
+	public void testXResourceCRUDForKnox() throws JsonGenerationException, JsonMappingException, IOException{
+		setup();
+		Long assetId = knoxAssetId;
+		int assetType = AppConstants.ASSET_KNOX;
+		int resourceType = AppConstants.RESOURCE_SERVICE_NAME;
+		VXResource vXResource = createVXResource("Knox", assetId, assetType, resourceType);
+		
+		vXResource.setPermMapList(new ArrayList<VXPermMap>());
+		vXResource.setAuditList(new ArrayList<VXAuditMap>());
+		XXAssetDao xxAssetDao = Mockito.mock(XXAssetDao.class);
+		XXAsset xxAsset = new XXAsset();
+		
+		xxAsset.setAssetType(AppConstants.ASSET_KNOX);
+		Mockito.when(xPolicyService.getResourceType(vXResource)).thenReturn(AppConstants.RESOURCE_PATH);
+		Mockito.when(stringUtil.split(vXResource.getTopologies(), ",")).thenReturn(new String[0]);
+		Mockito.when(xPolicyService.getResourceType(vXResource)).thenReturn(AppConstants.RESOURCE_TOPOLOGY);
+		Mockito.when(stringUtil.split("", ",")).thenReturn(new String[0]);
+		
+		VXResponse vXResponse = new VXResponse();
+		Mockito.when(xADaoManager.getXXAsset()).thenReturn(xxAssetDao);
+		Mockito.when(xxAssetDao.getById(assetId)).thenReturn(xxAsset);
+		Mockito.when(stringUtil.split(vXResource.getName(), ",")).thenReturn(new String[0]);
+		Mockito.when(xaBizUtil.hasPermission(vXResource,AppConstants.XA_PERM_TYPE_ADMIN)).thenReturn(vXResponse);
+		Mockito.when(xResourceService.createResource(vXResource)).thenReturn(vXResource);
+		
+		VXResource vXResourceChk = assetMgr.createXResource(vXResource);
+		Assert.assertNotNull(vXResourceChk);
+		Assert.assertEquals(vXResourceChk.getAssetType(), AppConstants.ASSET_KNOX);
+		
+		Mockito.when(xResourceService.readResource(vXResourceChk.getId())).thenReturn(vXResource);
+		
+		VXResource vXResourceChkDb = assetMgr.getXResource(vXResourceChk.getId());
+		Assert.assertNotNull(vXResourceChkDb);
+		Assert.assertEquals(vXResourceChkDb.getAssetType(), AppConstants.ASSET_KNOX);
+		Assert.assertEquals(vXResourceChkDb.getResourceType(), resourceType);
+		Assert.assertEquals(vXResourceChkDb.getPolicyName(), vXResourceChk.getPolicyName());
+		Assert.assertEquals(vXResourceChkDb.getAssetName(), vXResourceChk.getAssetName());
+		Assert.assertEquals(vXResourceChkDb.getResourceStatus(), vXResourceChk.getResourceStatus());
+		
+		Mockito.when(xResourceService.readResource(vXResourceChk.getId())).thenReturn(vXResource);
+		Mockito.when(jsonUtil.writeJsonToFile(vXResource, vXResource.getName())).thenReturn(new File(vXResource.getName()));
+		
+		File fileChk = assetMgr.getXResourceFile(vXResourceChk.getId(),"json");
+		Assert.assertNotNull(fileChk);
+		
+		String policyNameUpd = "KnoxUpd_"+getDateTimeForFileName();
+		vXResourceChkDb.setPolicyName(policyNameUpd);
+		vXResourceChkDb.setDatabases(policyNameUpd);
+		
+		XXResourceDao xxResourceDao = Mockito.mock(XXResourceDao.class);
+		XXResource xxResource = new XXResource();
+		Mockito.when(xResourceService.updateResource(vXResourceChkDb)).thenReturn(vXResourceChkDb);
+		Mockito.when(xADaoManager.getXXResource()).thenReturn(xxResourceDao);
+		Mockito.when(xxResourceDao.getById(vXResource.getId())).thenReturn(xxResource);
+		
+		VXResource vXResourceUpd = assetMgr.updateXResource(vXResourceChkDb);
+		Assert.assertNotNull(vXResourceUpd);
+		Assert.assertEquals(vXResourceUpd.getPolicyName(), policyNameUpd);
+		Assert.assertEquals(vXResourceUpd.getDatabases(), policyNameUpd);
+		
+		VXPermMapList vXPermMapList = new VXPermMapList();
+		Mockito.when(xPermMapService.searchXPermMaps((SearchCriteria)Mockito.anyObject())).thenReturn(vXPermMapList);
+		VXAuditMapList vXAuditMapsList = new VXAuditMapList(); 
+		Mockito.when(xAuditMapService.searchXAuditMaps((SearchCriteria)Mockito.anyObject())).thenReturn(vXAuditMapsList);
+		
+		assetMgr.deleteXResource(vXResourceChkDb.getId(), true);		
+	}
+	
+	@Test
+	public void testXResourceCRUDForStorm() throws JsonGenerationException, JsonMappingException, IOException{
+		setup();
+		Long assetId = stormAssetId;
+		int assetType = AppConstants.ASSET_STORM;
+		int resourceType = AppConstants.RESOURCE_SERVICE_NAME;
+		VXResource vXResource = createVXResource("Storm",assetId, assetType, resourceType);
+		
+		vXResource.setPermMapList(new ArrayList<VXPermMap>());
+		vXResource.setAuditList(new ArrayList<VXAuditMap>());
+		XXAssetDao xxAssetDao = Mockito.mock(XXAssetDao.class);
+		XXAsset xxAsset = new XXAsset();
+		
+		xxAsset.setAssetType(AppConstants.ASSET_STORM);
+		Mockito.when(xPolicyService.getResourceType(vXResource)).thenReturn(AppConstants.RESOURCE_PATH);
+		Mockito.when(stringUtil.split(vXResource.getTopologies(), ",")).thenReturn(new String[0]);
+		Mockito.when(xPolicyService.getResourceType(vXResource)).thenReturn(AppConstants.RESOURCE_TOPOLOGY);
+		Mockito.when(stringUtil.split("", ",")).thenReturn(new String[0]);
+		
+		VXResponse vXResponse = new VXResponse();
+		Mockito.when(xADaoManager.getXXAsset()).thenReturn(xxAssetDao);
+		Mockito.when(xxAssetDao.getById(assetId)).thenReturn(xxAsset);
+		Mockito.when(stringUtil.split(vXResource.getName(), ",")).thenReturn(new String[0]);
+		Mockito.when(xaBizUtil.hasPermission(vXResource,AppConstants.XA_PERM_TYPE_ADMIN)).thenReturn(vXResponse);
+		Mockito.when(xResourceService.createResource(vXResource)).thenReturn(vXResource);
+		
+		VXResource vXResourceChk = assetMgr.createXResource(vXResource);
+		Assert.assertNotNull(vXResourceChk);
+		Assert.assertEquals(vXResourceChk.getAssetType(), AppConstants.ASSET_STORM);
+		
+		Mockito.when(xResourceService.readResource(vXResourceChk.getId())).thenReturn(vXResource);
+		
+		VXResource vXResourceChkDb = assetMgr.getXResource(vXResourceChk.getId());
+		Assert.assertNotNull(vXResourceChkDb);
+		Assert.assertEquals(vXResourceChkDb.getAssetType(), AppConstants.ASSET_STORM);
+		Assert.assertEquals(vXResourceChkDb.getResourceType(), resourceType);
+		Assert.assertEquals(vXResourceChkDb.getPolicyName(), vXResourceChk.getPolicyName());
+		Assert.assertEquals(vXResourceChkDb.getAssetName(), vXResourceChk.getAssetName());
+		Assert.assertEquals(vXResourceChkDb.getResourceStatus(), vXResourceChk.getResourceStatus());
+		
+		Mockito.when(xResourceService.readResource(vXResourceChk.getId())).thenReturn(vXResource);
+		Mockito.when(jsonUtil.writeJsonToFile(vXResource, vXResource.getName())).thenReturn(new File(vXResource.getName()));
+		
+		File fileChk = assetMgr.getXResourceFile(vXResourceChk.getId(),"json");
+		Assert.assertNotNull(fileChk);
+		
+		String policyNameUpd = "StormUpd_"+getDateTimeForFileName();
+		vXResourceChkDb.setPolicyName(policyNameUpd);
+		vXResourceChkDb.setDatabases(policyNameUpd);
+		
+		XXResourceDao xxResourceDao = Mockito.mock(XXResourceDao.class);
+		XXResource xxResource = new XXResource();
+		Mockito.when(xResourceService.updateResource(vXResourceChkDb)).thenReturn(vXResourceChkDb);
+		Mockito.when(xADaoManager.getXXResource()).thenReturn(xxResourceDao);
+		Mockito.when(xxResourceDao.getById(vXResource.getId())).thenReturn(xxResource);
+		
+		VXResource vXResourceUpd = assetMgr.updateXResource(vXResourceChkDb);
+		Assert.assertNotNull(vXResourceUpd);
+		Assert.assertEquals(vXResourceUpd.getPolicyName(), policyNameUpd);
+		Assert.assertEquals(vXResourceUpd.getDatabases(), policyNameUpd);
+		
+		VXPermMapList vXPermMapList = new VXPermMapList();
+		Mockito.when(xPermMapService.searchXPermMaps((SearchCriteria)Mockito.anyObject())).thenReturn(vXPermMapList);
+		VXAuditMapList vXAuditMapsList = new VXAuditMapList(); 
+		Mockito.when(xAuditMapService.searchXAuditMaps((SearchCriteria)Mockito.anyObject())).thenReturn(vXAuditMapsList);
+		
+		assetMgr.deleteXResource(vXResourceChkDb.getId(), true);
+	}	
+	
+	@Test
+	public void testDeleteXAssetForHive(){
+		setup();
+		VXAsset vXAsset = new VXAsset();
+		vXAsset.setId(hiveAssetId);
+		vXAsset.setActiveStatus(XACommonEnums.STATUS_ENABLED);
+		Mockito.when(xAssetService.readResource(hiveAssetId)).thenReturn(vXAsset);
+		assetMgr.deleteXAsset(hiveAssetId, true);
+		Assert.assertEquals(vXAsset.getActiveStatus(), XACommonEnums.STATUS_DELETED);
+	} 
+	
+	@Test
+	public void testDeleteXAssetForHbase(){
+		setup();
+		VXAsset vXAsset = new VXAsset();
+		vXAsset.setId(hbaseAssetId);
+		vXAsset.setActiveStatus(XACommonEnums.STATUS_ENABLED);
+		Mockito.when(xAssetService.readResource(hiveAssetId)).thenReturn(vXAsset);
+		assetMgr.deleteXAsset(hbaseAssetId, true);
+		Assert.assertEquals(vXAsset.getActiveStatus(), XACommonEnums.STATUS_DELETED);
+	}
+	
+	@Test
+	public void testDeleteXAssetForKnox(){
+		setup();
+		VXAsset vXAsset = new VXAsset();
+		vXAsset.setId(knoxAssetId);
+		vXAsset.setActiveStatus(XACommonEnums.STATUS_ENABLED);
+		Mockito.when(xAssetService.readResource(hiveAssetId)).thenReturn(vXAsset);
+		assetMgr.deleteXAsset(knoxAssetId, true);
+		Assert.assertEquals(vXAsset.getActiveStatus(), XACommonEnums.STATUS_DELETED);
+	}
+	
+	@Test
+	public void testDeleteXAssetForStorm(){
+		setup();
+		VXAsset vXAsset = new VXAsset();
+		vXAsset.setId(stormAssetId);
+		vXAsset.setActiveStatus(XACommonEnums.STATUS_ENABLED);
+		Mockito.when(xAssetService.readResource(hiveAssetId)).thenReturn(vXAsset);
+		assetMgr.deleteXAsset(stormAssetId, true);
+		Assert.assertEquals(vXAsset.getActiveStatus(), XACommonEnums.STATUS_DELETED);
+	}
+	
+	private VXResource createVXResource(String assetTypeName, Long assetId, int assetType, int resourceType){
+		VXResource vxResource = new VXResource();
+		vxResource.setAssetId(assetId);
+		vxResource.setAssetType(assetType);
+		vxResource.setResourceType(resourceType);
+		vxResource.setName("Test"+getDateTimeForFileName());
+		vxResource.setDatabases("TestDB"+getDateTimeForFileName());
+		vxResource.setColumns("TestCol"+getDateTimeForFileName());
+		vxResource.setTables("TestTables"+getDateTimeForFileName());
+		vxResource.setUdfs("TestUDF"+getDateTimeForFileName());
+		vxResource.setDescription(assetTypeName+"_"+getDateTimeForFileName());
+		vxResource.setPolicyName(assetTypeName+"_"+getDateTimeForFileName());
+		vxResource.setTopologies("Topo_"+getDateTimeForFileName());
+		vxResource.setServices("Serv_"+getDateTimeForFileName());
+		vxResource.setResourceStatus(1);
+		vxResource.setOwner("Admin");
+		vxResource.setUpdatedBy("Admin");
+		return vxResource;
+	}
+			
+	private String getDateTimeForFileName() {
+		Date currentDate = new Date();
+		SimpleDateFormat dateFormatter = new SimpleDateFormat("ddMMyyyyHHmmsss");
+		return dateFormatter.format(currentDate);
+	}
+	
+	private VXAsset createVXAsset(String assetTypeName, int assetType, String config){
+		VXAsset vXAsset = new VXAsset();		
+		vXAsset.setName(assetTypeName+"_"+getDateTimeForFileName());
+		vXAsset.setActiveStatus(1);
+		vXAsset.setAssetType(assetType);
+		vXAsset.setConfig(config);	
+		vXAsset.setDescription(assetTypeName+"Descr_"+getDateTimeForFileName());
+		return vXAsset;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/65b6d83d/security-admin/src/test/java/com/xasecure/biz/TestUserMgr.java
----------------------------------------------------------------------
diff --git a/security-admin/src/test/java/com/xasecure/biz/TestUserMgr.java b/security-admin/src/test/java/com/xasecure/biz/TestUserMgr.java
new file mode 100644
index 0000000..625b09d
--- /dev/null
+++ b/security-admin/src/test/java/com/xasecure/biz/TestUserMgr.java
@@ -0,0 +1,557 @@
+package com.xasecure.biz;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import javax.ws.rs.WebApplicationException;
+
+import org.junit.Assert;
+import org.junit.FixMethodOrder;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.junit.runners.MethodSorters;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import com.xasecure.common.ContextUtil;
+import com.xasecure.common.MessageEnums;
+import com.xasecure.common.RESTErrorUtil;
+import com.xasecure.common.SearchCriteria;
+import com.xasecure.common.StringUtil;
+import com.xasecure.common.UserSessionBase;
+import com.xasecure.db.XADaoManager;
+import com.xasecure.db.XXPortalUserDao;
+import com.xasecure.db.XXPortalUserRoleDao;
+import com.xasecure.entity.XXPortalUser;
+import com.xasecure.entity.XXPortalUserRole;
+import com.xasecure.security.context.XAContextHolder;
+import com.xasecure.security.context.XASecurityContext;
+import com.xasecure.view.VXPasswordChange;
+import com.xasecure.view.VXPortalUser;
+import com.xasecure.view.VXPortalUserList;
+import com.xasecure.view.VXResponse;
+import com.xasecure.view.VXString;
+
+@RunWith(MockitoJUnitRunner.class)
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestUserMgr {
+
+	private static Long userId = 1L;
+
+	@InjectMocks
+	UserMgr userMgr = new UserMgr();
+
+	@Mock
+	VXPortalUser VXPortalUser;
+
+	@Mock
+	XADaoManager daoManager;
+
+	@Mock
+	RESTErrorUtil restErrorUtil;
+
+	@Mock
+	ContextUtil contextUtil;
+
+	@Mock
+	StringUtil stringUtil;
+
+	@Mock
+	XABizUtil msBizUtil;
+
+	@Rule
+	public ExpectedException thrown = ExpectedException.none();
+
+	public void setup() {
+		XASecurityContext context = new XASecurityContext();
+		context.setUserSession(new UserSessionBase());
+		XAContextHolder.setSecurityContext(context);
+		UserSessionBase currentUserSession = ContextUtil
+				.getCurrentUserSession();
+		currentUserSession.setUserAdmin(true);
+	}
+
+	private VXPortalUser userProfile() {
+		VXPortalUser userProfile = new VXPortalUser();
+		userProfile.setEmailAddress("test@test.com");
+		userProfile.setFirstName("user12");
+		userProfile.setLastName("test12");
+		userProfile.setLoginId("134");
+		userProfile.setPassword("usertest12323");
+		userProfile.setUserSource(123);
+		userProfile.setPublicScreenName("user");
+		userProfile.setId(userId);
+		return userProfile;
+	}
+
+	@Test
+	public void test11CreateUser() {
+		XXPortalUserDao userDao = Mockito.mock(XXPortalUserDao.class);
+		XXPortalUserRoleDao roleDao = Mockito.mock(XXPortalUserRoleDao.class);
+
+		VXPortalUser userProfile = userProfile();
+
+		Collection<String> userRoleList = new ArrayList<String>();
+		userRoleList.add("ROLE_USER");
+
+		XXPortalUser user = new XXPortalUser();
+		user.setEmailAddress(userProfile.getEmailAddress());
+		user.setFirstName(userProfile.getFirstName());
+		user.setLastName(userProfile.getLastName());
+		user.setLoginId(userProfile.getLoginId());
+		user.setPassword(userProfile.getPassword());
+		user.setUserSource(userProfile.getUserSource());
+		user.setPublicScreenName(userProfile.getPublicScreenName());
+		user.setId(userProfile.getId());
+
+		XXPortalUserRole XXPortalUserRole = new XXPortalUserRole();
+		XXPortalUserRole.setId(user.getId());
+		XXPortalUserRole.setUserRole("ROLE_USER");
+		List<XXPortalUserRole> list = new ArrayList<XXPortalUserRole>();
+		list.add(XXPortalUserRole);
+
+		Mockito.when(daoManager.getXXPortalUser()).thenReturn(userDao);
+		Mockito.when(userDao.create((XXPortalUser) Mockito.anyObject()))
+				.thenReturn(user);
+		Mockito.when(daoManager.getXXPortalUserRole()).thenReturn(roleDao);
+		Mockito.when(roleDao.findByUserId(userId)).thenReturn(list);
+
+		XXPortalUser dbxxPortalUser = userMgr.createUser(userProfile, 1,
+				userRoleList);
+		userId = dbxxPortalUser.getId();
+		
+		Assert.assertNotNull(dbxxPortalUser);
+		Assert.assertEquals(userId, dbxxPortalUser.getId());
+		Assert.assertEquals(userProfile.getFirstName(), dbxxPortalUser.getFirstName());		
+		Assert.assertEquals(userProfile.getFirstName(), dbxxPortalUser.getFirstName());
+		Assert.assertEquals(userProfile.getLastName(), dbxxPortalUser.getLastName());
+		Assert.assertEquals(userProfile.getLoginId(), dbxxPortalUser.getLoginId());
+		Assert.assertEquals(userProfile.getEmailAddress(), dbxxPortalUser.getEmailAddress());
+		Assert.assertEquals(userProfile.getPassword(), dbxxPortalUser.getPassword());
+		
+		Mockito.verify(daoManager).getXXPortalUser();
+		Mockito.verify(daoManager).getXXPortalUserRole();
+	}
+	
+
+	@Test
+	public void test12CreateUser() {
+		XXPortalUserDao userDao = Mockito.mock(XXPortalUserDao.class);
+		XXPortalUserRoleDao roleDao = Mockito.mock(XXPortalUserRoleDao.class);
+
+		VXPortalUser userProfile = userProfile();
+
+		XXPortalUser user = new XXPortalUser();
+		user.setEmailAddress(userProfile.getEmailAddress());
+		user.setFirstName(userProfile.getFirstName());
+		user.setLastName(userProfile.getLastName());
+		user.setLoginId(userProfile.getLoginId());
+		user.setPassword(userProfile.getPassword());
+		user.setUserSource(userProfile.getUserSource());
+		user.setPublicScreenName(userProfile.getPublicScreenName());
+		user.setId(userProfile.getId());
+
+		XXPortalUserRole XXPortalUserRole = new XXPortalUserRole();
+		XXPortalUserRole.setId(user.getId());
+		XXPortalUserRole.setUserRole("ROLE_USER");
+		List<XXPortalUserRole> list = new ArrayList<XXPortalUserRole>();
+		list.add(XXPortalUserRole);
+
+		Mockito.when(daoManager.getXXPortalUser()).thenReturn(userDao);
+		Mockito.when(userDao.create((XXPortalUser) Mockito.anyObject()))
+				.thenReturn(user);
+		Mockito.when(daoManager.getXXPortalUserRole()).thenReturn(roleDao);
+		Mockito.when(roleDao.findByUserId(userId)).thenReturn(list);
+
+		XXPortalUser dbxxPortalUser = userMgr.createUser(userProfile, 1);
+		userId = dbxxPortalUser.getId();
+		
+		Assert.assertNotNull(dbxxPortalUser);
+		Assert.assertEquals(userId, dbxxPortalUser.getId());
+		Assert.assertEquals(userProfile.getFirstName(), dbxxPortalUser.getFirstName());		
+		Assert.assertEquals(userProfile.getFirstName(), dbxxPortalUser.getFirstName());
+		Assert.assertEquals(userProfile.getLastName(), dbxxPortalUser.getLastName());
+		Assert.assertEquals(userProfile.getLoginId(), dbxxPortalUser.getLoginId());
+		Assert.assertEquals(userProfile.getEmailAddress(), dbxxPortalUser.getEmailAddress());
+		Assert.assertEquals(userProfile.getPassword(), dbxxPortalUser.getPassword());
+
+		Mockito.verify(daoManager).getXXPortalUser();
+		Mockito.verify(daoManager).getXXPortalUserRole();
+	}
+
+	@Test
+	public void test15ChangePassword() {
+
+		XXPortalUserDao userDao = Mockito.mock(XXPortalUserDao.class);
+		VXPortalUser userProfile = userProfile();
+
+		VXPasswordChange pwdChange = new VXPasswordChange();
+		pwdChange.setId(userProfile.getId());
+		pwdChange.setLoginId(userProfile.getLoginId());
+		pwdChange.setOldPassword(userProfile.getPassword());
+		pwdChange.setEmailAddress(userProfile.getEmailAddress());
+		pwdChange.setUpdPassword(userProfile.getPassword());
+
+		XXPortalUser user = new XXPortalUser();
+
+		Mockito.when(daoManager.getXXPortalUser()).thenReturn(userDao);
+		Mockito.when(userDao.findByLoginId(Mockito.anyString())).thenReturn(
+				user);
+		Mockito.when(
+				stringUtil.equals(Mockito.anyString(), Mockito.anyString()))
+				.thenReturn(true);
+
+		Mockito.when(daoManager.getXXPortalUser()).thenReturn(userDao);
+		Mockito.when(userDao.getById(Mockito.anyLong())).thenReturn(user);
+		Mockito.when(
+				stringUtil.validatePassword(Mockito.anyString(),
+						new String[] { Mockito.anyString() })).thenReturn(true);
+		
+		VXResponse dbVXResponse = userMgr.changePassword(pwdChange);
+		Assert.assertNotNull(dbVXResponse);		
+		Assert.assertEquals(userProfile.getStatus(), dbVXResponse.getStatusCode());		
+		
+		Mockito.verify(stringUtil).equals(Mockito.anyString(),Mockito.anyString());
+		Mockito.verify(stringUtil).validatePassword(Mockito.anyString(),
+				new String[] { Mockito.anyString() });
+	}
+
+	@Test
+	public void test16GetEmailAddress() {
+
+		VXPortalUser userProfile = userProfile();
+
+		XXPortalUser user = new XXPortalUser();
+		user.setEmailAddress(userProfile.getEmailAddress());
+		user.setFirstName(userProfile.getFirstName());
+		user.setLastName(userProfile.getLastName());
+		user.setLoginId(userProfile.getLoginId());
+		user.setPassword(userProfile.getPassword());
+		user.setUserSource(userProfile.getUserSource());
+		user.setPublicScreenName(userProfile.getPublicScreenName());
+		user.setId(userProfile.getId());
+
+		VXPasswordChange changeEmail = new VXPasswordChange();
+		changeEmail.setEmailAddress(user.getEmailAddress());
+		changeEmail.setId(user.getId());
+		changeEmail.setLoginId(user.getLoginId());
+
+		Mockito.when(
+				restErrorUtil.createRESTException(
+						"serverMsg.userMgrEmailChange",
+						MessageEnums.OPER_NO_PERMISSION, null, null, ""
+								+ changeEmail)).thenThrow(
+				new WebApplicationException());
+		thrown.expect(WebApplicationException.class);
+		
+		VXPortalUser dbVXPortalUser = userMgr.changeEmailAddress(user,changeEmail);
+		Assert.assertNotNull(dbVXPortalUser);
+		Assert.assertEquals(userId, dbVXPortalUser.getId());		
+		Assert.assertEquals(userProfile.getLastName(), dbVXPortalUser.getLastName());
+		Assert.assertEquals(changeEmail.getLoginId(), dbVXPortalUser.getLoginId());
+		Assert.assertEquals(changeEmail.getEmailAddress(), dbVXPortalUser.getEmailAddress());
+		
+		Mockito.verify(restErrorUtil).createRESTException("serverMsg.userMgrEmailChange",
+				MessageEnums.OPER_NO_PERMISSION, null, null, ""
+						+ changeEmail);
+	}
+
+	@Test
+	public void test17ValidateEmailAddress() {
+
+		VXPortalUser userProfile = userProfile();
+
+		XXPortalUser user = new XXPortalUser();
+		user.setFirstName(userProfile.getFirstName());
+		user.setLastName(userProfile.getLastName());
+		user.setLoginId(userProfile.getLoginId());
+		user.setPassword(userProfile.getPassword());
+		user.setUserSource(userProfile.getUserSource());
+		user.setPublicScreenName(userProfile.getPublicScreenName());
+		user.setId(userProfile.getId());
+
+		VXPasswordChange changeEmail = new VXPasswordChange();
+		changeEmail.setId(user.getId());
+		changeEmail.setLoginId(user.getLoginId());
+
+		Mockito.when(
+				restErrorUtil.createRESTException(
+						"serverMsg.userMgrInvalidEmail",
+						MessageEnums.INVALID_INPUT_DATA, changeEmail.getId(),
+						"emailAddress", changeEmail.toString())).thenThrow(
+				new WebApplicationException());
+		thrown.expect(WebApplicationException.class);
+		
+		VXPortalUser dbVXPortalUser = userMgr.changeEmailAddress(user,
+				changeEmail);
+		Assert.assertNotNull(dbVXPortalUser);
+		Assert.assertEquals(userId, dbVXPortalUser.getId());		
+		Assert.assertEquals(userProfile.getLastName(), dbVXPortalUser.getLastName());
+		Assert.assertEquals(changeEmail.getLoginId(), dbVXPortalUser.getLoginId());
+		Assert.assertEquals(changeEmail.getEmailAddress(), dbVXPortalUser.getEmailAddress());
+		
+		Mockito.verify(restErrorUtil).createRESTException("serverMsg.userMgrInvalidEmail",
+				MessageEnums.INVALID_INPUT_DATA, changeEmail.getId(),
+				"emailAddress", changeEmail.toString());
+	}
+
+	@Test
+	public void test21CreateUser() {
+		setup();
+		XXPortalUserDao userDao = Mockito.mock(XXPortalUserDao.class);
+		XXPortalUserRoleDao roleDao = Mockito.mock(XXPortalUserRoleDao.class);
+
+		XXPortalUser user = new XXPortalUser();
+		VXPortalUser userProfile = userProfile();
+
+		XXPortalUserRole XXPortalUserRole = new XXPortalUserRole();
+		XXPortalUserRole.setId(userId);
+		XXPortalUserRole.setUserRole("ROLE_USER");
+		List<XXPortalUserRole> list = new ArrayList<XXPortalUserRole>();
+		list.add(XXPortalUserRole);
+
+		Mockito.when(daoManager.getXXPortalUser()).thenReturn(userDao);
+		Mockito.when(userDao.create((XXPortalUser) Mockito.anyObject()))
+				.thenReturn(user);
+		Mockito.when(daoManager.getXXPortalUserRole()).thenReturn(roleDao);
+		Mockito.when(roleDao.findByUserId(Mockito.anyLong())).thenReturn(list);
+		
+		VXPortalUser dbVXPortalUser = userMgr.createUser(userProfile);
+		Assert.assertNotNull(dbVXPortalUser);
+		Assert.assertEquals(user.getId(), dbVXPortalUser.getId());
+		Assert.assertEquals(user.getFirstName(), dbVXPortalUser.getFirstName());		
+		Assert.assertEquals(user.getFirstName(), dbVXPortalUser.getFirstName());
+		Assert.assertEquals(user.getLastName(), dbVXPortalUser.getLastName());
+		Assert.assertEquals(user.getLoginId(), dbVXPortalUser.getLoginId());
+		Assert.assertEquals(user.getEmailAddress(), dbVXPortalUser.getEmailAddress());
+		Assert.assertEquals(user.getPassword(), dbVXPortalUser.getPassword());
+		
+		Mockito.verify(daoManager).getXXPortalUser();
+	}
+
+	@Test
+	public void test22CreateDefaultAccountUser() {
+		XXPortalUserDao userDao = Mockito.mock(XXPortalUserDao.class);
+		XXPortalUserRoleDao roleDao = Mockito.mock(XXPortalUserRoleDao.class);
+		VXPortalUser userProfile = userProfile();
+		XXPortalUser user = new XXPortalUser();
+
+		XXPortalUserRole XXPortalUserRole = new XXPortalUserRole();
+		XXPortalUserRole.setId(userId);
+		XXPortalUserRole.setUserRole("ROLE_USER");
+
+		List<XXPortalUserRole> list = new ArrayList<XXPortalUserRole>();
+		list.add(XXPortalUserRole);
+
+		Mockito.when(daoManager.getXXPortalUser()).thenReturn(userDao);
+		Mockito.when(userDao.findByLoginId(Mockito.anyString())).thenReturn(
+				user);
+		Mockito.when(daoManager.getXXPortalUserRole()).thenReturn(roleDao);
+		Mockito.when(roleDao.findByParentId(Mockito.anyLong()))
+				.thenReturn(list);
+
+		VXPortalUser dbVXPortalUser = userMgr
+				.createDefaultAccountUser(userProfile);
+		Assert.assertNotNull(dbVXPortalUser);
+		Assert.assertEquals(user.getId(), dbVXPortalUser.getId());
+		Assert.assertEquals(user.getFirstName(), dbVXPortalUser.getFirstName());		
+		Assert.assertEquals(user.getFirstName(), dbVXPortalUser.getFirstName());
+		Assert.assertEquals(user.getLastName(), dbVXPortalUser.getLastName());
+		Assert.assertEquals(user.getLoginId(), dbVXPortalUser.getLoginId());
+		Assert.assertEquals(user.getEmailAddress(), dbVXPortalUser.getEmailAddress());
+		Assert.assertEquals(user.getPassword(), dbVXPortalUser.getPassword());
+		
+		Mockito.verify(daoManager).getXXPortalUser();
+		Mockito.verify(daoManager).getXXPortalUserRole();
+	}
+
+	@Test
+	public void test23IsUserInRole() {
+		XXPortalUserRoleDao roleDao = Mockito.mock(XXPortalUserRoleDao.class);
+
+		XXPortalUserRole XXPortalUserRole = new XXPortalUserRole();
+		XXPortalUserRole.setId(userId);
+		XXPortalUserRole.setUserRole("ROLE_USER");
+
+		List<XXPortalUserRole> list = new ArrayList<XXPortalUserRole>();
+		list.add(XXPortalUserRole);
+
+		Mockito.when(daoManager.getXXPortalUserRole()).thenReturn(roleDao);
+		Mockito.when(roleDao.findByRoleUserId(userId, "ROLE_USER")).thenReturn(
+				XXPortalUserRole);
+
+		boolean isValue = userMgr.isUserInRole(userId, "ROLE_USER");
+		Assert.assertTrue(isValue);
+		
+		Mockito.verify(daoManager).getXXPortalUserRole();
+	}
+
+	@Test
+	public void test24UpdateUserWithPass() {
+		XXPortalUserDao userDao = Mockito.mock(XXPortalUserDao.class);
+
+		VXPortalUser userProfile = userProfile();
+		XXPortalUser user = new XXPortalUser();
+
+		Mockito.when(daoManager.getXXPortalUser()).thenReturn(userDao);
+		Mockito.when(userDao.getById(userProfile.getId())).thenReturn(user);
+
+		Mockito.when(
+				restErrorUtil.createRESTException(
+						"Please provide valid email address.",
+						MessageEnums.INVALID_INPUT_DATA)).thenThrow(
+				new WebApplicationException());
+		thrown.expect(WebApplicationException.class);
+		
+		XXPortalUser dbXXPortalUser = userMgr.updateUserWithPass(userProfile);
+		Assert.assertNotNull(dbXXPortalUser);
+		Assert.assertEquals(userId, dbXXPortalUser.getId());
+		Assert.assertEquals(userProfile.getFirstName(), dbXXPortalUser.getFirstName());		
+		Assert.assertEquals(userProfile.getFirstName(), dbXXPortalUser.getFirstName());
+		Assert.assertEquals(userProfile.getLastName(), dbXXPortalUser.getLastName());
+		Assert.assertEquals(userProfile.getLoginId(), dbXXPortalUser.getLoginId());
+		Assert.assertEquals(userProfile.getEmailAddress(), dbXXPortalUser.getEmailAddress());
+		Assert.assertEquals(userProfile.getPassword(), dbXXPortalUser.getPassword());
+		
+		Mockito.verify(restErrorUtil).createRESTException("Please provide valid email address.",
+				MessageEnums.INVALID_INPUT_DATA);
+	}
+
+	@Test
+	public void test25searchUsers() {
+		Query query = Mockito.mock(Query.class);
+		EntityManager entityManager = Mockito.mock(EntityManager.class);
+		SearchCriteria searchCriteria = new SearchCriteria();
+		searchCriteria.setDistinct(true);
+		searchCriteria.setGetChildren(true);
+		searchCriteria.setGetCount(true);
+		searchCriteria.setMaxRows(12);
+		searchCriteria.setOwnerId(userId);
+		searchCriteria.setStartIndex(1);
+		searchCriteria.setSortBy("asc");
+
+		Mockito.when(daoManager.getEntityManager()).thenReturn(entityManager);
+		Mockito.when(entityManager.createQuery(Mockito.anyString()))
+				.thenReturn(query);
+		
+		VXPortalUserList dbVXPortalUserList = userMgr
+				.searchUsers(searchCriteria);
+
+		Assert.assertNotNull(dbVXPortalUserList);
+		
+		Mockito.verify(daoManager).getEntityManager();
+	}
+
+	@Test
+	public void test26FindByEmailAddress() {
+		XXPortalUserDao userDao = Mockito.mock(XXPortalUserDao.class);
+
+		XXPortalUser user = new XXPortalUser();
+
+		String emailId = "jeet786sonkar@gmail.com";
+		Mockito.when(daoManager.getXXPortalUser()).thenReturn(userDao);
+		Mockito.when(userDao.findByEmailAddress(emailId)).thenReturn(user);
+
+		XXPortalUser dbXXPortalUser = userMgr.findByEmailAddress(emailId);
+		Assert.assertNotNull(dbXXPortalUser);
+		Assert.assertNotEquals(emailId, dbXXPortalUser.getEmailAddress());
+		
+		Mockito.verify(daoManager).getXXPortalUser();
+	}
+
+	@Test
+	public void test27GetRolesForUser() {
+		XXPortalUserRoleDao roleDao = Mockito.mock(XXPortalUserRoleDao.class);
+		VXPortalUser userProfile = userProfile();
+
+		XXPortalUser user = new XXPortalUser();
+		user.setEmailAddress(userProfile.getEmailAddress());
+		user.setFirstName(userProfile.getFirstName());
+		user.setLastName(userProfile.getLastName());
+		user.setLoginId(userProfile.getLoginId());
+		user.setPassword(userProfile.getPassword());
+		user.setUserSource(userProfile.getUserSource());
+		user.setPublicScreenName(userProfile.getPublicScreenName());
+		user.setId(userProfile.getId());
+
+		XXPortalUserRole XXPortalUserRole = new XXPortalUserRole();
+		XXPortalUserRole.setId(user.getId());
+		XXPortalUserRole.setUserRole("ROLE_USER");
+		List<XXPortalUserRole> list = new ArrayList<XXPortalUserRole>();
+		list.add(XXPortalUserRole);
+
+		Mockito.when(daoManager.getXXPortalUserRole()).thenReturn(roleDao);
+		Mockito.when(roleDao.findByUserId(userId)).thenReturn(list);
+		
+		Collection<String> stringReturn = userMgr.getRolesForUser(user);
+		Assert.assertNotNull(stringReturn);
+		
+		Mockito.verify(daoManager).getXXPortalUserRole();
+	}
+
+	@Test
+	public void test28DeleteUserRole() {
+		XXPortalUserRoleDao roleDao = Mockito.mock(XXPortalUserRoleDao.class);
+
+		XXPortalUserRole XXPortalUserRole = new XXPortalUserRole();
+		String userRole = "ROLE_USER";
+		XXPortalUser user = new XXPortalUser();
+		XXPortalUserRole.setId(user.getId());
+		XXPortalUserRole.setUserRole("ROLE_USER");
+		List<XXPortalUserRole> list = new ArrayList<XXPortalUserRole>();
+		list.add(XXPortalUserRole);
+
+		Mockito.when(daoManager.getXXPortalUserRole()).thenReturn(roleDao);
+		Mockito.when(roleDao.findByUserId(userId)).thenReturn(list);
+		
+		boolean deleteValue = userMgr.deleteUserRole(userId, userRole);
+		Assert.assertTrue(deleteValue);
+	}
+
+	@Test
+	public void test29DeactivateUser() {
+		XXPortalUserDao userDao = Mockito.mock(XXPortalUserDao.class);
+		XXPortalUserRoleDao roleDao = Mockito.mock(XXPortalUserRoleDao.class);
+		VXPortalUser userProfile = userProfile();
+
+		XXPortalUser user = new XXPortalUser();
+		user.setEmailAddress(userProfile.getEmailAddress());
+		user.setFirstName(userProfile.getFirstName());
+		user.setLastName(userProfile.getLastName());
+		user.setLoginId(userProfile.getLoginId());
+		user.setPassword(userProfile.getPassword());
+		user.setUserSource(userProfile.getUserSource());
+		user.setPublicScreenName(userProfile.getPublicScreenName());
+		user.setId(userProfile.getId());
+
+		XXPortalUserRole XXPortalUserRole = new XXPortalUserRole();
+		XXPortalUserRole.setId(userId);
+		XXPortalUserRole.setUserRole("ROLE_USER");
+
+		List<XXPortalUserRole> list = new ArrayList<XXPortalUserRole>();
+		list.add(XXPortalUserRole);
+		Mockito.when(daoManager.getXXPortalUser()).thenReturn(userDao);
+		Mockito.when(userDao.update(user)).thenReturn(user);
+
+		Mockito.when(daoManager.getXXPortalUserRole()).thenReturn(roleDao);
+		Mockito.when(roleDao.findByParentId(Mockito.anyLong()))
+				.thenReturn(list);
+
+		VXPortalUser dbVXPortalUser = userMgr.deactivateUser(user);
+		Assert.assertNotNull(dbVXPortalUser);
+		Assert.assertEquals(user.getId(), dbVXPortalUser.getId());
+		Assert.assertEquals(user.getFirstName(), dbVXPortalUser.getFirstName());		
+		Assert.assertEquals(user.getFirstName(), dbVXPortalUser.getFirstName());
+		Assert.assertEquals(user.getLastName(), dbVXPortalUser.getLastName());
+		Assert.assertEquals(user.getLoginId(), dbVXPortalUser.getLoginId());
+		
+		Mockito.verify(daoManager).getXXPortalUser();
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/65b6d83d/security-admin/src/test/java/com/xasecure/biz/TestXABizUtil.java
----------------------------------------------------------------------
diff --git a/security-admin/src/test/java/com/xasecure/biz/TestXABizUtil.java b/security-admin/src/test/java/com/xasecure/biz/TestXABizUtil.java
new file mode 100644
index 0000000..c4c5393
--- /dev/null
+++ b/security-admin/src/test/java/com/xasecure/biz/TestXABizUtil.java
@@ -0,0 +1,530 @@
+package com.xasecure.biz;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import com.xasecure.common.AppConstants;
+import com.xasecure.common.ContextUtil;
+import com.xasecure.common.StringUtil;
+import com.xasecure.common.UserSessionBase;
+import com.xasecure.common.XACommonEnums;
+import com.xasecure.common.XAConstants;
+import com.xasecure.common.db.BaseDao;
+import com.xasecure.db.XADaoManager;
+import com.xasecure.db.XXAssetDao;
+import com.xasecure.db.XXPortalUserDao;
+import com.xasecure.db.XXResourceDao;
+import com.xasecure.db.XXUserDao;
+import com.xasecure.entity.XXAsset;
+import com.xasecure.entity.XXDBBase;
+import com.xasecure.entity.XXPortalUser;
+import com.xasecure.entity.XXResource;
+import com.xasecure.entity.XXUser;
+import com.xasecure.security.context.XAContextHolder;
+import com.xasecure.security.context.XASecurityContext;
+import com.xasecure.view.VXAsset;
+import com.xasecure.view.VXDataObject;
+import com.xasecure.view.VXPortalUser;
+import com.xasecure.view.VXResource;
+import com.xasecure.view.VXResponse;
+
+@RunWith(MockitoJUnitRunner.class)
+public class TestXABizUtil {
+	
+	private Long id = 1L;
+	private String resourceName = "hadoopdev";
+	
+	@InjectMocks
+	XABizUtil xABizUtil = new XABizUtil();
+	
+	@Mock
+	XADaoManager daoManager;
+	
+	@Mock
+	StringUtil stringUtil; 
+	
+	@Before
+	public void setup(){
+		XASecurityContext context = new XASecurityContext();
+		context.setUserSession(new UserSessionBase());
+		XAContextHolder.setSecurityContext(context);		
+	}
+	
+	@Test
+	public void testHasPermission_When_disableAccessControl(){
+		VXResource vXResource = null;
+		xABizUtil.enableResourceAccessControl = false;
+		VXResponse resp = xABizUtil.hasPermission(vXResource, AppConstants.XA_PERM_TYPE_UNKNOWN);
+		Assert.assertNotNull(resp);		
+	}
+	
+	@Test
+	public void testHasPermission_When_NoResource(){
+		VXResource vXResource = null;
+		VXResponse resp = xABizUtil.hasPermission(vXResource, AppConstants.XA_PERM_TYPE_UNKNOWN);
+		Assert.assertNotNull(resp);
+		Assert.assertEquals(VXResponse.STATUS_ERROR, resp.getStatusCode());
+		Assert.assertEquals("Please provide valid policy.", resp.getMsgDesc());
+	}
+	
+	@Test
+	public void testHasPermission_emptyResourceName(){
+		VXResource vXResource = new VXResource();
+		XXPortalUser portalUser = new XXPortalUser();
+		XXUserDao xxUserDao = Mockito.mock(XXUserDao.class);
+		XXPortalUserDao userDao = Mockito.mock(XXPortalUserDao.class);
+		XXUser xxUser = new XXUser(); 
+		XXAsset xxAsset = new XXAsset();
+		List<XXResource> lst = new ArrayList<XXResource>();
+		XXResourceDao xxResourceDao = Mockito.mock(XXResourceDao.class);
+		XXAssetDao xxAssetDao = Mockito.mock(XXAssetDao.class);
+		Mockito.when(daoManager.getXXPortalUser()).thenReturn(userDao);
+		Mockito.when(userDao.getById(Mockito.anyLong())).thenReturn(portalUser);
+		Mockito.when(daoManager.getXXUser()).thenReturn(xxUserDao);
+		Mockito.when(xxUserDao.findByUserName(Mockito.anyString())).thenReturn(xxUser);	
+		Mockito.when(daoManager.getXXResource()).thenReturn(xxResourceDao);
+		Mockito.when(xxResourceDao.findByAssetIdAndResourceStatus(Mockito.anyLong(),Mockito.anyInt())).thenReturn(lst);
+		Mockito.when(daoManager.getXXAsset()).thenReturn(xxAssetDao);
+		Mockito.when(xxAssetDao.getById(Mockito.anyLong())).thenReturn(xxAsset);
+		VXResponse resp = xABizUtil.hasPermission(vXResource, AppConstants.XA_PERM_TYPE_UNKNOWN);
+		Mockito.verify(daoManager).getXXPortalUser();
+		Mockito.verify(userDao).getById(Mockito.anyLong());
+		Mockito.verify(daoManager).getXXUser();
+		Mockito.verify(xxUserDao).findByUserName(Mockito.anyString());
+		Assert.assertNotNull(resp);
+		Assert.assertEquals(VXResponse.STATUS_ERROR, resp.getStatusCode());
+		Assert.assertEquals("Permission Denied !", resp.getMsgDesc());		
+	}
+	
+	@Test
+	public void testHasPermission_isAdmin(){
+		VXResource vXResource = new VXResource();
+		vXResource.setName(resourceName);
+		vXResource.setAssetId(id);		
+		UserSessionBase currentUserSession = ContextUtil.getCurrentUserSession();
+		currentUserSession.setUserAdmin(true);
+		VXResponse resp = xABizUtil.hasPermission(vXResource, AppConstants.XA_PERM_TYPE_UNKNOWN);
+		Assert.assertNotNull(resp);
+		Assert.assertEquals(VXResponse.STATUS_SUCCESS, resp.getStatusCode());
+	}	
+	
+	@Test
+	public void testIsNotAdmin(){
+		boolean isAdminChk = xABizUtil.isAdmin();
+		Assert.assertFalse(isAdminChk);
+	}
+	
+	@Test
+	public void testIsAdmin(){
+		UserSessionBase currentUserSession = ContextUtil.getCurrentUserSession();
+		currentUserSession.setUserAdmin(true);
+		boolean isAdminChk = xABizUtil.isAdmin();
+		Assert.assertTrue(isAdminChk);
+	}	
+	
+	@Test
+	public void testUserSessionNull_forIsAdmin(){
+		XAContextHolder.setSecurityContext(null);	
+		boolean isAdminChk = xABizUtil.isAdmin();
+		Assert.assertFalse(isAdminChk);
+	}
+	
+	@Test
+	public void testGetXUserId_NoUserSession(){
+		XAContextHolder.setSecurityContext(null);
+		Long chk = xABizUtil.getXUserId();
+		Assert.assertNull(chk);
+	}
+	
+	@Test
+	public void testGetXUserId_NoUser(){
+		XASecurityContext context = new XASecurityContext();
+		context.setUserSession(new UserSessionBase());
+		XAContextHolder.setSecurityContext(context);	
+		XXPortalUser xxPortalUser = new XXPortalUser();
+		XXUser xxUser = new XXUser();
+		XXUserDao xxUserDao = Mockito.mock(XXUserDao.class);
+		XXPortalUserDao xxPortalUserDao = Mockito.mock(XXPortalUserDao.class);
+		Mockito.when(daoManager.getXXPortalUser()).thenReturn(xxPortalUserDao);
+		Mockito.when(xxPortalUserDao.getById(Mockito.anyLong())).thenReturn(xxPortalUser);
+		Mockito.when(daoManager.getXXUser()).thenReturn(xxUserDao);
+		Mockito.when(xxUserDao.findByUserName(Mockito.anyString())).thenReturn(xxUser);
+		Long chk = xABizUtil.getXUserId();
+		Mockito.verify(daoManager).getXXPortalUser();
+		Mockito.verify(xxPortalUserDao).getById(Mockito.anyLong());
+		Mockito.verify(daoManager).getXXUser();
+		Mockito.verify(xxUserDao).findByUserName(Mockito.anyString());
+		Assert.assertNull(chk);	
+	}
+	
+	@Test
+	public void testGetXUserId(){
+		XXPortalUser xxPortalUser = new XXPortalUser();
+		xxPortalUser.setId(id);
+		XXUser xxUser = new XXUser();
+		xxUser.setId(id);
+		XXPortalUserDao xxPortalUserDao = Mockito.mock(XXPortalUserDao.class);
+		XXUserDao xxUserDao = Mockito.mock(XXUserDao.class);
+		XASecurityContext context = new XASecurityContext();
+		UserSessionBase userSessionBase = new UserSessionBase();
+		userSessionBase.setUserAdmin(true);
+		context.setUserSession(userSessionBase);
+		userSessionBase.setXXPortalUser(xxPortalUser);
+		XAContextHolder.setSecurityContext(context);	
+		Mockito.when(daoManager.getXXPortalUser()).thenReturn(xxPortalUserDao);
+		Mockito.when(xxPortalUserDao.getById(Mockito.anyLong())).thenReturn(xxPortalUser);
+		Mockito.when(daoManager.getXXUser()).thenReturn(xxUserDao);
+		Mockito.when(xxUserDao.findByUserName(Mockito.anyString())).thenReturn(xxUser);		
+		Long chk = xABizUtil.getXUserId();
+		Mockito.verify(daoManager).getXXPortalUser();
+		Mockito.verify(xxPortalUserDao).getById(Mockito.anyLong());
+		Mockito.verify(daoManager).getXXUser();
+		Mockito.verify(xxUserDao).findByUserName(Mockito.anyString());
+		Assert.assertEquals(chk, id);		
+	}
+	
+	@Test
+	public void testReplaceMetaChars_PathEmpty(){
+		String path = "";
+		String pathChk = xABizUtil.replaceMetaChars(path);
+		Assert.assertFalse(pathChk.contains("\\*"));
+		Assert.assertFalse(pathChk.contains("\\?"));
+	}
+	
+	@Test
+	public void testReplaceMetaChars_NoMetaChars(){
+		String path = "\\Demo\\Test";
+		String pathChk = xABizUtil.replaceMetaChars(path);
+		Assert.assertFalse(pathChk.contains("\\*"));
+		Assert.assertFalse(pathChk.contains("\\?"));
+	}
+	
+	@Test
+	public void testReplaceMetaChars_PathNull(){
+		String path = null;
+		String pathChk = xABizUtil.replaceMetaChars(path);
+		Assert.assertNull(pathChk);
+	}
+	
+	@Test
+	public void testReplaceMetaChars(){
+		String path = "\\Demo\\Test\\*\\?";
+		String pathChk = xABizUtil.replaceMetaChars(path);
+		Assert.assertFalse(pathChk.contains("\\*"));
+		Assert.assertFalse(pathChk.contains("\\?"));
+	}
+	
+	@Test
+	public void testGeneratePublicName(){		
+		String firstName = "Test123456789123456789";
+		String lastName = "Unit";
+		String publicNameChk = xABizUtil.generatePublicName(firstName, lastName);
+		Assert.assertEquals("Test12345678... U.", publicNameChk);
+	}
+	
+	@Test
+	public void testGeneratePublicName_fNameLessThanMax(){		
+		String firstName = "Test";
+		String lastName = "";
+		String publicNameChk = xABizUtil.generatePublicName(firstName, lastName);
+		Assert.assertNull(publicNameChk);
+	}
+	
+	@Test
+	public void testGeneratePublicName_withPortalUser(){
+		VXPortalUser vXPortalUser = new VXPortalUser();
+		vXPortalUser.setFirstName("Test");
+		vXPortalUser.setLastName(null);
+		String publicNameChk = xABizUtil.generatePublicName(vXPortalUser, null);
+		Assert.assertNull(publicNameChk);
+	}
+	
+	@Test
+	public void testGetDisplayName_EmptyName() {
+		String displayNameChk = xABizUtil.getDisplayName(null);
+		Assert.assertEquals(xABizUtil.EMPTY_CONTENT_DISPLAY_NAME, displayNameChk);
+	}
+	
+	@Test
+	public void testGetDisplayName_AssetName() {
+		XXAsset obj = new XXAsset();
+		obj.setDescription(resourceName);
+		String displayNameChk = xABizUtil.getDisplayName(obj);
+		Assert.assertEquals(resourceName, displayNameChk);
+	}
+	
+	@Test
+	public void testGetDisplayName_MoreThanMaxLen() {
+		XXAsset obj = new XXAsset();
+		String name = resourceName;
+		for(int i=0;i<16;i++){
+			name = name + "_" + name + "1";
+		}
+		obj.setDescription(name);
+		String displayNameChk = xABizUtil.getDisplayName(obj);
+		Assert.assertEquals(displayNameChk.length(), 150);
+	}
+	
+	@Test
+	public void testGetDisplayNameForClassName(){
+		XXAsset obj = new XXAsset();
+		String displayNameChk = xABizUtil.getDisplayNameForClassName(obj);
+		Assert.assertEquals("Asset",displayNameChk);
+	}
+	
+	@Test
+	public void testGetFileNameWithoutExtension(){
+		File file = new File("test.txt");
+		String fileNameChk = xABizUtil.getFileNameWithoutExtension(file);
+		Assert.assertEquals("test",fileNameChk);
+	}
+	
+	@Test
+	public void testGetFileNameWithoutExtension_NoFile(){
+		String fileNameChk = xABizUtil.getFileNameWithoutExtension(null);
+		Assert.assertNull(fileNameChk);
+	}
+	
+	@Test
+	public void testGetFileNameWithoutExtension_noExt(){
+		File file = new File("test");
+		String fileNameChk = xABizUtil.getFileNameWithoutExtension(file);
+		Assert.assertEquals("test",fileNameChk);
+	}
+	
+	@Test
+	public void testGetImageExtension_TestJPG(){
+		String contentType = "img.JPG";
+		String extChk = xABizUtil.getImageExtension(contentType);
+		Assert.assertEquals("jpg",extChk);
+	}
+	
+	@Test
+	public void testGetImageExtension_TestJPEG(){
+		String contentType = "img.JPEG";
+		String extChk = xABizUtil.getImageExtension(contentType);
+		Assert.assertEquals("jpg",extChk);
+	}
+	
+	@Test
+	public void testGetImageExtension_TestPNG(){
+		String contentType = "img.PNG";
+		String extChk = xABizUtil.getImageExtension(contentType);
+		Assert.assertEquals("png",extChk);
+	}
+	
+	@Test
+	public void testGetImageExtension_NoExt(){
+		String contentType = "img";
+		String extChk = xABizUtil.getImageExtension(contentType);
+		Assert.assertEquals("",extChk);
+	}
+	
+	@Test
+	public void testGetMimeType_ForJPG(){
+		String mimeTypeChk = xABizUtil.getMimeType(XAConstants.MIME_JPEG);
+		Assert.assertEquals("jpg",mimeTypeChk);		
+	}
+	
+	@Test
+	public void testGetMimeType_ForPNG(){
+		String mimeTypeChk = xABizUtil.getMimeType(XAConstants.MIME_PNG);
+		Assert.assertEquals("png",mimeTypeChk);		
+	}
+	
+	@Test
+	public void testGetMimeType_ForEmpty(){
+		String mimeTypeChk = xABizUtil.getMimeType(1);
+		Assert.assertEquals("",mimeTypeChk);
+	}
+	
+	@Test
+	public void testGetMimeTypeInt_ForUnknow(){
+		int mimeTypeChk = xABizUtil.getMimeTypeInt("");
+		Assert.assertEquals(XAConstants.MIME_UNKNOWN, mimeTypeChk);
+	}
+	
+	@Test
+	public void testGetMimeTypeInt_Forjpg(){
+		int mimeTypeChk = xABizUtil.getMimeTypeInt("jpg");
+		Assert.assertEquals(XAConstants.MIME_JPEG, mimeTypeChk);
+	}
+	
+	@Test
+	public void testGetMimeTypeInt_ForJPEG(){
+		int mimeTypeChk = xABizUtil.getMimeTypeInt("JPEG");
+		Assert.assertEquals(XAConstants.MIME_JPEG, mimeTypeChk);
+	}
+	
+	@Test
+	public void testGetMimeTypeInt_EndsWithJPEG(){
+		int mimeTypeChk = xABizUtil.getMimeTypeInt("txt.jpeg");
+		Assert.assertEquals(XAConstants.MIME_JPEG, mimeTypeChk);
+	}
+	
+	@Test
+	public void testGetMimeTypeInt_EndsWithJPG(){
+		int mimeTypeChk = xABizUtil.getMimeTypeInt("txt.jpg");
+		Assert.assertEquals(XAConstants.MIME_JPEG, mimeTypeChk);
+	}
+	
+	@Test
+	public void testGetMimeTypeInt_EndsWithPNG(){
+		int mimeTypeChk = xABizUtil.getMimeTypeInt("txt.png");
+		Assert.assertEquals(XAConstants.MIME_PNG, mimeTypeChk);
+	}
+	
+	@Test
+	public void testGetMimeTypeInt_ForPNG(){
+		int mimeTypeChk = xABizUtil.getMimeTypeInt("png");
+		Assert.assertEquals(XAConstants.MIME_PNG, mimeTypeChk);		
+	}	
+	
+	@SuppressWarnings({ "unchecked", "rawtypes" })
+	@Test
+	public void testGetMObject(){
+		BaseDao baseDao = Mockito.mock(BaseDao.class);
+		Mockito.when(daoManager.getDaoForClassType(XACommonEnums.CLASS_TYPE_USER_PROFILE)).thenReturn(baseDao);
+		Mockito.when(baseDao.getById(id)).thenReturn(new XXAsset());
+		XXDBBase mObjChk = xABizUtil.getMObject(XACommonEnums.CLASS_TYPE_USER_PROFILE,id);
+		Assert.assertNotNull(mObjChk);
+	}
+	
+	@Test
+	public void testGetMObject_NoObjId(){
+		XXDBBase mObjChk = xABizUtil.getMObject(XACommonEnums.CLASS_TYPE_USER_PROFILE,null);
+		Assert.assertNull(mObjChk);
+	}
+	
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	@Test
+	public void testGetMObject_VXDataObject(){
+		VXAsset vXDataObject = new VXAsset();
+		vXDataObject.setId(id);	
+		BaseDao baseDao = Mockito.mock(BaseDao.class);
+		Mockito.when(daoManager.getDaoForClassType(vXDataObject.getMyClassType())).thenReturn(baseDao);
+		Mockito.when(baseDao.getById(vXDataObject.getId())).thenReturn(new XXAsset());
+		XXDBBase xXDBaseChk = xABizUtil.getMObject(vXDataObject);		
+		Assert.assertNotNull(xXDBaseChk);
+	}
+	
+	@Test
+	public void testGetMObject_NOVXDataObject(){
+		XXDBBase xXDBaseChk = xABizUtil.getMObject(null);		
+		Assert.assertNull(xXDBaseChk);
+	}
+	
+	@Test
+	public void testGetVObject_NOObjId(){
+		VXDataObject objchk = xABizUtil.getVObject(XAConstants.CLASS_TYPE_USER_PROFILE, null);
+		Assert.assertNull(objchk);
+	}	
+	
+	@Test
+	public void testMatchHdfsPolicy_NoResourceName(){
+		boolean bnlChk = xABizUtil.matchHbasePolicy(null, null, null, id, AppConstants.XA_PERM_TYPE_UNKNOWN);
+		Assert.assertFalse(bnlChk);
+	}
+	
+	@Test
+	public void testMatchHdfsPolicy_NoResourceList(){
+		boolean bnlChk = xABizUtil.matchHbasePolicy(resourceName, null, null, id, AppConstants.XA_PERM_TYPE_UNKNOWN);
+		Assert.assertFalse(bnlChk);
+	}
+	
+	@Test
+	public void testMatchHdfsPolicy_NoUserId(){
+		VXResponse vXResponse = new VXResponse();
+		List<XXResource> xResourceList = new ArrayList<XXResource>();
+		XXResource xXResource = new XXResource();
+		xXResource.setId(id);
+		xXResource.setName(resourceName);
+		xXResource.setIsRecursive(AppConstants.BOOL_TRUE);
+		xXResource.setResourceStatus(AppConstants.STATUS_ENABLED);
+		xResourceList.add(xXResource);
+		boolean bnlChk = xABizUtil.matchHbasePolicy(resourceName, xResourceList, vXResponse, null, AppConstants.XA_PERM_TYPE_UNKNOWN);
+		Assert.assertFalse(bnlChk);
+	}
+	
+	@Test
+	public void testMatchHdfsPolicy_NoPremission(){
+		VXResponse vXResponse = new VXResponse();
+		List<XXResource> xResourceList = new ArrayList<XXResource>();
+		XXResource xXResource = new XXResource();
+		xXResource.setId(id);
+		xXResource.setName(resourceName);
+		xXResource.setIsRecursive(AppConstants.BOOL_TRUE);
+		xXResource.setResourceStatus(AppConstants.STATUS_ENABLED);
+		xResourceList.add(xXResource);
+		Mockito.when(stringUtil.isEmpty(resourceName)).thenReturn(true);
+		Mockito.when(stringUtil.split(Mockito.anyString(), Mockito.anyString())).thenReturn(new String[0]);
+		boolean bnlChk = xABizUtil.matchHbasePolicy("/*/*/*", xResourceList, vXResponse, id, AppConstants.XA_PERM_TYPE_UNKNOWN);
+		Mockito.verify(stringUtil).split(Mockito.anyString(), Mockito.anyString());
+		Assert.assertFalse(bnlChk);
+	}
+	
+	@Test
+	public void testMatchHivePolicy_NoResourceName(){
+		boolean bnlChk = xABizUtil.matchHivePolicy(null, null, null, 0);
+		Assert.assertFalse(bnlChk);
+		
+	}
+	
+	@Test
+	public void testMatchHivePolicy_NoResourceList(){
+		boolean bnlChk = xABizUtil.matchHivePolicy(resourceName, null, null, 0);
+		Assert.assertFalse(bnlChk);
+		
+	}
+	
+	@Test
+	public void testMatchHivePolicy_NoUserId(){
+		List<XXResource> xResourceList = new ArrayList<XXResource>();
+		XXResource xXResource = new XXResource();
+		xXResource.setId(id);
+		xXResource.setName(resourceName);
+		xXResource.setIsRecursive(AppConstants.BOOL_TRUE);
+		xXResource.setResourceStatus(AppConstants.STATUS_ENABLED);
+		xResourceList.add(xXResource);
+		boolean bnlChk = xABizUtil.matchHivePolicy(resourceName, xResourceList, null, 0);
+		Assert.assertFalse(bnlChk);
+		
+	}
+	
+	@Test
+	public void testMatchHivePolicy_NoPremission(){
+		List<XXResource> xResourceList = new ArrayList<XXResource>();
+		XXResource xXResource = new XXResource();
+		xXResource.setId(id);
+		xXResource.setName(resourceName);
+		xXResource.setIsRecursive(AppConstants.BOOL_TRUE);
+		xXResource.setResourceStatus(AppConstants.STATUS_ENABLED);
+		xResourceList.add(xXResource);
+		Mockito.when(stringUtil.split(Mockito.anyString(), Mockito.anyString())).thenReturn(new String[0]);
+		boolean bnlChk = xABizUtil.matchHivePolicy("/*/*/*", xResourceList, id, 0);
+		Assert.assertFalse(bnlChk);		
+	}
+	
+	@Test
+	public void testMatchHivePolicy(){
+		List<XXResource> xResourceList = new ArrayList<XXResource>();
+		XXResource xXResource = new XXResource();
+		xXResource.setId(5L);
+		xXResource.setName(resourceName);
+		xXResource.setIsRecursive(AppConstants.BOOL_TRUE);
+		xXResource.setResourceStatus(AppConstants.STATUS_ENABLED);
+		xResourceList.add(xXResource);
+		Mockito.when(stringUtil.split(Mockito.anyString(), Mockito.anyString())).thenReturn(new String[0]);
+		boolean bnlChk = xABizUtil.matchHivePolicy("/*/*/*", xResourceList, id, 17);
+		Mockito.verify(stringUtil).split(Mockito.anyString(), Mockito.anyString());
+		Assert.assertFalse(bnlChk);		
+	}		
+}
\ No newline at end of file


Mime
View raw message