diff options
author | Tomasz Golabek <tomasz.golabek@nokia.com> | 2019-08-29 13:32:30 +0200 |
---|---|---|
committer | Tomasz Golabek <tomasz.golabek@nokia.com> | 2019-08-29 13:34:32 +0000 |
commit | 0a65bd7d842fb8617b3c6a7b2d4a16af583dc8be (patch) | |
tree | 785f6645b7aa2c8ffe4206f3b8dbf721dfd38f02 /openecomp-be/api/openecomp-sdc-rest-webapp/unique-type-rest/unique-type-rest-services/src/main/java/org | |
parent | fbe82ee87f03ca9f581eeff47101698247cfe8b1 (diff) |
unit tests - openecomp-be
Additional junit tests for item-rest-services and unique-type-rest-services
Change-Id: I330954ad4eb432c126c7f163f9fdea30d3173cd9
Issue-ID: SDC-2326
Signed-off-by: Tomasz Golabek <tomasz.golabek@nokia.com>
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/unique-type-rest/unique-type-rest-services/src/main/java/org')
-rw-r--r-- | openecomp-be/api/openecomp-sdc-rest-webapp/unique-type-rest/unique-type-rest-services/src/main/java/org/openecomp/sdcrests/uniquevalue/rest/services/UniqueTypesImpl.java | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/unique-type-rest/unique-type-rest-services/src/main/java/org/openecomp/sdcrests/uniquevalue/rest/services/UniqueTypesImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/unique-type-rest/unique-type-rest-services/src/main/java/org/openecomp/sdcrests/uniquevalue/rest/services/UniqueTypesImpl.java index bc346a8a63..0e657903b6 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/unique-type-rest/unique-type-rest-services/src/main/java/org/openecomp/sdcrests/uniquevalue/rest/services/UniqueTypesImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/unique-type-rest/unique-type-rest-services/src/main/java/org/openecomp/sdcrests/uniquevalue/rest/services/UniqueTypesImpl.java @@ -12,9 +12,13 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * ================================================================================ + * Modifications copyright (c) 2019 Nokia + * ================================================================================ */ package org.openecomp.sdcrests.uniquevalue.rest.services; +import com.google.common.annotations.VisibleForTesting; import org.openecomp.core.dao.UniqueValueDaoFactory; import org.openecomp.core.util.UniqueValueUtil; import org.openecomp.sdc.common.errors.ErrorCategory; @@ -42,6 +46,7 @@ public class UniqueTypesImpl implements UniqueTypes { private static final String UNIQUE_TYPE_NOT_FOUND_MSG = "%s is not a supported unique type."; private static final Map<String, String> UNIQUE_TYPE_TO_INTERNAL; + private UniqueValueUtil uniqueValueUtil; static { Map<String, String> uniqueTypes = new HashMap<>(); @@ -50,8 +55,6 @@ public class UniqueTypesImpl implements UniqueTypes { UNIQUE_TYPE_TO_INTERNAL = Collections.unmodifiableMap(uniqueTypes); } - private final UniqueValueUtil uniqueValueUtil = - new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface()); @Override public Response listUniqueTypes(String user) { @@ -73,7 +76,19 @@ public class UniqueTypesImpl implements UniqueTypes { } return Response.ok(Collections - .singletonMap("occupied", uniqueValueUtil.isUniqueValueOccupied(internalType, value))) + .singletonMap("occupied", getUniqueValueUtil().isUniqueValueOccupied(internalType, value))) .build(); } + + @VisibleForTesting + void setUniqueValueUtil(UniqueValueUtil uniqueValueUtil) { + this.uniqueValueUtil = uniqueValueUtil; + } + + private UniqueValueUtil getUniqueValueUtil() { + if (uniqueValueUtil == null){ + uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface()); + } + return uniqueValueUtil; + } } |