aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshrikantawachar <shrikant.awachar@amdocs.com>2018-11-20 19:08:06 +0530
committerAvi Gaffa <avi.gaffa@amdocs.com>2018-12-02 08:48:20 +0000
commitc2a1b7c2eea934f309838f0082b2b851012be9a1 (patch)
tree12b3dac98cec264a12d96fe76c727df714ca4601
parent594a8c618a763e79e05229509dbf2b60ab831213 (diff)
Enhance or write new tests
Enhance or write new tests Change-Id: I4281b83410645ca0b6f64ab719adcd01c2a04ed3 Issue-ID: SDC-1816 Signed-off-by: shrikantawachar <shrikant.awachar@amdocs.com>
-rw-r--r--openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/impl/ActionManagerImpl.java66
-rw-r--r--openecomp-be/backend/openecomp-sdc-action-manager/src/test/java/org/openecomp/sdc/action/impl/ActionManagerImplTest.java18
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml6
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ManufacturerReferenceNumberHealer.java17
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/NetworkPackageHealer.java20
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ManufacturerReferenceNumberHealerTest.java126
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/NetworkPackageHealerTest.java116
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/resources/logback-test.xml13
8 files changed, 335 insertions, 47 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/impl/ActionManagerImpl.java b/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/impl/ActionManagerImpl.java
index 87edc9a0d4..dc101ae955 100644
--- a/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/impl/ActionManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/impl/ActionManagerImpl.java
@@ -18,6 +18,8 @@ package org.openecomp.sdc.action.impl;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
+import org.openecomp.core.dao.UniqueValueDao;
+import org.openecomp.core.dao.UniqueValueDao;
import org.openecomp.core.dao.UniqueValueDaoFactory;
import org.openecomp.core.util.UniqueValueUtil;
import org.openecomp.core.utilities.CommonMethods;
@@ -73,40 +75,38 @@ public class ActionManagerImpl implements ActionManager {
private final ActionVersioningManager versioningManager;
private final ActionArtifactDao actionArtifactDao;
private final VersionInfoDao versionInfoDao;
+ private final UniqueValueDao uniqueValueDao;
private final Logger log = LoggerFactory.getLogger(this.getClass()
.getName());
- public ActionManagerImpl() {
- actionDao = ActionDaoFactory.getInstance()
- .createInterface();
- versioningManager = ActionVersioningManagerFactory.getInstance()
- .createInterface();
- actionArtifactDao = ActionArtifactDaoFactory.getInstance()
- .createInterface();
- versionInfoDao = VersionInfoDaoFactory.getInstance()
- .createInterface();
- actionDao.registerVersioning(ACTION_VERSIONABLE_TYPE);
- }
-
- public ActionManagerImpl(ActionDao actionDao, ActionVersioningManager versioningManager,
- ActionArtifactDao actionArtifactDao, VersionInfoDao versionInfoDao) {
- this.actionDao = actionDao;
- this.versioningManager = versioningManager;
- this.actionArtifactDao = actionArtifactDao;
- this.versionInfoDao = versionInfoDao;
- }
-
- /**
- * List All Major, Last Minor and Candidate version (if any) for Given
- * Action Invariant UUID
- *
- * @param invariantId
- * Invariant UUID of the action for which the information is
- * required
- * @return List of All Major, Last Minor and Candidate version if any Of
- * {@link Action} with given actionInvariantUuId.
- */
+ public ActionManagerImpl() {
+ actionDao = ActionDaoFactory.getInstance().createInterface();
+ versioningManager = ActionVersioningManagerFactory.getInstance().createInterface();
+ actionArtifactDao = ActionArtifactDaoFactory.getInstance().createInterface();
+ versionInfoDao = VersionInfoDaoFactory.getInstance().createInterface();
+ actionDao.registerVersioning(ACTION_VERSIONABLE_TYPE);
+ uniqueValueDao = UniqueValueDaoFactory.getInstance().createInterface();
+ }
+
+ public ActionManagerImpl(ActionDao actionDao, ActionVersioningManager versioningManager,
+ ActionArtifactDao actionArtifactDao, VersionInfoDao versionInfoDao,
+ UniqueValueDao uniqueValueDao) {
+ this.actionDao = actionDao;
+ this.versioningManager = versioningManager;
+ this.actionArtifactDao = actionArtifactDao;
+ this.versionInfoDao = versionInfoDao;
+ this.uniqueValueDao = uniqueValueDao;
+ }
+ /**
+ * List All Major, Last Minor and Candidate version (if any) for Given Action Invariant UUID
+ *
+ * @param invariantId Invariant UUID of the action for which the information is required
+ * @return List of All Major, Last Minor and Candidate version if any Of {@link Action} with given
+ * actionInvariantUuId.
+ * @throws ActionException Exception with an action library specific code, short description and
+ * detailed message for the error occurred during the operation
+ */
@Override
public List<Action> getActionsByActionInvariantUuId(String invariantId) {
@@ -239,8 +239,7 @@ public class ActionManagerImpl implements ActionManager {
*/
@Override
public Action createAction(Action action, String user) {
- UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory.getInstance()
- .createInterface());
+ UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(uniqueValueDao);
try {
actionLogPreProcessor(ActionSubOperation.VALIDATE_ACTION_UNIQUE_NAME, TARGET_ENTITY_API);
uniqueValueUtil.validateUniqueValue(ActionConstants.UniqueValues.ACTION_NAME, action.getName());
@@ -403,8 +402,7 @@ public class ActionManagerImpl implements ActionManager {
if (version.equals(new Version(0, 0))) {
actionLogPreProcessor(ActionSubOperation.DELETE_UNIQUEVALUE, TARGET_ENTITY_API);
- UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory.getInstance()
- .createInterface());
+ UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(uniqueValueDao);
uniqueValueUtil.deleteUniqueValue(ActionConstants.UniqueValues.ACTION_NAME, action.getName());
actionLogPostProcessor(StatusCode.COMPLETE);
log.metrics("");
diff --git a/openecomp-be/backend/openecomp-sdc-action-manager/src/test/java/org/openecomp/sdc/action/impl/ActionManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-action-manager/src/test/java/org/openecomp/sdc/action/impl/ActionManagerImplTest.java
index 40cf107c53..7143271613 100644
--- a/openecomp-be/backend/openecomp-sdc-action-manager/src/test/java/org/openecomp/sdc/action/impl/ActionManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-action-manager/src/test/java/org/openecomp/sdc/action/impl/ActionManagerImplTest.java
@@ -27,6 +27,7 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
+import org.openecomp.core.dao.UniqueValueDao;
import org.openecomp.sdc.action.ActionConstants;
import org.openecomp.sdc.action.dao.ActionArtifactDao;
import org.openecomp.sdc.action.dao.ActionDao;
@@ -57,6 +58,7 @@ import java.util.Map;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
@@ -71,14 +73,26 @@ public class ActionManagerImplTest {
private ActionArtifactDao actionArtifactDao;
@Mock
private VersionInfoDao versionInfoDao;
+ @Mock
+ private UniqueValueDao uniqueValueDao;
private ActionManagerImpl actionManager;
-
@Before
public void init() {
MockitoAnnotations.initMocks(this);
- actionManager = new ActionManagerImpl(actionDao, versioningManager, actionArtifactDao, versionInfoDao);
+ actionManager = new ActionManagerImpl(actionDao, versioningManager, actionArtifactDao,
+ versionInfoDao, uniqueValueDao);
+ }
+
+ @Test
+ public void testCreateAction() {
+ Action action = createAction();
+ Version version = createVersion();
+ doReturn(version).when(versioningManager).create(anyString(), anyString(), anyString());
+ doReturn(action).when(actionDao).createAction(any());
+ actionManager.createAction(action, "USER");
+ Mockito.verify(actionDao,times(1)).createAction(any());
}
@Test
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml
index 07e3226006..9904b97858 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml
@@ -75,7 +75,11 @@
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ManufacturerReferenceNumberHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ManufacturerReferenceNumberHealer.java
index 4bb5bc865a..0416cc9479 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ManufacturerReferenceNumberHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ManufacturerReferenceNumberHealer.java
@@ -33,10 +33,19 @@ import java.util.Set;
public class ManufacturerReferenceNumberHealer implements Healer {
private static final String MANUFACTURER_REFERENCE_NUMBER = "MRN";
- private VendorLicenseFacade vendorLicenseFacade = VendorLicenseFacadeFactory.getInstance()
- .createInterface();
- private static final FeatureGroupDao featureGroupDao =
- FeatureGroupDaoFactory.getInstance().createInterface();
+ private final VendorLicenseFacade vendorLicenseFacade;
+ private final FeatureGroupDao featureGroupDao;
+
+ public ManufacturerReferenceNumberHealer() {
+ this(VendorLicenseFacadeFactory.getInstance().createInterface(), FeatureGroupDaoFactory
+ .getInstance().createInterface());
+ }
+
+ public ManufacturerReferenceNumberHealer(VendorLicenseFacade vendorLicenseFacade,
+ FeatureGroupDao featureGroupDao) {
+ this.vendorLicenseFacade = vendorLicenseFacade;
+ this.featureGroupDao = featureGroupDao;
+ }
@Override
public boolean isHealingNeeded(String itemId, Version version) {
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/NetworkPackageHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/NetworkPackageHealer.java
index 5ff90ae1c1..e1807bafad 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/NetworkPackageHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/NetworkPackageHealer.java
@@ -75,14 +75,22 @@ public class NetworkPackageHealer implements Healer {
"Vsp with invalid structure: does not contain element OrchestrationTemplateValidationData"
+ " under OrchestrationTemplate element";
- private VendorSoftwareProductInfoDao vspInfoDao;
- private ZusammenAdaptor zusammenAdaptor;
- private CandidateService candidateService;
+ private final VendorSoftwareProductInfoDao vspInfoDao;
+ private final ZusammenAdaptor zusammenAdaptor;
+ private final CandidateService candidateService;
public NetworkPackageHealer() {
- this.vspInfoDao = VendorSoftwareProductInfoDaoFactory.getInstance().createInterface();
- this.zusammenAdaptor = ZusammenAdaptorFactory.getInstance().createInterface();
- this.candidateService = CandidateServiceFactory.getInstance().createInterface();
+ this(VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
+ ZusammenAdaptorFactory.getInstance().createInterface(), CandidateServiceFactory
+ .getInstance().createInterface());
+ }
+
+ public NetworkPackageHealer(VendorSoftwareProductInfoDao vspInfoDao,
+ ZusammenAdaptor zusammenAdaptor,
+ CandidateService candidateService) {
+ this.vspInfoDao = vspInfoDao;
+ this.zusammenAdaptor = zusammenAdaptor;
+ this.candidateService = candidateService;
}
@Override
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ManufacturerReferenceNumberHealerTest.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ManufacturerReferenceNumberHealerTest.java
new file mode 100644
index 0000000000..2d432fcee5
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ManufacturerReferenceNumberHealerTest.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.
+ */
+
+package org.openecomp.sdc.healing.healers;
+
+import static java.lang.Boolean.FALSE;
+import static java.lang.Boolean.TRUE;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
+import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+public class ManufacturerReferenceNumberHealerTest {
+
+ @Mock
+ private VendorLicenseFacade vendorLicenseFacade;
+ @Mock
+ private FeatureGroupDao featureGroupDao;
+ private ManufacturerReferenceNumberHealer manufacturerReferenceNumberHealer;
+
+ private final String ITEM_ID = "ITEM_ID";
+ private final Version version = new Version();
+
+ @Before
+ public void init(){
+ MockitoAnnotations.initMocks(this);
+ manufacturerReferenceNumberHealer = new ManufacturerReferenceNumberHealer
+ (vendorLicenseFacade, featureGroupDao);
+ }
+
+ @Test
+ public void testIsHealingNeeded_Positive() {
+ Collection<EntitlementPoolEntity> entitlementPoolEntities = new ArrayList<>();
+ entitlementPoolEntities.add(new EntitlementPoolEntity(ITEM_ID, version, ""));
+
+ when(vendorLicenseFacade.listEntitlementPools(ITEM_ID, version )).thenReturn(entitlementPoolEntities);
+ Assert.assertEquals(TRUE, manufacturerReferenceNumberHealer.isHealingNeeded("ITEM_ID", version));
+ }
+
+ @Test
+ public void testIsHealingNeeded_Negative() {
+ Collection<EntitlementPoolEntity> entitlementPoolEntities = new ArrayList<>();
+ EntitlementPoolEntity entitlementPoolEntity = new EntitlementPoolEntity(ITEM_ID, version, "");
+ entitlementPoolEntity.setManufacturerReferenceNumber("MRN");
+ entitlementPoolEntities.add(entitlementPoolEntity);
+
+ when(vendorLicenseFacade.listEntitlementPools(ITEM_ID, version )).thenReturn(entitlementPoolEntities);
+ Assert.assertEquals(FALSE, manufacturerReferenceNumberHealer.isHealingNeeded("ITEM_ID", version));
+ }
+
+ @Test
+ public void testHeal() throws Exception {
+
+ Collection<EntitlementPoolEntity> entitlementPoolEntities = getEntitlementPoolEntities();
+ when(vendorLicenseFacade.listEntitlementPools(ITEM_ID, version)).thenReturn(entitlementPoolEntities);
+ doNothing().when(vendorLicenseFacade).updateEntitlementPool(any());
+ Collection<LicenseKeyGroupEntity> licenseKeyGroupEntities = getLicenseKeyGroupEntities();
+ when(vendorLicenseFacade.listLicenseKeyGroups(ITEM_ID, version)).thenReturn
+ (licenseKeyGroupEntities);
+ doNothing().when(vendorLicenseFacade).updateLicenseKeyGroup(any());
+
+ FeatureGroupEntity featureGroupEntity = new FeatureGroupEntity();
+ when(vendorLicenseFacade.getFeatureGroup(any())).thenReturn(featureGroupEntity);
+
+ Collection<FeatureGroupEntity> featureGroupEntities = new ArrayList<>();
+ featureGroupEntities.add(featureGroupEntity);
+ when(vendorLicenseFacade.listFeatureGroups(ITEM_ID, version)).thenReturn
+ (featureGroupEntities);
+ doNothing().when(featureGroupDao).update(any());
+
+ manufacturerReferenceNumberHealer.heal(ITEM_ID, version);
+
+ verify(vendorLicenseFacade, times(1)).updateEntitlementPool(any());
+ verify(vendorLicenseFacade,times(1)).updateLicenseKeyGroup(any());
+ }
+
+ private Collection<EntitlementPoolEntity> getEntitlementPoolEntities() {
+ Set<String> oneReferencingFeatureGroups = new HashSet<String>(Arrays.asList("1"));
+ Collection<EntitlementPoolEntity> entitlementPoolEntities = new ArrayList<>();
+ EntitlementPoolEntity entitlementPoolEntity = new EntitlementPoolEntity();
+ entitlementPoolEntity.setReferencingFeatureGroups(oneReferencingFeatureGroups);
+ entitlementPoolEntities.add(entitlementPoolEntity);
+ return entitlementPoolEntities;
+ }
+
+ private Collection<LicenseKeyGroupEntity> getLicenseKeyGroupEntities() {
+ Set<String> oneReferencingFeatureGroups = new HashSet<String>(Arrays.asList("1"));
+ Collection<LicenseKeyGroupEntity> licenseKeyGroupEntities = new ArrayList<>();
+ LicenseKeyGroupEntity licenseKeyGroupEntity = new LicenseKeyGroupEntity();
+ licenseKeyGroupEntity.setReferencingFeatureGroups(oneReferencingFeatureGroups);
+ licenseKeyGroupEntities.add(licenseKeyGroupEntity);
+ return licenseKeyGroupEntities;
+ }
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/NetworkPackageHealerTest.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/NetworkPackageHealerTest.java
new file mode 100644
index 0000000000..d94d10cf0f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/NetworkPackageHealerTest.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.
+ */
+
+package org.openecomp.sdc.healing.healers;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+
+import static java.lang.Boolean.FALSE;
+import static java.lang.Boolean.TRUE;
+import static org.mockito.Mockito.any;
+
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
+import org.openecomp.sdc.datatypes.model.ElementType;
+import org.openecomp.sdc.healing.healers.NetworkPackageHealer;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import java.util.ArrayList;
+import java.util.Collection;
+
+public class NetworkPackageHealerTest {
+
+ @Mock
+ private VendorSoftwareProductInfoDao vspInfoDaoMock;
+ @Mock
+ private ZusammenAdaptor zusammenAdaptorMock;
+ @Mock
+ private CandidateService candidateService;
+
+ private NetworkPackageHealer networkPackageHealer;
+ private static final String tenant = "dox";
+
+ @Before
+ public void init() {
+ SessionContextProviderFactory.getInstance().createInterface().create("test", tenant);
+ MockitoAnnotations.initMocks(this);
+ networkPackageHealer = new NetworkPackageHealer(vspInfoDaoMock, zusammenAdaptorMock, candidateService);
+ }
+
+ @After
+ public void tearDown(){
+ SessionContextProviderFactory.getInstance().createInterface().close();
+ }
+
+ @Test
+ public void testIsHealingNeeded_Positive() {
+ VspDetails vspDetails = new VspDetails("ITEM_ID",new Version());
+ vspDetails.setOnboardingMethod("NetworkPackage");
+ Mockito.when(vspInfoDaoMock.get(any())).thenReturn(vspDetails);
+ Collection<ElementInfo> elementInfos = new ArrayList<>();
+ ElementInfo elementInfo = new ElementInfo();
+ Info info = new Info();
+ info.setName(ElementType.OrchestrationTemplateCandidate.name());
+ elementInfo.setInfo(info);
+ elementInfos.add(elementInfo);
+ Mockito.when(zusammenAdaptorMock.listElementsByName(any(),any(),any(),any())).thenReturn
+ (elementInfos);
+ Assert.assertEquals(TRUE,networkPackageHealer.isHealingNeeded("ITEM_ID", new Version()));
+}
+
+ @Test
+ public void testIsHealingNeeded_Negative() {
+ VspDetails vspDetails = new VspDetails("ITEM_ID",new Version());
+ vspDetails.setOnboardingMethod("NetworkPackage");
+ Mockito.when(vspInfoDaoMock.get(any())).thenReturn(vspDetails);
+ Collection<ElementInfo> elementInfos = new ArrayList<>();
+
+ ElementInfo elementInfo = new ElementInfo();
+ Info info = new Info();
+ info.setName(ElementType.OrchestrationTemplateCandidate.name());
+ elementInfo.setInfo(info);
+ elementInfos.add(elementInfo);
+
+ ElementInfo elementInfo1 = new ElementInfo();
+ Info info1 = new Info();
+ info1.setName(ElementType.OrchestrationTemplateCandidateValidationData.name());
+ elementInfo1.setInfo(info1);
+ elementInfos.add(elementInfo1);
+
+ Mockito.when(zusammenAdaptorMock.listElementsByName(any(),any(),any(),any())).thenReturn
+ (elementInfos);
+ Assert.assertEquals(FALSE,networkPackageHealer.isHealingNeeded("ITEM_ID", new Version()));
+ }
+
+ @Test
+ public void testIsHealingNeeded_OnboardingMethod() {
+ VspDetails vspDetails = new VspDetails("ITEM_ID",new Version());
+ vspDetails.setOnboardingMethod("Manual");
+ Mockito.when(vspInfoDaoMock.get(any())).thenReturn(vspDetails);
+
+ Assert.assertEquals(FALSE,networkPackageHealer.isHealingNeeded("ITEM_ID", new Version()));
+ }
+}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/resources/logback-test.xml b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/resources/logback-test.xml
new file mode 100644
index 0000000000..04378bf3ad
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/resources/logback-test.xml
@@ -0,0 +1,13 @@
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="off">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration> \ No newline at end of file