aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-catalog-db-adapter/src/test/java
diff options
context:
space:
mode:
authorRob Daugherty <rd472p@att.com>2018-08-23 14:18:28 +0000
committerGerrit Code Review <gerrit@onap.org>2018-08-23 14:18:28 +0000
commit192001c6494494aec9874d1346802b004cdc9c0e (patch)
tree8f5bb3fac45ba2db9c513e0278eac6a01afaa426 /adapters/mso-catalog-db-adapter/src/test/java
parentc6e91a4ee3d1a699a41fa2e3107cc236a7704965 (diff)
parent1dce2e1792763171edad8a5a2afbb0321c189cc7 (diff)
Merge "Changed RequestFactory for Catalog DB client"
Diffstat (limited to 'adapters/mso-catalog-db-adapter/src/test/java')
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java23
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java78
2 files changed, 78 insertions, 23 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java
index 9ed61b33a3..0606848b04 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java
@@ -21,33 +21,16 @@
package org.onap.so.adapters.catalogdb.catalogrest;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import java.net.URI;
-import java.util.List;
-
import javax.transaction.Transactional;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.adapters.catalogdb.CatalogDBApplication;
import org.onap.so.db.catalog.beans.AuthenticationType;
-import org.onap.so.db.catalog.beans.BuildingBlockDetail;
import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.db.catalog.beans.CloudSite;
-import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
-import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
-import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
-import org.onap.so.db.catalog.beans.InstanceGroup;
-import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
import org.onap.so.db.catalog.beans.ServerType;
-import org.onap.so.db.catalog.client.CatalogDbClient;
-import org.onap.so.logger.MsoLogger;
-import org.onap.so.logging.jaxrs.filter.jersey.SpringClientFilter;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
@@ -55,15 +38,9 @@ import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
-import org.springframework.http.client.BufferingClientHttpRequestFactory;
-import org.springframework.http.client.ClientHttpRequestFactory;
-import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.util.UriComponentsBuilder;
-import uk.co.blackpepper.bowman.Client;
-import uk.co.blackpepper.bowman.ClientFactory;
-import uk.co.blackpepper.bowman.Configuration;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
new file mode 100644
index 0000000000..f75adc62c0
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
@@ -0,0 +1,78 @@
+package org.onap.so.db.catalog.client;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.adapters.catalogdb.CatalogDBApplication;
+import org.onap.so.db.catalog.beans.CloudIdentity;
+import org.onap.so.db.catalog.beans.CloudSite;
+import org.onap.so.db.catalog.beans.CloudifyManager;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.UUID;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+public class CatalogDbClientTest {
+ public static final String MTN13 = "mtn13";
+ @LocalServerPort
+ private int port;
+ @Autowired
+ CatalogDbClient client;
+
+ @Before
+ public void setPort() {
+ client.removePortFromEndpoint();
+ client.setPortToEndpoint(Integer.toString(port));
+ }
+
+ @Test
+ public void testGetCloudSiteHappyPath() throws Exception {
+ CloudSite cloudSite = client.getCloudSite(MTN13);
+ Assert.assertNotNull(cloudSite);
+ Assert.assertNotNull(cloudSite.getIdentityService());
+ Assert.assertEquals("MDT13", cloudSite.getClli());
+ Assert.assertEquals("mtn13", cloudSite.getRegionId());
+ Assert.assertEquals("MTN13", cloudSite.getIdentityServiceId());
+ }
+
+ @Test
+ public void testGetCloudSiteNotFound() throws Exception {
+ CloudSite cloudSite = client.getCloudSite(UUID.randomUUID().toString());
+ Assert.assertNull(cloudSite);
+ }
+
+ @Test
+ public void testGetCloudifyManagerHappyPath() throws Exception {
+ CloudifyManager cloudifyManager = client.getCloudifyManager("mtn13");
+ Assert.assertNotNull(cloudifyManager);
+ Assert.assertEquals("http://localhost:28090/v2.0", cloudifyManager.getCloudifyUrl());
+
+ }
+
+ @Test
+ public void testGetCloudifyManagerNotFound() throws Exception {
+ CloudifyManager cloudifyManager = client.getCloudifyManager(UUID.randomUUID().toString());
+ Assert.assertNull(cloudifyManager);
+ }
+
+
+
+ @Test
+ public void testGetCloudSiteByClliAndAicVersionHappyPath() throws Exception{
+ CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13","2.5");
+ Assert.assertNotNull(cloudSite);
+ }
+
+ @Test
+ public void testGetCloudSiteByClliAndAicVersionNotFound() throws Exception{
+ CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13","232496239746328");
+ Assert.assertNull(cloudSite);
+ }
+}