diff options
author | Jim Hahn <jrh3@att.com> | 2021-01-04 12:11:32 -0500 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-01-04 17:32:12 -0500 |
commit | f9add40e0d87baff4ed56529bc61c31a577dc93d (patch) | |
tree | d1be521c0f4e84c8fd6a75b196b7f372c87aa38b /common-parameters/src/main/java/org/onap/policy/common/parameters/ItemValidator.java | |
parent | 5f1b1162d047d2a743f1ce57cc17494a6150c75c (diff) |
Update junits for Validation
The Validation code was previously refactored. Added/updated junits
correspondingly.
Issue-ID: POLICY-2648
Change-Id: I570c0ec692ecfcb6e69ada45f7997f6e63735ea0
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'common-parameters/src/main/java/org/onap/policy/common/parameters/ItemValidator.java')
-rw-r--r-- | common-parameters/src/main/java/org/onap/policy/common/parameters/ItemValidator.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ItemValidator.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ItemValidator.java index d0c027c1..07efebbe 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ItemValidator.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ItemValidator.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,6 +65,7 @@ public class ItemValidator extends ValueValidator { * @return the annotation, or {@code null} if the {@link #annotationContainer} does * not contain the desired annotation */ + @Override public <T extends Annotation> T getAnnotation(Class<T> annotClass) { try { for (Method meth : annotationContainer.getClass().getDeclaredMethods()) { @@ -80,7 +81,10 @@ public class ItemValidator extends ValueValidator { return null; } - private <T extends Annotation> T getAnnotation2(Class<T> annotClass, Method method) + /** + * Note: this is only marked "protected" so it can be overridden for junit testing. + */ + protected <T extends Annotation> T getAnnotation2(Class<T> annotClass, Method method) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { Class<?> ret = method.getReturnType(); @@ -101,7 +105,9 @@ public class ItemValidator extends ValueValidator { return null; } - // TODO log if there's more than one item + if (arrobj.length > 1) { + throw new IllegalArgumentException("extra item annotations of type: " + annotClass.getName()); + } return arrobj[0]; } |