Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BVTCK-48 Adding more integration tests for executable validation
- Loading branch information
1 parent
2d3c19b
commit 4f328b4
Showing
7 changed files
with
309 additions
and
1 deletion.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
.../hibernate/beanvalidation/tck/tests/integration/cdi/executable/AnotherBookingService.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,50 @@ | ||
/* | ||
* 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.integration.cdi.executable; | ||
|
||
import javax.inject.Inject; | ||
import javax.validation.constraints.Null; | ||
import javax.validation.constraints.Size; | ||
|
||
/** | ||
* @author Gunnar Morling | ||
*/ | ||
public class AnotherBookingService { | ||
|
||
public interface IgnoredValidationGroup { | ||
} | ||
|
||
private static int invocationCount = 0; | ||
|
||
private static String name; | ||
|
||
@Inject | ||
@ValidAnotherBookingService | ||
@Null(groups = IgnoredValidationGroup.class) | ||
public AnotherBookingService(@Size(min = 5) @Null(groups = IgnoredValidationGroup.class) String name) { | ||
this.name = name; | ||
invocationCount++; | ||
} | ||
|
||
public static String getName() { | ||
return name; | ||
} | ||
|
||
public static int getInvocationCount() { | ||
return invocationCount; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...ava/org/hibernate/beanvalidation/tck/tests/integration/cdi/executable/BookingService.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,43 @@ | ||
/* | ||
* 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.integration.cdi.executable; | ||
|
||
import javax.validation.constraints.DecimalMin; | ||
import javax.validation.constraints.Null; | ||
import javax.validation.constraints.Size; | ||
|
||
/** | ||
* @author Gunnar Morling | ||
*/ | ||
public class BookingService { | ||
|
||
public interface IgnoredValidationGroup { | ||
} | ||
|
||
private int invocationCount = 0; | ||
|
||
@DecimalMin("10001") | ||
@Null(groups = IgnoredValidationGroup.class) | ||
public String placeBooking(@Size(min = 5) @Null(groups = IgnoredValidationGroup.class) String name) { | ||
invocationCount++; | ||
return name; | ||
} | ||
|
||
public int getInvocationCount() { | ||
return invocationCount; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...idation/tck/tests/integration/cdi/executable/CalendarServiceWithCascadingReturnValue.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,30 @@ | ||
/* | ||
* 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.integration.cdi.executable; | ||
|
||
import javax.validation.Valid; | ||
|
||
/** | ||
* @author Gunnar Morling | ||
*/ | ||
public class CalendarServiceWithCascadingReturnValue { | ||
|
||
@Valid | ||
public Event createValidEvent() { | ||
return new Event(); | ||
} | ||
} |
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
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
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
58 changes: 58 additions & 0 deletions
58
...rnate/beanvalidation/tck/tests/integration/cdi/executable/ValidAnotherBookingService.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,58 @@ | ||
/* | ||
* 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.integration.cdi.executable; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
import javax.validation.Constraint; | ||
import javax.validation.ConstraintValidator; | ||
import javax.validation.ConstraintValidatorContext; | ||
import javax.validation.Payload; | ||
|
||
import static java.lang.annotation.ElementType.CONSTRUCTOR; | ||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
/** | ||
* @author Gunnar Morling | ||
*/ | ||
@Documented | ||
@Constraint(validatedBy = ValidAnotherBookingService.Validator.class) | ||
@Target({ METHOD, CONSTRUCTOR, TYPE, FIELD }) | ||
@Retention(RUNTIME) | ||
public @interface ValidAnotherBookingService { | ||
String message() default "default message"; | ||
|
||
Class<?>[] groups() default { }; | ||
|
||
Class<? extends Payload>[] payload() default { }; | ||
|
||
public static class Validator implements ConstraintValidator<ValidAnotherBookingService, AnotherBookingService> { | ||
|
||
@Override | ||
public void initialize(ValidAnotherBookingService parameters) { | ||
} | ||
|
||
@Override | ||
public boolean isValid(AnotherBookingService service, ConstraintValidatorContext constraintValidatorContext) { | ||
return Integer.parseInt( AnotherBookingService.getName() ) > 10000; | ||
} | ||
} | ||
} |