Skip to content

Commit

Permalink
BVTCK-32 Adding tests for property paths
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnarmorling committed Jan 18, 2013
1 parent 9095e23 commit 8571f26
Show file tree
Hide file tree
Showing 8 changed files with 1,396 additions and 19 deletions.
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()] );
}
}
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;
}
}
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;
}
}
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;
}
}

0 comments on commit 8571f26

Please sign in to comment.