当前位置: 首页>>代码示例>>Java>>正文


Java ExecutableValidator.validateConstructorParameters方法代码示例

本文整理汇总了Java中javax.validation.executable.ExecutableValidator.validateConstructorParameters方法的典型用法代码示例。如果您正苦于以下问题:Java ExecutableValidator.validateConstructorParameters方法的具体用法?Java ExecutableValidator.validateConstructorParameters怎么用?Java ExecutableValidator.validateConstructorParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.validation.executable.ExecutableValidator的用法示例。


在下文中一共展示了ExecutableValidator.validateConstructorParameters方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: constructorViolationsWhenNullParameters

import javax.validation.executable.ExecutableValidator; //导入方法依赖的package包/类
@Test
public void constructorViolationsWhenNullParameters() throws NoSuchMethodException, SecurityException {
       final MyParameter parameter = new MyParameter();

	ExecutableValidator methodValidator = validator.forExecutables();
	Constructor<MyBean2> constructor = MyBean2.class
			.getConstructor(parameter.getClass());

	Set<ConstraintViolation<MyBean2>> constraints = methodValidator
			.validateConstructorParameters(constructor, new Object[] {parameter});

	ConstraintViolation<MyBean2> violation = constraints.iterator().next();
	assertThat(constraints.size(), equalTo(1));
	assertThat(violation.getMessageTemplate(), equalTo("{javax.validation.constraints.NotNull.message}"));
	assertThat(violation.getPropertyPath().toString(), equalTo("MyBean2.arg0.value"));
}
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:17,代码来源:ConstructorParametersConstraintsTest.java

示例2: constructorViolationsWhenNotNullParameters

import javax.validation.executable.ExecutableValidator; //导入方法依赖的package包/类
@Test
public void constructorViolationsWhenNotNullParameters() throws NoSuchMethodException, SecurityException {
	final MyParameter parameter = new MyParameter();
       parameter.setValue("foo");

       ExecutableValidator methodValidator = validator.forExecutables();
	Constructor<MyBean2> constructor = MyBean2.class
			.getConstructor(parameter.getClass());

	Set<ConstraintViolation<MyBean2>> constraints = methodValidator
			.validateConstructorParameters(constructor, new Object[] {parameter});

	assertThat(constraints.isEmpty(), equalTo(true));
}
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:15,代码来源:ConstructorParametersConstraintsTest.java

示例3: testConstructorParameters

import javax.validation.executable.ExecutableValidator; //导入方法依赖的package包/类
@Test
public void testConstructorParameters() throws NoSuchMethodException {
    ExecutableValidator executableValidator = validator.forExecutables();
    Constructor<RentalStation> constructor = RentalStation.class.getConstructor(String.class, String.class);
    Set<ConstraintViolation<RentalStation>> violations = executableValidator.validateConstructorParameters
            (constructor, new Object[] {"Hertz", ""});
    assertThat(violations.size()).isEqualTo(0);
    violations = executableValidator.validateConstructorParameters
            (constructor, new Object[] {null, ""});
    assertThat(violations.size()).isEqualTo(1);
    violations = executableValidator.validateConstructorParameters
            (constructor, new Object[] {null, null});
    assertThat(violations.size()).isEqualTo(2);
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:15,代码来源:ValidationTest.java

示例4: validateParameters

import javax.validation.executable.ExecutableValidator; //导入方法依赖的package包/类
@Override
public void validateParameters(final Constructor constructor, final Object[] parameters) {
    final ExecutableValidator executableValidator = validatorFactory.getValidator().forExecutables();
    final Set<ConstraintViolation<?>> violations = executableValidator.validateConstructorParameters(constructor, parameters);
    if (!violations.isEmpty()) {
        throw new ConstraintViolationException(violations);
    }
}
 
开发者ID:tomitribe,项目名称:crest,代码行数:9,代码来源:BeanValidation11.java


注:本文中的javax.validation.executable.ExecutableValidator.validateConstructorParameters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。