aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
authorSindhuri.A <arcot.sindhuri@huawei.com>2018-10-23 18:33:14 +0530
committerMichael Lando <michael.lando@intl.att.com>2018-10-25 09:27:40 +0000
commit32320724e9fa45d18593cf81314ac068f02560dd (patch)
treebaeab7aec677c4eded7c34f70f99d7ce3509bd7a /catalog-be/src
parent9125b48d8813a254d5ae14109d5bd81fd34c2f33 (diff)
UT-ArtifactsBL handleDelete
UT for catalog be ArtifactsBusinessLogic class handleDelete method Issue-ID: SDC-1775 Change-Id: I1ef9807208cca1dc7ad1d23c5096642ea35b072b Signed-off-by: Sindhuri.A <arcot.sindhuri@huawei.com>
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java50
1 files changed, 41 insertions, 9 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java
index 43430adb9e..066813448f 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -51,6 +51,7 @@ import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.jsontitan.operations.ArtifactsOperations;
import org.openecomp.sdc.be.model.jsontitan.operations.NodeTemplateOperation;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.model.operations.api.*;
import org.openecomp.sdc.be.model.operations.impl.ArtifactOperation;
import org.openecomp.sdc.be.resources.data.ESArtifactData;
@@ -117,10 +118,10 @@ public class ArtifactBusinessLogicTest {
TitanDao titanDao;
@Mock
private IInterfaceLifecycleOperation interfaceLifecycleOperation;
-
- // public static final InformationDeployedArtifactsBusinessLogic
- // informationDeployedArtifactsBusinessLogic =
- // Mockito.mock(InformationDeployedArtifactsBusinessLogic.class);
+ @Mock
+ private ResponseFormat responseFormat;
+ @Mock
+ private User user;
public static final Resource resource = Mockito.mock(Resource.class);
private Gson gson = new GsonBuilder().setPrettyPrinting().create();
@@ -428,9 +429,9 @@ public class ArtifactBusinessLogicTest {
@Test
public void testValidMibAritactsConfiguration() {
Map<String, ArtifactTypeConfig> componentDeploymentArtifacts =
- ConfigurationManager.getConfigurationManager().getConfiguration().getResourceDeploymentArtifacts();
+ ConfigurationManager.getConfigurationManager().getConfiguration().getResourceDeploymentArtifacts();
Map<String, ArtifactTypeConfig> componentInstanceDeploymentArtifacts =
- ConfigurationManager.getConfigurationManager().getConfiguration().getResourceInstanceDeploymentArtifacts();
+ ConfigurationManager.getConfigurationManager().getConfiguration().getResourceInstanceDeploymentArtifacts();
assertThat(componentDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_POLL.getType())).isTrue();
assertThat(componentDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_TRAP.getType())).isTrue();
assertThat(componentInstanceDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_POLL.getType())).isTrue();
@@ -471,7 +472,7 @@ public class ArtifactBusinessLogicTest {
Either<List<org.openecomp.sdc.be.model.Component>, StorageOperationStatus> getServiceRes = Either.left(serviceList);
when(toscaOperationFacade.getBySystemName(ComponentTypeEnum.SERVICE, serviceName)).thenReturn(getServiceRes);
Either<byte[], ResponseFormat> downloadServiceArtifactByNamesRes =
- artifactBL.downloadServiceArtifactByNames(serviceName, serviceVersion, artifactName);
+ artifactBL.downloadServiceArtifactByNames(serviceName, serviceVersion, artifactName);
assertThat(downloadServiceArtifactByNamesRes.isLeft()).isTrue();
assertThat(downloadServiceArtifactByNamesRes.left().value() !=null &&
downloadServiceArtifactByNamesRes.left().value().length == payload.length).isTrue();
@@ -562,6 +563,37 @@ public class ArtifactBusinessLogicTest {
verify(titanDao, times(1)).commit();
}
+ @Test
+ public void testDeleteComponent_ArtifactNotFound(){
+ Either<Either<ArtifactDefinition, Operation>, ResponseFormat> result;
+ Resource resource = new Resource();
+ String uniqueId = "uniqueId";
+ resource.setUniqueId(uniqueId);
+ Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
+ ArtifactDefinition artifact = new ArtifactDefinition();
+ artifact.setArtifactName("artifactName");
+ artifact.setEsId("esId");
+ artifact.setArtifactUUID("artifactUUID");
+ artifact.setArtifactType("YANG");
+ artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
+ artifact.setDescription("description");
+ artifact.setArtifactLabel("artifactLabel");
+ toscaArtifacts.put("artifactId", artifact);
+ resource.setArtifacts(toscaArtifacts);
+ resource.setToscaArtifacts(toscaArtifacts);
+ when(graphLockOperation.lockComponent(uniqueId, NodeTypeEnum.Resource))
+ .thenReturn(StorageOperationStatus.OK);
+ when(graphLockOperation.unlockComponent(uniqueId, NodeTypeEnum.Resource))
+ .thenReturn(StorageOperationStatus.OK);
+ when(toscaOperationFacade.getToscaElement(uniqueId)).thenReturn(Either.left(resource));
+ when(componentsUtils.getResponseFormatByArtifactId(ActionStatus.ARTIFACT_NOT_FOUND, "artifactId")).
+ thenReturn(responseFormat);
+ result = artifactBL.handleDelete("parentId", "artifactId", user, AuditingActionEnum.ARTIFACT_DELETE,
+ ComponentTypeEnum.RESOURCE, resource,
+ true, false);
+ assertThat(result.isRight());
+ }
+
private void verifyHeatParam(HeatParameterDefinition heatEnvParam, HeatParameterDefinition heatYamlParam) {
assertThat(heatYamlParam.getCurrentValue()).isEqualTo(heatEnvParam.getDefaultValue());
assertThat(heatEnvParam.getCurrentValue()).isNull();