summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test')
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/externaltesting-configuration.yaml5
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/heat.zipbin0 -> 3771 bytes
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/managertestconfiguration.yaml13
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testconfiguration.yaml11
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ConfigurationTests.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/CsarMetadataVariableResolverTest.java88
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ExternalTestingManagerImplTests.java251
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ExternalTestingTestSuite.java1
8 files changed, 203 insertions, 170 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/externaltesting-configuration.yaml b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/externaltesting-configuration.yaml
new file mode 100644
index 0000000000..5910ab5b44
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/externaltesting-configuration.yaml
@@ -0,0 +1,5 @@
+client:
+ enabled: true
+endpoints:
+ - vtp,VTP,true,http://bogus.ec2-34-237-35-152.compute-1.amazonaws.com,c.*,FOO
+ - repository,Repository,true,http://bogus.ec2-34-237-35-152.compute-1.amazonaws.com,.* \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/heat.zip b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/heat.zip
new file mode 100644
index 0000000000..ac63ba6fc8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/heat.zip
Binary files differ
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/managertestconfiguration.yaml b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/managertestconfiguration.yaml
deleted file mode 100644
index d65becedf9..0000000000
--- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/managertestconfiguration.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-externalTestingConfig:
- client:
- enabled: true
- endpoints:
- - id: vtp
- enabled: true
- url: http://bogus.ec2-34-237-35-152.compute-1.amazonaws.com
- apiKey: FOOBAR
- scenarioFilter: c.*
- - id: repository
- url: http://bogus.ec2-34-237-35-152.compute-1.amazonaws.com
- enabled: true
- apiKey: FOOBAR
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testconfiguration.yaml b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testconfiguration.yaml
deleted file mode 100644
index 1bf800b8f2..0000000000
--- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testconfiguration.yaml
+++ /dev/null
@@ -1,11 +0,0 @@
- client:
- enabled: true
- endpoints:
- - id: vtp
- enabled: false
- url: http://bogus.ec2-34-237-35-152.compute-1.amazonaws.com
- apiKey: FOOBAR
- - id: repository
- url: http://bogus.ec2-34-237-35-152.compute-1.amazonaws.com
- enabled: true
- apiKey: FOOBAR
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ConfigurationTests.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ConfigurationTests.java
index 6b530daa09..103320f755 100644
--- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ConfigurationTests.java
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ConfigurationTests.java
@@ -20,6 +20,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Assert;
import org.junit.Test;
import org.onap.sdc.tosca.services.YamlUtil;
+import org.openecomp.core.externaltesting.api.ClientConfiguration;
+import org.openecomp.core.externaltesting.api.RemoteTestingEndpointDefinition;
import java.io.File;
import java.io.FileInputStream;
@@ -40,7 +42,7 @@ public class ConfigurationTests {
@Test
public void testConfig() throws Exception {
- try (InputStream fileInput = new FileInputStream(new File("src/test/data/testconfiguration.yaml"))) {
+ try (InputStream fileInput = new FileInputStream(new File("src/test/data/config-externaltesting.yaml"))) {
YamlUtil yamlUtil = new YamlUtil();
Object raw = yamlUtil.yamlToMap(fileInput);
TestingAccessConfig accessConfig = new ObjectMapper().convertValue(raw, TestingAccessConfig.class);
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/CsarMetadataVariableResolverTest.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/CsarMetadataVariableResolverTest.java
deleted file mode 100644
index b8471eb77b..0000000000
--- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/CsarMetadataVariableResolverTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright © 2019 iconectiv
- *
- * 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.core.externaltesting.impl;
-
-import org.apache.commons.io.IOUtils;
-import org.junit.Assert;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.openecomp.core.externaltesting.api.VtpTestExecutionRequest;
-import org.openecomp.core.externaltesting.errors.ExternalTestingException;
-import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
-import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
-import org.openecomp.sdc.versioning.VersioningManager;
-import org.springframework.core.io.ByteArrayResource;
-import org.springframework.util.LinkedMultiValueMap;
-import org.springframework.util.MultiValueMap;
-
-import java.io.FileInputStream;
-import java.util.*;
-
-public class CsarMetadataVariableResolverTest {
-
- @Mock
- private VersioningManager versioningManager;
-
- @Mock
- private VendorSoftwareProductManager vendorSoftwareProductManager;
-
- @Mock
- private OrchestrationTemplateCandidateManager candidateManager;
-
- @Test
- public void testResolverResolves() throws Exception {
- MockitoAnnotations.initMocks(this);
- CsarMetadataVariableResolver resolver = new CsarMetadataVariableResolver(versioningManager,
- vendorSoftwareProductManager, candidateManager);
- resolver.init();
-
- VtpTestExecutionRequest doesNotResolve = new VtpTestExecutionRequest();
- Assert.assertFalse("should not resolve empty request", resolver.resolvesVariablesForRequest(doesNotResolve));
-
- doesNotResolve.setParameters(new HashMap<>());
- Assert.assertFalse("should not resolve empty parameters", resolver.resolvesVariablesForRequest(doesNotResolve));
-
-
-
- VtpTestExecutionRequest resolves = new VtpTestExecutionRequest();
- resolves.setParameters(new HashMap<>());
- resolves.getParameters().put(CsarMetadataVariableResolver.VSP_VERSION, "1.0");
- resolves.getParameters().put(CsarMetadataVariableResolver.VSP_ID, "vspid");
- resolves.getParameters().put(CsarMetadataVariableResolver.CSAR_PREFIX + "MainServiceTemplate.yaml", "");
- Assert.assertTrue("should resolve", resolver.resolvesVariablesForRequest(resolves));
-
- MultiValueMap<String,Object> fakeRequestBody = new LinkedMultiValueMap<>();
-
- try {
- resolver.resolve(resolves, fakeRequestBody);
- }
- catch (ExternalTestingException e) {
- // exception expected.
- }
-
- // test the metadata extraction on a know CSAR zip.
- byte[] zip = IOUtils.toByteArray(new FileInputStream("src/test/data/csar.zip"));
- resolver.processArchive(resolves, fakeRequestBody, zip);
- Assert.assertTrue("body contains file", fakeRequestBody.containsKey("file"));
- LinkedList ll = (LinkedList)fakeRequestBody.get("file");
- Assert.assertEquals("body contains one file", 1, ll.size());
- ByteArrayResource res = (ByteArrayResource)ll.get(0);
- Assert.assertEquals("file should have matching name", "MainServiceTemplate.yaml", res.getFilename());
-
- }
-}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ExternalTestingManagerImplTests.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ExternalTestingManagerImplTests.java
index be328ea73f..2233f85ccf 100644
--- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ExternalTestingManagerImplTests.java
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ExternalTestingManagerImplTests.java
@@ -19,25 +19,30 @@ package org.openecomp.core.externaltesting.impl;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.tuple.Pair;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.ArgumentMatchers;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
+import org.mockito.*;
import org.mockito.junit.MockitoJUnitRunner;
import org.openecomp.core.externaltesting.api.*;
import org.openecomp.core.externaltesting.errors.ExternalTestingException;
+import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
+import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
+import org.openecomp.sdc.versioning.VersioningManager;
+import org.openecomp.sdc.versioning.dao.types.Version;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.*;
-import org.springframework.util.MultiValueMap;
+import org.springframework.util.LinkedMultiValueMap;
import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.RestTemplate;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.*;
@@ -48,36 +53,25 @@ public class ExternalTestingManagerImplTests {
@Mock
private RestTemplate restTemplate;
- static {
- System.setProperty("configuration.yaml", "src/test/data/testconfiguration.yaml");
- }
-
- class JUnitExternalTestingManagerImpl extends ExternalTestingManagerImpl {
- JUnitExternalTestingManagerImpl() {
- super(Collections.singletonList(
- new VariableResolver() {
-
- @Override
- public boolean resolvesVariablesForRequest(VtpTestExecutionRequest requestItem) {
- return false;
- }
+ @Mock
+ private VersioningManager versioningManager;
- @Override
- public void resolve(VtpTestExecutionRequest requestItem, MultiValueMap<String, Object> body) {
+ @Mock
+ private VendorSoftwareProductManager vendorSoftwareProductManager;
- // unit test resolver does nothing for this case. See specific test for resolver.
- }
- }));
- }
- }
+ @Mock
+ private OrchestrationTemplateCandidateManager candidateManager;
@InjectMocks
- private ExternalTestingManager mgr = new JUnitExternalTestingManagerImpl();
+ private ExternalTestingManagerImpl mgr = new ExternalTestingManagerImpl();
@SuppressWarnings("unchecked")
- private ExternalTestingManager configTestManager(boolean loadConfig) throws IOException {
+ private ExternalTestingManagerImpl configTestManager(boolean loadConfig) throws IOException {
+
+ MockitoAnnotations.initMocks(this);
+
if (loadConfig) {
- ((ExternalTestingManagerImpl) mgr).loadConfig();
+ mgr.init();
}
ObjectMapper mapper = new ObjectMapper();
@@ -112,7 +106,55 @@ public class ExternalTestingManagerImplTests {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.parseMediaType("application/problem+json"));
- HttpStatusCodeException missingException = new HttpServerErrorException(HttpStatus.NOT_FOUND, "Not Found", headers, notFound.getBytes(), Charset.defaultCharset());
+
+ byte[] csar = IOUtils.toByteArray(new FileInputStream("src/test/data/csar.zip"));
+ byte[] heat = IOUtils.toByteArray(new FileInputStream("src/test/data/heat.zip"));
+
+ List<Version> versionList = new ArrayList<>();
+ versionList.add(new Version(UUID.randomUUID().toString()));
+
+ Mockito
+ .when(candidateManager.get(
+ ArgumentMatchers.contains("csar"),
+ ArgumentMatchers.any()))
+ .thenReturn(Optional.of(Pair.of("Processed.zip", csar)));
+
+ Mockito
+ .when(candidateManager.get(
+ ArgumentMatchers.contains("heat"),
+ ArgumentMatchers.any()))
+ .thenReturn(Optional.empty());
+
+ Mockito
+ .when(vendorSoftwareProductManager.get(
+ ArgumentMatchers.contains("heat"),
+ ArgumentMatchers.any()))
+ .thenReturn(Optional.of(Pair.of("Processed.zip", heat)));
+
+
+
+ Mockito
+ .when(vendorSoftwareProductManager.get(
+ ArgumentMatchers.contains("missing"),
+ ArgumentMatchers.any()))
+ .thenReturn(Optional.empty());
+
+ Mockito
+ .when(candidateManager.get(
+ ArgumentMatchers.contains("missing"),
+ ArgumentMatchers.any()))
+ .thenReturn(Optional.empty());
+
+
+ Mockito
+ .when(versioningManager.list(
+ ArgumentMatchers.contains("missing")))
+ .thenReturn(versionList);
+
+
+
+
+
Mockito
.when(restTemplate.exchange(
@@ -124,10 +166,10 @@ public class ExternalTestingManagerImplTests {
Mockito
.when(restTemplate.exchange(
- ArgumentMatchers.endsWith("/testsuites"),
- ArgumentMatchers.eq(HttpMethod.GET),
- ArgumentMatchers.any(),
- ArgumentMatchers.eq(listOfPairType)))
+ ArgumentMatchers.endsWith("/testsuites"),
+ ArgumentMatchers.eq(HttpMethod.GET),
+ ArgumentMatchers.any(),
+ ArgumentMatchers.eq(listOfPairType)))
.thenReturn(new ResponseEntity(testSuites, HttpStatus.OK));
Mockito
@@ -166,6 +208,8 @@ public class ExternalTestingManagerImplTests {
ArgumentMatchers.eq(new ParameterizedTypeReference<VtpTestExecutionResponse>() {})))
.thenReturn(new ResponseEntity(priorExecution, HttpStatus.OK));
+
+ HttpStatusCodeException missingException = new HttpServerErrorException(HttpStatus.NOT_FOUND, "Not Found", headers, notFound.getBytes(), Charset.defaultCharset());
Mockito
.when(restTemplate.exchange(
ArgumentMatchers.endsWith("/missing"),
@@ -174,6 +218,7 @@ public class ExternalTestingManagerImplTests {
ArgumentMatchers.eq(caseType)))
.thenThrow(missingException);
+
Mockito
.when(restTemplate.exchange(
ArgumentMatchers.endsWith("/sitedown"),
@@ -182,18 +227,31 @@ public class ExternalTestingManagerImplTests {
ArgumentMatchers.eq(caseType)))
.thenThrow(new ResourceAccessException("Remote site is down"));
+ Mockito
+ .when(restTemplate.exchange(
+ ArgumentMatchers.endsWith("throwexception"),
+ ArgumentMatchers.eq(HttpMethod.POST),
+ ArgumentMatchers.any(),
+ ArgumentMatchers.eq(new ParameterizedTypeReference<List<VtpTestExecutionResponse>>() {})))
+ .thenThrow(missingException);
+
+
return mgr;
}
+ @Before
+ public void setConfigLocation() {
+ System.setProperty("config.location", "src/test/data");
+ }
+
@Test
public void testManager() throws IOException {
- System.setProperty("configuration.yaml", "src/test/data/managertestconfiguration.yaml");
ExternalTestingManager m = configTestManager(true);
- String config = m.getConfig();
+ ClientConfiguration config = m.getConfig();
Assert.assertNotNull(config);
- List<VtpNameDescriptionPair> endpoints = m.getEndpoints();
+ List<RemoteTestingEndpointDefinition> endpoints = m.getEndpoints();
Assert.assertEquals("two endpoints", 2, endpoints.size());
@@ -210,8 +268,8 @@ public class ExternalTestingManagerImplTests {
catch (ExternalTestingException e) {
// expecting this exception.
Assert.assertNotNull(e.getDetail());
- Assert.assertNotEquals(0, e.getCode());
- Assert.assertNotNull(e.getTitle());
+ Assert.assertNotEquals(0, e.getHttpStatus());
+ Assert.assertNotNull(e.getMessageCode());
}
// get a particular test case
@@ -222,10 +280,14 @@ public class ExternalTestingManagerImplTests {
catch (ExternalTestingException e) {
// expecting this exception.
Assert.assertNotNull(e.getDetail());
- Assert.assertNotEquals(0, e.getCode());
- Assert.assertNotNull(e.getTitle());
+ Assert.assertNotEquals(0, e.getHttpStatus());
+ Assert.assertNotNull(e.getMessageCode());
}
+ }
+ @Test
+ public void testManagerExecution() throws IOException {
+ ExternalTestingManager m = configTestManager(true);
// execute a test.
List<VtpTestExecutionRequest> requests = new ArrayList<>();
@@ -234,8 +296,8 @@ public class ExternalTestingManagerImplTests {
requests.add(req);
// send a request with the endpoint defined.
- List<VtpTestExecutionResponse> responses = m.execute( requests, "rid");
- Assert.assertEquals(1,responses.size());
+ List<VtpTestExecutionResponse> responses = m.execute(requests, "rid");
+ Assert.assertEquals(1, responses.size());
// send a request for a prior execution.
VtpTestExecutionResponse execRsp = m.getExecution("repository", "execId");
@@ -243,26 +305,67 @@ public class ExternalTestingManagerImplTests {
}
@Test
+ public void testMissingConfig() throws IOException {
+ // directory exists but no config file should be found here.
+ System.setProperty("config.location", "src/test");
+ ExternalTestingManager m = configTestManager(true);
+ Assert.assertFalse("missing config client enabled false", m.getConfig().isEnabled());
+ Assert.assertEquals("missing config no endpoints", 0, m.getEndpoints().size());
+ }
+
+ @Test
+ public void testMissingEndpoint() throws IOException {
+ ExternalTestingManager m = configTestManager(true);
+
+ // execute a test.
+ List<VtpTestExecutionRequest> requests = new ArrayList<>();
+ VtpTestExecutionRequest req = new VtpTestExecutionRequest();
+ req.setEndpoint("repository");
+ requests.add(req);
+
+ // send a request with the endpoint defined.
+ try {
+ m.execute(requests, "throwexception");
+ }
+ catch (ExternalTestingException e) {
+ // expected.
+ }
+ }
+
+
+ @Test
+ public void testManagerConfigOverrides() throws IOException {
+ ExternalTestingManager m = configTestManager(false);
+
+ ClientConfiguration cc = new ClientConfiguration();
+ cc.setEnabled(true);
+ m.setConfig(cc);
+ Assert.assertTrue(m.getConfig().isEnabled());
+
+ List<RemoteTestingEndpointDefinition> lst = new ArrayList<>();
+ lst.add(new RemoteTestingEndpointDefinition());
+ lst.get(0).setEnabled(true);
+ m.setEndpoints(lst);
+ Assert.assertEquals(1,m.getEndpoints().size());
+ }
+
+ @Test
public void testManagerErrorCases() throws IOException {
ExternalTestingManager m = configTestManager(false);
- Map<String,Object> expectedEmptyConfig = new HashMap<>();
- expectedEmptyConfig.put("enabled", false);
- String expected = new ObjectMapper().writeValueAsString(expectedEmptyConfig);
- String emptyConfig = m.getConfig();
- Assert.assertEquals(expected, emptyConfig);
-
- try {
- m.getEndpoints();
- Assert.assertTrue("should have exception here", true);
- }
- catch (ExternalTestingException e) {
- // eat the exception cause this is what should happen.
- }
+ ClientConfiguration emptyConfig = m.getConfig();
+ Assert.assertFalse("empty configuration should have client enabled of false", emptyConfig.isEnabled());
+
+ try {
+ m.getEndpoints();
+ Assert.assertTrue("should have exception here", true);
}
+ catch (ExternalTestingException e) {
+ // eat the exception cause this is what should happen.
+ }
+ }
@Test
public void testExecutionDistribution() throws IOException {
- System.setProperty("configuration.yaml", "src/test/data/managertestconfiguration.yaml");
ExternalTestingManager m = configTestManager(true);
VtpTestExecutionRequest r1 = new VtpTestExecutionRequest();
@@ -280,4 +383,40 @@ public class ExternalTestingManagerImplTests {
List<VtpTestExecutionResponse> results = m.execute(Arrays.asList(r1,r2,r3), "rid");
Assert.assertEquals("three in two out merged", 2, results.size());
}
+
+ @Test
+ public void testArchiveProcessing() throws IOException {
+ ExternalTestingManagerImpl m = configTestManager(true);
+ VtpTestExecutionRequest r1 = new VtpTestExecutionRequest();
+ r1.setScenario("scenario1");
+ r1.setEndpoint("vtp");
+ r1.setParameters(new HashMap<>());
+ r1.getParameters().put(ExternalTestingManagerImpl.VSP_ID, "something.with.csar.content");
+ r1.getParameters().put(ExternalTestingManagerImpl.VSP_VERSION, UUID.randomUUID().toString());
+
+ LinkedMultiValueMap<String,Object> body = new LinkedMultiValueMap<>();
+ m.attachArchiveContent(r1, body);
+
+ r1.setParameters(new HashMap<>());
+ r1.getParameters().put(ExternalTestingManagerImpl.VSP_ID, "something.with.heat.content");
+ r1.getParameters().put(ExternalTestingManagerImpl.VSP_VERSION, UUID.randomUUID().toString());
+
+ LinkedMultiValueMap<String,Object> body2 = new LinkedMultiValueMap<>();
+ m.attachArchiveContent(r1, body2);
+
+ // now, let's handle a missing archive.
+ r1.setParameters(new HashMap<>());
+ r1.getParameters().put(ExternalTestingManagerImpl.VSP_ID, "something.with.missing.content");
+ r1.getParameters().put(ExternalTestingManagerImpl.VSP_VERSION, UUID.randomUUID().toString());
+
+ LinkedMultiValueMap<String,Object> body3 = new LinkedMultiValueMap<>();
+ try {
+ m.attachArchiveContent(r1, body3);
+ Assert.fail("expected to receive an exception here");
+ }
+ catch (ExternalTestingException ex) {
+ Assert.assertEquals(500, ex.getHttpStatus());
+ }
+
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ExternalTestingTestSuite.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ExternalTestingTestSuite.java
index 31346a135e..d9e4612774 100644
--- a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ExternalTestingTestSuite.java
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ExternalTestingTestSuite.java
@@ -21,7 +21,6 @@ import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
- CsarMetadataVariableResolverTest.class,
ExternalTestingManagerImplTests.class,
ConfigurationTests.class
})