summaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap
diff options
context:
space:
mode:
authorxg353y <xg353y@intl.att.com>2019-04-03 15:54:21 +0200
committerxg353y <xg353y@intl.att.com>2019-04-03 15:54:21 +0200
commited8e2a71029088ecc7f29b484ef1b7a71d536604 (patch)
treefa48dc2d59e7d5f46ca65a2142e5acc2f88ca390 /src/test/java/org/onap
parent8d36cfd7ccec9ea9a55894eeafba00da6037747d (diff)
Update Csar handler
Update Csar handler, return the content of policies.yaml concatenateed with data.yaml while getting the policy model yaml. Issue-ID: CLAMP-261 Change-Id: I8ef7bcb9b2daaea37f13ca9d3ad9f38b889d6041 Signed-off-by: xg353y <xg353y@intl.att.com>
Diffstat (limited to 'src/test/java/org/onap')
-rw-r--r--src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java
index 2578f68ed..0cadef9ae 100644
--- a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java
+++ b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java
@@ -36,6 +36,7 @@ import javax.transaction.Transactional;
import org.apache.commons.lang3.RandomStringUtils;
import org.json.JSONException;
+import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
@@ -47,6 +48,7 @@ import org.onap.clamp.clds.sdc.controller.installer.BlueprintArtifact;
import org.onap.clamp.clds.sdc.controller.installer.CsarHandler;
import org.onap.clamp.clds.sdc.controller.installer.CsarInstaller;
import org.onap.clamp.clds.util.ResourceFileUtil;
+import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.INotificationData;
import org.onap.sdc.api.notification.IResourceInstance;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
@@ -55,6 +57,7 @@ import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
import org.onap.sdc.toscaparser.api.elements.Metadata;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
@@ -63,7 +66,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@ActiveProfiles(profiles = "clamp-default,clamp-default-user,clamp-sdc-controller-new")
public class CsarInstallerItCase {
- private static final String CSAR_ARTIFACT_NAME = "example/sdc/service-Simsfoimap0112.csar";
+ private static final String CSAR_ARTIFACT_NAME = "example/sdc/service-Vloadbalancerms-csar.csar";
private static final String INVARIANT_SERVICE_UUID = "4cc5b45a-1f63-4194-8100-cd8e14248c92";
private static final String INVARIANT_RESOURCE1_UUID = "07e266fc-49ab-4cd7-8378-ca4676f1b9ec";
private static final String INVARIANT_RESOURCE2_UUID = "023a3f0d-1161-45ff-b4cf-8918a8ccf3ad";
@@ -129,8 +132,9 @@ public class CsarInstallerItCase {
// Create helper based on real csar to test policy yaml and global properties
// set
SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
+ String path = Thread.currentThread().getContextClassLoader().getResource(CSAR_ARTIFACT_NAME).getFile();
ISdcCsarHelper sdcHelper = factory
- .getSdcCsarHelper(Thread.currentThread().getContextClassLoader().getResource(CSAR_ARTIFACT_NAME).getFile());
+ .getSdcCsarHelper(path);
Mockito.when(csarHandler.getSdcCsarHelper()).thenReturn(sdcHelper);
// Mockito.when(csarHandler.getSdcCsarHelper()).thenReturn(csarHelper);
@@ -141,6 +145,24 @@ public class CsarInstallerItCase {
@Test
@Transactional
+ public void testGetPolicyModelYaml() throws IOException, SdcToscaParserException, CsarHandlerException {
+ INotificationData notificationData = Mockito.mock(INotificationData.class);
+ IArtifactInfo serviceArtifacts = Mockito.mock(IArtifactInfo.class);
+ Mockito.when(serviceArtifacts.getArtifactType()).thenReturn("TOSCA_CSAR");
+ List<IArtifactInfo> serviceArtifactsList = new ArrayList<>();
+ serviceArtifactsList.add(serviceArtifacts);
+ Mockito.when(notificationData.getServiceArtifacts()).thenReturn(serviceArtifactsList);
+
+ CsarHandler csarHandler = new CsarHandler(notificationData, "", "");
+ csarHandler.setFilePath(Thread.currentThread().getContextClassLoader()
+ .getResource(CSAR_ARTIFACT_NAME).getFile());
+ Optional<String> testyaml = csarHandler.getPolicyModelYaml();
+ Assert.assertEquals(testyaml, Optional.ofNullable(ResourceFileUtil
+ .getResourceAsString("example/sdc/expected-result/policy-data.yaml")));
+ }
+
+ @Test
+ @Transactional
public void testIsCsarAlreadyDeployedTca() throws SdcArtifactInstallerException, SdcToscaParserException,
CsarHandlerException, IOException, InterruptedException, PolicyModelException {
String generatedName = RandomStringUtils.randomAlphanumeric(5);