-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BVTCK-32 Adding tests for property paths
- Loading branch information
1 parent
9095e23
commit 8571f26
Showing
8 changed files
with
1,396 additions
and
19 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
...n/java/org/hibernate/beanvalidation/tck/tests/validation/CustomParameterNameProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* 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.validation; | ||
|
||
import java.lang.reflect.Constructor; | ||
import java.lang.reflect.Method; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import javax.validation.ParameterNameProvider; | ||
|
||
/** | ||
* @author Gunnar Morling | ||
*/ | ||
public class CustomParameterNameProvider implements ParameterNameProvider { | ||
|
||
@Override | ||
public String[] getParameterNames(Constructor<?> constructor) { | ||
List<String> names = new ArrayList<String>(); | ||
|
||
for ( int i = 0; i < constructor.getParameterTypes().length; i++ ) { | ||
names.add( "param" + i ); | ||
} | ||
|
||
return names.toArray( new String[names.size()] ); | ||
} | ||
|
||
@Override | ||
public String[] getParameterNames(Method method) { | ||
List<String> names = new ArrayList<String>(); | ||
|
||
for ( int i = 0; i < method.getParameterTypes().length; i++ ) { | ||
names.add( "param" + i ); | ||
} | ||
|
||
return names.toArray( new String[names.size()] ); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
tests/src/main/java/org/hibernate/beanvalidation/tck/tests/validation/Employee.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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.validation; | ||
|
||
/** | ||
* @author Gunnar Morling | ||
*/ | ||
public class Employee implements Person { | ||
|
||
private final String firstName; | ||
private final String lastName; | ||
|
||
public Employee(String firstName, String lastName) { | ||
this.firstName = firstName; | ||
this.lastName = lastName; | ||
} | ||
|
||
@Override | ||
public String getFirstName() { | ||
return firstName; | ||
} | ||
|
||
@Override | ||
public String getMiddleName() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getLastName() { | ||
return lastName; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
tests/src/main/java/org/hibernate/beanvalidation/tck/tests/validation/Movie.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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.validation; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
/** | ||
* @author Gunnar Morling | ||
*/ | ||
public class Movie { | ||
|
||
@NotNull | ||
private String title; | ||
|
||
public Movie() { | ||
} | ||
|
||
public Movie(String title) { | ||
this.title = title; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
tests/src/main/java/org/hibernate/beanvalidation/tck/tests/validation/MovieStudio.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* 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.validation; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import javax.validation.Valid; | ||
import javax.validation.constraints.NotNull; | ||
|
||
/** | ||
* @author Gunnar Morling | ||
*/ | ||
public class MovieStudio { | ||
|
||
@NotNull | ||
private final String name; | ||
|
||
public MovieStudio() { | ||
this.name = null; | ||
} | ||
|
||
@ValidMovieStudio | ||
public MovieStudio(@NotNull String name, @NotNull @Valid Person generalManager) { | ||
this.name = name; | ||
} | ||
|
||
@Valid | ||
public MovieStudio(String name) { | ||
this.name = name; | ||
} | ||
|
||
public MovieStudio(String name, Person generalManager, @Valid List<Actor> recurringActors) { | ||
this.name = name; | ||
} | ||
|
||
public MovieStudio(String name, Person generalManager, @Valid Actor[] recurringActors) { | ||
this.name = name; | ||
} | ||
|
||
public MovieStudio(String name, Person generalManager, @Valid Set<Actor> recurringActors) { | ||
this.name = name; | ||
} | ||
|
||
public MovieStudio(String name, Person generalManager, @Valid Map<String, Actor> recurringActors) { | ||
this.name = name; | ||
} | ||
|
||
@NotNull | ||
public Movie makeMovie(@NotNull String title, @NotNull @Valid Person director, @Valid List<Actor> actors) { | ||
return null; | ||
} | ||
|
||
public Movie makeMovieArrayBased(String title, Person director, @Valid Actor[] actors) { | ||
return null; | ||
} | ||
|
||
public Movie makeMovieSetBased(String title, Person director, @Valid Set<Actor> actors) { | ||
return null; | ||
} | ||
|
||
public Movie makeMovieMapBased(String title, Person director, @Valid Map<String, Actor> actors) { | ||
return null; | ||
} | ||
|
||
@Valid | ||
public Movie getBestSellingMovie() { | ||
return null; | ||
} | ||
|
||
@Valid | ||
public List<Movie> getBestSellingMoviesListBased() { | ||
return null; | ||
} | ||
|
||
@Valid | ||
public Movie[] getBestSellingMoviesArrayBased() { | ||
return null; | ||
} | ||
|
||
@Valid | ||
public Set<Movie> getBestSellingMoviesSetBased() { | ||
return null; | ||
} | ||
|
||
@Valid | ||
public Map<String, Movie> getBestSellingMoviesMapBased() { | ||
return null; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
} |
Oops, something went wrong.