@Test
public void test2mapViewToEntityBeanNullValue() {

	XXServiceDao xServiceDao = Mockito.mock(XXServiceDao.class);
	RangerPolicy rangerPolicy = rangerPolicy();
	XXPolicy policy = policy();
	int OPERATION_CONTEXT = 0;
	Mockito.when(
			restErrorUtil.createRESTException(
					"No corresponding service found for policyName: "
							+ rangerPolicy.getName()
							+ "Service Not Found : "
							+ rangerPolicy.getName(),
					MessageEnums.INVALID_INPUT_DATA)).thenThrow(
			new WebApplicationException());
	thrown.expect(WebApplicationException.class);
	Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao);
	Mockito.when(xServiceDao.findByName(rangerPolicy.getService()))
			.thenReturn(null);
	XXPolicy dbPolicy = policyService.mapViewToEntityBean(rangerPolicy,
			policy, OPERATION_CONTEXT);
	Assert.assertNotNull(dbPolicy);
	Assert.assertEquals(dbPolicy.getId(), policy.getId());
	Assert.assertEquals(dbPolicy.getGuid(), policy.getGuid());
	Assert.assertEquals(dbPolicy.getName(), policy.getName());
	Assert.assertEquals(dbPolicy.getAddedByUserId(),
			policy.getAddedByUserId());
	Assert.assertEquals(dbPolicy.getIsEnabled(), policy.getIsEnabled());
	Assert.assertEquals(dbPolicy.getVersion(), policy.getVersion());
	Assert.assertEquals(dbPolicy.getDescription(), policy.getDescription());
	Mockito.verify(daoManager).getXXService();
}