Search in sources :

Example 1 with CustomerRepositoryImpl

use of org.hibernate.validator.test.internal.engine.methodvalidation.service.CustomerRepositoryImpl in project hibernate-validator by hibernate.

the class AbstractConstructorValidationTest method cascadedConstructorParameterValidationYieldsConstraintViolation.

@Test
public void cascadedConstructorParameterValidationYieldsConstraintViolation() throws Exception {
    Set<ConstraintViolation<CustomerRepositoryImpl>> violations = executableValidator.validateConstructorParameters(CustomerRepositoryImpl.class.getConstructor(Customer.class), new Customer[] { new Customer(null) });
    assertThat(violations).containsOnlyViolations(violationOf(NotNull.class).withMessage(messagePrefix() + "must not be null").withInvalidValue(null).withRootBeanClass(CustomerRepositoryImpl.class).withPropertyPath(pathWith().constructor(CustomerRepositoryImpl.class).parameter("customer", 0).property("name")));
}
Also used : Customer(org.hibernate.validator.test.internal.engine.methodvalidation.model.Customer) ConstraintViolation(jakarta.validation.ConstraintViolation) CustomerRepositoryImpl(org.hibernate.validator.test.internal.engine.methodvalidation.service.CustomerRepositoryImpl) NotNull(jakarta.validation.constraints.NotNull) Test(org.testng.annotations.Test)

Example 2 with CustomerRepositoryImpl

use of org.hibernate.validator.test.internal.engine.methodvalidation.service.CustomerRepositoryImpl in project hibernate-validator by hibernate.

the class AbstractMethodValidationTest method createProxy.

protected void createProxy(Class<?>... groups) {
    customerRepositoryOriginalBean = new CustomerRepositoryImpl();
    customerRepositoryValidatingProxy = getValidatingProxy(customerRepositoryOriginalBean, validator, groups);
    repositoryBase = customerRepositoryValidatingProxy;
}
Also used : CustomerRepositoryImpl(org.hibernate.validator.test.internal.engine.methodvalidation.service.CustomerRepositoryImpl)

Example 3 with CustomerRepositoryImpl

use of org.hibernate.validator.test.internal.engine.methodvalidation.service.CustomerRepositoryImpl in project hibernate-validator by hibernate.

the class WrongMethodOrParameterForMethodValidationTest method setUp.

@BeforeClass
public void setUp() {
    validator = ValidatorUtil.getValidator().forExecutables();
    customerRepository = new CustomerRepositoryImpl();
}
Also used : CustomerRepositoryImpl(org.hibernate.validator.test.internal.engine.methodvalidation.service.CustomerRepositoryImpl) BeforeClass(org.testng.annotations.BeforeClass)

Example 4 with CustomerRepositoryImpl

use of org.hibernate.validator.test.internal.engine.methodvalidation.service.CustomerRepositoryImpl in project hibernate-validator by hibernate.

the class AbstractConstructorValidationTest method cascadedConstructorReturnValueValidationYieldsConstraintViolation.

@Test
public void cascadedConstructorReturnValueValidationYieldsConstraintViolation() throws Exception {
    CustomerRepositoryImpl customerRepository = new CustomerRepositoryImpl();
    Set<ConstraintViolation<CustomerRepositoryImpl>> violations = executableValidator.validateConstructorReturnValue(CustomerRepositoryImpl.class.getConstructor(String.class), customerRepository);
    assertThat(violations).containsOnlyViolations(violationOf(NotNull.class).withMessage(messagePrefix() + "must not be null").withInvalidValue(null).withRootBeanClass(CustomerRepositoryImpl.class).withPropertyPath(pathWith().constructor(CustomerRepositoryImpl.class).returnValue().property("customer")));
}
Also used : ConstraintViolation(jakarta.validation.ConstraintViolation) CustomerRepositoryImpl(org.hibernate.validator.test.internal.engine.methodvalidation.service.CustomerRepositoryImpl) NotNull(jakarta.validation.constraints.NotNull) Test(org.testng.annotations.Test)

Example 5 with CustomerRepositoryImpl

use of org.hibernate.validator.test.internal.engine.methodvalidation.service.CustomerRepositoryImpl in project hibernate-validator by hibernate.

the class AbstractConstructorValidationTest method constructorReturnValueValidationYieldsConstraintViolation.

@Test
public void constructorReturnValueValidationYieldsConstraintViolation() throws Exception {
    CustomerRepositoryImpl customerRepository = new CustomerRepositoryImpl();
    Set<ConstraintViolation<CustomerRepositoryImpl>> violations = executableValidator.validateConstructorReturnValue(CustomerRepositoryImpl.class.getConstructor(), customerRepository);
    assertThat(violations).containsOnlyViolations(violationOf(ValidB2BRepository.class).withMessage(messagePrefix() + "{ValidB2BRepository.message}").withInvalidValue(customerRepository).withRootBeanClass(CustomerRepositoryImpl.class).withPropertyPath(pathWith().constructor(CustomerRepositoryImpl.class).returnValue()));
}
Also used : ValidB2BRepository(org.hibernate.validator.test.internal.engine.methodvalidation.service.CustomerRepositoryImpl.ValidB2BRepository) ConstraintViolation(jakarta.validation.ConstraintViolation) CustomerRepositoryImpl(org.hibernate.validator.test.internal.engine.methodvalidation.service.CustomerRepositoryImpl) Test(org.testng.annotations.Test)

Aggregations

CustomerRepositoryImpl (org.hibernate.validator.test.internal.engine.methodvalidation.service.CustomerRepositoryImpl)5 ConstraintViolation (jakarta.validation.ConstraintViolation)3 Test (org.testng.annotations.Test)3 NotNull (jakarta.validation.constraints.NotNull)2 Customer (org.hibernate.validator.test.internal.engine.methodvalidation.model.Customer)1 ValidB2BRepository (org.hibernate.validator.test.internal.engine.methodvalidation.service.CustomerRepositoryImpl.ValidB2BRepository)1 BeforeClass (org.testng.annotations.BeforeClass)1