@Test
public void test_isValid_happyPath() throws Exception {

	// create a service def with some required parameters
	Object[][] serviceDefInput = new Object[][] {
			{ "param1", true },
			{ "param2", true },
			{ "param3", false },
			{ "param4", false },
			{ "param5", true },
	};
	List<RangerServiceConfigDef> configDefs = _utils.createServiceConditionDefs(serviceDefInput);
	RangerServiceDef serviceDef = mock(RangerServiceDef.class);
	when(serviceDef.getConfigs()).thenReturn(configDefs);
	// create a service with some parameters on it
	RangerService service = mock(RangerService.class);
	when(service.getName()).thenReturn("aName");
	when(service.getDisplayName()).thenReturn("aDisplayName");
	when(service.getType()).thenReturn("aType");
	// contains an extra parameter (param6) and one optional is missing(param4)
	String[] configs = new String[] { "param1", "param2", "param3", "param5", "param6" };
	Map<String, String> configMap = _utils.createMap(configs);
	when(service.getConfigs()).thenReturn(configMap);
	// wire then into the store
	// service does not exists
	when(_store.getServiceByName("aName")).thenReturn(null);
	// service def exists
	when(_store.getServiceDefByName("aType")).thenReturn(serviceDef);
	Assert.assertTrue(_validator.isValid(service, Action.CREATE, _failures));
	// for update to work the only additional requirement is that id is required and service should exist
	// if name is not null and it points to a service then it should match the id
	when(service.getId()).thenReturn(7L);
	RangerService existingService = mock(RangerService.class);
	when(existingService.getId()).thenReturn(Long.valueOf(7L));
	when(_store.getService(7L)).thenReturn(existingService);
	when(_store.getServiceByName("aName")).thenReturn(existingService);
	Assert.assertTrue(_validator.isValid(service, Action.UPDATE, _failures));
	// name need not point to a service for update to work, of course.
	when(_store.getServiceByName("aName")).thenReturn(null);
	Assert.assertTrue(_validator.isValid(service, Action.UPDATE, _failures));
}