Skip to content

Commit

Permalink
#1 testfix (missing test config, typeName wrapper - typeOf[Boolean].t…
Browse files Browse the repository at this point in the history
…oString returning `Boolean` vs `scala.Boolean`
  • Loading branch information
dk1844 committed Dec 7, 2021
1 parent d872bc6 commit a83f0a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,18 @@ class FieldValidator {
protected def checkMetadataKey[T: TypeTag](field: TypedStructField,
metadataKey: String,
issueConstructor: String => ValidationIssue = ValidationError.apply): Seq[ValidationIssue] = {
/**
* Keeps part of the string after last dot. E.g. `scala.Boolean` -> `Boolean`. Does nothing if there is no dot.
* @param typeName possibly dot-separated type name
* @return simple type name
*/
def simpleTypeName(typeName: String) = {
typeName.split("""\.""").last
}

def optionToValidationIssueSeq(option: Option[_], typeName: String): Seq[ValidationIssue] = {
option.map(_ => Nil).getOrElse(
Seq(issueConstructor(s"$metadataKey metadata value of field '${field.name}' is not $typeName in String format"))
Seq(issueConstructor(s"$metadataKey metadata value of field '${field.name}' is not ${simpleTypeName(typeName)} in String format"))
)
}

Expand Down
5 changes: 4 additions & 1 deletion src/test/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

standardization.recordId.generation.strategy="none"
standardization.recordId.generation.strategy="none"

standardization.defaultTimestampTimeZone.default="CET"
standardization.defaultTimestampTimeZone.xml="Africa/Johannesburg"

0 comments on commit a83f0a4

Please sign in to comment.