| 
 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ValidationResultInfo | Line # 25 | 22 | 0% | 16 | 20 | 47.4% | 0.47368422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ValidationResultInfo.ErrorLevel | Line # 29 | 4 | 0% | 6 | 10 | 16.7% | 0.16666667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (17) | |||
| Result | |||
| 0.36 | org.kuali.student.common.validator.TestValidator.testNestedStructures  org.kuali.student.common.validator.TestValidator.testNestedStructures | 1 PASS | |
| 0.36 | org.kuali.student.common.validator.TestValidator.testRequired  org.kuali.student.common.validator.TestValidator.testRequired | 1 PASS | |
| 0.32 | org.kuali.student.common.validator.TestValidator.testMinDateValue  org.kuali.student.common.validator.TestValidator.testMinDateValue | 1 PASS | |
| 0.32 | org.kuali.student.common.validator.TestValidator.testMinLength  org.kuali.student.common.validator.TestValidator.testMinLength | 1 PASS | |
| 0.32 | org.kuali.student.common.validator.TestValidator.testLengthRange  org.kuali.student.common.validator.TestValidator.testLengthRange | 1 PASS | |
| 0.32 | org.kuali.student.common.validator.TestValidator.testDoubleValueRange  org.kuali.student.common.validator.TestValidator.testDoubleValueRange | 1 PASS | |
| 0.32 | org.kuali.student.common.validator.TestValidator.testValidChars  org.kuali.student.common.validator.TestValidator.testValidChars | 1 PASS | |
| 0.32 | org.kuali.student.common.validator.TestValidator.testMaxLength  org.kuali.student.common.validator.TestValidator.testMaxLength | 1 PASS | |
| 0.3 | org.kuali.student.common.validator.old.ValidatorTest.testRequired  org.kuali.student.common.validator.old.ValidatorTest.testRequired | 1 PASS | |
| 0.3 | org.kuali.student.core.dictionary.service.impl.DictionaryValidatorTest.testRequiredValidation  org.kuali.student.core.dictionary.service.impl.DictionaryValidatorTest.testRequiredValidation | 1 PASS | |
| 0.26 | org.kuali.student.common.validator.old.ValidatorTest.testMinDateValue  org.kuali.student.common.validator.old.ValidatorTest.testMinDateValue | 1 PASS | |
| 0.26 | org.kuali.student.common.validator.old.ValidatorTest.testValidChars  org.kuali.student.common.validator.old.ValidatorTest.testValidChars | 1 PASS | |
| 0.26 | org.kuali.student.common.validator.old.ValidatorTest.testLengthRange  org.kuali.student.common.validator.old.ValidatorTest.testLengthRange | 1 PASS | |
| 0.26 | org.kuali.student.common.validator.old.ValidatorTest.testMaxLength  org.kuali.student.common.validator.old.ValidatorTest.testMaxLength | 1 PASS | |
| 0.26 | org.kuali.student.common.validator.old.ValidatorTest.testMinLength  org.kuali.student.common.validator.old.ValidatorTest.testMinLength | 1 PASS | |
| 0.26 | org.kuali.student.common.validator.old.ValidatorTest.testDoubleValueRange  org.kuali.student.common.validator.old.ValidatorTest.testDoubleValueRange | 1 PASS | |
| 0.26 | org.kuali.student.common.validator.old.ValidatorTest.testNestedStructures  org.kuali.student.common.validator.old.ValidatorTest.testNestedStructures | 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.core.validation.dto; | |
| 17 | ||
| 18 | import java.io.Serializable; | |
| 19 | ||
| 20 | import javax.xml.bind.annotation.XmlAccessType; | |
| 21 | import javax.xml.bind.annotation.XmlAccessorType; | |
| 22 | import javax.xml.bind.annotation.XmlElement; | |
| 23 | ||
| 24 | @XmlAccessorType(XmlAccessType.FIELD) | |
| 25 | public class ValidationResultInfo implements Serializable{ | |
| 26 | ||
| 27 | private static final long serialVersionUID = 1L; | |
| 28 | ||
| 29 | public enum ErrorLevel { | |
| 30 | OK(0), WARN(1), ERROR(2); | |
| 31 | ||
| 32 | int level; | |
| 33 | ||
| 34 | 9 |  private ErrorLevel(int level) { | 
| 35 | 9 | this.level = level; | 
| 36 | } | |
| 37 | ||
| 38 | 0 |  public int getLevel() { | 
| 39 | 0 | return level; | 
| 40 | } | |
| 41 | ||
| 42 | 0 |  public static ErrorLevel min(ErrorLevel e1, ErrorLevel e2) { | 
| 43 | 0 | return e1.ordinal() < e2.ordinal() ? e1 : e2; | 
| 44 | } | |
| 45 | 0 |  public static ErrorLevel max(ErrorLevel e1, ErrorLevel e2) { | 
| 46 | 0 | return e1.ordinal() > e2.ordinal() ? e1 : e2; | 
| 47 | } | |
| 48 | } | |
| 49 | ||
| 50 | 0 |  public ValidationResultInfo() { | 
| 51 | 0 | super(); | 
| 52 | 0 | this.level = ErrorLevel.OK; | 
| 53 | } | |
| 54 | ||
| 55 | private transient Object invalidData = null; | |
| 56 | ||
| 57 | 72 |  public ValidationResultInfo(String element) { | 
| 58 | 72 | super(); | 
| 59 | 72 | this.level = ErrorLevel.OK; | 
| 60 | 72 | this.element = element; | 
| 61 | } | |
| 62 | ||
| 63 | 45 |  public ValidationResultInfo(String element, Object invalidData) { | 
| 64 | 45 | this(element); | 
| 65 | 45 | this.invalidData = invalidData; | 
| 66 | } | |
| 67 | ||
| 68 | ||
| 69 | @XmlElement | |
| 70 | protected String element; | |
| 71 | ||
| 72 | @XmlElement | |
| 73 | protected ErrorLevel level = ErrorLevel.OK; | |
| 74 | ||
| 75 | @XmlElement | |
| 76 | protected String message; | |
| 77 | ||
| 78 | /** | |
| 79 | * @return the level | |
| 80 | */ | |
| 81 | 0 |  public ErrorLevel getLevel() { | 
| 82 | 0 | return level; | 
| 83 | } | |
| 84 | ||
| 85 | /** | |
| 86 | * @param level the level to set | |
| 87 | */ | |
| 88 | 0 |  public void setLevel(ErrorLevel level) { | 
| 89 | 0 | this.level = level; | 
| 90 | } | |
| 91 | ||
| 92 | /** | |
| 93 | * @return the message | |
| 94 | */ | |
| 95 | 40 |  public String getMessage() { | 
| 96 | 40 | return message; | 
| 97 | } | |
| 98 | ||
| 99 | /** | |
| 100 | * @param message the message to set | |
| 101 | */ | |
| 102 | 0 |  public void setMessage(String message) { | 
| 103 | 0 | this.message = message; | 
| 104 | } | |
| 105 | ||
| 106 | 18 |  public String getElement() { | 
| 107 | 18 | return element; | 
| 108 | } | |
| 109 | ||
| 110 | 0 |  public void setElement(String element) { | 
| 111 | 0 | this.element = element; | 
| 112 | } | |
| 113 | ||
| 114 | /** | |
| 115 | * Returns the ValidationResult's error level | |
| 116 | * | |
| 117 | * @return | |
| 118 | */ | |
| 119 | 94 |  public ErrorLevel getErrorLevel() { | 
| 120 | 94 | return level; | 
| 121 | } | |
| 122 | ||
| 123 | /** | |
| 124 | * Convenience method. Adds a message with an error level of WARN | |
| 125 | * | |
| 126 | * @param message | |
| 127 | * the message to add | |
| 128 | */ | |
| 129 | 0 |  public void setWarning(String message) { | 
| 130 | 0 | this.level = ErrorLevel.WARN; | 
| 131 | 0 | this.message = message; | 
| 132 | } | |
| 133 | ||
| 134 | /** | |
| 135 | * Convenience method. Adds a message with an error level of ERROR | |
| 136 | * | |
| 137 | * @param message | |
| 138 | * the message to add | |
| 139 | */ | |
| 140 | 47 |  public void setError(String message) { | 
| 141 | 47 | this.level = ErrorLevel.ERROR; | 
| 142 | 47 | this.message = message; | 
| 143 | } | |
| 144 | ||
| 145 | /** | |
| 146 | * Convenience method. Returns true if getErrorLevel() == ErrorLevel.OK | |
| 147 | * | |
| 148 | * @return true if getErrorLevel() == ErrorLevel.OK | |
| 149 | */ | |
| 150 | 56 |  public boolean isOk() { | 
| 151 | 56 | return getErrorLevel() == ErrorLevel.OK; | 
| 152 | } | |
| 153 | ||
| 154 | /** | |
| 155 | * Convenience method. Returns true if getErrorLevel() == ErrorLevel.WARN | |
| 156 | * | |
| 157 | * @return true if getErrorLevel() == ErrorLevel.WARN | |
| 158 | */ | |
| 159 | 0 |  public boolean isWarn() { | 
| 160 | 0 | return getErrorLevel() == ErrorLevel.WARN; | 
| 161 | } | |
| 162 | ||
| 163 | /** | |
| 164 | * Convenience method. Returns true if getErrorLevel() == ErrorLevel.ERROR | |
| 165 | * | |
| 166 | * @return true if getErrorLevel() == ErrorLevel.ERROR | |
| 167 | */ | |
| 168 | 0 |  public boolean isError() { | 
| 169 | 0 | return getErrorLevel() == ErrorLevel.ERROR; | 
| 170 | } | |
| 171 | ||
| 172 | 0 |  public String toString(){ | 
| 173 | 0 | return "[" + level + "] Path: [" + element + "] - " + message + " data=[" + invalidData + "]"; | 
| 174 | } | |
| 175 | ||
| 176 | } | |
| 
 | ||||||||||||