Skip to content

Commit

Permalink
BVTCK-32 Adding test for finding cross-parameter constraints looking …
Browse files Browse the repository at this point in the history
…at scope
  • Loading branch information
gunnarmorling authored and hferentschik committed Jan 25, 2013
1 parent ae58a76 commit 18644fa
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
@@ -0,0 +1,23 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.beanvalidation.tck.tests.metadata;

/**
* @author Gunnar Morling
*/
public class CustomerServiceExtension extends CustomerService {
}
Expand Up @@ -22,6 +22,7 @@
import javax.validation.metadata.ElementDescriptor;
import javax.validation.metadata.ElementDescriptor.Kind;
import javax.validation.metadata.MethodDescriptor;
import javax.validation.metadata.Scope;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.testng.Arquillian;
Expand Down Expand Up @@ -55,6 +56,7 @@ public static WebArchive createTestArchive() {
Account.class,
Customer.class,
CustomerService.class,
CustomerServiceExtension.class,
Executables.class,
Person.class
)
Expand Down Expand Up @@ -490,6 +492,38 @@ public void testFindConstraintsForMethod() {
);
}

//Fails due to https://hibernate.onjira.com/browse/HV-682
@Test(groups = Groups.FAILING_IN_RI)
@SpecAssertion(section = "6.5", id = "f")
public void testFindConstraintsForMethodLookingAt() {
MethodDescriptor crossParameterConstrainedDescriptor = Executables.methodOverridingCrossParameterConstrainedMethod();
assertEquals(
crossParameterConstrainedDescriptor.findConstraints()
.lookingAt( Scope.LOCAL_ELEMENT )
.getConstraintDescriptors()
.size(),
0,
"Should have no local constraints"
);

crossParameterConstrainedDescriptor = Executables.methodOverridingCrossParameterConstrainedMethod();
assertEquals(
crossParameterConstrainedDescriptor.findConstraints().lookingAt( Scope.HIERARCHY )
.getConstraintDescriptors()
.size(),
1,
"Should have one hierarchy constraint"
);

assertEquals(
crossParameterConstrainedDescriptor.getConstraintDescriptors()
.iterator()
.next()
.getAnnotation()
.annotationType(), MyCrossParameterConstraint.class, "Wrong constraint type"
);
}

@Test(groups = Groups.FAILING_IN_RI)
@SpecAssertion(section = "6.5", id = "f")
public void testFindConstraintsForConstructor() {
Expand Down
Expand Up @@ -68,6 +68,14 @@ public static MethodDescriptor crossParameterConstrainedMethod() {
);
}

public static MethodDescriptor methodOverridingCrossParameterConstrainedMethod() {
return getMethodDescriptor(
CustomerServiceExtension.class,
"removeCustomer",
Customer.class
);
}

public static MethodDescriptor unconstrainedMethod() {
return getMethodDescriptor(
CustomerService.class,
Expand Down

0 comments on commit 18644fa

Please sign in to comment.