aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java6
-rw-r--r--src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java7
-rw-r--r--src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandlerTest.java25
3 files changed, 31 insertions, 7 deletions
diff --git a/src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java b/src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java
index d4c7e5c2a..7d48086cb 100644
--- a/src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java
@@ -120,16 +120,14 @@ public class CldsToscaServiceItCase {
@Test
public void testGetToscaModel() throws Exception {
- ResponseEntity<CldsToscaModel> responseEntity = cldsToscaService.getToscaModel("tca-policy-test");
- CldsToscaModel savedModel = responseEntity.getBody();
+ CldsToscaModel savedModel = cldsToscaService.getToscaModel("tca-policy-test");
assertNotNull(savedModel);
assertEquals("tca-policy-test", savedModel.getToscaModelName());
}
@Test
public void testGetToscaModelsByPolicyType() throws Exception {
- ResponseEntity<CldsToscaModel> responseEntity = cldsToscaService.getToscaModelsByPolicyType("tca");
- CldsToscaModel savedModel = responseEntity.getBody();
+ CldsToscaModel savedModel = cldsToscaService.getToscaModelsByPolicyType("tca");
assertNotNull(savedModel);
assertEquals("tca-policy-test", savedModel.getToscaModelName());
assertEquals("tca", savedModel.getPolicyType());
diff --git a/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java
index 2c24dcb5c..0df252388 100644
--- a/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java
@@ -42,6 +42,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.onap.clamp.clds.dao.CldsDao;
+import org.onap.clamp.clds.exception.policy.PolicyModelException;
import org.onap.clamp.clds.exception.sdc.controller.CsarHandlerException;
import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException;
import org.onap.clamp.clds.model.CldsModel;
@@ -78,7 +79,7 @@ public class CsarInstallerItCase {
@Test(expected = SdcArtifactInstallerException.class)
public void testInstallTheCsarFail() throws SdcArtifactInstallerException, SdcToscaParserException,
- CsarHandlerException, IOException, InterruptedException {
+ CsarHandlerException, IOException, InterruptedException, PolicyModelException {
CsarHandler csarHandler = Mockito.mock(CsarHandler.class);
BlueprintArtifact blueprintArtifact = Mockito.mock(BlueprintArtifact.class);
Mockito.when(blueprintArtifact.getResourceAttached()).thenReturn(Mockito.mock(IResourceInstance.class));
@@ -145,7 +146,7 @@ public class CsarInstallerItCase {
@Test
public void testIsCsarAlreadyDeployedTca() throws SdcArtifactInstallerException, SdcToscaParserException,
- CsarHandlerException, IOException, InterruptedException {
+ CsarHandlerException, IOException, InterruptedException, PolicyModelException {
String generatedName = RandomStringUtils.randomAlphanumeric(5);
CsarHandler csarHandler = buildFakeCsarHandler(generatedName);
assertFalse(csarInstaller.isCsarAlreadyDeployed(csarHandler));
@@ -155,7 +156,7 @@ public class CsarInstallerItCase {
@Test
public void testInstallTheCsarTca() throws SdcArtifactInstallerException, SdcToscaParserException,
- CsarHandlerException, IOException, JSONException, InterruptedException {
+ CsarHandlerException, IOException, JSONException, InterruptedException, PolicyModelException {
String generatedName = RandomStringUtils.randomAlphanumeric(5);
CsarHandler csar = buildFakeCsarHandler(generatedName);
csarInstaller.installTheCsar(csar);
diff --git a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandlerTest.java b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandlerTest.java
index bb4fd01f2..544c8ca1d 100644
--- a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandlerTest.java
+++ b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandlerTest.java
@@ -24,6 +24,7 @@
package org.onap.clamp.clds.sdc.controller.installer;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -115,6 +116,13 @@ public class CsarHandlerTest {
return resultArtifact;
}
+ private IDistributionClientDownloadResult buildFakeSdcResultWithoutPolicyModel() throws IOException {
+ IDistributionClientDownloadResult resultArtifact = Mockito.mock(IDistributionClientDownloadResult.class);
+ Mockito.when(resultArtifact.getArtifactPayload()).thenReturn(
+ IOUtils.toByteArray(ResourceFileUtil.getResourceAsStream("example/sdc/service-without-policy.csar")));
+ return resultArtifact;
+ }
+
@Test
public void testSave()
throws SdcArtifactInstallerException, SdcToscaParserException, CsarHandlerException, IOException {
@@ -148,6 +156,23 @@ public class CsarHandlerTest {
}
@Test
+ public void testLoadingOfPolicyModelFromCsar()
+ throws CsarHandlerException, IOException, SdcArtifactInstallerException, SdcToscaParserException {
+ CsarHandler csar = new CsarHandler(buildFakeSdcNotification(), "test-controller", "/tmp/csar-handler-tests");
+ csar.save(buildFakeSdcResut());
+ String policyModelYaml = csar.getPolicyModelYaml().get();
+ assertTrue(policyModelYaml.contains("tosca_simple_yaml_1_1"));
+ }
+
+ @Test
+ public void testLoadingOfNonexistentPolicyModelFromCsar()
+ throws CsarHandlerException, IOException, SdcArtifactInstallerException, SdcToscaParserException {
+ CsarHandler csar = new CsarHandler(buildFakeSdcNotification(), "test-controller", "/tmp/csar-handler-tests");
+ csar.save(buildFakeSdcResultWithoutPolicyModel());
+ assertFalse(csar.getPolicyModelYaml().isPresent());
+ }
+
+ @Test
public void testDoubleSave()
throws SdcArtifactInstallerException, SdcToscaParserException, CsarHandlerException, IOException {
CsarHandler csar = new CsarHandler(buildFakeSdcNotification(), "test-controller", "/tmp/csar-handler-tests");