aboutsummaryrefslogtreecommitdiffstats
path: root/asdc-controller/src/test
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-04-30 10:07:45 -0400
committerSteve Smokowski <ss835w@att.com>2019-05-03 16:20:12 +0000
commita16bf8f9315060822c16ec92a0532b8375c1a399 (patch)
treeccb13c95c1b6c63f0495566e8bd347ad7402a84b /asdc-controller/src/test
parentd26574fe0e44f43bfbf507adbf91a28c1b53c63a (diff)
parent54b6e6ac185b55d89248cd3c55b1d7766ecaf294 (diff)
Merge remote-tracking branch 'origin/dublin'
merged dublin into master branch Change-Id: Ifb78d405611b65764fd4f01558b0e703551ed663 Issue-ID: SO-1830 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com> Signed-off-by: Smokowski, Steve (ss835w) <ss835w@us.att.com>
Diffstat (limited to 'asdc-controller/src/test')
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java38
1 files changed, 37 insertions, 1 deletions
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
index ce70a252c9..dd107f7775 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
@@ -24,12 +24,14 @@ import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.exception.LockAcquisitionException;
@@ -39,6 +41,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.IResourceInstance;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.impl.SdcCsarHelperImpl;
@@ -58,15 +61,17 @@ import org.onap.so.db.catalog.beans.ConfigurationResource;
import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
+import org.onap.so.db.catalog.beans.ToscaCsar;
import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository;
import org.onap.so.db.catalog.data.repository.AllottedResourceRepository;
import org.onap.so.db.catalog.data.repository.ConfigurationResourceCustomizationRepository;
import org.onap.so.db.catalog.data.repository.ServiceRepository;
+import org.onap.so.db.catalog.data.repository.ToscaCsarRepository;
import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.util.ReflectionTestUtils;
-
+import java.util.Optional;
public class ToscaResourceInstallerTest extends BaseTest {
@Autowired
@@ -117,6 +122,37 @@ public class ToscaResourceInstallerTest extends BaseTest {
}
@Test
+ public void isCsarAlreadyDeployedTest() throws ArtifactInstallerException {
+ IArtifactInfo inputCsar = mock(IArtifactInfo.class);
+ String artifactUuid = "0122c05e-e13a-4c63-b5d2-475ccf13aa74";
+ String checkSum = "MGUzNjJjMzk3OTBkYzExYzQ0MDg2ZDc2M2E2ZjZiZmY=";
+
+ doReturn(checkSum).when(inputCsar).getArtifactChecksum();
+ doReturn(artifactUuid).when(inputCsar).getArtifactUUID();
+
+ doReturn(inputCsar).when(toscaResourceStructure).getToscaArtifact();
+
+ ToscaCsar toscaCsar = mock(ToscaCsar.class);
+
+ Optional<ToscaCsar> returnValue = Optional.of(toscaCsar);
+
+ ToscaCsarRepository toscaCsarRepo = spy(ToscaCsarRepository.class);
+
+
+ doReturn(artifactUuid).when(toscaCsar).getArtifactUUID();
+ doReturn(checkSum).when(toscaCsar).getArtifactChecksum();
+ doReturn(returnValue).when(toscaCsarRepo).findById(artifactUuid);
+
+ ReflectionTestUtils.setField(toscaInstaller, "toscaCsarRepo", toscaCsarRepo);
+
+ boolean isCsarDeployed = toscaInstaller.isCsarAlreadyDeployed(toscaResourceStructure);
+ assertTrue(isCsarDeployed);
+ verify(toscaCsarRepo, times(1)).findById(artifactUuid);
+ verify(toscaResourceStructure, times(1)).getToscaArtifact();
+ verify(toscaCsar, times(2)).getArtifactChecksum();
+ }
+
+ @Test
public void isResourceAlreadyDeployedTest() throws Exception {
notificationData.setServiceName("serviceName");
notificationData.setServiceVersion("123456");