@Test
public void test12updateServiceDef() throws Exception {

	setup();
	XXServiceDefDao xServiceDefDao = Mockito.mock(XXServiceDefDao.class);
	XXServiceDef xServiceDef = Mockito.mock(XXServiceDef.class);
	XXServiceConfigDefDao xServiceConfigDefDao = Mockito
			.mock(XXServiceConfigDefDao.class);
	XXResourceDefDao xResourceDefDao = Mockito.mock(XXResourceDefDao.class);
	XXAccessTypeDefDao xAccessTypeDefDao = Mockito
			.mock(XXAccessTypeDefDao.class);
	XXPolicyConditionDefDao xPolicyConditionDefDao = Mockito
			.mock(XXPolicyConditionDefDao.class);
	XXContextEnricherDefDao xContextEnricherDefDao = Mockito
			.mock(XXContextEnricherDefDao.class);
	XXEnumDefDao xEnumDefDao = Mockito.mock(XXEnumDefDao.class);
	XXDataMaskTypeDefDao xDataMaskDefDao = Mockito.mock(XXDataMaskTypeDefDao.class);
	XXServiceDao xServiceDao = Mockito.mock(XXServiceDao.class);
	RangerServiceDef rangerServiceDef = rangerServiceDef();
	Long serviceDefId = rangerServiceDef.getId();
	List<XXServiceConfigDef> svcConfDefList = new ArrayList<XXServiceConfigDef>();
	XXServiceConfigDef serviceConfigDefObj = new XXServiceConfigDef();
	serviceConfigDefObj.setId(Id);
	serviceConfigDefObj.setType("1");
	svcConfDefList.add(serviceConfigDefObj);
	Mockito.when(
			serviceDefService.populateRangerServiceConfigDefToXX(
					Mockito.any(RangerServiceConfigDef.class), Mockito.any(XXServiceConfigDef.class), Mockito.any(XXServiceDef.class),
					Mockito.eq(RangerServiceDefService.OPERATION_CREATE_CONTEXT))).thenReturn(serviceConfigDefObj);
	Mockito.when(xServiceConfigDefDao.create(serviceConfigDefObj))
			.thenReturn(serviceConfigDefObj);
	List<XXResourceDef> resDefList = new ArrayList<XXResourceDef>();
	XXResourceDef resourceDef = new XXResourceDef();
	resourceDef.setAddedByUserId(Id);
	resourceDef.setCreateTime(new Date());
	resourceDef.setDefid(Id);
	resourceDef.setDescription("test");
	resourceDef.setId(Id);
	resDefList.add(resourceDef);
	List<XXAccessTypeDef> accessTypeDefList = new ArrayList<XXAccessTypeDef>();
	XXAccessTypeDef accessTypeDefObj = new XXAccessTypeDef();
	accessTypeDefObj.setAddedByUserId(Id);
	accessTypeDefObj.setCreateTime(new Date());
	accessTypeDefObj.setDefid(Id);
	accessTypeDefObj.setId(Id);
	accessTypeDefObj.setLabel("Read");
	accessTypeDefObj.setName("read");
	accessTypeDefObj.setOrder(null);
	accessTypeDefObj.setRbkeylabel(null);
	accessTypeDefObj.setUpdatedByUserId(Id);
	accessTypeDefObj.setUpdateTime(new Date());
	accessTypeDefList.add(accessTypeDefObj);
	List<XXPolicyConditionDef> policyConditionDefList = new ArrayList<XXPolicyConditionDef>();
	XXPolicyConditionDef policyConditionDefObj = new XXPolicyConditionDef();
	policyConditionDefObj.setAddedByUserId(Id);
	policyConditionDefObj.setCreateTime(new Date());
	policyConditionDefObj.setDefid(Id);
	policyConditionDefObj.setDescription("policy");
	policyConditionDefObj.setId(Id);
	policyConditionDefObj.setName("country");
	policyConditionDefObj.setOrder(0);
	policyConditionDefObj.setUpdatedByUserId(Id);
	policyConditionDefObj.setUpdateTime(new Date());
	policyConditionDefList.add(policyConditionDefObj);
	List<XXContextEnricherDef> contextEnricherDefList = new ArrayList<XXContextEnricherDef>();
	XXContextEnricherDef contextEnricherDefObj = new XXContextEnricherDef();
	contextEnricherDefObj.setAddedByUserId(Id);
	contextEnricherDefObj.setCreateTime(new Date());
	contextEnricherDefObj.setDefid(Id);
	contextEnricherDefObj.setId(Id);
	contextEnricherDefObj.setName("country-provider");
	contextEnricherDefObj
			.setEnricherOptions("contextName=COUNTRY;dataFile=/etc/ranger/data/userCountry.properties");
	contextEnricherDefObj.setEnricher("RangerCountryProvider");
	contextEnricherDefObj.setOrder(null);
	contextEnricherDefObj.setUpdatedByUserId(Id);
	contextEnricherDefObj.setUpdateTime(new Date());
	contextEnricherDefList.add(contextEnricherDefObj);
	List<XXEnumDef> enumDefList = new ArrayList<XXEnumDef>();
	XXEnumDef enumDefObj = new XXEnumDef();
	enumDefObj.setAddedByUserId(Id);
	enumDefObj.setCreateTime(new Date());
	enumDefObj.setDefaultindex(0);
	enumDefObj.setDefid(Id);
	enumDefObj.setId(Id);
	enumDefObj.setName("authnType");
	enumDefObj.setUpdatedByUserId(Id);
	enumDefObj.setUpdateTime(new Date());
	enumDefList.add(enumDefObj);
	Mockito.when(daoManager.getXXServiceDef()).thenReturn(xServiceDefDao);
	Mockito.when(xServiceDefDao.getById(serviceDefId)).thenReturn(
			xServiceDef);
	Mockito.when(daoManager.getXXServiceConfigDef()).thenReturn(
			xServiceConfigDefDao);
	Mockito.when(daoManager.getXXResourceDef()).thenReturn(xResourceDefDao);
	Mockito.when(daoManager.getXXAccessTypeDef()).thenReturn(
			xAccessTypeDefDao);
	Mockito.when(daoManager.getXXPolicyConditionDef()).thenReturn(
			xPolicyConditionDefDao);
	Mockito.when(daoManager.getXXContextEnricherDef()).thenReturn(
			xContextEnricherDefDao);
	Mockito.when(daoManager.getXXEnumDef()).thenReturn(xEnumDefDao);
	Mockito.when(daoManager.getXXDataMaskTypeDef()).thenReturn(xDataMaskDefDao);
	Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao);
	Mockito.when(xServiceDao.findByServiceDefId(serviceDefId)).thenReturn(null);
	Mockito.when(serviceDefService.read(Id)).thenReturn(rangerServiceDef);
	RangerServiceDef dbServiceDef = serviceDBStore
			.updateServiceDef(rangerServiceDef);
	Assert.assertNotNull(dbServiceDef);
	Assert.assertEquals(dbServiceDef, rangerServiceDef);
	Assert.assertEquals(dbServiceDef.getId(), rangerServiceDef.getId());
	Assert.assertEquals(dbServiceDef.getCreatedBy(),
			rangerServiceDef.getCreatedBy());
	Assert.assertEquals(dbServiceDef.getDescription(),
			rangerServiceDef.getDescription());
	Assert.assertEquals(dbServiceDef.getGuid(), rangerServiceDef.getGuid());
	Assert.assertEquals(dbServiceDef.getImplClass(),
			rangerServiceDef.getImplClass());
	Assert.assertEquals(dbServiceDef.getLabel(),
			rangerServiceDef.getLabel());
	Assert.assertEquals(dbServiceDef.getName(), rangerServiceDef.getName());
	Assert.assertEquals(dbServiceDef.getRbKeyDescription(),
			rangerServiceDef.getRbKeyDescription());
	Assert.assertEquals(dbServiceDef.getConfigs(),
			rangerServiceDef.getConfigs());
	Assert.assertEquals(dbServiceDef.getVersion(),
			rangerServiceDef.getVersion());
	Assert.assertEquals(dbServiceDef.getResources(),
			rangerServiceDef.getResources());
}