@Test
public final void testIsValid_errorPaths() throws Exception {

	boolean isAdmin = true;
	// 1. create policy in a non-existing service
	Action action = Action.CREATE;
	when(_policy.getService()).thenReturn("non-existing-service-name");
	when(_store.getServiceByName("non-existing-service-name")).thenReturn(null);
	Assert.assertFalse(action.toString(), _validator.isValid(_policy, action, isAdmin, _failures));
	// 2. update a policy to change the service-name
	RangerPolicy existingPolicy = mock(RangerPolicy.class);
	when(existingPolicy.getId()).thenReturn(8L);
	when(existingPolicy.getService()).thenReturn("service-name");
	RangerService service = mock(RangerService.class);
	when(service.getType()).thenReturn("service-type");
	when(service.getName()).thenReturn("service-name");
	when(_store.getServiceByName("service-name")).thenReturn(service);
	RangerService service2 = mock(RangerService.class);
	when(service2.getType()).thenReturn("service-type");
	when(service2.getName()).thenReturn("service-name2");
	when(_store.getServiceByName("service-name2")).thenReturn(service2);
	when(_policy.getService()).thenReturn("service-name2");
	when(_store.getServiceByName("service-name2")).thenReturn(service2);
	action = Action.UPDATE;
	Assert.assertFalse(action.toString(), _validator.isValid(_policy, action, isAdmin, _failures));
	// 3. update a policy to change the policy-type
	when(existingPolicy.getId()).thenReturn(8L);
	when(existingPolicy.getService()).thenReturn("service-name");
	when(existingPolicy.getPolicyType()).thenReturn(Integer.valueOf(0));
	when(_policy.getId()).thenReturn(8L);
	when(_policy.getService()).thenReturn("service-name");
	when(_policy.getPolicyType()).thenReturn(Integer.valueOf(1));
	Assert.assertFalse(action.toString(), _validator.isValid(_policy, action, isAdmin, _failures));
}