ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sneet...@apache.org
Subject [1/2] ARGUS-102:Add JUnit Test Cases
Date Sun, 12 Oct 2014 16:51:21 GMT
Repository: incubator-argus
Updated Branches:
  refs/heads/master 38ed20357 -> 65b6d83d9


http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/65b6d83d/security-admin/src/test/java/com/xasecure/biz/TestXUserMgr.java
----------------------------------------------------------------------
diff --git a/security-admin/src/test/java/com/xasecure/biz/TestXUserMgr.java b/security-admin/src/test/java/com/xasecure/biz/TestXUserMgr.java
new file mode 100644
index 0000000..f1a090f
--- /dev/null
+++ b/security-admin/src/test/java/com/xasecure/biz/TestXUserMgr.java
@@ -0,0 +1,382 @@
+package com.xasecure.biz;
+
+import java.util.ArrayList;
+import java.util.Collection;
+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.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.XXGroupDao;
+import com.xasecure.db.XXGroupUserDao;
+
+import com.xasecure.db.XXUserDao;
+import com.xasecure.entity.XXGroup;
+
+import com.xasecure.security.context.XAContextHolder;
+import com.xasecure.security.context.XASecurityContext;
+import com.xasecure.service.XGroupService;
+import com.xasecure.service.XGroupUserService;
+import com.xasecure.service.XUserService;
+import com.xasecure.view.VXGroup;
+import com.xasecure.view.VXGroupList;
+import com.xasecure.view.VXGroupUser;
+import com.xasecure.view.VXGroupUserList;
+import com.xasecure.view.VXPortalUser;
+import com.xasecure.view.VXUser;
+import com.xasecure.view.VXUserList;
+
+@RunWith(MockitoJUnitRunner.class)
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestXUserMgr {
+
+	private static Long userId = 1L;
+
+	@InjectMocks
+	XUserMgr xUserMgr = new XUserMgr();
+
+	@Mock
+	XGroupService xGroupService;
+
+	@Mock
+	XADaoManager daoManager;
+
+	@Mock
+	RESTErrorUtil restErrorUtil;
+
+	@Mock
+	XGroupUserService xGroupUserService;
+
+	@Mock
+	StringUtil stringUtil;
+
+	@Mock
+	XABizUtil msBizUtil;
+
+	@Mock
+	UserMgr userMgr;
+
+	@Mock
+	XUserService xUserService;
+
+	@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 VXUser vxUser() {
+		Collection<String> userRoleList = new ArrayList<String>();
+		userRoleList.add("ROLE_USER");
+		Collection<String> groupNameList = new ArrayList<String>();
+		groupNameList.add("Grp2");
+		VXUser vxUser = new VXUser();
+		vxUser.setId(userId);
+		vxUser.setDescription("group test working");
+		vxUser.setName("grouptest");
+		vxUser.setUserRoleList(userRoleList);
+		vxUser.setGroupNameList(groupNameList);
+		return vxUser;
+	}
+
+	@Test
+	public void test11CreateXUser() {
+
+		setup();
+		VXUser vxUser = vxUser();
+
+		VXPortalUser vXPortalUser = new VXPortalUser();
+
+		Mockito.when(userMgr.createDefaultAccountUser(vXPortalUser))
+				.thenReturn(vXPortalUser);
+		Mockito.when(xUserService.createResource(vxUser)).thenReturn(vxUser);
+
+		VXUser dbUser = xUserMgr.createXUser(vxUser);
+		Assert.assertNotNull(dbUser);
+		userId = dbUser.getId();
+		Assert.assertEquals(userId, dbUser.getId());
+		Assert.assertEquals(dbUser.getDescription(), vxUser.getDescription());
+		Assert.assertEquals(dbUser.getName(), vxUser.getName());
+		Assert.assertEquals(dbUser.getUserRoleList(), vxUser.getUserRoleList());
+		Assert.assertEquals(dbUser.getGroupNameList(),
+				vxUser.getGroupNameList());
+	
+		Mockito.verify(xUserService).createResource(vxUser);
+
+		Mockito.when(xUserService.readResourceWithOutLogin(userId)).thenReturn(
+				vxUser);
+		VXUser dbvxUser = xUserMgr.getXUser(userId);
+		Assert.assertNotNull(dbvxUser);
+		Assert.assertEquals(userId, dbvxUser.getId());
+		Assert.assertEquals(dbvxUser.getDescription(), vxUser.getDescription());
+		Assert.assertEquals(dbvxUser.getName(), vxUser.getName());
+		Assert.assertEquals(dbvxUser.getUserRoleList(),
+				vxUser.getUserRoleList());
+		Assert.assertEquals(dbvxUser.getGroupNameList(),
+				vxUser.getGroupNameList());
+		Mockito.verify(xUserService).readResourceWithOutLogin(userId);
+	}
+
+	@Test
+	public void test12UpdateXUser() {
+		VXUser vxUser = vxUser();
+		Mockito.when(xUserService.updateResource(vxUser)).thenReturn(vxUser);
+
+		VXUser dbvxUser = xUserMgr.updateXUser(vxUser);
+		Assert.assertNotNull(dbvxUser);
+		Assert.assertEquals(dbvxUser.getId(), vxUser.getId());
+		Assert.assertEquals(dbvxUser.getDescription(), vxUser.getDescription());
+		Assert.assertEquals(dbvxUser.getName(), vxUser.getName());
+		Mockito.verify(xUserService).updateResource(vxUser);
+	}
+
+	@Test
+	public void test13CreateXGroup() {
+		setup();
+		VXGroup vXGroup = new VXGroup();
+		vXGroup.setId(userId);
+		vXGroup.setDescription("group test");
+		vXGroup.setName("grouptest");
+
+		Mockito.when(xGroupService.createResource(vXGroup)).thenReturn(vXGroup);
+
+		VXGroup dbXGroup = xUserMgr.createXGroup(vXGroup);
+		Assert.assertNotNull(dbXGroup);
+		userId = dbXGroup.getId();
+		Assert.assertEquals(userId, dbXGroup.getId());
+		Assert.assertEquals(vXGroup.getDescription(), dbXGroup.getDescription());
+		Assert.assertEquals(vXGroup.getName(), dbXGroup.getName());
+		Mockito.verify(xGroupService).createResource(vXGroup);
+
+		Mockito.when(xGroupService.readResourceWithOutLogin(userId))
+				.thenReturn(vXGroup);
+		VXGroup dbxGroup = xUserMgr.getXGroup(userId);
+		Assert.assertNotNull(dbXGroup);
+		Assert.assertEquals(userId, dbxGroup.getId());
+		Assert.assertEquals(dbXGroup.getDescription(),
+				dbxGroup.getDescription());
+		Assert.assertEquals(dbXGroup.getName(), dbxGroup.getName());
+		Mockito.verify(xGroupService).readResourceWithOutLogin(userId);	
+	}
+
+	@Test
+	public void test14UpdateXGroup() {
+		XXGroupDao xxGroupDao = Mockito.mock(XXGroupDao.class);
+		setup();
+		VXGroup vXGroup = new VXGroup();
+		vXGroup.setId(userId);
+		vXGroup.setDescription("group test");
+		vXGroup.setName("grouptest");
+
+		XXGroup xxGroup = new XXGroup();
+		Mockito.when(daoManager.getXXGroup()).thenReturn(xxGroupDao);
+		Mockito.when(xxGroupDao.getById(vXGroup.getId())).thenReturn(xxGroup);
+		Mockito.when(xGroupService.updateResource(vXGroup)).thenReturn(vXGroup);
+
+		VXGroup dbvxGroup = xUserMgr.updateXGroup(vXGroup);
+		Assert.assertNotNull(dbvxGroup);
+		userId = dbvxGroup.getId();
+		Assert.assertEquals(userId, dbvxGroup.getId());
+		Assert.assertEquals(vXGroup.getDescription(),
+				dbvxGroup.getDescription());
+		Assert.assertEquals(vXGroup.getName(), dbvxGroup.getName());
+		Mockito.verify(daoManager).getXXGroup();	
+		Mockito.verify(xGroupService).updateResource(vXGroup);	
+	}
+
+	@Test
+	public void test15createXGroupUser() {
+		VXGroupUser vxGroupUser = new VXGroupUser();
+		vxGroupUser.setId(userId);
+		vxGroupUser.setName("group user test");
+		vxGroupUser.setOwner("Admin");
+		vxGroupUser.setUserId(userId);
+		vxGroupUser.setUpdatedBy("User");
+
+		Mockito.when(
+				xGroupUserService.createXGroupUserWithOutLogin(vxGroupUser))
+				.thenReturn(vxGroupUser);
+
+		VXGroupUser dbVXGroupUser = xUserMgr.createXGroupUser(vxGroupUser);
+		Assert.assertNotNull(dbVXGroupUser);
+		userId = dbVXGroupUser.getId();
+		Assert.assertEquals(userId, dbVXGroupUser.getId());
+		Assert.assertEquals(dbVXGroupUser.getOwner(), vxGroupUser.getOwner());
+		Assert.assertEquals(dbVXGroupUser.getName(), vxGroupUser.getName());
+		Assert.assertEquals(dbVXGroupUser.getUserId(), vxGroupUser.getUserId());
+		Assert.assertEquals(dbVXGroupUser.getUpdatedBy(),
+				vxGroupUser.getUpdatedBy());
+		Mockito.verify(xGroupUserService).createXGroupUserWithOutLogin(vxGroupUser);	
+
+		Mockito.when(xGroupUserService.readResourceWithOutLogin(userId))
+				.thenReturn(vxGroupUser);
+		VXGroup vXGroup = new VXGroup();
+				vXGroup.setId(userId);
+				vXGroup.setDescription("group test");
+				vXGroup.setName("grouptest");
+
+		VXGroupUser dbvxGroupUser = xUserMgr.getXGroupUser(userId);
+		Assert.assertNotNull(dbvxGroupUser);
+		userId = dbvxGroupUser.getId();
+		Assert.assertEquals(userId, dbvxGroupUser.getId());
+		Assert.assertEquals(dbvxGroupUser.getOwner(), vxGroupUser.getOwner());
+		Assert.assertEquals(dbvxGroupUser.getName(), vxGroupUser.getName());
+		Assert.assertEquals(dbvxGroupUser.getUserId(), vxGroupUser.getUserId());
+		Assert.assertEquals(dbvxGroupUser.getUpdatedBy(),
+				vxGroupUser.getUpdatedBy());
+		Mockito.verify(xGroupUserService).readResourceWithOutLogin(userId);	
+	}
+
+	@Test
+	public void test16GetXUserGroups() {
+		VXGroupList dbVXGroupList = xUserMgr.getXUserGroups(userId);
+		Assert.assertNotNull(dbVXGroupList);
+	}
+
+	@Test
+	public void test17GetXGroupUsers() {
+		VXUserList dbVXUserList = xUserMgr.getXGroupUsers(userId);VXGroup vXGroup = new VXGroup();
+		vXGroup.setId(userId);
+		vXGroup.setDescription("group test");
+		vXGroup.setName("grouptest");
+		Assert.assertNotNull(dbVXUserList);
+	}
+
+	@Test
+	public void test18GetXUserByUserName() {
+		VXUser vxUser = vxUser();
+		String userName = "test";
+
+		Mockito.when(xUserService.getXUserByUserName(userName)).thenReturn(
+				vxUser);
+
+		VXUser dbVXUser = xUserMgr.getXUserByUserName(userName);
+		Assert.assertNotNull(dbVXUser);
+		userId = dbVXUser.getId();
+		Assert.assertEquals(userId, dbVXUser.getId());
+		Assert.assertEquals(dbVXUser.getName(), vxUser.getName());
+		Assert.assertEquals(dbVXUser.getOwner(), vxUser.getOwner());
+		Mockito.verify(xUserService).getXUserByUserName(userName);	
+	}
+
+	@Test
+	public void test19CreateXUserWithOutLogin(){
+		VXUser vxUser = vxUser();
+	
+		Mockito.when(xUserService.createXUserWithOutLogin(vxUser))
+		.thenReturn(vxUser);
+		
+		VXUser dbUser = xUserMgr.createXUserWithOutLogin(vxUser);
+		Assert.assertNotNull(dbUser);
+		userId = dbUser.getId();
+		Assert.assertEquals(userId, dbUser.getId());
+		Assert.assertEquals(dbUser.getDescription(), vxUser.getDescription());
+		Assert.assertEquals(dbUser.getName(), vxUser.getName());
+		Assert.assertEquals(dbUser.getUserRoleList(), vxUser.getUserRoleList());
+		Assert.assertEquals(dbUser.getGroupNameList(),
+				vxUser.getGroupNameList());
+		Mockito.verify(xUserService).createXUserWithOutLogin(vxUser);	
+	}
+	
+	@Test
+	public void test20CreateXGroupWithoutLogin(){
+
+		VXGroup vXGroup = new VXGroup();
+		vXGroup.setId(userId);
+		vXGroup.setDescription("group test");
+		vXGroup.setName("grouptest");
+	
+		Mockito.when(xGroupService.createXGroupWithOutLogin(vXGroup))
+		.thenReturn(vXGroup);
+		
+	    VXGroup dbVXGroup = xUserMgr.createXGroupWithoutLogin(vXGroup);
+	    Assert.assertNotNull(dbVXGroup);
+		userId = dbVXGroup.getId();
+		Assert.assertEquals(userId, dbVXGroup.getId());
+		Assert.assertEquals(vXGroup.getDescription(), dbVXGroup.getDescription());
+		Assert.assertEquals(vXGroup.getName(), dbVXGroup.getName());
+		Mockito.verify(xGroupService).createXGroupWithOutLogin(vXGroup);	
+	}
+	
+	@Test
+	public void test21DeleteXGroup() {
+		XXGroupDao xxGroupDao = Mockito.mock(XXGroupDao.class);
+
+		VXGroupUserList vxGroupUserList = new VXGroupUserList();
+		XXGroup xxGroup = new XXGroup();
+		boolean force = true;
+		Mockito.when(
+				xGroupUserService.searchXGroupUsers((SearchCriteria) Mockito
+						.anyObject())).thenReturn(vxGroupUserList);
+
+		Mockito.when(daoManager.getXXGroup()).thenReturn(xxGroupDao);
+		Mockito.when(xxGroupDao.getById(userId)).thenReturn(xxGroup);
+
+		xUserMgr.deleteXGroup(userId, force);
+		Mockito.verify(xGroupUserService).searchXGroupUsers((SearchCriteria) Mockito.anyObject());	
+	}
+
+	@Test
+	public void test22DeleteXUser() {
+		XXGroupUserDao xxGroupDao = Mockito.mock(XXGroupUserDao.class);
+		XXUserDao xxUserDao = Mockito.mock(XXUserDao.class);
+		VXGroupUserList vxGroupUserList = new VXGroupUserList();
+		boolean force = true;
+
+		Mockito.when(
+				xGroupUserService.searchXGroupUsers((SearchCriteria) Mockito
+						.anyObject())).thenReturn(vxGroupUserList);
+		Mockito.when(daoManager.getXXGroupUser()).thenReturn(xxGroupDao);
+		Mockito.when(daoManager.getXXUser()).thenReturn(xxUserDao);
+		Mockito.when(xxUserDao.remove(userId)).thenReturn(true);
+
+		xUserMgr.deleteXUser(userId, force);
+		Mockito.verify(xGroupUserService).searchXGroupUsers((SearchCriteria) Mockito
+				.anyObject());
+		Mockito.verify(daoManager).getXXGroupUser();
+		Mockito.verify(daoManager).getXXUser();
+	}
+
+	@Test
+	public void test23deleteXGroupAndXUser() {
+		VXUser vxUser = vxUser();
+		VXGroup vxGroup = new VXGroup();
+		VXGroupUserList vxGroupUserList = new VXGroupUserList();
+
+		String groupName = "Grp2";
+		String userName = "test";
+
+		Mockito.when(xGroupService.getGroupByGroupName(Mockito.anyString()))
+				.thenReturn(vxGroup);
+		Mockito.when(xUserService.getXUserByUserName(Mockito.anyString()))
+				.thenReturn(vxUser);
+		Mockito.when(
+				xGroupUserService.searchXGroupUsers((SearchCriteria) Mockito
+						.anyObject())).thenReturn(vxGroupUserList);
+
+		xUserMgr.deleteXGroupAndXUser(groupName, userName);
+		Mockito.verify(xGroupService).getGroupByGroupName(Mockito.anyString());
+		Mockito.verify(xUserService).getXUserByUserName(Mockito.anyString());
+		Mockito.verify(xGroupUserService).searchXGroupUsers((SearchCriteria) Mockito
+				.anyObject());
+	}
+}
\ 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/common/TestDateUtil.java
----------------------------------------------------------------------
diff --git a/security-admin/src/test/java/com/xasecure/common/TestDateUtil.java b/security-admin/src/test/java/com/xasecure/common/TestDateUtil.java
new file mode 100644
index 0000000..ce36670
--- /dev/null
+++ b/security-admin/src/test/java/com/xasecure/common/TestDateUtil.java
@@ -0,0 +1,64 @@
+package com.xasecure.common;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import com.xasecure.common.DateUtil;
+
+@SuppressWarnings("deprecation")
+public class TestDateUtil {
+
+	@Autowired
+	DateUtil dateUtil = new DateUtil();
+
+	public void testGetDateFromNow() {
+		int days = 1;		
+		Date dateCheck= dateUtil.getDateFromNow(days);
+		int minutes=dateCheck.getMinutes();
+		int hourse=dateCheck.getHours();
+		Assert.assertEquals(dateCheck.getDay(),days+2);
+		Assert.assertEquals(dateCheck.getMinutes(), minutes);
+		Assert.assertEquals(dateCheck.getHours(), hourse);
+	}
+
+	@Test
+	public void testDateToString() {
+		Date date = new Date();
+		SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd-MM-yyyy");
+		String dateFromat = DATE_FORMAT.format(date);
+		String dateCheck = DateUtil.dateToString(date, dateFromat);
+		Assert.assertEquals(dateCheck,dateFromat);
+	}
+	
+	@Test
+	public void testGetDateFromGivenDate(){
+		Date date = new Date();
+		int days=0;
+		int hours=date.getHours();
+		int minutes=date.getMinutes();
+		int second=date.getSeconds();
+		Date currentDate = dateUtil.getDateFromGivenDate(date, days, 0, 0, 0);
+		Assert.assertEquals(currentDate.getDay(),date.getDay()+days);
+		Assert.assertEquals(currentDate.getHours(),hours);
+		Assert.assertEquals(currentDate.getMinutes(),minutes);
+		Assert.assertEquals(currentDate.getSeconds(),second);
+	}
+	
+	@Test
+	public void testAddTimeOffset(){
+		Date date = new Date();
+		int mins=date.getMinutes();
+		Date currentDate=dateUtil.addTimeOffset(date, 0);
+		Assert.assertEquals(currentDate.getDate(),date.getDate());
+		Assert.assertEquals(currentDate.getMinutes(),mins);
+	}
+	
+	@Test
+	public void testGetUTCDate1(){
+		Date date=new Date();
+		Date userdate=DateUtil.getUTCDate();
+		Assert.assertEquals(userdate.getDate(),date.getDate());
+	}
+}
\ 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/common/TestJSONUtil.java
----------------------------------------------------------------------
diff --git a/security-admin/src/test/java/com/xasecure/common/TestJSONUtil.java b/security-admin/src/test/java/com/xasecure/common/TestJSONUtil.java
new file mode 100644
index 0000000..7fc077a
--- /dev/null
+++ b/security-admin/src/test/java/com/xasecure/common/TestJSONUtil.java
@@ -0,0 +1,55 @@
+package com.xasecure.common;
+
+import java.util.HashMap;
+import java.util.Map;
+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.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.transaction.TransactionConfiguration;
+import org.springframework.transaction.annotation.Transactional;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestJSONUtil {
+
+	@Autowired
+	JSONUtil jsonUtil = new JSONUtil();
+
+	@Rule
+	public ExpectedException thrown = ExpectedException.none();
+
+	@Test
+	public void testJsonToMapNull() {
+		String jsonStr = null;
+		Map<String, String> dbMap = jsonUtil.jsonToMap(jsonStr);
+		Assert.assertEquals(dbMap.get(jsonStr), jsonStr);
+	}
+
+	@Test
+	public void testJsonToMapIsEmpty() {
+		String jsonStr = "";
+		Map<String, String> dbMap = jsonUtil.jsonToMap(jsonStr);
+		boolean isEmpty = dbMap.isEmpty();
+		Assert.assertTrue(isEmpty);
+	}
+
+	@Test
+	public void testJsonToMap() {
+		String jsonStr = "{\"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\"}";
+		Map<String, String> dbMap = jsonUtil.jsonToMap(jsonStr);
+	    Assert.assertNotNull(dbMap);
+	}
+
+	@Test
+	public void testReadMapToString() {		
+		Map<?, ?> map = new HashMap<Object, Object>();
+		String value = jsonUtil.readMapToString(map);
+		Assert.assertNotNull(value);
+	}	
+}
\ 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/common/TestPropertiesUtil.java
----------------------------------------------------------------------
diff --git a/security-admin/src/test/java/com/xasecure/common/TestPropertiesUtil.java b/security-admin/src/test/java/com/xasecure/common/TestPropertiesUtil.java
new file mode 100644
index 0000000..446c4da
--- /dev/null
+++ b/security-admin/src/test/java/com/xasecure/common/TestPropertiesUtil.java
@@ -0,0 +1,96 @@
+package com.xasecure.common;
+
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+public class TestPropertiesUtil {
+
+	@Autowired
+	PropertiesUtil propertiesUtil;
+
+	@Rule
+	public ExpectedException thrown = ExpectedException.none();
+
+	@Test
+	public void testGetPropertyNull() {
+		String key=null;
+		String defaultValue="test";
+		String value= PropertiesUtil.getProperty(key, defaultValue);
+		Assert.assertNull(value);
+	}
+	
+	@Test
+	public void testGetProperty() {
+		String key="1";
+		String defaultValue="test";
+		String value= PropertiesUtil.getProperty(key, defaultValue);
+		Assert.assertNotNull(value);
+	}	
+	
+	@Test
+	public void testgetPropertyNullValue(){
+		String key=null;
+		String value = PropertiesUtil.getProperty(key);
+		Assert.assertNull(value);
+	}
+	
+	@Test
+	public void testGetIntPropertyNull1(){
+		String key=null;
+		PropertiesUtil.getIntProperty(key);
+		Assert.assertNull(key);
+	}
+	
+	@Test
+	public void testGetIntPropertyl1(){
+		String key="1";
+		Integer value= PropertiesUtil.getIntProperty(key);
+		Assert.assertNull(value);
+	}	
+	
+	@Test
+	public void testGetIntPropertyNull(){
+		String key=null;
+		int defaultValue=0;
+		PropertiesUtil.getIntProperty(key, defaultValue);
+		Assert.assertNull(key);
+	}
+	
+	@Test
+	public void testGetIntPropertyl(){
+		String key="1";
+		int defaultValue=1;
+		Integer value= PropertiesUtil.getIntProperty(key, defaultValue);
+		Assert.assertEquals(value, Integer.valueOf(key));
+	}
+	
+	@Test
+	public void testGetBooleanPropertyNull() {
+		String key = null;
+		boolean defaultValue = true;
+		boolean returnAvlue = PropertiesUtil.getBooleanProperty(key , defaultValue);
+		Assert.assertTrue(returnAvlue);
+	}
+	
+	@Test
+	public void testGetBooleanProperty() {
+		String key = "1";
+		boolean defaultValue = true;
+		boolean returnAvlue = PropertiesUtil.getBooleanProperty(key , defaultValue);
+		Assert.assertTrue(returnAvlue);
+	}
+	
+	@Test
+	public void testGetPropertyStringList(){
+		String key = null;
+		PropertiesUtil.getPropertyStringList(key);
+		Assert.assertNull(key);
+	}
+	
+}
\ 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/common/TestStringUtil.java
----------------------------------------------------------------------
diff --git a/security-admin/src/test/java/com/xasecure/common/TestStringUtil.java b/security-admin/src/test/java/com/xasecure/common/TestStringUtil.java
new file mode 100644
index 0000000..334b533
--- /dev/null
+++ b/security-admin/src/test/java/com/xasecure/common/TestStringUtil.java
@@ -0,0 +1,177 @@
+ package com.xasecure.common;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.xasecure.common.StringUtil;
+
+public class TestStringUtil {
+
+	@Autowired
+	StringUtil stringUtil=new StringUtil();
+	
+	@Test
+	public void testToCamelCaseAllWords(){
+		String camelcase="hello world";
+		String camelCaseWords=stringUtil.toCamelCaseAllWords(camelcase);
+		Assert.assertEquals("Hello World",camelCaseWords);		
+	}
+	
+	@Test
+	public void testNullValidatePassword(){
+		String password=null; 
+		String[] invalidValues={"aa","bb","aa12345dd"};
+		boolean value=stringUtil.validatePassword(password, invalidValues);
+		Assert.assertFalse(value);
+	}
+	
+	@Test
+	public void testValidatePassword(){
+		String password="aa1234ddas12"; 
+		String[] invalidValues={"aa","bb","aa12345dd"};
+		boolean value=stringUtil.validatePassword(password, invalidValues);
+		Assert.assertTrue(password.length() >= 8);
+		Assert.assertTrue(value);
+	}
+	
+	@Test
+	public void testNotValidatePassword(){
+		String password="aassasavcvcvc"; 
+		String[] invalidValues={"aa","bb","aa12345dd"};
+		boolean value=stringUtil.validatePassword(password, invalidValues);
+		Assert.assertTrue(password.length() >= 8);
+		Assert.assertFalse(value);
+	}
+	
+	@Test
+	public void testIsEmptyValue(){		
+		String str="";
+		boolean value=stringUtil.isEmpty(str);
+		Assert.assertTrue(value);
+	}
+	@Test
+	public void testIsNullValue(){		
+		String str=null;
+		boolean value=stringUtil.isEmpty(str);
+		Assert.assertTrue(value);
+	}
+	
+	@Test
+	public void testIsWithValue(){		
+		String str="test value";
+		boolean value=stringUtil.isEmpty(str);
+		Assert.assertFalse(value);
+	}
+	
+	@Test
+	public void testEquals(){
+		String str1="test";
+		String str2="test";		
+		boolean value = stringUtil.equals(str1, str2);
+		Assert.assertTrue(value);
+	}
+	
+	@Test
+	public void testNormalizeEmail(){
+		String email="test.Demo@test.COM";
+		String lowercase=stringUtil.normalizeEmail(email);
+		String emailId=email.toLowerCase();
+		boolean value = emailId.equals(lowercase);
+		Assert.assertTrue(value);
+	}
+	
+	@Test
+	public void testNormalizeEmailIdNull(){
+		String email=null;
+		String lowercase=stringUtil.normalizeEmail(email);
+		Assert.assertEquals(lowercase,email);
+		Assert.assertNull(lowercase);
+	}
+	
+	@Test
+	public void testSplit(){
+		String str1 = "Test1";
+		String str2 = "Test2";
+		String str3 = "Test3";
+		String value = str1 + "," + str2 + "," + str3;
+		String[] stringArray = stringUtil.split(value);
+		 Assert.assertTrue(stringArray.length == 3);
+		 Assert.assertEquals(stringArray[0],str1);
+		 Assert.assertEquals(stringArray[1],str2);
+		 Assert.assertEquals(stringArray[2],str3);
+	}
+	
+	@Test
+	public void testTrim(){
+		String str="test";
+		String dataString = StringUtil.trim(str);
+		Assert.assertEquals(str,dataString);		
+	}
+	
+	@Test
+	public void testValidateEmailId(){
+		String email="jitendra.sonkar@freestoneinfotech.com";				
+		boolean value=stringUtil.validateEmail(email);
+		Assert.assertTrue(email.length() < 128);
+		Assert.assertTrue(value);
+	}
+	
+	@Test
+	public void testNullEmailId(){
+		String email=null;				
+		boolean value=stringUtil.validateEmail(email);
+		Assert.assertFalse(value);
+	}
+	
+	@Test
+	public void testValidateString(){
+		String regExStr = "^[\\w]([\\-\\.\\w])+[\\w]+@[\\w]+[\\w\\-]+[\\w]*\\.([\\w]+[\\w\\-]+[\\w]*(\\.[a-z][a-z|0-9]*)?)$";
+		String str="test.test@gmail.com";
+		boolean value = stringUtil.validateString(regExStr, str);
+		Assert.assertTrue(value);
+	}	
+	
+	@Test
+	public void testNotValidateString(){
+		String regExStr = "^[\\w]([\\-\\.\\w])+[\\w]+[\\w]*\\.([\\w]+[\\w\\-]+[\\w]*(\\.[a-z][a-z|0-9]*)?)$";
+		String str="test.test@gmail.com";
+		boolean value = stringUtil.validateString(regExStr, str);
+		Assert.assertFalse(value);
+	}	
+	
+	@Test
+	public void testIsListEmpty(){
+		List<String> list=new ArrayList<String>() ;			
+		boolean listValue = stringUtil.isEmpty(list);
+		Assert.assertTrue(listValue);
+	}
+	
+	@Test
+	public void testIsListNotEmpty(){
+		List<String> list=new ArrayList<String>() ;
+		             list.add("a");
+		             list.add("b");
+		boolean listValue = stringUtil.isEmpty(list);
+		Assert.assertFalse(listValue);
+	}
+	
+	@Test
+	public void testIsValidName(){
+		String name="test";
+		boolean value = stringUtil.isValidName(name);
+		Assert.assertTrue(value);
+	}
+	
+	@Test
+	public void testIsValidNameNull(){
+		String name=null;
+		boolean value = stringUtil.isValidName(name);
+		Assert.assertFalse(value);
+	}
+}
\ 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/common/TestXAConfigUtil.java
----------------------------------------------------------------------
diff --git a/security-admin/src/test/java/com/xasecure/common/TestXAConfigUtil.java b/security-admin/src/test/java/com/xasecure/common/TestXAConfigUtil.java
new file mode 100644
index 0000000..e7fa64c
--- /dev/null
+++ b/security-admin/src/test/java/com/xasecure/common/TestXAConfigUtil.java
@@ -0,0 +1,38 @@
+package com.xasecure.common;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+public class TestXAConfigUtil {
+
+	@Autowired
+	XAConfigUtil xaConfigUtil = new XAConfigUtil();	
+
+	@Test
+	public void testGetDefaultMaxRows() {
+		int maxrow = xaConfigUtil.getDefaultMaxRows();
+		Assert.assertEquals(maxrow,xaConfigUtil.defaultMaxRows );
+	}
+	
+	@Test
+	public void testIsAccessFilterEnabled() {
+		boolean value = xaConfigUtil.isAccessFilterEnabled();
+        Assert.assertTrue(value);
+	}
+	
+	@Test
+	public void testGetWebAppRootURL(){
+		String returnValue = xaConfigUtil.getWebAppRootURL();
+		Assert.assertEquals(returnValue,xaConfigUtil.webappRootURL);
+	}
+	
+	@Test
+	public void testGetRoles(){
+		String[] str=xaConfigUtil.getRoles();
+		Assert.assertArrayEquals(str, xaConfigUtil.roles);
+	}
+}
\ 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/rest/TestPublicAPIs.java
----------------------------------------------------------------------
diff --git a/security-admin/src/test/java/com/xasecure/rest/TestPublicAPIs.java b/security-admin/src/test/java/com/xasecure/rest/TestPublicAPIs.java
index 3aa67ac..897ba1b 100644
--- a/security-admin/src/test/java/com/xasecure/rest/TestPublicAPIs.java
+++ b/security-admin/src/test/java/com/xasecure/rest/TestPublicAPIs.java
@@ -19,33 +19,34 @@
 
  package com.xasecure.rest;
 
