From 8b1be00c0642f1f167cd3d136aa8215e40deb142 Mon Sep 17 00:00:00 2001 From: Joss Armstrong Date: Wed, 19 Dec 2018 14:15:04 +0000 Subject: Fix for test coverage in oam.utils package Removed 'PrepareForTest' annotations which were preventing test coverage of classes in appc.oam.utils package. Added unit tests for untested code. Increased line coverage of the package from 49% to 83%. Issue-ID: APPC-1287 Change-Id: I893de5281f8c46e92269be895ef304bbf87c88b9 Signed-off-by: Joss Armstrong --- .../src/main/java/org/onap/appc/oam/util/BundleHelper.java | 8 +++++++- .../src/main/java/org/onap/appc/oam/util/StateHelper.java | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'appc-oam/appc-oam-bundle/src/main') diff --git a/appc-oam/appc-oam-bundle/src/main/java/org/onap/appc/oam/util/BundleHelper.java b/appc-oam/appc-oam-bundle/src/main/java/org/onap/appc/oam/util/BundleHelper.java index b862ed3a7..7639c4075 100644 --- a/appc-oam/appc-oam-bundle/src/main/java/org/onap/appc/oam/util/BundleHelper.java +++ b/appc-oam/appc-oam-bundle/src/main/java/org/onap/appc/oam/util/BundleHelper.java @@ -5,6 +5,8 @@ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs + * ================================================================================ + * Modifications (C) 2018 Ericsson * ============================================================================= * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -166,7 +168,7 @@ public class BundleHelper { String[] bundlesToStop = readPropsFromPropListName(PROP_BUNDLE_TO_STOP); String[] regExBundleNotStop = readPropsFromPropListName(PROP_BUNDLES_TO_NOT_STOP); - BundleFilter bundleList = new BundleFilter(bundlesToStop, regExBundleNotStop, getBundleList()); + BundleFilter bundleList = getBundleFilter(bundlesToStop, regExBundleNotStop, getBundleList()); logger.info(String.format("(%d) APPC bundles to Stop/Start: %s.", bundleList.getBundlesToStop().size(), bundleList.getBundlesToStop().toString())); @@ -220,6 +222,10 @@ public class BundleHelper { } } + protected BundleFilter getBundleFilter(String[] stopRegexes, String[] exceptRegexes, Bundle[] bundles) { + return new BundleFilter(stopRegexes, exceptRegexes, bundles); + } + /** * Runnable to execute bundle operations: start or stop */ diff --git a/appc-oam/appc-oam-bundle/src/main/java/org/onap/appc/oam/util/StateHelper.java b/appc-oam/appc-oam-bundle/src/main/java/org/onap/appc/oam/util/StateHelper.java index 0d24b5e8a..6ed50dbe6 100644 --- a/appc-oam/appc-oam-bundle/src/main/java/org/onap/appc/oam/util/StateHelper.java +++ b/appc-oam/appc-oam-bundle/src/main/java/org/onap/appc/oam/util/StateHelper.java @@ -5,6 +5,8 @@ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs + * ================================================================================ + * Modifications (C) 2018 Ericsson * ============================================================================= * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -122,7 +124,7 @@ public class StateHelper { * @return AppcOamStates */ public AppcOamStates getBundlesState() { - BundleHelper bundleHelper = new BundleHelper(logger, configurationHelper, this); + BundleHelper bundleHelper = getBundleHelper(logger, configurationHelper); Map lcmBundleMap = bundleHelper.getAppcLcmBundles(); if (lcmBundleMap == null || lcmBundleMap.isEmpty()) { return AppcOamStates.Unknown; @@ -140,4 +142,7 @@ public class StateHelper { return AppcOamStates.getOamStateFromBundleState(currentState); } + protected BundleHelper getBundleHelper(EELFLogger logger, ConfigurationHelper configurationHelper) { + return new BundleHelper(logger, configurationHelper, this); + } } -- cgit 1.2.3-korg