### Question:
AopValidator { private boolean contains(Annotation[] annotations, Class<?> annotation) { Optional<Annotation> res = Arrays.asList(annotations).stream() .filter(a -> a.annotationType().isAssignableFrom(annotation)).findFirst(); return res.isPresent(); }    }### Answer:
@Test public void testSingleNullParamViolation() { try { assertEquals("abc", service.singleStringParam(null)); fail(); } catch (BeanValidationException ve) { String msg = ve.getMessage(); assertTrue(msg, msg.contains("METHOD_PARAM_INDEX_0=[NULL_ROOT_OBJECT]")); } }
@Test public void testMultpileParamsWithViolations() { try { service.mixedParams(new CqlKeySpace(" "), new CqlTable(" "), null); fail(); } catch (BeanValidationException ve) { String msg = ve.getMessage(); assertTrue(msg, msg.contains("METHOD_PARAM_INDEX_0=[ConstraintViolation")); assertTrue(msg, msg.contains("METHOD_PARAM_INDEX_1=[ConstraintViolation")); assertTrue(msg, msg.contains("METHOD_PARAM_INDEX_2=[NULL_ROOT_OBJECT]")); } }
@Test public void testReturnNullObjectViolation() { try { service.mixedParams(null, new CqlTable("table"), "123"); fail(); } catch (BeanValidationException ve) { String msg = ve.getMessage(); assertTrue(msg, msg.contains("METHOD_RETURN_VALUE=[NULL_ROOT_OBJECT]")); } }
@Test public void testFirstParamViolation() { try { service.mixedParams(null, new CqlTable(" "), "123"); fail(); } catch (BeanValidationException ve) { String msg = ve.getMessage(); assertTrue(msg, msg.contains("METHOD_PARAM_INDEX_1=")); assertTrue(msg, msg.contains("propertyPath=partLc")); } }
@Test public void testReturnNotEmptyViolation() { try { service.returnOptional(new CqlKeySpace(" ")); fail(); } catch (BeanValidationException ve) { String msg = ve.getMessage(); assertTrue(msg, msg.contains("METHOD_RETURN_VALUE")); assertTrue(msg, msg.contains("propertyPath=partLc, rootBeanClass=class org.cyclop.model.CqlKeySpace")); } }