-import static org.junit.Assert.*;
+import javax.servlet.http.HttpServletRequest;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.junit.Before;
+import org.junit.Assert;
 import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.mock.web.MockHttpServletRequest;
-import org.springframework.test.annotation.Rollback;
-
-import com.xasecure.common.AppConstants;
-import com.xasecure.common.GUIDUtil;
-import com.xasecure.common.JSONUtil;
+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.biz.AssetMgr;
+import com.xasecure.common.RESTErrorUtil;
+import com.xasecure.common.SearchCriteria;
+import com.xasecure.common.StringUtil;
+import com.xasecure.common.XASearchUtil;
 import com.xasecure.db.XADaoManager;
-import com.xasecure.entity.XXAsset;
-import com.xasecure.entity.XXGroup;
-import com.xasecure.entity.XXResource;
 import com.xasecure.rest.PublicAPIs;
-import com.xasecure.util.BaseTest;
-import com.xasecure.view.VXGroup;
+import com.xasecure.service.AbstractBaseResourceService;
+import com.xasecure.service.XAssetService;
+import com.xasecure.service.XPolicyService;
+import com.xasecure.service.XRepositoryService;
+import com.xasecure.service.XResourceService;
+import com.xasecure.view.VXAsset;
 import com.xasecure.view.VXLong;
