some TCK fixes

Project: http://git-wip-us.apache.org/repos/asf/bval/repo
Commit: http://git-wip-us.apache.org/repos/asf/bval/commit/330afb5b
Tree: http://git-wip-us.apache.org/repos/asf/bval/tree/330afb5b
Diff: http://git-wip-us.apache.org/repos/asf/bval/diff/330afb5b

Branch: refs/heads/bv2
Commit: 330afb5b64ed6b6eb73e41e0eb3163e4824127d0
Parents: e33bd2a
Author: Matt Benson <mben...@apache.org>
Authored: Thu Feb 22 15:24:40 2018 -0600
Committer: Matt Benson <mben...@apache.org>
Committed: Thu Feb 22 15:24:40 2018 -0600

----------------------------------------------------------------------
 .../org/apache/bval/jsr/ConfigurationImpl.java     | 17 ++++++++++++-----
 .../org/apache/bval/jsr/metadata/XmlBuilder.java   |  8 +++++---
 2 files changed, 17 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bval/blob/330afb5b/bval-jsr/src/main/java/org/apache/bval/jsr/ConfigurationImpl.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/ConfigurationImpl.java 
b/bval-jsr/src/main/java/org/apache/bval/jsr/ConfigurationImpl.java
index 046d6d2..3545383 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/ConfigurationImpl.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/ConfigurationImpl.java
@@ -26,6 +26,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
 
@@ -49,6 +50,7 @@ import 
org.apache.bval.jsr.parameter.DefaultParameterNameProvider;
 import org.apache.bval.jsr.resolver.DefaultTraversableResolver;
 import org.apache.bval.jsr.util.IOs;
 import org.apache.bval.jsr.xml.ValidationParser;
+import org.apache.bval.util.Exceptions;
 import org.apache.commons.weaver.privilizer.Privileged;
 
 /**
@@ -422,12 +424,17 @@ public class ConfigurationImpl implements 
ApacheValidatorConfiguration, Configur
         if (providerClass == null) {
             return providerResolver.getValidationProviders().get(0);
         }
-        for (ValidationProvider<?> provider : 
providerResolver.getValidationProviders()) {
-            if (providerClass.isAssignableFrom(provider.getClass())) {
-                return provider;
-            }
+        final Optional<ValidationProvider<?>> knownProvider =
+            
providerResolver.getValidationProviders().stream().filter(providerClass::isInstance).findFirst();
+        if (knownProvider.isPresent()) {
+            return knownProvider.get();
+        }
+        try {
+            return providerClass.newInstance();
+        } catch (Exception e) {
+            throw Exceptions.create(ValidationException::new, "Unable to 
find/create %s of type %s",
+                ValidationProvider.class.getSimpleName(), providerClass);
         }
-        throw new ValidationException("Unable to find suitable provider: " + 
providerClass);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/bval/blob/330afb5b/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/XmlBuilder.java
----------------------------------------------------------------------
diff --git 
a/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/XmlBuilder.java 
b/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/XmlBuilder.java
index 8743be5..bd71ccc 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/XmlBuilder.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/XmlBuilder.java
@@ -139,7 +139,7 @@ public class XmlBuilder {
                 
.map(ParameterType::getType).map(XmlBuilder.this::resolveClass).toArray(Class[]::new);
 
             final Function<ConstructorType, Signature> signature =
-                ct -> new Signature(meta.getHost().getSimpleName(), 
params.apply(ct));
+                ct -> new Signature(meta.getHost().getName(), 
params.apply(ct));
 
             return descriptor.getConstructor().stream()
                 .collect(Collectors.toMap(signature, 
XmlBuilder.ForConstructor::new));
@@ -218,7 +218,7 @@ public class XmlBuilder {
 
         ForClass(ClassType descriptor) {
             super(descriptor);
-            this.withGetConstraintTypes(ct -> ct.getConstraint());
+            this.withGetConstraintTypes(ClassType::getConstraint);
         }
 
         @Override
@@ -441,7 +441,9 @@ public class XmlBuilder {
             super(descriptor);
             this.withGetDeclaredConstraints(d -> d.getConstraint().stream()
                 .map(ct -> createConstraint(ct, 
ConstraintTarget.RETURN_VALUE)).toArray(Annotation[]::new))
-                .withGetContainerElementTypes(d -> 
d.getContainerElementType());
+                
.withGetIgnoreAnnotations(ReturnValueType::getIgnoreAnnotations).withGetValid(ReturnValueType::getValid)
+                .withGetGroupConversions(ReturnValueType::getConvertGroup)
+                
.withGetContainerElementTypes(ReturnValueType::getContainerElementType);
         }
     }
 

Reply via email to