diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-08-23 08:55:54 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-08-23 08:58:09 -0400 |
commit | 1dce2e1792763171edad8a5a2afbb0321c189cc7 (patch) | |
tree | 5c42972aa18faf6dfb2b97e297d4accf429d4fb6 /adapters/mso-catalog-db-adapter/src/test/java/org/onap | |
parent | bb6310f30287b352ad941ecc97aeb278a327d595 (diff) |
Changed RequestFactory for Catalog DB client
- Missed some files, the repository isn't required now that we
dont fetch the identity service directly
- Fixing review comments and removing the unused import
- Fixing the build :) Now that cloudSite has a 1-1 relationship with
cloudidentity, there shouldn't be a need to query the identity on its
own unless the site is missing Refactored some code to use site to
fetch identity as a composition
- Changing the catalogDb client to use
HttpComponentsClientHttpRequestFactory instead of
SimpleClientHttpRequestFactory, the later would lead to a IOException
(FileNotFoundException specifically) whenever a 40X type of a response
code is returned from the spring rest endpoint. Adding some tests for
the catalogDbClient which earlier got missed in handover. Also fixing
another issue with cloudSite repository which was not fetching data
correctly. Fixed a repository which was added initially but later the
same went missing (Not sure how)
Change-Id: I72506865c4c5f7fd07a6031c146a4aba1a96c2c8
Issue-ID: SO-892
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'adapters/mso-catalog-db-adapter/src/test/java/org/onap')
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); + } +} |