-import com.xasecure.view.VXPermObj;
 import com.xasecure.view.VXPolicy;
+import com.xasecure.view.VXPolicyList;
 import com.xasecure.view.VXRepository;
-import com.xasecure.view.VXResponse;
+import com.xasecure.view.VXRepositoryList;
+import com.xasecure.view.VXResource;
 
 /**
  * @author tushar
@@ -57,799 +58,192 @@ import com.xasecure.view.VXResponse;
  * 
  */
 
-public class TestPublicAPIs extends BaseTest {
-	static Logger logger = Logger.getLogger(TestPublicAPIs.class);
-
-	@Autowired
-	PublicAPIs publicAPIs;
-
-	@Autowired
-	XADaoManager daoManager;
-
-	@Autowired
-	JSONUtil jsonUtil;
-
-	@Autowired
-	XUserREST xUserREST;
-
-	VXRepository vXRepoHDFS;
-	VXRepository vXRepoHBase;
-	VXRepository vXRepoHive;
-	VXRepository vXRepoKnox;
-	VXRepository vXRepoStorm;
-
-	VXPolicy vXPolicyHDFS;
-	VXPolicy vXPolicyHBase;
-	VXPolicy vXPolicyHive;
-	VXPolicy vXPolicyKnox;
-	VXPolicy vXPolicyStorm;
-
-	@Override
-	public void init() {
-		super.startSession();
-		super.startRequest();
-	}
-
-	/**
-	 * @throws java.lang.Exception
-	 */
-	@Before
-	public void setUp() throws Exception {
-		super.authenticate();
-	}
-
-	/**
-	 * Test method for
-	 * {@link com.xasecure.rest.PublicAPIs#createRepository(com.xasecure.view.VXRepository)}
-	 * .
-	 */
-	public void testCreateRepository() {
-		vXRepoHDFS = new VXRepository();
-		vXRepoHBase = new VXRepository();
-		vXRepoHive = new VXRepository();
-		vXRepoKnox = new VXRepository();
-		vXRepoStorm = new VXRepository();
-
-		// Create HDFS Repository
-		String configHdfs = "{"
-				+ "  \"username\": \"policymgr\","
-				+ "  \"password\": \"policymgr\","
-				+ "  \"fs.default.name\": \"hdfs://sandbox.hortonworks.com:8020\","
-				+ "  \"hadoop.security.authorization\": \"true\","
-				+ "  \"hadoop.security.authentication\": \"simple\","
-				+ "  \"hadoop.security.auth_to_local\": \"\","
-				+ "  \"dfs.datanode.kerberos.principal\": \"\","
-				+ "  \"dfs.namenode.kerberos.principal\": \"\","
-				+ "  \"dfs.secondary.namenode.kerberos.principal\": \"\","
-				+ "  \"commonNameForCertificate\": \"\"}";
-
-		vXRepoHDFS.setName("HDFS Repo_" + GUIDUtil.genGUI());
-		vXRepoHDFS.setDescription("HDFS Repository, using JUnit");
-		vXRepoHDFS.setIsActive(true);
-		vXRepoHDFS.setRepositoryType("hdfs");
-		vXRepoHDFS.setConfig(configHdfs);
-
-		String preCreatedHdfsRepo = jsonUtil.writeObjectAsString(vXRepoHDFS);
-		logger.info(preCreatedHdfsRepo);
-		vXRepoHDFS = publicAPIs.createRepository(vXRepoHDFS);
-		String postCreatedHdfsRepo = jsonUtil.writeObjectAsString(vXRepoHDFS);
-		logger.info(postCreatedHdfsRepo);
-
-		assertNotNull("Error while creating Repository for HDFS", vXRepoHDFS);
-		logger.info("Create : Repo for HDFS created Successfully");
-
-		// Create Hive Repository
-		String configHive = "{"
-				+ "  \"username\": \"policymgr_hive\" ,"
-				+ "  \"password\": \"policymgr_hive\","
-				+ "  \"jdbc.driverClassName\": \"org.apache.hive.jdbc.HiveDriver\","
-				+ "  \"jdbc.url\": \"jdbc:hive2://127.0.0.1:10000/default\","
-				+ "  \"commonNameForCertificate\": \"\"}";
-
-		vXRepoHive.setName("hivedev_" + GUIDUtil.genGUI());
-		vXRepoHive.setDescription("Hive Dev");
-		vXRepoHive.setIsActive(true);
-		vXRepoHive.setRepositoryType("Hive");
-		vXRepoHive.setConfig(configHive);
-
-		String preCreatedHiveRepo = jsonUtil.writeObjectAsString(vXRepoHive);
-		logger.info(preCreatedHiveRepo);
-		vXRepoHive = publicAPIs.createRepository(vXRepoHive);
-		String postCreatedHiveRepo = jsonUtil.writeObjectAsString(vXRepoHive);
-		logger.info(postCreatedHiveRepo);
-
-		assertNotNull("Error while creating Repository for Hive", vXRepoHive);
-		logger.info("Create : Repo for Hive created Successfully");
-
-		// Create HBase Repository
-		String configHbase = "{"
-				+ "  \"username\": \"policymgr_hbase\","
-				+ "  \"password\": \"policymgr_hbase\","
-				+ "  \"fs.default.name\": \"hdfs://sandbox.hortonworks.com:8020\","
-				+ "  \"hadoop.security.authorization\": \"true\","
-				+ "  \"hadoop.security.authentication\": \"simple\","
-				+ "  \"hadoop.security.auth_to_local\": \"\","
-				+ "  \"dfs.datanode.kerberos.principal\": \"\","
-				+ "  \"dfs.namenode.kerberos.principal\": \"\","
-				+ "  \"dfs.secondary.namenode.kerberos.principal\": \"\","
-				+ "  \"hbase.master.kerberos.principal\": \"\","
-				+ "  \"hbase.rpc.engine\": \"org.apache.hadoop.hbase.ipc.SecureRpcEngine\","
-				+ "  \"hbase.rpc.protection\": \"PRIVACY\","
-				+ "  \"hbase.security.authentication\": \"simple\","
-				+ "  \"hbase.zookeeper.property.clientPort\": \"2181\","
-				+ "  \"hbase.zookeeper.quorum\": \"sandbox.hortonworks.com\","
-				+ "  \"zookeeper.znode.parent\": \"/hbase-unsecure\","
-				+ "  \"commonNameForCertificate\": \"\"}";
-
-		vXRepoHBase.setName("hbasedev_" + GUIDUtil.genGUI());
-		vXRepoHBase.setDescription("HBase Dev");
-		vXRepoHBase.setIsActive(true);
-		vXRepoHBase.setRepositoryType("HBase");
-		vXRepoHBase.setConfig(configHbase);
-
-		String preCreatedHBaseRepo = jsonUtil.writeObjectAsString(vXRepoHBase);
-		logger.info(preCreatedHBaseRepo);
-		vXRepoHBase = publicAPIs.createRepository(vXRepoHBase);
-		String postCreatedHBaseRepo = jsonUtil.writeObjectAsString(vXRepoHBase);
-		logger.info(postCreatedHBaseRepo);
-
-		assertNotNull("Error while creating Repo for HBase", vXRepoHBase);
-		logger.info("Create : Repo for HBase created Successfully");
-
-		String configKnox = "{" + "  \"username\": \"policymgr_hive\" ,"
-				+ "  \"password\": \"policymgr_hive\","
-				+ "  \"knox.url\": \"jdbc:hive2://127.0.0.1:10000/default\","
-				+ "  \"commonNameForCertificate\": \"\"}";
-
-		vXRepoKnox.setConfig(configKnox);
-		vXRepoKnox.setName("knoxdev_" + GUIDUtil.genGUI());
-		vXRepoKnox.setDescription("Knox Repo.. from JUnit");
-		vXRepoKnox.setIsActive(true);
-		vXRepoKnox.setRepositoryType("Knox");
-
-		String preCreatedKnoxRepo = jsonUtil.writeObjectAsString(vXRepoKnox);
-		logger.info(preCreatedKnoxRepo);
-		vXRepoKnox = publicAPIs.createRepository(vXRepoKnox);
-		String postCreatedKnoxRepo = jsonUtil.writeObjectAsString(vXRepoKnox);
-		logger.info(postCreatedKnoxRepo);
-
-		assertNotNull("Error while creating Repo for Knox", vXRepoKnox);
-		logger.info("Create : Repo for Knox created Successfully");
-
-		String configStorm = "{" + "  \"username\": \"policymgr_hive\" ,"
-				+ "  \"password\": \"policymgr_hive\","
-				+ "  \"commonNameForCertificate\": \"\"}";
-
-		vXRepoStorm.setConfig(configStorm);
-		vXRepoStorm.setName("stormdev_" + GUIDUtil.genGUI());
-		vXRepoStorm.setDescription("Storm Repo.. from JUnit");
-		vXRepoStorm.setIsActive(true);
-		vXRepoStorm.setRepositoryType("Storm");
-
-		String preCreatedStormRepo = jsonUtil.writeObjectAsString(vXRepoStorm);
-		logger.info(preCreatedStormRepo);
-		vXRepoStorm = publicAPIs.createRepository(vXRepoStorm);
-		String postCreatedStormRepo = jsonUtil.writeObjectAsString(vXRepoStorm);
-		logger.info(postCreatedStormRepo);
-
-		assertNotNull("Error while creating Repo for Knox", vXRepoStorm);
-		logger.info("Create : Repo for Storm created Successfully");
-
-	}
-
-	/**
-	 * Test method for
-	 * {@link com.xasecure.rest.PublicAPIs#updateRepository(com.xasecure.view.VXRepository)}
-	 * .
-	 */
-	public void testUpdateRepository() {
-
-		// Update HDFS Repo
-		vXRepoHDFS.setName("HDFS Repo Updated_" + GUIDUtil.genGUI());
-		vXRepoHDFS = publicAPIs
-				.updateRepository(vXRepoHDFS, vXRepoHDFS.getId());
-
-		assertNotNull("Error While updating Repo", vXRepoHDFS);
-		logger.info("Update : Repo for HDFS updated Successfully");
-
-		// Update HBase Repo
-		vXRepoHBase.setName("HBase Repo Updated_" + GUIDUtil.genGUI());
-		vXRepoHBase = publicAPIs.updateRepository(vXRepoHBase,
-				vXRepoHBase.getId());
-
-		assertNotNull("Error While updating Repo", vXRepoHBase);
-		logger.info("Update : Repo for HBase updated Successfully");
-
-		// Update HIVE Repo
-		vXRepoHive.setName("Hive Repo Updated_" + GUIDUtil.genGUI());
-		vXRepoHive = publicAPIs
-				.updateRepository(vXRepoHive, vXRepoHive.getId());
-
-		assertNotNull("Error While updating Repo", vXRepoHive);
-		logger.info("Update : Repo for Hive updated Successfully");
-	}
-
-	/**
-	 * Test method for
-	 * {@link com.xasecure.rest.PublicAPIs#getRepository(java.lang.Long)}.
-	 */
-	public void testGetRepository() {
-		VXRepository vXRepositoryHDFS = publicAPIs.getRepository(vXRepoHDFS
-				.getId());
-
-		String vXRepoHDFSJson = jsonUtil.writeObjectAsString(vXRepositoryHDFS);
-		logger.info(vXRepoHDFSJson);
-		assertNotNull(
-				"No Repository found for this Id : " + vXRepoHDFS.getId(),
-				vXRepositoryHDFS);
-		logger.info("Get : Repo found for this id : " + vXRepoHDFS.getId());
-
-		VXRepository vXRepositoryHBase = publicAPIs.getRepository(vXRepoHBase
-				.getId());
-		assertNotNull(
-				"No Repository found for this Id : " + vXRepoHBase.getId(),
-				vXRepositoryHBase);
-		logger.info("Get : Repo found for this id : " + vXRepoHBase.getId());
-
-		VXRepository vXRepositoryHive = publicAPIs.getRepository(vXRepoHive
-				.getId());
-		assertNotNull(
-				"No Repository found for this Id : " + vXRepoHive.getId(),
-				vXRepositoryHive);
-		logger.info("Get : Repo found for this id : " + vXRepoHive.getId());
-	}
-
-	/**
-	 * Test method for
-	 * {@link com.xasecure.rest.PublicAPIs#deleteRepository(java.lang.Long, javax.servlet.http.HttpServletRequest)}
-	 * .
-	 */
-	public void testDeleteRepository() {
-
-		XXAsset xxAsset = daoManager.getXXAsset().findByAssetName(
-				vXRepoHDFS.getName());
-		MockHttpServletRequest request = super.startRequest();
-		request.addParameter("force", "true");
-		publicAPIs.deleteRepository(xxAsset.getId(), request);
-
-		VXRepository deletedRepo = publicAPIs.getRepository(xxAsset.getId());
-
-		if (deletedRepo != null && deletedRepo.getIsActive() == false) {
-			logger.info("Repository has been deleted"
-					+ " successfully, and DB change has been rolled back");
-		} else {
-			fail("Delete Repository test failed");
-		}
-
-		super.endRequest();
-	}
-
-	/**
-	 * Test method for
-	 * {@link com.xasecure.rest.PublicAPIs#testConfig(com.xasecure.view.VXRepository)}
-	 * .
-	 */
-	public void testTestConfig() {
-		VXResponse vXResponseHDFS = publicAPIs.testConfig(vXRepoHDFS);
-		assertNotNull(
-				"Error while testing testConfig : for HDFS, testConfig function",
-				vXResponseHDFS);
-
-		if (vXResponseHDFS.getStatusCode() == VXResponse.STATUS_SUCCESS) {
-			logger.info("testConfig : for HDFS, testConfig function has been tested and working as expected");
-		} else if (vXResponseHDFS.getStatusCode() == VXResponse.STATUS_ERROR) {
-			logger.info("testConfig : for HDFS, testConfig function send error response");
-		}
-
-		// NOTE : testConfig will not work on local server but to test
-		// PublicREST API we need write it over here
-	}
-
-	/**
-	 * Test method for
-	 * {@link com.xasecure.rest.PublicAPIs#searchRepositories(javax.servlet.http.HttpServletRequest)}
-	 * .
-	 */
-	public void testSearchRepositories() {
-
-	}
-
-	/**
-	 * Test method for
-	 * {@link com.xasecure.rest.PublicAPIs#countRepositories(javax.servlet.http.HttpServletRequest)}
-	 * .
-	 */
-	public void testCountRepositories() {
-		VXLong vXLong = publicAPIs.countRepositories(super.startRequest());
-
-		assertNotNull("Count : Error while counting Repos", vXLong);
-		logger.info("Count : Total no of Repos are : " + vXLong.getValue());
-
-		super.endRequest();
-	}
-
-	/**
-	 * Test method for
-	 * {@link com.xasecure.rest.PublicAPIs#createPolicy(com.xasecure.view.VXPolicy)}
-	 * .
-	 */
-	public void testCreatePolicy() {
-		vXPolicyHDFS = new VXPolicy();
-		vXPolicyHBase = new VXPolicy();
-		vXPolicyHive = new VXPolicy();
-		vXPolicyKnox = new VXPolicy();
-		vXPolicyStorm = new VXPolicy();
-
-		// Create Policy for HDFS
-		createHDFSPolicy();
-		// Create Policy for HBase
-		createHBasePolicy();
-		// Create Policy for Hive
-		createHivePolicy();
-		// Create Policy for Knox
-		createKnoxPolicy();
-		// Create Policy for Storm
-		createStormPolicy();
-
-	}
-
-	private void createStormPolicy() {
-		vXPolicyStorm.setPolicyName("HomePolicy_" + GUIDUtil.genGUI());
-		vXPolicyStorm.setDescription("home policy for Storm");
-		vXPolicyStorm.setRepositoryName(vXRepoStorm.getName());
-		vXPolicyStorm.setRepositoryType("Storm");
-		vXPolicyStorm.setIsAuditEnabled(true);
-		vXPolicyStorm.setIsEnabled(true);
-		vXPolicyStorm.setTopologies("topo1, topo2, topo3");
-
-		VXPermObj vXPermObj = new VXPermObj();
-		List<String> userList = new ArrayList<String>();
-		userList.add("policymgr");
-		vXPermObj.setUserList(userList);
-
-		List<String> permList = new ArrayList<String>();
-		permList.add("Get Nimbus Conf");
-		permList.add("Get Cluster Info");
-		permList.add("Rebalance");
-		vXPermObj.setPermList(permList);
-
-		VXPermObj vXPermObj2 = new VXPermObj();
-		List<String> userList2 = new ArrayList<String>();
-		List<String> permList2 = new ArrayList<String>();
-
-		userList2.add("policymgr_hbase");
-		userList2.add("policymgr_hive");
-
-		permList2.add("File Download");
-		permList2.add("File Upload");
-		vXPermObj2.setUserList(userList2);
-		vXPermObj2.setPermList(permList2);
-
-		List<VXPermObj> permObjList = new ArrayList<VXPermObj>();
-		permObjList.add(vXPermObj);
-		permObjList.add(vXPermObj2);
-
-		vXPolicyStorm.setPermMapList(permObjList);
-
-		String preCreatedPolicyStorm = jsonUtil
-				.writeObjectAsString(vXPolicyStorm);
-		logger.info(preCreatedPolicyStorm);
-
-		vXPolicyStorm = publicAPIs.createPolicy(vXPolicyStorm);
-
-		String postCreatedPolicyStorm = jsonUtil
-				.writeObjectAsString(vXPolicyStorm);
-		logger.info(postCreatedPolicyStorm);
-
-		assertNotNull("Create Policy : Error while creating Policy for Storm",
-				vXPolicyStorm);
-		logger.info("Create Policy : Policy created successfully for Storm");
-	}
-
-	private void createKnoxPolicy() {
-		vXPolicyKnox.setPolicyName("HomePolicy_" + GUIDUtil.genGUI());
-		vXPolicyKnox.setDescription("home policy for Knox");
-		vXPolicyKnox.setRepositoryName(vXRepoKnox.getName());
-		vXPolicyKnox.setRepositoryType("Knox");
-		vXPolicyKnox.setIsAuditEnabled(true);
-		vXPolicyKnox.setIsEnabled(true);
-		vXPolicyKnox.setTopologies("topo1, topo2, topo3");
-		vXPolicyKnox.setServices("service1, service2, service3");
-
-		VXPermObj vXPermObj = new VXPermObj();
-		List<String> userList = new ArrayList<String>();
-		userList.add("policymgr");
-		vXPermObj.setUserList(userList);
-
-		List<String> permList = new ArrayList<String>();
-		permList.add("Allow");
-		permList.add("Admin");
-		vXPermObj.setPermList(permList);
-
-		VXPermObj vXPermObj2 = new VXPermObj();
-		List<String> userList2 = new ArrayList<String>();
-		List<String> permList2 = new ArrayList<String>();
-
-		userList2.add("policymgr_hbase");
-		userList2.add("policymgr_hive");
-
-		permList2.add("Allow");
-		vXPermObj2.setUserList(userList2);
-		vXPermObj2.setPermList(permList2);
-
-		VXPermObj vXPermObj3 = new VXPermObj();
-		List<String> grpList = new ArrayList<String>();
-		List<String> permList3 = new ArrayList<String>();
+@RunWith(MockitoJUnitRunner.class)
+public class TestPublicAPIs {
+	
+	private Long id = 1L;
+	
+	@InjectMocks
+	PublicAPIs publicAPIs = new PublicAPIs();
 
-		grpList.add("Grp1");
-		grpList.add("Grp2");
-		permList3.add("Allow");
-		permList3.add("Admin");
-		vXPermObj3.setGroupList(grpList);
-		vXPermObj3.setPermList(permList3);
-		vXPermObj3.setUserList(userList);
+	@Mock
+	XASearchUtil searchUtil;
 
-		List<VXPermObj> permObjList = new ArrayList<VXPermObj>();
-		permObjList.add(vXPermObj);
-		permObjList.add(vXPermObj2);
-		permObjList.add(vXPermObj3);
+	@Mock
+	AssetMgr assetMgr;
 
-		vXPolicyKnox.setPermMapList(permObjList);
+	@Mock
+	XAssetService xAssetService;
 
-		String preCreatedPolicyKnox = jsonUtil
-				.writeObjectAsString(vXPolicyKnox);
-		logger.info(preCreatedPolicyKnox);
+	@Mock
+	RESTErrorUtil restErrorUtil;
 
-		vXPolicyKnox = publicAPIs.createPolicy(vXPolicyKnox);
+	@Mock
+	XRepositoryService xRepositoryService;
 
-		String postCreatedPolicyKnox = jsonUtil
-				.writeObjectAsString(vXPolicyKnox);
-		logger.info(postCreatedPolicyKnox);
+	@Mock
+	XResourceService xResourceService;
 
-		assertNotNull("Create Policy : Error while creating Policy for Knox",
-				vXPolicyKnox);
-		logger.info("Create Policy : Policy created successfully for Knox");
-	}
-
-	private void createHivePolicy() {
-		vXPolicyHive.setPolicyName("HomePolicy_" + GUIDUtil.genGUI());
-		vXPolicyHive.setDatabases("vXPolicyHive_" + GUIDUtil.genGUI());
-		vXPolicyHive.setTables("finance,hr," + GUIDUtil.genGUI());
-		vXPolicyHive.setColumns("amt, emp_id, " + GUIDUtil.genGUI());
-		vXPolicyHive.setDescription("home policy for Hive");
-		vXPolicyHive.setRepositoryName(vXRepoHive.getName());
-		vXPolicyHive.setRepositoryType("Hive");
-		vXPolicyHive.setIsEnabled(true);
-		vXPolicyHive.setIsRecursive(true);
-		vXPolicyHive.setIsAuditEnabled(true);
-		vXPolicyHive.setColumnType("Exclusion");
-
-		VXPermObj vXPermObj = new VXPermObj();
-		List<String> userList = new ArrayList<String>();
-		userList.add("policymgr");
-		vXPermObj.setUserList(userList);
-
-		List<String> permList = new ArrayList<String>();
-		permList.add("read");
-		permList.add("write");
-		permList.add("admin");
-		vXPermObj.setPermList(permList);
-
-		VXPermObj vXPermObj2 = new VXPermObj();
-		List<String> userList2 = new ArrayList<String>();
-		List<String> permList2 = new ArrayList<String>();
-
-		userList2.add("policymgr_hbase");
-		userList2.add("policymgr_hive");
-
-		permList2.add("admin");
-		permList2.add("write");
-		vXPermObj2.setUserList(userList2);
-		vXPermObj2.setPermList(permList2);
-
-		List<VXPermObj> permObjList = new ArrayList<VXPermObj>();
-		permObjList.add(vXPermObj);
-		permObjList.add(vXPermObj2);
-
-		vXPolicyHive.setPermMapList(permObjList);
-
-		String preCreatedPolicyHive = jsonUtil
-				.writeObjectAsString(vXPolicyHive);
-		logger.info(preCreatedPolicyHive);
-
-		vXPolicyHive = publicAPIs.createPolicy(vXPolicyHive);
-
-		String postCreatedPolicyHive = jsonUtil
-				.writeObjectAsString(vXPolicyHive);
-		logger.info(postCreatedPolicyHive);
-
-		assertNotNull("Create Policy : Error while creating Policy for Hive",
-				vXPolicyHive);
-		logger.info("Create Policy : Policy created successfully for Hive");
-	}
-
-	private void createHBasePolicy() {
-		vXPolicyHBase.setPolicyName("HomePolicy_" + GUIDUtil.genGUI());
-		vXPolicyHBase.setTables("finance,hr," + GUIDUtil.genGUI());
-		vXPolicyHBase.setColumnFamilies("invoices,emps," + GUIDUtil.genGUI());
-		vXPolicyHBase.setColumns("amt, emp_id, " + GUIDUtil.genGUI());
-		vXPolicyHBase.setDescription("home policy for HBase");
-		vXPolicyHBase.setRepositoryName(vXRepoHBase.getName());
-		vXPolicyHBase.setRepositoryType("HBase");
-		vXPolicyHBase.setIsEnabled(true);
-		vXPolicyHBase.setIsRecursive(true);
-		vXPolicyHBase.setIsAuditEnabled(true);
-
-		VXPermObj vXPermObj = new VXPermObj();
-		List<String> userList = new ArrayList<String>();
-		userList.add("policymgr");
-		vXPermObj.setUserList(userList);
-
-		List<String> permList = new ArrayList<String>();
-		permList.add("read");
-		permList.add("write");
-		permList.add("admin");
-		vXPermObj.setPermList(permList);
-
-		VXPermObj vXPermObj2 = new VXPermObj();
-		List<String> userList2 = new ArrayList<String>();
-		List<String> permList2 = new ArrayList<String>();
-
-		userList2.add("policymgr_hbase");
-		userList2.add("policymgr_hive");
-
-		permList2.add("admin");
-		permList2.add("write");
-		vXPermObj2.setUserList(userList2);
-		vXPermObj2.setPermList(permList2);
-
-		List<VXPermObj> permObjList = new ArrayList<VXPermObj>();
-		permObjList.add(vXPermObj);
-		permObjList.add(vXPermObj2);
-
-		vXPolicyHBase.setPermMapList(permObjList);
-
-		String preCreatedPolicyHBase = jsonUtil
-				.writeObjectAsString(vXPolicyHBase);
-		logger.info(preCreatedPolicyHBase);
-
-		vXPolicyHBase = publicAPIs.createPolicy(vXPolicyHBase);
-
-		String postCreatedPolicyHBase = jsonUtil
-				.writeObjectAsString(vXPolicyHBase);
-		logger.info(postCreatedPolicyHBase);
-
-		assertNotNull("Create Policy : Error while creating Policy for HBase",
-				vXPolicyHBase);
-		logger.info("Create Policy : Policy created successfully for HBase");
-	}
-
-	private void createHDFSPolicy() {
-		vXPolicyHDFS.setPolicyName("HomePolicy_" + GUIDUtil.genGUI());
-		vXPolicyHDFS.setResourceName("/user/, / ,/hr/," + GUIDUtil.genGUI());
-		vXPolicyHDFS.setDescription("home policy for HDFS");
-		vXPolicyHDFS.setRepositoryName(vXRepoHDFS.getName());
-		vXPolicyHDFS.setRepositoryType("hdfs");
-		vXPolicyHDFS.setIsEnabled(true);
-		vXPolicyHDFS.setIsRecursive(true);
-		vXPolicyHDFS.setIsAuditEnabled(true);
-
-		VXPermObj vXPermObj = new VXPermObj();
-		List<String> userList = new ArrayList<String>();
-		userList.add("policymgr");
-		userList.add("policymgr_hive");
-		vXPermObj.setUserList(userList);
-
-		List<String> permList = new ArrayList<String>();
-		permList.add("read");
-		permList.add("write");
-		permList.add("admin");
-		vXPermObj.setPermList(permList);
-
-		VXPermObj vXPermObj2 = new VXPermObj();
-		List<String> userList2 = new ArrayList<String>();
-		List<String> permList2 = new ArrayList<String>();
-
-		userList2.add("policymgr_hbase");
-
-		permList2.add("admin");
-		permList2.add("write");
-		vXPermObj2.setUserList(userList2);
-		vXPermObj2.setPermList(permList2);
-
-		List<VXPermObj> permObjList = new ArrayList<VXPermObj>();
-		permObjList.add(vXPermObj);
-		permObjList.add(vXPermObj2);
-
-		vXPolicyHDFS.setPermMapList(permObjList);
-
-		String preCreatedPolicyHDFS = jsonUtil
-				.writeObjectAsString(vXPolicyHDFS);
-		logger.info(preCreatedPolicyHDFS);
-
-		vXPolicyHDFS = publicAPIs.createPolicy(vXPolicyHDFS);
-
-		String postCreatedPolicyHDFS = jsonUtil
-				.writeObjectAsString(vXPolicyHDFS);
-		logger.info(postCreatedPolicyHDFS);
-
-		assertNotNull("Create Policy : Error while creating Policy for HDFS",
-				vXPolicyHDFS);
-		logger.info("Create Policy : Policy created successfully for HDFS");
-	}
-
-	/**
-	 * Test method for
-	 * {@link com.xasecure.rest.PublicAPIs#updatePolicy(com.xasecure.view.VXPolicy)}
-	 * .
-	 */
-	public void testUpdatePolicy() {
-
-		// Update HDFS Policy
-		vXPolicyHDFS.setPolicyName("HDFS Policy Updated_" + GUIDUtil.genGUI());
-		vXPolicyHDFS.setIsRecursive(false);
-		vXPolicyHDFS.setPermMapList(vXPolicyHive.getPermMapList());
-		vXPolicyHDFS = publicAPIs.updatePolicy(vXPolicyHDFS,
-				vXPolicyHDFS.getId());
-
-		assertNotNull("Error While updating Policy", vXPolicyHDFS);
-		logger.info("Update : Policy for HDFS updated Successfully");
-
-		// Update HBase Policy
-		vXPolicyHBase
-				.setPolicyName("HBase Policy Updated_" + GUIDUtil.genGUI());
-		vXPolicyHBase.setIsEnabled(false);
-		vXPolicyHBase = publicAPIs.updatePolicy(vXPolicyHBase,
-				vXPolicyHBase.getId());
-
-		assertNotNull("Error While updating Policy", vXPolicyHBase);
-		logger.info("Update : Policy for HBase updated Successfully");
+	@Mock
+	XPolicyService xPolicyService;
 
-		// Update HIVE Policy
-		vXPolicyHive.setPolicyName("Hive Policy Updated_" + GUIDUtil.genGUI());
-		vXPolicyHive.setIsAuditEnabled(false);
-		vXPolicyHive.setPermMapList(null);
-		vXPolicyHive = publicAPIs.updatePolicy(vXPolicyHive,
-				vXPolicyHive.getId());
+	@Mock
+	StringUtil stringUtil;
 
-		assertNotNull("Error While updating Policy", vXPolicyHive);
-		logger.info("Update : Policy for Hive updated Successfully");
-
-		// Update Knox Policy
-		vXPolicyKnox.setPolicyName("Knox Policy Updated_" + GUIDUtil.genGUI());
-		vXPolicyKnox.setIsAuditEnabled(false);
-		vXPolicyKnox.setPermMapList(null);
-		vXPolicyKnox = publicAPIs.updatePolicy(vXPolicyKnox,
-				vXPolicyKnox.getId());
-
-		assertNotNull("Error While updating Policy", vXPolicyStorm);
-		logger.info("Update : Policy for Hive updated Successfully");
-
-		// Update Storm Policy
-		vXPolicyStorm
-				.setPolicyName("Storm Policy Updated_" + GUIDUtil.genGUI());
-		vXPolicyStorm.setIsAuditEnabled(false);
-		vXPolicyStorm.setPermMapList(null);
-		vXPolicyStorm = publicAPIs.updatePolicy(vXPolicyStorm,
-				vXPolicyStorm.getId());
-
-		assertNotNull("Error While updating Policy", vXPolicyStorm);
-		logger.info("Update : Policy for Hive updated Successfully");
-	}
-
-	/**
-	 * Test method for
-	 * {@link com.xasecure.rest.PublicAPIs#getPolicy(java.lang.Long)}.
-	 */
-	public void testGetPolicy() {
-
-		VXPolicy vXPolHDFS = publicAPIs.getPolicy(vXPolicyHDFS.getId());
-		String policyHDFSString = jsonUtil.writeObjectAsString(vXPolHDFS);
-		logger.info(policyHDFSString);
-
-		assertNotNull("No Policy found for this Id : " + vXPolicyHDFS.getId(),
-				vXPolHDFS);
-		logger.info("Get : Policy found for this id : " + vXPolicyHDFS.getId());
-
-		VXPolicy vXPolHBase = publicAPIs.getPolicy(vXPolicyHBase.getId());
-		assertNotNull("No Policy found for this Id : " + vXPolicyHBase.getId(),
-				vXPolHBase);
-		logger.info("Get : Policy found for this id : " + vXPolicyHBase.getId());
-
-		VXPolicy vXPolHive = publicAPIs.getPolicy(vXPolicyHive.getId());
-		assertNotNull("No Policy found for this Id : " + vXPolicyHive.getId(),
-				vXPolHive);
-		logger.info("Get : Policy found for this id : " + vXPolicyHive.getId());
-	}
-
-	/**
-	 * Test method for
-	 * {@link com.xasecure.rest.PublicAPIs#deletePolicy(java.lang.Long, javax.servlet.http.HttpServletRequest)}
-	 * .
-	 */
-	public void testDeletePolicy() {
-
-		XXResource xxResource = daoManager.getXXResource()
-				.findByAssetType(AppConstants.ASSET_HBASE).get(0);
-
-		if (xxResource == null) {
-			fail("No Resource found with name : HDFS Repo Updated");
-		}
-
-		MockHttpServletRequest request = super.startRequest();
-		request.addParameter("force", "true");
-		publicAPIs.deletePolicy(xxResource.getId(), request);
-
-		super.endRequest();
-	}
-
-	/**
-	 * Test method for
-	 * {@link com.xasecure.rest.PublicAPIs#searchPolicies(javax.servlet.http.HttpServletRequest)}
-	 * .
-	 */
-	public void testSearchPolicies() {
-
-	}
-
-	/**
-	 * Test method for
-	 * {@link com.xasecure.rest.PublicAPIs#countPolicies(javax.servlet.http.HttpServletRequest)}
-	 * .
-	 */
-	public void testCountPolicies() {
-		VXLong vXLong = publicAPIs.countPolicies(super.startRequest());
-
-		assertNotNull("Count : Error while counting Policies", vXLong);
-		logger.info("Count : Total no of Policies are : " + vXLong.getValue());
-
-		super.endRequest();
-	}
+	@Mock
+	XADaoManager xaDaoMgr;
 
 	@Test
-	@Rollback(false)
-	public void test() throws Exception {
-
-		createGroups();
-
-		testCreateRepository();
-		testUpdateRepository();
-		testGetRepository();
-		testTestConfig();
-		testSearchRepositories();
-		testCountRepositories();
-		testCreatePolicy();
-		testUpdatePolicy();
-		testGetPolicy();
-		testSearchPolicies();
-		testCountPolicies();
-		testDeleteRepository();
-		testDeletePolicy();
-	}
-
-	private void createGroups() {
-
-		XXGroup xGrp1 = daoManager.getXXGroup().findByGroupName("Grp1");
-		XXGroup xGrp2 = daoManager.getXXGroup().findByGroupName("Grp2");
-
-		if (xGrp1 == null) {
-			VXGroup vXGrp1 = new VXGroup();
-			vXGrp1.setName("Grp1");
-			vXGrp1.setDescription("Group 1");
-			xUserREST.createXGroup(vXGrp1);
-
-			assertNotNull("Error while creating Group", vXGrp1);
-			logger.info("New Groups Created Grp Name : " + vXGrp1.getName());
-		}
-		if (xGrp2 == null) {
-			VXGroup vXGrp2 = new VXGroup();
-			vXGrp2.setName("Grp2");
-			vXGrp2.setDescription("Group 2");
-			xUserREST.createXGroup(vXGrp2);
-
-			assertNotNull("Error while creating Group", vXGrp2);
-			logger.info("New Groups Created. Grp Name : " + vXGrp2.getName());
-		}
+	public void testGetRepository(){
+		VXAsset vXAsset = new VXAsset();
+		VXRepository vXRepository = new VXRepository();
+		Mockito.when(assetMgr.getXAsset(id)).thenReturn(vXAsset);
+		Mockito.when(xRepositoryService.mapXAToPublicObject(vXAsset)).thenReturn(vXRepository);
+		VXRepository vXRepositoryChk = publicAPIs.getRepository(id);
+		Mockito.verify(assetMgr).getXAsset(id);
+		Mockito.verify(xRepositoryService).mapXAToPublicObject(vXAsset);
+		Assert.assertEquals(vXRepositoryChk, vXRepository);
+	}
+	
+	@Test
+	public void testCreateRepository(){
+		VXAsset vXAsset = new VXAsset();
+		VXRepository vXRepository = new VXRepository();
+		Mockito.when(xRepositoryService.mapPublicToXAObject(vXRepository)).thenReturn(vXAsset);
+		Mockito.when(assetMgr.createXAsset(vXAsset)).thenReturn(vXAsset);
+		Mockito.when(xRepositoryService.mapXAToPublicObject(vXAsset)).thenReturn(vXRepository);		
+		VXRepository vXRepoChk = publicAPIs.createRepository(vXRepository);		
+		Mockito.verify(xRepositoryService).mapXAToPublicObject(vXAsset);
+		Mockito.verify(assetMgr).createXAsset(vXAsset);
+		Mockito.verify(xRepositoryService).mapPublicToXAObject(vXRepository);
+		Assert.assertEquals(vXRepository, vXRepoChk);
+	}
+	
+	@Test
+	public void testUpdateRepository(){
+		VXAsset vXAsset = new VXAsset();
+		VXRepository vXRepository = new VXRepository();
+		Mockito.when(xRepositoryService.mapPublicToXAObject(vXRepository)).thenReturn(vXAsset);
+		Mockito.when(assetMgr.updateXAsset(vXAsset)).thenReturn(vXAsset);
+		Mockito.when(xRepositoryService.mapXAToPublicObject(vXAsset)).thenReturn(vXRepository);
+		VXRepository vXRepoChk = publicAPIs.updateRepository(vXRepository, id);
+		Mockito.verify(xRepositoryService).mapPublicToXAObject(vXRepository);
+		Mockito.verify(assetMgr).updateXAsset(vXAsset);
+		Mockito.verify(xRepositoryService).mapXAToPublicObject(vXAsset);
+		Assert.assertEquals(vXRepository, vXRepoChk);
+	}
+	
+	@Test
+	public void testDeleteRepository(){
+		String forceStr = "true";
+		HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+		Mockito.when(request.getParameter("force")).thenReturn(forceStr);
+		Mockito.when(stringUtil.isEmpty(forceStr)).thenReturn(false);
+		publicAPIs.deleteRepository(id, request);
+		Mockito.verify(request).getParameter("force");
+		Mockito.verify(stringUtil).isEmpty(forceStr);
+	}
+	
+	@Test
+	public void testSearchRepositories(){
+		HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+		VXRepositoryList vXRepoList = new VXRepositoryList();
+		SearchCriteria searchCriteria = new SearchCriteria();
+		Mockito.when(searchUtil.extractCommonCriterias(request, xAssetService.sortFields)).thenReturn(searchCriteria);
+		Mockito.when(xRepositoryService.mapToVXRepositoryList(null)).thenReturn(vXRepoList);
+		VXRepositoryList chk = publicAPIs.searchRepositories(request);
+		Mockito.verify(searchUtil).extractCommonCriterias(request, xAssetService.sortFields);
+		Mockito.verify(xRepositoryService).mapToVXRepositoryList(null);
+		Assert.assertEquals(vXRepoList, chk);
+	}
+	
+	@Test
+	public void testCountRepositories(){
+		VXLong vXLong = new VXLong();
+		HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+		SearchCriteria searchCriteria = new SearchCriteria();
+		Mockito.when(searchUtil.extractCommonCriterias(request, xAssetService.sortFields)).thenReturn(searchCriteria);
+		Mockito.when(assetMgr.getXAssetSearchCount(searchCriteria)).thenReturn(vXLong);		
+		VXLong chk = publicAPIs.countRepositories(request);
+		Mockito.verify(searchUtil).extractCommonCriterias(request, xAssetService.sortFields);
+		Mockito.verify(assetMgr).getXAssetSearchCount(searchCriteria);
+		Assert.assertEquals(vXLong, chk);
+	}	
+	
+	@Test
+	public void testGetPolicy(){
+		VXResource vXResource = new VXResource();
+		VXPolicy vXPolicy = new VXPolicy();
+		Mockito.when(assetMgr.getXResource(id)).thenReturn(vXResource);
+		Mockito.when(xPolicyService.mapXAToPublicObject(vXResource)).thenReturn(vXPolicy);
+		VXPolicy chk = publicAPIs.getPolicy(id);
+		Mockito.verify(assetMgr).getXResource(id);
+		Mockito.verify(xPolicyService).mapXAToPublicObject(vXResource);
+		Assert.assertEquals(vXPolicy, chk);
+	}
+	
+	@Test
+	public void testCreatePolicy(){
+		VXPolicy vXPolicy = new VXPolicy();
+		VXResource vXResource = new VXResource();
+		Mockito.when(xPolicyService.mapPublicToXAObject(vXPolicy,AbstractBaseResourceService.OPERATION_CREATE_CONTEXT)).thenReturn(vXResource);
+		Mockito.when(assetMgr.createXResource(vXResource)).thenReturn(vXResource);
+		Mockito.when(xPolicyService.mapXAToPublicObject(vXResource)).thenReturn(vXPolicy);
+		VXPolicy chk = publicAPIs.createPolicy(vXPolicy);
+		Mockito.verify(xPolicyService).mapPublicToXAObject(vXPolicy,AbstractBaseResourceService.OPERATION_CREATE_CONTEXT);
+		Mockito.verify(assetMgr).createXResource(vXResource);
+		Mockito.verify(xPolicyService).mapXAToPublicObject(vXResource);
+		Assert.assertEquals(vXPolicy, chk);
+	}
+	
+	@Test
+	public void testUpdatePolicy(){
+		VXPolicy vXPolicy = new VXPolicy();
+		VXResource vXResource = new VXResource();
+		Mockito.when(xPolicyService.mapPublicToXAObject(vXPolicy,AbstractBaseResourceService.OPERATION_UPDATE_CONTEXT)).thenReturn(vXResource);
+		Mockito.when(assetMgr.updateXResource(vXResource)).thenReturn(vXResource);
+		Mockito.when(xPolicyService.mapXAToPublicObject(vXResource)).thenReturn(vXPolicy);
+		VXPolicy chk = publicAPIs.updatePolicy(vXPolicy, id);
+		Mockito.verify(xPolicyService).mapPublicToXAObject(vXPolicy,AbstractBaseResourceService.OPERATION_UPDATE_CONTEXT);
+		Mockito.verify(assetMgr).updateXResource(vXResource);
+		Mockito.verify(xPolicyService).mapXAToPublicObject(vXResource);
+		Assert.assertEquals(vXPolicy, chk);		
+	}
+	
+	@Test
+	public void testDeletePolicy(){
+		String forceStr = "true";
+		HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+		Mockito.when(request.getParameter("force")).thenReturn(forceStr);
+		Mockito.when(stringUtil.isEmpty(forceStr)).thenReturn(false);
+		publicAPIs.deletePolicy(id, request);
+		Mockito.verify(request).getParameter("force");
+		Mockito.verify(stringUtil).isEmpty(forceStr);
+	}
+	
+	@Test
+	public void testSearchPolicies(){
+		HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+		VXPolicyList vXRepoList = new VXPolicyList();
+		SearchCriteria searchCriteria = new SearchCriteria();
+		Mockito.when(searchUtil.extractCommonCriterias(request, xAssetService.sortFields)).thenReturn(searchCriteria);
+		Mockito.when(xPolicyService.mapToVXPolicyList(null)).thenReturn(vXRepoList);
+		VXPolicyList chk = publicAPIs.searchPolicies(request);
+		Mockito.verify(searchUtil).extractCommonCriterias(request, xAssetService.sortFields);
+		Mockito.verify(xPolicyService).mapToVXPolicyList(null);
+		Assert.assertEquals(vXRepoList, chk);
+	}
+	
+	@Test
+	public void testCountPolicies(){
+		VXLong vXLong = new VXLong();
+		HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+		SearchCriteria searchCriteria = new SearchCriteria();
+		Mockito.when(searchUtil.extractCommonCriterias(request, xResourceService.sortFields)).thenReturn(searchCriteria);
+		Mockito.when(assetMgr.getXResourceSearchCount(searchCriteria)).thenReturn(vXLong);
+		VXLong chk = publicAPIs.countPolicies(request);
+		Mockito.verify(searchUtil).extractCommonCriterias(request, xResourceService.sortFields);
+		Mockito.verify(assetMgr).getXResourceSearchCount(searchCriteria);
+		Assert.assertEquals(vXLong, chk);
 	}
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/65b6d83d/security-admin/src/test/java/com/xasecure/util/TestXAEnumUtil.java
----------------------------------------------------------------------
diff --git a/security-admin/src/test/java/com/xasecure/util/TestXAEnumUtil.java b/security-admin/src/test/java/com/xasecure/util/TestXAEnumUtil.java
new file mode 100644
index 0000000..6fe91cc
--- /dev/null
+++ b/security-admin/src/test/java/com/xasecure/util/TestXAEnumUtil.java
@@ -0,0 +1,108 @@
+package com.xasecure.util;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.springframework.beans.factory.annotation.Autowired;
+import com.xasecure.common.view.VEnum;
+import com.xasecure.common.view.VEnumElement;
+
+public class TestXAEnumUtil {
+
+	@Autowired
+	XAEnumUtil xaEnumUtil = new XAEnumUtil();
+
+	@Rule
+	public ExpectedException thrown = ExpectedException.none();
+
+	@Test
+	public void testGetEnums() {
+
+		VEnumElement VEnumElement = new VEnumElement();
+		VEnumElement.setEnumName("test1");
+		VEnumElement.setElementName("test2");
+		VEnumElement.setElementLabel("test3");
+		VEnumElement.setElementValue(0);
+		VEnumElement.setRbKey("11");
+		List<VEnumElement> listVEnumElement = new ArrayList<VEnumElement>();
+
+		VEnum vEnum = new VEnum();
+		vEnum.setEnumName("test");
+		vEnum.setElementList(listVEnumElement);
+		             xaEnumUtil.enumList.add(vEnum);
+		 List<VEnum>  dbvEnum= xaEnumUtil.getEnums();
+	     Assert.assertNotNull(dbvEnum);
+	}
+	
+	@Test
+	public void testGetEnumEmpty() {
+		
+		String enumName = "";
+	        xaEnumUtil.getEnum(enumName);
+	    Assert.assertNotNull(xaEnumUtil.enumList.size() > 0);
+	}
+
+	@Test
+	public void testGetEnum() {
+
+		String enumName = "enumtest";
+
+		VEnumElement vEnumElement1 = new VEnumElement();
+		vEnumElement1.setEnumName(enumName);
+		vEnumElement1.setElementName("test12");
+		vEnumElement1.setElementLabel("test13");
+		vEnumElement1.setElementValue(1);
+		vEnumElement1.setRbKey("11");
+		List<VEnumElement> VEnumElement = new ArrayList<VEnumElement>();
+		                   VEnumElement.add(vEnumElement1);
+
+		VEnum vEnum = new VEnum();
+		vEnum.setEnumName(enumName);
+		vEnum.setElementList(VEnumElement);
+
+		xaEnumUtil.enumMap.put(enumName, vEnum);
+
+		VEnum dbvEnum = xaEnumUtil.getEnum(enumName);
+
+		Assert.assertNotNull(dbvEnum);
+		Assert.assertEquals(enumName, dbvEnum.getEnumName());
+	}
+
+	@Test
+	public void testGetLabelIsNUll() {
+		String enumName = "CommonEnums.ActiveStatus";
+		int enumValue = 1;		
+		String value = xaEnumUtil.getLabel(enumName, enumValue);
+		boolean checkValue=value.isEmpty();
+		Assert.assertFalse(checkValue);
+	}
+
+	@Test
+	public void testGetLabel() {
+		testGetEnum();
+		String enumName = "CommonEnums.ActiveStatus";
+		int enumValue = 1;		
+		String value = xaEnumUtil.getLabel(enumName, enumValue);
+		Assert.assertNotNull(value);
+	}
+	
+	@Test
+	public void testgetValueIsNull() {
+		String enumName = "CommonEnums.BooleanValue";
+		String elementName = "BOOL_NONE";	
+		int value = xaEnumUtil.getValue(enumName, elementName);
+		Assert.assertEquals(0, value);
+	}
+	
+	@Test
+	public void testgetValue() {
+		testGetEnum();
+		String enumName = "CommonEnums.ActivationStatus";
+		String elementName = "ACT_STATUS_DISABLED";	
+		int value = xaEnumUtil.getValue(enumName, elementName);
+		Assert.assertEquals(0, value);
+	}
+}
\ No newline at end of file


Mime
View raw message