| 
 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BeanConstraintDataProvider | Line # 27 | 24 | 0% | 12 | 8 | 77.1% | 0.7714286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (72) | |||
| Result | |||
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.7714286 | $testMethod.qualifiedName  $testMethod.qualifiedName | 1 PASS | |
| 0.71428573 | org.kuali.student.common.validator.TestValidator.testMaxLength  org.kuali.student.common.validator.TestValidator.testMaxLength | 1 PASS | |
| 0.71428573 | org.kuali.student.common.validator.TestValidator.testMaxLength  org.kuali.student.common.validator.TestValidator.testMaxLength | 1 PASS | |
| 0.71428573 | org.kuali.student.common.validator.TestValidator.testMaxLength  org.kuali.student.common.validator.TestValidator.testMaxLength | 1 PASS | |
| 0.71428573 | org.kuali.student.common.validator.TestValidator.testMaxLength  org.kuali.student.common.validator.TestValidator.testMaxLength | 1 PASS | |
| 0.71428573 | org.kuali.student.common.validator.TestValidator.testMinDateValue  org.kuali.student.common.validator.TestValidator.testMinDateValue | 1 PASS | |
| 0.71428573 | org.kuali.student.common.validator.TestValidator.testMinLength  org.kuali.student.common.validator.TestValidator.testMinLength | 1 PASS | |
| 0.71428573 | org.kuali.student.common.validator.TestValidator.testMinLength  org.kuali.student.common.validator.TestValidator.testMinLength | 1 PASS | |
| 0.71428573 | org.kuali.student.common.validator.TestValidator.testDoubleValueRange  org.kuali.student.common.validator.TestValidator.testDoubleValueRange | 1 PASS | |
| 0.71428573 | org.kuali.student.common.validator.TestValidator.testNestedStructures  org.kuali.student.common.validator.TestValidator.testNestedStructures | 1 PASS | |
| 0.71428573 | org.kuali.student.common.validator.TestValidator.testRequired  org.kuali.student.common.validator.TestValidator.testRequired | 1 PASS | |
| 0.71428573 | org.kuali.student.common.validator.TestValidator.testRequired  org.kuali.student.common.validator.TestValidator.testRequired | 1 PASS | |
| 0.71428573 | org.kuali.student.common.validator.TestValidator.testRequired  org.kuali.student.common.validator.TestValidator.testRequired | 1 PASS | |
| 0.71428573 | org.kuali.student.common.validator.TestValidator.testLengthRange  org.kuali.student.common.validator.TestValidator.testLengthRange | 1 PASS | |
| 0.71428573 | org.kuali.student.common.validator.TestValidator.testLengthRange  org.kuali.student.common.validator.TestValidator.testLengthRange | 1 PASS | |
| 0.71428573 | org.kuali.student.common.validator.TestValidator.testLengthRange  org.kuali.student.common.validator.TestValidator.testLengthRange | 1 PASS | |
| 0.71428573 | org.kuali.student.common.validator.TestValidator.testLengthRange  org.kuali.student.common.validator.TestValidator.testLengthRange | 1 PASS | |
| 0.71428573 | org.kuali.student.common.validator.TestValidator.testValidChars  org.kuali.student.common.validator.TestValidator.testValidChars | 1 PASS | |
| 0.6571429 | org.kuali.student.common.validator.TestValidator.testValidChars  org.kuali.student.common.validator.TestValidator.testValidChars | 1 PASS | |
| 0.6571429 | org.kuali.student.common.validator.TestValidator.testValidChars  org.kuali.student.common.validator.TestValidator.testValidChars | 1 PASS | |
| 0.6571429 | org.kuali.student.common.validator.TestValidator.testValidChars  org.kuali.student.common.validator.TestValidator.testValidChars | 1 PASS | |
| 1 | /** | |
| 2 | * Copyright 2010 The Kuali Foundation Licensed under the | |
| 3 | * Educational Community License, Version 2.0 (the "License"); you may | |
| 4 | * not use this file except in compliance with the License. You may | |
| 5 | * obtain a copy of the License at | |
| 6 | * | |
| 7 | * http://www.osedu.org/licenses/ECL-2.0 | |
| 8 | * | |
| 9 | * Unless required by applicable law or agreed to in writing, | |
| 10 | * software distributed under the License is distributed on an "AS IS" | |
| 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
| 12 | * or implied. See the License for the specific language governing | |
| 13 | * permissions and limitations under the License. | |
| 14 | */ | |
| 15 | ||
| 16 | package org.kuali.student.common.validator; | |
| 17 | ||
| 18 | import java.beans.BeanInfo; | |
| 19 | import java.beans.IntrospectionException; | |
| 20 | import java.beans.Introspector; | |
| 21 | import java.beans.PropertyDescriptor; | |
| 22 | import java.util.HashMap; | |
| 23 | import java.util.Map; | |
| 24 | ||
| 25 | import org.apache.log4j.Logger; | |
| 26 | ||
| 27 | public class BeanConstraintDataProvider implements ConstraintDataProvider { | |
| 28 | final static Logger LOG = Logger.getLogger(BeanConstraintDataProvider.class); | |
| 29 | ||
| 30 | private static final String DYNAMIC_ATTRIBUTE = "attributes"; | |
| 31 | ||
| 32 | Map<String, Object> dataMap = null; | |
| 33 | ||
| 34 | /* | |
| 35 | * The only place where the dataprovider should get initialized is | |
| 36 | * BeanConstraintSetupFactory | |
| 37 | */ | |
| 38 | 1578 |  public BeanConstraintDataProvider() { | 
| 39 | ||
| 40 | } | |
| 41 | ||
| 42 | //TODO fix it later. | |
| 43 | 1564 |  public String getPath(){ | 
| 44 | 1564 | return ""; | 
| 45 | } | |
| 46 | ||
| 47 | 1578 |  @SuppressWarnings("unchecked") | 
| 48 | @Override | |
| 49 | public void initialize(Object o) { | |
| 50 | ||
| 51 | 1578 | dataMap = new HashMap<String, Object>(); | 
| 52 | ||
| 53 | 1578 | Map<String, PropertyDescriptor> beanInfo = getBeanInfo(o.getClass()); | 
| 54 | ||
| 55 | 1578 | for (String propName : beanInfo.keySet()) { | 
| 56 | ||
| 57 | 11981 | PropertyDescriptor pd = beanInfo.get(propName); | 
| 58 | 11981 | Object value = null; | 
| 59 | 11981 | try { | 
| 60 | 11981 | value = pd.getReadMethod().invoke(o); | 
| 61 | } catch (Exception e) { | |
| 62 | 0 | LOG.warn("Method invokation failed",e); | 
| 63 | } | |
| 64 | ||
| 65 | // Extract dynamic attributes | |
| 66 | 11981 | if(DYNAMIC_ATTRIBUTE.equals(propName)) { | 
| 67 | 717 | dataMap.putAll((Map<String, String>)value); | 
| 68 | } else { | |
| 69 | 11264 | dataMap.put(propName, value); | 
| 70 | } | |
| 71 | } | |
| 72 | } | |
| 73 | ||
| 74 | 0 |  @Override | 
| 75 | public String getObjectId() { | |
| 76 | 0 | return (dataMap.containsKey("id") && null != dataMap.get("id")) ? dataMap.get("id").toString() : null; | 
| 77 | } | |
| 78 | ||
| 79 | 8889 |  @Override | 
| 80 | public Object getValue(String fieldKey) { | |
| 81 | 8889 | return dataMap.get(fieldKey); | 
| 82 | } | |
| 83 | ||
| 84 | 0 |  @Override | 
| 85 | public Boolean hasField(String fieldKey) { | |
| 86 | 0 | return dataMap.containsKey(fieldKey); | 
| 87 | } | |
| 88 | ||
| 89 | 1578 |  private Map<String, PropertyDescriptor> getBeanInfo(Class<?> clazz) { | 
| 90 | 1578 | Map<String, PropertyDescriptor> properties = new HashMap<String, PropertyDescriptor>(); | 
| 91 | 1578 | BeanInfo beanInfo = null; | 
| 92 | 1578 | try { | 
| 93 | 1578 | beanInfo = Introspector.getBeanInfo(clazz); | 
| 94 | } catch (IntrospectionException e) { | |
| 95 | 0 | throw new RuntimeException(e); | 
| 96 | } | |
| 97 | 1578 | PropertyDescriptor[] propertyDescriptors = beanInfo | 
| 98 | .getPropertyDescriptors(); | |
| 99 | 1578 | for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { | 
| 100 | 11981 | properties.put(propertyDescriptor.getName(), propertyDescriptor); | 
| 101 | } | |
| 102 | 1578 | return properties; | 
| 103 | } | |
| 104 | } | |
| 
 | ||||||||||||