summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorJennie Jia <Jennie.Jia@amdocs.com>2018-07-20 21:23:51 +0000
committerJennie Jia <Jennie.Jia@amdocs.com>2018-08-07 18:12:43 +0000
commit9338362c1605a84a2b8e0a00ad1d65e14789bd6a (patch)
treee42db405d19d1420926287040a1000f7886a9320 /src/test
parentf9776d084d3a39dbe5e4ea4849020b630d5da3ec (diff)
Upstreaming the POMBA SDC Context Builder
Issue-ID: LOG-522 Change-Id: Ic4606c987a8950ff3d19a8f42f330b08e3f4e4ca Signed-off-by: Jennie Jia <Jennie.Jia@amdocs.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/sdc/model/test/ArtifactInfoTest.java38
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/sdc/model/test/SDCContextRequestTest.java56
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/sdc/test/JerseyConfigurationTest.java36
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/sdc/test/SDCClientConfigurationTest.java52
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/sdc/test/SDCContextConfigTest.java57
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/sdc/test/ToscaBuildConfigTest.java45
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/sdc/unittest/service/SDCContextBuilderTest.java142
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/sdc/unittest/service/SDCContextRestAPITest.java90
-rw-r--r--src/test/resources/toscaModel.csar.zipbin0 -> 78649 bytes
9 files changed, 516 insertions, 0 deletions
diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdc/model/test/ArtifactInfoTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdc/model/test/ArtifactInfoTest.java
new file mode 100644
index 0000000..2ebb891
--- /dev/null
+++ b/src/test/java/org/onap/pomba/contextbuilder/sdc/model/test/ArtifactInfoTest.java
@@ -0,0 +1,38 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * 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.
+ * ============LICENSE_END=====================================================
+ */
+package org.onap.pomba.contextbuilder.sdc.model.test;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.onap.pomba.contextbuilder.sdc.model.ArtifactInfo;
+
+public class ArtifactInfoTest {
+
+ @Test
+ public void testArtifactInfo() throws Exception {
+ String url = "/sdc/v1/catalog/services/e9851a43-c068-4eb2-9fe7-2d123bd94ff0/toscaModel";
+ String artifactType = "TOSCA_CSAR";
+ ArtifactInfo artifact = new ArtifactInfo();
+ artifact.setArtifactType(artifactType);
+ artifact.setArtifactURL(url);
+
+ assertEquals(artifactType, artifact.getArtifactType());
+ assertEquals(url, artifact.getArtifactURL());
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdc/model/test/SDCContextRequestTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdc/model/test/SDCContextRequestTest.java
new file mode 100644
index 0000000..e7ace4b
--- /dev/null
+++ b/src/test/java/org/onap/pomba/contextbuilder/sdc/model/test/SDCContextRequestTest.java
@@ -0,0 +1,56 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * 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.
+ * ============LICENSE_END=====================================================
+ */
+package org.onap.pomba.contextbuilder.sdc.model.test;
+
+import static org.junit.Assert.assertEquals;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+import java.util.UUID;
+import org.junit.Test;
+import org.onap.pomba.contextbuilder.sdc.model.SDCContextRequest;
+
+public class SDCContextRequestTest {
+
+
+ @Test
+ public void testSDCContextRequest() throws Exception {
+ String authorization = "Basic " + Base64.getEncoder().encodeToString(("admin" + ":" + "admin").getBytes(StandardCharsets.UTF_8));
+ String fromAppId = "POMBA";
+ String transactionId = UUID.randomUUID().toString();
+ String serviceInstanceId = "b06270ab-99e6-4a58-9bc0-db2df5c36f4d";
+ String modelVersionId= "e9851a43-c068-4eb2-9fe7-2d123bd94ff0";
+ String modelInvariantId = "4fd21763-23ed-4f69-8654-e121626df327" ;
+
+ SDCContextRequest sdcContext = new SDCContextRequest(null, authorization, fromAppId, transactionId,
+ serviceInstanceId, modelVersionId, modelInvariantId);
+ sdcContext.toString().contains(fromAppId);
+ sdcContext.toString().contains(transactionId);
+ sdcContext.toString().contains(serviceInstanceId);
+ sdcContext.toString().contains(modelVersionId);
+ sdcContext.toString().contains(modelInvariantId);
+
+ assertEquals(authorization, sdcContext.getAuthorization());
+ assertEquals(fromAppId, sdcContext.getFromAppId());
+ assertEquals(transactionId, sdcContext.getTransactionId());
+ assertEquals(serviceInstanceId, sdcContext.getServiceInstanceId());
+ assertEquals(modelVersionId, sdcContext.getModelVersionId());
+ assertEquals(modelInvariantId, sdcContext.getModelInvariantId());
+ }
+
+}
diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdc/test/JerseyConfigurationTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdc/test/JerseyConfigurationTest.java
new file mode 100644
index 0000000..f10ac09
--- /dev/null
+++ b/src/test/java/org/onap/pomba/contextbuilder/sdc/test/JerseyConfigurationTest.java
@@ -0,0 +1,36 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * 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.
+ * ============LICENSE_END=====================================================
+ */
+package org.onap.pomba.contextbuilder.sdc.test;
+
+import static org.junit.Assert.assertEquals;
+
+import javax.ws.rs.client.Client;
+import org.junit.Test;
+import org.onap.pomba.contextbuilder.sdc.JerseyConfiguration;
+
+
+public class JerseyConfigurationTest {
+
+ @Test
+ public void runTest() {
+ JerseyConfiguration jerseyConfiguration = new JerseyConfiguration();
+ Client client = jerseyConfiguration.jerseyClient();
+ String protocol = client.getSslContext().getProtocol();
+ assertEquals(protocol, "TLS");
+ }
+}
diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdc/test/SDCClientConfigurationTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdc/test/SDCClientConfigurationTest.java
new file mode 100644
index 0000000..c838a1c
--- /dev/null
+++ b/src/test/java/org/onap/pomba/contextbuilder/sdc/test/SDCClientConfigurationTest.java
@@ -0,0 +1,52 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * 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.
+ * ============LICENSE_END=====================================================
+ */
+package org.onap.pomba.contextbuilder.sdc.test;
+
+import org.onap.pomba.contextbuilder.sdc.SDCClientConfiguration;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class SDCClientConfigurationTest {
+
+ @Test
+ public void testSDCClientConfig() throws Exception {
+ SDCClientConfiguration config = new SDCClientConfiguration();
+ config.setConsumerID("consumerID");
+ config.setPassword("password");
+ config.setSdcAddress("10.147.58.6:30204");
+ config.setUsername("username");
+ config.setPollingTimeout("6666");
+
+ assertEquals("username", config.getUsername());
+ assertEquals("consumerID", config.getConsumerID());
+ assertEquals("password", config.getPassword());
+ assertEquals("6666", config.getPollingTimeout());
+ assertEquals("10.147.58.6:30204", config.getSdcAddress());
+ }
+
+
+ @Test
+ public void testGetHttpBasicAuth() {
+ String msg = "Basic YWRtaW46YWRtaW4=";
+ SDCClientConfiguration config = new SDCClientConfiguration();
+ config.setHttpUserId("admin");
+ config.setHttpPassword("admin");
+ assertEquals(msg, config.getHttpBasicAuth());
+ }
+}
diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdc/test/SDCContextConfigTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdc/test/SDCContextConfigTest.java
new file mode 100644
index 0000000..a02fffd
--- /dev/null
+++ b/src/test/java/org/onap/pomba/contextbuilder/sdc/test/SDCContextConfigTest.java
@@ -0,0 +1,57 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * 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.
+ * ============LICENSE_END=====================================================
+ */
+package org.onap.pomba.contextbuilder.sdc.test;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.onap.pomba.contextbuilder.sdc.SDCContextConfig;
+
+
+public class SDCContextConfigTest {
+
+ @Test
+ public void testSDCContextConfig() throws Exception {
+
+ SDCContextConfig sdcContextConfig= new SDCContextConfig();
+
+ sdcContextConfig.setUser("pomba");
+ sdcContextConfig.setAsdcAddress("10.69.100.139");
+ sdcContextConfig.setPassword("pomba");
+ sdcContextConfig.setUseHttpsWithDmaap(false);
+ sdcContextConfig.setConsumerId("pomba");
+ sdcContextConfig.setActivateServerTLSAuth(false);
+ sdcContextConfig.setPollingTimeout(Integer.parseInt("12000"));
+ sdcContextConfig.setConsumerGroup("consumerGroup");
+ sdcContextConfig.setEnvironmentName("environmentName");
+ sdcContextConfig.setKeyStorePassword("aegwhfef234e3dd111cdcd");
+
+ assertEquals("pomba", sdcContextConfig.getUser());
+ assertEquals("10.69.100.139", sdcContextConfig.getAsdcAddress());
+ assertEquals("pomba", sdcContextConfig.getPassword());
+ assertEquals("pomba", sdcContextConfig.getConsumerID());
+ assertEquals(12000, sdcContextConfig.getPollingTimeout());
+ assertEquals(false, sdcContextConfig.activateServerTLSAuth());
+ assertEquals(false, sdcContextConfig.isUseHttpsWithDmaap());
+ assertEquals("consumerGroup", sdcContextConfig.getConsumerGroup());
+ assertEquals("environmentName", sdcContextConfig.getEnvironmentName());
+ assertEquals("aegwhfef234e3dd111cdcd", sdcContextConfig.getKeyStorePassword());
+
+
+ }
+}
diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdc/test/ToscaBuildConfigTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdc/test/ToscaBuildConfigTest.java
new file mode 100644
index 0000000..8f16d5e
--- /dev/null
+++ b/src/test/java/org/onap/pomba/contextbuilder/sdc/test/ToscaBuildConfigTest.java
@@ -0,0 +1,45 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * 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.
+ * ============LICENSE_END=====================================================
+ */
+package org.onap.pomba.contextbuilder.sdc.test;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import org.onap.pomba.contextbuilder.sdc.ToscaBuilderConfig;
+
+public class ToscaBuildConfigTest {
+
+
+ @Test
+ public void testToscaBuilderConfig() throws Exception {
+
+ String urlTemplate = "/sdc/v1/catalog/services/e9851a43-c068-4eb2-9fe7-2d123bd94ff0/toscaModel";
+ ToscaBuilderConfig configTest= new ToscaBuilderConfig();
+ configTest.setCsarFilePrefix("csar-");
+ configTest.setCsarFileSuffix(".zip");
+ configTest.setArtifactType("TOSCA_CSAR");
+ configTest.setUrlTemplate(urlTemplate);
+
+
+ assertEquals(configTest.getCsarFilePrefix().toString(), "csar-");
+ assertEquals(configTest.getCsarFileSuffix().toString(), ".zip");
+ assertEquals(configTest.getArtifactType().toString(), "TOSCA_CSAR");
+ assertEquals(configTest.getUrlTemplate().toString(), urlTemplate);
+
+ }
+
+}
diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdc/unittest/service/SDCContextBuilderTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdc/unittest/service/SDCContextBuilderTest.java
new file mode 100644
index 0000000..e5e584f
--- /dev/null
+++ b/src/test/java/org/onap/pomba/contextbuilder/sdc/unittest/service/SDCContextBuilderTest.java
@@ -0,0 +1,142 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * 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.
+ * ============LICENSE_END=====================================================
+ */
+package org.onap.pomba.contextbuilder.sdc.unittest.service;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Paths;
+import java.util.Base64;
+import java.util.UUID;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.pomba.contextbuilder.sdc.model.SDCContextRequest;
+import org.onap.pomba.contextbuilder.sdc.model.SDCContextResponse;
+import org.onap.pomba.contextbuilder.sdc.service.SpringService;
+import org.onap.pomba.contextbuilder.sdc.service.rs.RestService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class })
+@WebAppConfiguration
+@SpringBootTest
+public class SDCContextBuilderTest {
+
+ static {
+ System.setProperty("test.tosca.csar.file", Paths.get(System.getProperty("user.dir"), "src/test/resources/toscaModel.csar.zip").toString());
+ }
+
+
+ @Autowired
+ private RestService service;
+ @Autowired
+ private SpringService springService;
+
+
+ private String authorization = "Basic " + Base64.getEncoder().encodeToString(("admin" + ":" + "admin").getBytes(StandardCharsets.UTF_8));
+ private String fromAppId = "POMBA";
+ private String transactionId = UUID.randomUUID().toString();
+ private String serviceInstanceId = "b06270ab-99e6-4a58-9bc0-db2df5c36f4d";
+ private String modelVersionId= "e9851a43-c068-4eb2-9fe7-2d123bd94ff0";
+ private String modelInvariantId = "4fd21763-23ed-4f69-8654-e121626df327" ;
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+
+ @Test
+ public void testNoAuthHeader() throws Exception {
+ Response response = this.service.getContext(null, fromAppId, transactionId, serviceInstanceId, modelVersionId, modelInvariantId);
+ assertEquals(Status.UNAUTHORIZED.getStatusCode(), response.getStatus());
+
+ }
+
+ @Test
+ public void testBadAuthoriztion() throws Exception {
+ String authorizationTest = "Basic " + Base64.getEncoder().encodeToString(("Test" + ":" + "Fake").getBytes(StandardCharsets.UTF_8));
+ Response response = this.service.getContext(authorizationTest, fromAppId, transactionId, serviceInstanceId, modelVersionId, modelInvariantId);
+ assertEquals(Status.UNAUTHORIZED.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testNullXFromAppId() throws Exception {
+ Response response = this.service.getContext(authorization, null, transactionId, serviceInstanceId, modelVersionId, modelInvariantId);
+ assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertTrue(((String)response.getEntity()).contains("X-FromAppId"));
+ }
+
+
+ @Test
+ public void testEmptyXFromAppId() throws Exception {
+ Response response = this.service.getContext(authorization, "", transactionId, serviceInstanceId, modelVersionId, modelInvariantId);
+ assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertTrue(((String)response.getEntity()).contains("X-FromAppId"));
+ }
+
+
+ @Test
+ public void testNullModelVersionId() throws Exception {
+ Response response = this.service.getContext(authorization, fromAppId, transactionId, serviceInstanceId, null, modelInvariantId);
+ assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertTrue(((String)response.getEntity()).contains("modelVersionId"));
+ }
+
+
+ @Test
+ public void testEmptyModelVersionId() throws Exception {
+ Response response = this.service.getContext(authorization, fromAppId, transactionId, serviceInstanceId, "", modelInvariantId);
+ assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertTrue(((String)response.getEntity()).contains("modelVersionId"));
+ }
+
+
+ @Test
+ public void testRestAPISuccess() throws Exception {
+ Response response = this.service.getContext(authorization, fromAppId, transactionId, serviceInstanceId, modelVersionId, modelInvariantId);
+ assertEquals(200, response.getStatus());
+ }
+
+
+ @Test
+ public void testSDCContextResponse() throws Exception {
+ SDCContextRequest request = new SDCContextRequest(null, authorization, fromAppId, transactionId,
+ serviceInstanceId, modelVersionId, modelInvariantId);
+ SDCContextResponse sdcResponse = springService.getModelData(request);
+ assertTrue(sdcResponse.getModelData().contains("service"));
+ assertTrue(sdcResponse.getModelData().contains("vf-list"));
+ }
+
+
+}
diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdc/unittest/service/SDCContextRestAPITest.java b/src/test/java/org/onap/pomba/contextbuilder/sdc/unittest/service/SDCContextRestAPITest.java
new file mode 100644
index 0000000..6f42584
--- /dev/null
+++ b/src/test/java/org/onap/pomba/contextbuilder/sdc/unittest/service/SDCContextRestAPITest.java
@@ -0,0 +1,90 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * 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.
+ * ============LICENSE_END=====================================================
+ */
+package org.onap.pomba.contextbuilder.sdc.unittest.service;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+import java.util.UUID;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.pomba.contextbuilder.sdc.exception.ToscaCsarException;
+import org.onap.pomba.contextbuilder.sdc.service.rs.RestService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class })
+@WebAppConfiguration
+@SpringBootTest
+@TestPropertySource(properties = {"sdcConnect.sdcAddress=localhost:30204"})
+public class SDCContextRestAPITest {
+
+ static {
+ System.setProperty("test.tosca.csar.file", "");
+ }
+
+ @Autowired
+ private RestService service;
+
+
+ private String authorization = "Basic " + Base64.getEncoder().encodeToString(("admin" + ":" + "admin").getBytes(StandardCharsets.UTF_8));
+ private String fromAppId = "POMBA";
+ private String transactionId = UUID.randomUUID().toString();
+ private String serviceInstanceId = "b06270ab-99e6-4a58-9bc0-db2df5c36f4d";
+ private String modelVersionId= "e9851a43-c068-4eb2-9fe7-2d123bd94ff0";
+ private String modelInvariantId = "4fd21763-23ed-4f69-8654-e121626df327" ;
+
+ @Before
+ public void setUp() throws Exception {
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ /**
+ * Call to SDC to download the Tosca Csar file
+ *
+ */
+ @Test
+ public void testVerifyAPI() throws Exception {
+ //TODO we need mock the localhost as SDC to return success. For now, assume it failed to reach the SDC
+ try {
+ this.service.getContext(authorization, fromAppId, transactionId, serviceInstanceId, modelVersionId, modelInvariantId);
+ }catch (ToscaCsarException x) {
+ fail("Failed to retrieve CSAR artifact from SDC");
+ }
+
+ }
+
+
+}
diff --git a/src/test/resources/toscaModel.csar.zip b/src/test/resources/toscaModel.csar.zip
new file mode 100644
index 0000000..66f818c
--- /dev/null
+++ b/src/test/resources/toscaModel.csar.zip
Binary files differ