summaryrefslogtreecommitdiffstats
path: root/adapters/mso-catalog-db-adapter/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-catalog-db-adapter/src/test')
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java9
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java42
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml6
3 files changed, 52 insertions, 5 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java
index bf69686a76..e38bd02069 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java
@@ -29,6 +29,15 @@ public class CatalogDbClientPortChanger extends CatalogDbClient {
public String wiremockPort;
+ CatalogDbClientPortChanger(){
+
+ }
+
+ CatalogDbClientPortChanger(String baseUri, String auth, String wiremockPort) {
+ super(baseUri, auth);
+ this.wiremockPort = wiremockPort;
+ }
+
protected URI getUri(String template) {
URI uri = URI.create(template);
String path = uri.getPath();
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
index 3783a51689..5c7b64d054 100644
--- 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
@@ -26,10 +26,13 @@ import org.junit.Ignore;
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.CloudIdentity;
import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.CloudifyManager;
import org.onap.so.db.catalog.beans.InstanceGroup;
import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
+import org.onap.so.db.catalog.beans.ServerType;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceRecipe;
import org.onap.so.db.catalog.beans.VfModule;
@@ -40,11 +43,13 @@ import org.onap.so.db.catalog.beans.VnfResource;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus;
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.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
+import java.net.URI;
import java.util.List;
import java.util.UUID;
@@ -55,12 +60,16 @@ public class CatalogDbClientTest {
public static final String MTN13 = "mtn13";
@LocalServerPort
private int port;
+
+ @Value("${mso.db.auth}")
+ private String msoAdaptersAuth;
+
@Autowired
CatalogDbClientPortChanger client;
@Before
- public void initialize() {
- client.wiremockPort = String.valueOf(port);
+ public void initialize(){
+ client.wiremockPort= String.valueOf(port);
}
@Test
@@ -376,4 +385,33 @@ public class CatalogDbClientTest {
VfModule module = moduleList.get(0);
Assert.assertEquals("vSAMP10a DEV Base",module.getDescription());
}
+
+ @Test
+ public void testPostCloudSite() {
+ CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger("http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
+ CloudSite cloudSite = new CloudSite();
+ cloudSite.setId("MTN6");
+ cloudSite.setClli("TESTCLLI");
+ cloudSite.setRegionId("regionId");
+ cloudSite.setCloudVersion("VERSION");
+ cloudSite.setPlatform("PLATFORM");
+
+ CloudIdentity cloudIdentity = new CloudIdentity();
+ cloudIdentity.setId("RANDOMID");
+ cloudIdentity.setIdentityUrl("URL");
+ cloudIdentity.setMsoId("MSO_ID");
+ cloudIdentity.setMsoPass("MSO_PASS");
+ cloudIdentity.setAdminTenant("ADMIN_TENANT");
+ cloudIdentity.setMemberRole("ROLE");
+ cloudIdentity.setIdentityServerType(ServerType.KEYSTONE);
+ cloudIdentity.setIdentityAuthenticationType(AuthenticationType.RACKSPACE_APIKEY);
+ cloudSite.setIdentityService(cloudIdentity);
+ localClient.postCloudSite(cloudSite);
+ CloudSite getCloudSite = this.client.getCloudSite("MTN6");
+ Assert.assertNotNull(getCloudSite);
+ Assert.assertNotNull(getCloudSite.getIdentityService());
+ Assert.assertEquals("TESTCLLI", getCloudSite.getClli());
+ Assert.assertEquals("regionId", getCloudSite.getRegionId());
+ Assert.assertEquals("RANDOMID", getCloudSite.getIdentityServiceId());
+ }
}
diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml b/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml
index a1e62f5e85..a59ea0ef65 100644
--- a/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml
+++ b/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml
@@ -1,5 +1,5 @@
# TEST FILE
-catalog.db.endpoint: "http://localhost:"
+catalog.db.endpoint: http://localhost:${wiremock.server.port}
ssl-enable: false
mso:
@@ -8,7 +8,7 @@ mso:
catalog:
db:
spring:
- endpoint: "http://localhost:"
+ endpoint: http://localhost:${wiremock.server.port}
db:
auth: Basic YnBlbDptc28tZGItMTUwNyE=
@@ -50,7 +50,7 @@ mariaDB4j:
databaseName: catalogdb
server:
- port: 8080
+ port: ${wiremock.server.port}
tomcat:
max-threads: 50