aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso')
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java380
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java490
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestTest.java103
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionTest.java55
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java155
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java67
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java74
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceCsarTest.java75
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java74
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java72
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java73
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModuleTest.java96
12 files changed, 0 insertions, 1714 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java
deleted file mode 100644
index 31594905fd..0000000000
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.openecomp.mso.adapters.catalogdb;
-
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.http.HttpStatus;
-import javax.json.*;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.openecomp.mso.adapters.catalogdb.CatalogDbAdapterRest;
-import org.openecomp.mso.adapters.catalogdb.catalogrest.CatalogQueryException;
-import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceVnfs;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.junit.Before;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.when;
-import static org.powermock.api.mockito.PowerMockito.mockStatic;
-import static org.powermock.api.mockito.PowerMockito.verifyStatic;
-import static org.hamcrest.CoreMatchers.instanceOf;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({CatalogDbAdapterRest.class, CatalogDatabase.class})
-public class CatalogDbAdapterRestClassTest {
- @Mock
- private static CatalogDatabase dbMock;
-
- private static List<VnfResourceCustomization> paramList;
-
- @Before
- public void prepare () {
- /*
- * 1. for non routing related methods/classes, use mockito
- * 2. for routing methods, use TJWSEmbeddedJaxrsServer
- */
-
- /*
- * in the setup portion, create a mock db object
- *
- */
- // set up mock return value
- paramList = new ArrayList<>();
- VnfResourceCustomization d1 = new VnfResourceCustomization();
- d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
- d1.setModelInstanceName("ciVFOnboarded-FNAT-aab06c41 1");
- paramList.add(d1);
- // end
-
- PowerMockito.mockStatic(CatalogDatabase.class);
- dbMock = PowerMockito.mock(CatalogDatabase.class);
- PowerMockito.when(CatalogDatabase.getInstance()).thenReturn(dbMock);
- try {
-
- PowerMockito.whenNew(CatalogDatabase.class).withAnyArguments().thenReturn(dbMock);
- PowerMockito.spy (dbMock);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void respond_Test(){
- QueryServiceVnfs qryResp = new QueryServiceVnfs(paramList);
- CatalogDbAdapterRest adapter = new CatalogDbAdapterRest();
- CatalogDbAdapterRest spyAdapter = Mockito.spy(adapter);
-
- Response resp = spyAdapter.respond("v1", HttpStatus.SC_OK, false, qryResp);
- Mockito.verify(spyAdapter,Mockito.times(1)).respond("v1", HttpStatus.SC_OK, false, qryResp);
-
- String s = resp.getEntity().toString();
- // System.out.println(s);
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- // end
- JsonArray jArray = respObj.getJsonArray("serviceVnfs");
-
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- assertEquals(jArray.size(), 1);
- assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
- }
-
-
- @Test
- public void serviceVnfsImpl_vnfUuid_ver_Test()
- {
- PowerMockito.when(dbMock.getAllVnfsByVnfModelCustomizationUuid(Mockito.anyString())).thenReturn (paramList);
-
- try {
- CatalogDbAdapterRest adapter = new CatalogDbAdapterRest();
-
- // Run
- Response resp = adapter.serviceVnfsImpl("v1", true, "16ea3e56-a8ce-4ad7-8edd-4d2eae095391", null, null, null, null);
- String s = resp.getEntity().toString();
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- // end
- JsonArray jArray = respObj.getJsonArray("serviceVnfs");
-
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- assertEquals(jArray.size(), 1);
- assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
- //
- Mockito.verify(dbMock, Mockito.times(1)).getAllVnfsByVnfModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void serviceVnfsImpl_smiUuid_NoVer_Test()
- {
- PowerMockito.when(dbMock.getAllVnfsByServiceModelInvariantUuid(Mockito.anyString())).thenReturn (paramList);
-
- try {
- CatalogDbAdapterRest adapter = new CatalogDbAdapterRest();
-
- // Run
- Response resp = adapter.serviceVnfsImpl("v1", true, null, null, "16ea3e56-a8ce-4ad7-8edd-4d2eae095391", null, null);
- String s = resp.getEntity().toString();
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- // end
- JsonArray jArray = respObj.getJsonArray("serviceVnfs");
-
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- assertEquals(jArray.size(), 1);
- assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
- Mockito.verify(dbMock, Mockito.times(1)).getAllVnfsByServiceModelInvariantUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void serviceVnfsImpl_smUuid_ver_Test()
- {
- PowerMockito.when(dbMock.getAllVnfsByServiceModelUuid(Mockito.anyString())).thenReturn (paramList);
-
- try {
- CatalogDbAdapterRest adapter = new CatalogDbAdapterRest();
-
- // Run
- Response resp = adapter.serviceVnfsImpl("v1", true, null,"16ea3e56-a8ce-4ad7-8edd-4d2eae095391", null, null, null);
- String s = resp.getEntity().toString();
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- // end
- JsonArray jArray = respObj.getJsonArray("serviceVnfs");
-
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- assertEquals(jArray.size(), 1);
- assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
- Mockito.verify(dbMock, Mockito.times(1)).getAllVnfsByServiceModelUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void serviceVnfsImpl_smiUuid_ver_Test()
- {
- PowerMockito.when(dbMock.getAllVnfsByServiceModelInvariantUuid(Mockito.anyString(),Mockito.anyString())).thenReturn (paramList);
-
- try {
- CatalogDbAdapterRest adapter = new CatalogDbAdapterRest();
-
- // Run
- Response resp = adapter.serviceVnfsImpl("v1", true, null, null, "16ea3e56-a8ce-4ad7-8edd-4d2eae095391", "v1", null);
- String s = resp.getEntity().toString();
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- JsonArray jArray = respObj.getJsonArray("serviceVnfs");
- // end
-
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- assertEquals(jArray.size(), 1);
- assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
- Mockito.verify(dbMock, Mockito.times(1)).getAllVnfsByServiceModelInvariantUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391","v1");
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void serviceVnfsImpl_smName_ver_Test()
- {
- PowerMockito.when(dbMock.getAllVnfsByServiceName(Mockito.anyString(),Mockito.anyString())).thenReturn (paramList);
-
- try {
- CatalogDbAdapterRest adapter = new CatalogDbAdapterRest();
-
- // Run
- Response resp = adapter.serviceVnfsImpl("v1", true, null, null, null, "v1", "16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
- String s = resp.getEntity().toString();
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- // end
- JsonArray jArray = respObj.getJsonArray("serviceVnfs");
-
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- assertEquals(jArray.size(), 1);
- assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
- Mockito.verify(dbMock, Mockito.times(1)).getAllVnfsByServiceName("16ea3e56-a8ce-4ad7-8edd-4d2eae095391","v1");
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void serviceVnfsImpl_smName_NoVer_Test()
- {
- PowerMockito.when(dbMock.getAllVnfsByServiceName(Mockito.anyString())).thenReturn (paramList);
-
- try {
- CatalogDbAdapterRest adapter = new CatalogDbAdapterRest();
-
- // Run
- Response resp = adapter.serviceVnfsImpl("v1", true, null, null, null, null, "16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
- String s = resp.getEntity().toString();
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- // end
- JsonArray jArray = respObj.getJsonArray("serviceVnfs");
-
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- assertEquals(jArray.size(), 1);
- assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
- Mockito.verify(dbMock, Mockito.times(1)).getAllVnfsByServiceName("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void serviceVnfsImpl_Exception_Test()
- {
- PowerMockito.when(dbMock.getAllVnfsByServiceName(Mockito.anyString())).thenReturn (null);
-
- try {
- CatalogDbAdapterRest adapter = new CatalogDbAdapterRest();
-
- // Run
- Response resp = adapter.serviceVnfsImpl("v1", true, null, null, null, null, null);
-
- assertEquals(resp.getStatus(), HttpStatus.SC_INTERNAL_SERVER_ERROR);
- assertThat(resp.getEntity(), instanceOf(CatalogQueryException.class));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void serviceNetworksImpl_nUuid_ver_Test(){
- CatalogDbAdapterRest adapter = new CatalogDbAdapterRest();
- CatalogDbAdapterRest spyAdapter = Mockito.spy(adapter);
-
- Response resp = Response
- .status(HttpStatus.SC_OK)
- .entity("{\"serviceVnfs\":[{\"version\":\"v1\",\"modelCustomizationUuid\":\"16ea3e56-a8ce-4ad7-8edd-4d2eae095391\",\"modelInstanceName\":\"ciVFOnboarded-FNAT-aab06c41 1\",\"created\":null,\"vnfResourceModelUuid\":null,\"vnfResourceModelUUID\":null,\"minInstances\":null,\"maxInstances\":null,\"availabilityZoneMaxCount\":null,\"vnfResource\":null,\"nfFunction\":null,\"nfType\":null,\"nfRole\":null,\"nfNamingCode\":null,\"multiStageDesign\":null,\"vfModuleCustomizations\":null,\"serviceResourceCustomizations\":null,\"creationTimestamp\":null}]}")
- .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .build();
-
- Mockito.doReturn(resp).when(spyAdapter).serviceNetworksImpl(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
-
- // Run
-
- Response ret = spyAdapter.serviceNetworksImpl("v1", false, "16ea3e56-a8ce-4ad7-8edd-4d2eae095391",null, null, null, null);
- Mockito.verify(spyAdapter).serviceNetworksImpl("v1", false, "16ea3e56-a8ce-4ad7-8edd-4d2eae095391", null, null, null, null);
-
- assertTrue(ret.getStatus() == HttpStatus.SC_OK);
- String s = resp.getEntity().toString();
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- // end
- JsonArray jArray = respObj.getJsonArray("serviceVnfs");
-
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- assertEquals(jArray.size(), 1);
- assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
-
- }
-
- @Test
- public void serviceAllottedResourcesImpl_Test()
- {
- CatalogDbAdapterRest adapter = new CatalogDbAdapterRest();
- CatalogDbAdapterRest spyAdapter = Mockito.spy(adapter);
-
- Response resp = Response
- .status(HttpStatus.SC_OK)
- .entity("{\"serviceVnfs\":[{\"version\":\"v1\",\"modelCustomizationUuid\":\"16ea3e56-a8ce-4ad7-8edd-4d2eae095391\",\"modelInstanceName\":\"ciVFOnboarded-FNAT-aab06c41 1\",\"created\":null,\"vnfResourceModelUuid\":null,\"vnfResourceModelUUID\":null,\"minInstances\":null,\"maxInstances\":null,\"availabilityZoneMaxCount\":null,\"vnfResource\":null,\"nfFunction\":null,\"nfType\":null,\"nfRole\":null,\"nfNamingCode\":null,\"multiStageDesign\":null,\"vfModuleCustomizations\":null,\"serviceResourceCustomizations\":null,\"creationTimestamp\":null}]}")
- .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .build();
-
- Mockito.doReturn(resp).when(spyAdapter).serviceAllottedResourcesImpl(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
-
- // Run
-
- Response ret = spyAdapter.serviceAllottedResourcesImpl("v1", false, "16ea3e56-a8ce-4ad7-8edd-4d2eae095391",null, null, null);
- Mockito.verify(spyAdapter).serviceAllottedResourcesImpl("v1", false, "16ea3e56-a8ce-4ad7-8edd-4d2eae095391", null, null, null);
-
- assertTrue(ret.getStatus() == HttpStatus.SC_OK);
- String s = resp.getEntity().toString();
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- // end
- JsonArray jArray = respObj.getJsonArray("serviceVnfs");
-
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- assertEquals(jArray.size(), 1);
- assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
-
- }
-
-}
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java
deleted file mode 100644
index ae5e663777..0000000000
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java
+++ /dev/null
@@ -1,490 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.openecomp.mso.adapters.catalogdb;
-
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.jboss.resteasy.plugins.server.tjws.TJWSEmbeddedJaxrsServer;
-import static org.junit.Assert.*;
-
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.resteasy.spi.Registry;
-import org.jboss.resteasy.spi.ResteasyProviderFactory;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.openecomp.mso.adapters.catalogdb.CatalogDbAdapterRest;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder;
-import org.openecomp.mso.db.catalog.beans.VfModule;
-import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
-import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PowerMockIgnore;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.apache.http.HttpStatus;
-import org.jboss.resteasy.client.jaxrs.ResteasyClient;
-import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
-import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({CatalogDatabase.class})
-@PowerMockIgnore("javax.net.ssl.*")
-public class CatalogDbAdapterRestHttpTest {
- @Mock
- private static CatalogDatabase dbMock;
- private static TJWSEmbeddedJaxrsServer server;
- private static final int PORT = 3099;
- private static Registry registry;
- private static ResteasyProviderFactory factory;
-
- @BeforeClass
- public static void beforeClass() throws Exception {
- server = new TJWSEmbeddedJaxrsServer();
- server.setPort(PORT);
- server.start();
- registry = server.getDeployment().getRegistry();
- factory = server.getDeployment().getDispatcher().getProviderFactory();
- registry.addPerRequestResource(CatalogDbAdapterRest.class);
- factory.registerProvider(CatalogDbAdapterRest.class);
- }
-
- @Before
- public void before(){
- PowerMockito.mockStatic(CatalogDatabase.class);
- dbMock = PowerMockito.mock(CatalogDatabase.class);
- PowerMockito.when(CatalogDatabase.getInstance()).thenReturn(dbMock);
-
- try {
- PowerMockito.whenNew(CatalogDatabase.class).withAnyArguments().thenReturn(dbMock);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void healthCheck_Test(){
- ResteasyClient client = new ResteasyClientBuilder().build();
- ResteasyWebTarget target = client.target("http://localhost:3099/v1/healthcheck");
- Response response = target.request().get();
- String value = response.readEntity(String.class);
- assertTrue(value.contains("Application v1 ready"));
- }
-
- @Test
- public void vnfResourcesUrl_Test()
- {
- try {
- List<VnfResourceCustomization> paramList;
- // set up mock return value
- paramList = new ArrayList<>();
- VnfResourceCustomization d1 = new VnfResourceCustomization();
- d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
- d1.setModelInstanceName("RG_6-26_mog11 0");
- d1.setVersion("v1");
- paramList.add(d1);
- PowerMockito.when(dbMock.getAllVnfsByVnfModelCustomizationUuid(Mockito.anyString())).thenReturn (paramList);
- // end
-
- // Run
- ResteasyClient client = new ResteasyClientBuilder().build();
- ResteasyWebTarget target = client.target("http://localhost:3099/v1/vnfResources/16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
- Response response = target.request().get();
- String value = response.readEntity(String.class);
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(value.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- JsonArray jArray = respObj.getJsonArray("serviceVnfs");
- assertTrue(jArray.size() == 1);
- if(jArray.size() == 1){
- JsonObject rec = jArray.getJsonObject(0);
- String version = rec.getString("version");
- String uuid = rec.getString("modelCustomizationUuid");
-
- assertTrue(version.equals("v1"));
- assertTrue(uuid.equals("16ea3e56-a8ce-4ad7-8edd-4d2eae095391"));
- }
- // end
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void serviceVnfsUrl_smiUuid_smVer_Test(){
- try {
- List<VnfResourceCustomization> paramList;
- // set up mock return value
- paramList = new ArrayList<>();
- VnfResourceCustomization d1 = new VnfResourceCustomization();
- d1.setVnfResourceModelUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
- d1.setModelInstanceName("RG_6-26_mog11 0");
- d1.setVersion("v1");
- d1.setMaxInstances(50);
- paramList.add(d1);
- PowerMockito.when(dbMock.getAllVnfsByServiceModelInvariantUuid(Mockito.anyString(),Mockito.anyString())).thenReturn (paramList);
- // end
-
- // Run
- ResteasyClient client = new ResteasyClientBuilder().build();
- ResteasyWebTarget target = client.target("http://localhost:3099/v1/serviceVnfs?serviceModelInvariantUuid=16ea3e56-a8ce-4ad7-8edd-4d2eae095391&serviceModelVersion=ver1");
- Response response = target.request().get();
- String value = response.readEntity(String.class);
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(value.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- JsonArray jArray = respObj.getJsonArray("serviceVnfs");
- assertTrue(jArray.size() == 1);
- if(jArray.size() == 1){
- JsonObject rec = jArray.getJsonObject(0);
- String version = rec.getString("version");
- String uuid = rec.getString("vnfResourceModelUuid");
- int maxInstance = rec.getInt("maxInstances");
-
- assertTrue(version.equals("v1"));
- assertTrue(uuid.equals("16ea3e56-a8ce-4ad7-8edd-4d2eae095391"));
- assertTrue(maxInstance == 50);
- }
- // end
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void serviceVnfsUrl_vnfUuid_Test(){
- try {
- List<VnfResourceCustomization> paramList;
- // set up mock return value
- paramList = new ArrayList<>();
- VnfResourceCustomization d1 = new VnfResourceCustomization();
- d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
- d1.setModelInstanceName("RG_6-26_mog11 0");
- d1.setVersion("v1");
- paramList.add(d1);
- PowerMockito.when(dbMock.getAllVnfsByVnfModelCustomizationUuid(Mockito.anyString())).thenReturn (paramList);
- // end
-
- // Run
- ResteasyClient client = new ResteasyClientBuilder().build();
- ResteasyWebTarget target = client.target("http://localhost:3099/v1/serviceVnfs?vnfModelCustomizationUuid=16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
- Response response = target.request().get();
- String value = response.readEntity(String.class);
-
- // System.out.println(value);
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(value.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- JsonArray jArray = respObj.getJsonArray("serviceVnfs");
- assertTrue(jArray.size() == 1);
- if(jArray.size() == 1){
- JsonObject rec = jArray.getJsonObject(0);
- String version = rec.getString("version");
- String uuid = rec.getString("modelCustomizationUuid");
-
- assertTrue(version.equals("v1"));
- assertTrue(uuid.equals("16ea3e56-a8ce-4ad7-8edd-4d2eae095391"));
- }
- // end
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void networkResourcesUrl_nUuid_Ver_Test(){
- try {
- List<NetworkResourceCustomization> paramList;
- // set up mock return value
- paramList = new ArrayList<>();
- NetworkResourceCustomization d1 = new NetworkResourceCustomization();
- d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
- paramList.add(d1);
- PowerMockito.when(dbMock.getAllNetworksByNetworkModelCustomizationUuid(Mockito.anyString())).thenReturn (paramList);
- // end
-
- // Run
- ResteasyClient client = new ResteasyClientBuilder().build();
- ResteasyWebTarget target = client.target("http://localhost:3099/v1/networkResources/0cb9b26a-9820-48a7-86e5-16c510e993d9");
- Response response = target.request().get();
- String value = response.readEntity(String.class);
-
- // System.out.println(value);
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(value.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- JsonArray jArray = respObj.getJsonArray("serviceNetworks");
- assertTrue(jArray.size() == 1);
- if(jArray.size() == 1){
- JsonObject rec = jArray.getJsonObject(0);
- String uuid = rec.getString("networkResourceModelUuid");
-
- assertTrue(uuid.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9"));
- }
- // end
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void serviceNetworksUrl_nType_Test(){
- try {
- List<NetworkResourceCustomization> paramList;
- // set up mock return value
- paramList = new ArrayList<>();
- NetworkResourceCustomization d1 = new NetworkResourceCustomization();
- d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
- paramList.add(d1);
- PowerMockito.when(dbMock.getAllNetworksByNetworkType(Mockito.anyString())).thenReturn (paramList);
- // end
-
- // Run
- ResteasyClient client = new ResteasyClientBuilder().build();
- ResteasyWebTarget target = client.target("http://localhost:3099/v1/serviceNetworks?networkModelName=0cb9b26a-9820-48a7-86e5-16c510e993d9");
- Response response = target.request().get();
- String value = response.readEntity(String.class);
-
- // System.out.println(value);
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(value.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- JsonArray jArray = respObj.getJsonArray("serviceNetworks");
- assertTrue(jArray.size() == 1);
- if(jArray.size() == 1){
- JsonObject rec = jArray.getJsonObject(0);
- String uuid = rec.getString("networkResourceModelUuid");
-
- assertTrue(uuid.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9"));
- }
- // end
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void serviceResourcesUrl_smiUuid_Ver_Test(){
- try {
- ArrayList<NetworkResourceCustomization> paramList;
- // set up mock return value
- paramList = new ArrayList<>();
- NetworkResourceCustomization d1 = new NetworkResourceCustomization();
- d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
- paramList.add(d1);
- ServiceMacroHolder ret = new ServiceMacroHolder();
- ret.setNetworkResourceCustomization(paramList);
- PowerMockito.when(dbMock.getAllResourcesByServiceModelInvariantUuid(Mockito.anyString(),Mockito.anyString())).thenReturn (ret);
- // end
-
- // Run
- ResteasyClient client = new ResteasyClientBuilder().build();
- ResteasyWebTarget target = client.target("http://localhost:3099/v1/serviceResources?serviceModelInvariantUuid=0cb9b26a-9820-48a7-86e5-16c510e993d9&serviceModelVersion=ver1");
- Response response = target.request().get();
- String value = response.readEntity(String.class);
-
- // System.out.println(value);
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(value.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- JsonObject obj = respObj.getJsonObject("serviceResources");
- JsonArray jArray = obj.getJsonArray("networkResourceCustomization");
- assertTrue(jArray.size() == 1);
-
- if(jArray.size() == 1){
- JsonObject rec = jArray.getJsonObject(0);
- String uuid = rec.getString("networkResourceModelUuid");
-
- assertTrue(uuid.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9"));
- }
- // end
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void allottedResourcesUrl_aUuid_Test()
- {
- try {
- List<AllottedResourceCustomization> paramList;
- // set up mock return value
- paramList = new ArrayList<>();
- AllottedResourceCustomization d1 = new AllottedResourceCustomization();
- d1.setArModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
- paramList.add(d1);
- PowerMockito.when(dbMock.getAllAllottedResourcesByArModelCustomizationUuid(Mockito.anyString())).thenReturn (paramList);
- // end
-
- // Run
- ResteasyClient client = new ResteasyClientBuilder().build();
- ResteasyWebTarget target = client.target("http://localhost:3099/v1/allottedResources/0cb9b26a-9820-48a7-86e5-16c510e993d9");
- Response response = target.request().get();
- String value = response.readEntity(String.class);
-
- // System.out.println(value);
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(value.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- JsonArray jArray = respObj.getJsonArray("serviceAllottedResources");
- assertTrue(jArray.size() == 1);
- if(jArray.size() == 1){
- JsonObject rec = jArray.getJsonObject(0);
- String uuid = rec.getString("arModelUuid");
-
- assertTrue(uuid.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9"));
- }
- // end
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
-
- }
-
- @Test
- public void serviceAllottedResourcesUrl_smiUuid_Test()
- {
- try {
- List<AllottedResourceCustomization> paramList;
- // set up mock return value
- paramList = new ArrayList<>();
- AllottedResourceCustomization d1 = new AllottedResourceCustomization();
- d1.setArModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
- paramList.add(d1);
- PowerMockito.when(dbMock.getAllAllottedResourcesByServiceModelInvariantUuid(Mockito.anyString(), Mockito.anyString())).thenReturn (paramList);
- // end
-
- // Run
- ResteasyClient client = new ResteasyClientBuilder().build();
- ResteasyWebTarget target = client.target("http://localhost:3099/v1/serviceAllottedResources?serviceModelInvariantUuid=0cb9b26a-9820-48a7-86e5-16c510e993d9&serviceModelVersion=ver1");
- Response response = target.request().get();
- String value = response.readEntity(String.class);
-
- // System.out.println(value);
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(value.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- JsonArray jArray = respObj.getJsonArray("serviceAllottedResources");
- assertTrue(jArray.size() == 1);
- if(jArray.size() == 1){
- JsonObject rec = jArray.getJsonObject(0);
- String uuid = rec.getString("arModelUuid");
-
- assertTrue(uuid.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9"));
- }
- // end
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void vfModulesUrl_modelName_Test()
- {
- try {
- // set up mock return value
- VfModule vfm = new VfModule();
- vfm.setModelName("test Model");
- vfm.setModelUUID("0cb9b26a-9820-48a7-86e5-16c510e993d9");
-
- VfModuleCustomization ret = new VfModuleCustomization();
- ret.setVfModule(vfm);
- PowerMockito.when(dbMock.getVfModuleCustomizationByModelName(Mockito.anyString())).thenReturn (ret);
- // end
-
- // Run
- ResteasyClient client = new ResteasyClientBuilder().build();
- ResteasyWebTarget target = client.target("http://localhost:3099/v1/vfModules?vfModuleModelName=0cb9b26a-9820-48a7-86e5-16c510e993d9");
- Response response = target.request().get();
- String value = response.readEntity(String.class);
-
- // System.out.println(value);
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(value.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- JsonObject jObj = respObj.getJsonObject("modelInfo");
- String uuid = jObj.getString("modelUuid");
- String name = jObj.getString("modelName");
- assertTrue(uuid.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9"));
- assertTrue(name.equals("test Model"));
- // end
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @AfterClass
- public static void afterClass() throws Exception {
- server.stop();
- }
-}
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestTest.java
deleted file mode 100644
index 2e22e97a81..0000000000
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.openecomp.mso.adapters.catalogdb;
-
-import org.junit.Test;
-
-public class CatalogDbAdapterRestTest {
-
- CatalogDbAdapterRest catalogDbAdapterRest = new CatalogDbAdapterRest();
-
- @Test(expected = NullPointerException.class)
- public void respond() throws Exception {
- catalogDbAdapterRest.respond(null, 0, true, null);
- }
-
- @Test
- public void healthcheck() throws Exception {
- catalogDbAdapterRest.healthcheck("test");
- }
-
- @Test
- public void serviceVnfs() throws Exception {
- catalogDbAdapterRest.serviceVnfs("test", "test");
- }
-
- @Test
- public void serviceVnfs1() throws Exception {
- catalogDbAdapterRest.serviceVnfs("test", "test", "test", "test", "test", "test");
- }
-
- @Test
- public void serviceVnfsImpl() throws Exception {
- catalogDbAdapterRest.serviceVnfsImpl("test", false, "test", "test", "test", "test", "test");
- }
-
- @Test
- public void serviceNetworks() throws Exception {
- catalogDbAdapterRest.serviceNetworks("test", "test");
- }
-
- @Test
- public void serviceNetworks1() throws Exception {
- catalogDbAdapterRest.serviceNetworks("test", "test", "test", "test", "test", "test", "test", "test");
- }
-
- @Test
- public void serviceNetworksImpl() throws Exception {
- catalogDbAdapterRest.serviceNetworksImpl("test", false, "test", "test", "test", "test", "test");
- }
-
- @Test
- public void serviceResources() throws Exception {
- catalogDbAdapterRest.serviceResources("test", "test", "test", "test");
- }
-
- @Test
- public void serviceAllottedResources() throws Exception {
- catalogDbAdapterRest.serviceAllottedResources("test", "test");
- }
-
- @Test
- public void serviceAllottedResources1() throws Exception {
- catalogDbAdapterRest.serviceAllottedResources("test", "test", "test", "test", "test");
- }
-
- @Test
- public void serviceAllottedResourcesImpl() throws Exception {
- catalogDbAdapterRest.serviceAllottedResourcesImpl("test", false, "test", "test", "test", "test");
- }
-
- @Test
- public void vfModules() throws Exception {
- catalogDbAdapterRest.vfModules("test");
- }
-
- @Test
- public void serviceToscaCsar() throws Exception {
- catalogDbAdapterRest.serviceToscaCsar("test");
- }
-
- @Test
- public void resourceRecipe() throws Exception {
- catalogDbAdapterRest.resourceRecipe("test", "test");
- }
-
-} \ No newline at end of file
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionTest.java
deleted file mode 100644
index 365c9abcf5..0000000000
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * 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.openecomp.mso.adapters.catalogdb.catalogrest;
-
-import org.junit.Test;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
-
-public class CatalogQueryExceptionTest {
- @Test
- public void catalogQueryExceptionConstructor(){
- CatalogQueryException messageCatalogQueryException = new CatalogQueryException("TestMessage");
- assertNotNull(messageCatalogQueryException.getMessage());
- assertEquals("TestMessage",messageCatalogQueryException.getMessage());
-
- CatalogQueryException paramsCatalogQueryException = new CatalogQueryException("TestMessage",CatalogQueryExceptionCategory.INTERNAL,true,"messageID");
- assertParams(paramsCatalogQueryException);
-
- CatalogQueryException defaultCatalogQueryException = new CatalogQueryException();
- defaultCatalogQueryException.setCategory(CatalogQueryExceptionCategory.INTERNAL);
- defaultCatalogQueryException.setMessage("TestMessage");
- defaultCatalogQueryException.setRolledBack(true);
- defaultCatalogQueryException.setMessageId("messageID");
- assertParams(defaultCatalogQueryException);
- }
-
- private void assertParams(CatalogQueryException paramsCatalogQueryException) {
- assertNotNull(paramsCatalogQueryException.getMessage());
- assertEquals("TestMessage",paramsCatalogQueryException.getMessage());
- assertNotNull(paramsCatalogQueryException.getCategory());
- assertEquals(CatalogQueryExceptionCategory.INTERNAL,paramsCatalogQueryException.getCategory());
- assertNotNull(paramsCatalogQueryException.getRolledBack());
- assertEquals(true,paramsCatalogQueryException.getRolledBack());
- assertNotNull(paramsCatalogQueryException.getMessageId());
- assertEquals("messageID",paramsCatalogQueryException.getMessageId());
- }
-}
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java
deleted file mode 100644
index a4a5df7536..0000000000
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.openecomp.mso.adapters.catalogdb.catalogrest;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
-
-public class CatalogQueryTest {
- private static final String MAP_KEY = "keyTest";
- private static final String VALUE_MAP = "valueTest";
- private CatalogQuery testedObject;
-
- @Before
- public void init() {
- testedObject = new CatalogQueryForTesting();
- }
-
- @Test
- public void putStringValueToMap() {
- Map<String, String> valueMap = new HashMap<>();
- testedObject.put(valueMap, MAP_KEY, VALUE_MAP);
- assertThat(valueMap).hasSize(1).containsEntry(MAP_KEY, "\"valueTest\"");
- }
-
- @Test
- public void putNullStringValueToMap() {
- Map<String, String> valueMap = new HashMap<>();
- String value = null;
- testedObject.put(valueMap, MAP_KEY, value);
- assertThat(valueMap).hasSize(1).containsEntry(MAP_KEY, "null");
- }
-
- @Test
- public void putIntegerValueToMap() {
- Map<String, String> valueMap = new HashMap<>();
- testedObject.put(valueMap, MAP_KEY, 1);
- assertThat(valueMap).hasSize(1).containsEntry(MAP_KEY, "1");
- }
-
- @Test
- public void putNullIntegerValueToMap() {
- Map<String, String> valueMap = new HashMap<>();
- Integer value = null;
- testedObject.put(valueMap, MAP_KEY, value);
- assertThat(valueMap).hasSize(1).containsEntry(MAP_KEY, "null");
- }
-
- @Test
- public void putTrueBooleanValueToMap() {
- Map<String, String> valueMap = new HashMap<>();
- testedObject.put(valueMap, MAP_KEY, true);
- assertThat(valueMap).hasSize(1).containsEntry(MAP_KEY, "true");
- }
-
- @Test
- public void putFalseBooleanValueToMap() {
- Map<String, String> valueMap = new HashMap<>();
- testedObject.put(valueMap, MAP_KEY, false);
- assertThat(valueMap).hasSize(1).containsEntry(MAP_KEY, "false");
- }
-
- @Test
- public void putNullBooleanValueToMap() {
- Map<String, String> valueMap = new HashMap<>();
- Boolean value = null;
- testedObject.put(valueMap, MAP_KEY, value);
- assertThat(valueMap).hasSize(1).containsEntry(MAP_KEY, "null");
- }
-
- @Test
- public void setTemplate_keyFindInMap() {
- Map<String, String> valueMap = new HashMap<>();
- valueMap.put(MAP_KEY, VALUE_MAP);
- String template = "<keyTest>";
- String result = testedObject.setTemplate(template, valueMap);
- assertThat(result).isEqualTo(VALUE_MAP);
- }
-
- @Test
- public void setTemplate_keyNotFindInMap() {
- Map<String, String> valueMap = new HashMap<>();
- String template = "<keyTest>";
- String result = testedObject.setTemplate(template, valueMap);
- assertThat(result).isEqualTo("\"TBD\"");
- }
-
- @Test
- public void setTemplate_templateDoesNotMatch() {
- Map<String, String> valueMap = new HashMap<>();
- String template = "key";
- String result = testedObject.setTemplate(template, valueMap);
- assertThat(result).isEqualTo("key");
- }
-
- @Test
- public void smartToJson(){
- String expectedResult = "{\"s\":\"s1\"}";
- assertThat(testedObject.smartToJSON()).isEqualTo(expectedResult);
- }
-
- @Test
- public void toJsonString_withVersion1() {
- String expectedResult = "{\"s\":\"s1\"}";
- assertThat(testedObject.toJsonString("v1",true)).isEqualTo(expectedResult);
- }
-
- @Test
- public void toJsonString_withVersion2() {
- assertThat(testedObject.toJsonString("v2",true)).isEqualTo("json2");
- }
-
- @Test
- public void toJsonString_withInvalidVersion() {
- assertThat(testedObject.toJsonString("ver77",true)).isEqualTo("invalid version: ver77");
- }
-
- private class CatalogQueryForTesting extends CatalogQuery {
-
- private String s = "s1";
-
- public String getS() {
- return s;
- }
-
- @Override
- public String JSON2(boolean isArray, boolean isEmbed) {
- return "json2";
- }
- }
-
-}
-
-
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java
deleted file mode 100644
index 0d86a6cf10..0000000000
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.openecomp.mso.adapters.catalogdb.catalogrest;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
-
-@RunWith(MockitoJUnitRunner.class)
-public class QueryAllottedResourceCustomizationTest {
-
- @Test
- public void JSON2_Test()
- {
- List<AllottedResourceCustomization> paramList;
- paramList = new ArrayList<>();
- AllottedResourceCustomization d1 = new AllottedResourceCustomization();
- d1.setModelInstanceName("0cb9b26a-9820-48a7-86e5-16c510e993d9");
- d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
- paramList.add(d1);
-
- QueryAllottedResourceCustomization qarcObj = new QueryAllottedResourceCustomization(paramList);
- String ret = qarcObj.JSON2(true, true);
- System.out.println(ret);
- ret = "{" + ret + "}";
-
- JsonReader reader = Json.createReader(new StringReader(ret.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- JsonArray jArray = respObj.getJsonArray("serviceAllottedResources");
- assertEquals(jArray.size(), 1);
-
- assertEquals(jArray.getJsonObject(0).getJsonObject("modelInfo").getString("modelInstanceName"), "0cb9b26a-9820-48a7-86e5-16c510e993d9");
- assertEquals(jArray.getJsonObject(0).getJsonObject("modelInfo").getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
- }
-
-}
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java
deleted file mode 100644
index fa1a1fc94e..0000000000
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.openecomp.mso.adapters.catalogdb.catalogrest;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.Recipe;
-import org.openecomp.mso.jsonpath.JsonPathUtil;
-
-public class QueryResourceRecipeTest {
-
- private static final int RECIPE_ID = 123;
- private static final String RECIPE_ACTION = "actionTest";
- private static final String RECIPE_URI = "uriTest";
- private static final int RECIPE_TIMEOUT = 100;
- private static final String RECIPE_PARAMS_XSD = "paramsXsdTest";
- private static final String RECIPE_DESCRIPTION = "descrTest";
-
- private QueryResourceRecipe testedObject;
-
- @Before
- public void init() {
- testedObject = new QueryResourceRecipe(createRecipe());
- }
-
- @Test
- public void convertingToJsonSuccessful() {
- String jsonResult = testedObject.JSON2(true, true);
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.id")).contains(String.valueOf(RECIPE_ID));
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.action")).contains(RECIPE_ACTION);
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.orchestrationUri")).contains(RECIPE_URI);
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.recipeTimeout"))
- .contains(String.valueOf(RECIPE_TIMEOUT));
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.paramXSD")).contains(RECIPE_PARAMS_XSD);
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.description")).contains(RECIPE_DESCRIPTION);
- }
-
- @Test
- public void toString_properContent() {
- assertThat(testedObject.toString()).contains("RECIPE: actionTest,uri=uriTest");
- }
-
- private Recipe createRecipe() {
- Recipe recipe = new Recipe();
- recipe.setId(RECIPE_ID);
- recipe.setAction(RECIPE_ACTION);
- recipe.setOrchestrationUri(RECIPE_URI);
- recipe.setRecipeTimeout(RECIPE_TIMEOUT);
- recipe.setParamXSD(RECIPE_PARAMS_XSD);
- recipe.setDescription(RECIPE_DESCRIPTION);
- return recipe;
- }
-
-}
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceCsarTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceCsarTest.java
deleted file mode 100644
index e9c947d50e..0000000000
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceCsarTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.openecomp.mso.adapters.catalogdb.catalogrest;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.ToscaCsar;
-import org.openecomp.mso.jsonpath.JsonPathUtil;
-
-public class QueryServiceCsarTest {
-
- private static final String TOSCA_ARTIFACT_UUID = "artUuidTest";
- private static final String TOSCA_NAME = "toscaNameTest";
- private static final String TOSCA_VERSION = "v12";
- private static final String TOSCA_ARTIFACT_CHECKSUM = "tosArtCheck";
- private static final String TOSCA_URL = "tosUrl";
- private static final String TOSCA_DESCRIPTION = "toscaDescr";
-
- private QueryServiceCsar testedObject;
-
- @Before
- public void init() {
- testedObject = new QueryServiceCsar(createToscaCsar());
- }
-
- @Test
- public void convertToJson_successful() {
- String jsonResult = testedObject.JSON2(true, true);
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.artifactUUID")).contains(TOSCA_ARTIFACT_UUID);
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.name")).contains(TOSCA_NAME);
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.version")).contains(TOSCA_VERSION);
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.artifactChecksum"))
- .contains(String.valueOf(TOSCA_ARTIFACT_CHECKSUM));
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.url")).contains(TOSCA_URL);
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.description")).contains(TOSCA_DESCRIPTION);
- }
-
- @Test
- public void toString_properContent() {
- assertThat(testedObject.toString()).contains(
- "TOSCACSAR: artifactUUID=artUuidTest,name=toscaNameTest,version=v12,description=toscaDescr,artifactChecksum=tosArtCheck,url=tosUrl");
- }
-
- private ToscaCsar createToscaCsar() {
- ToscaCsar toscaCsar = new ToscaCsar();
- toscaCsar.setArtifactUUID(TOSCA_ARTIFACT_UUID);
- toscaCsar.setName(TOSCA_NAME);
- toscaCsar.setVersion(TOSCA_VERSION);
- toscaCsar.setArtifactChecksum(TOSCA_ARTIFACT_CHECKSUM);
- toscaCsar.setUrl(TOSCA_URL);
- toscaCsar.setDescription(TOSCA_DESCRIPTION);
- return toscaCsar;
- }
-
-}
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java
deleted file mode 100644
index 3a767a8609..0000000000
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.openecomp.mso.adapters.catalogdb.catalogrest;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.StringReader;
-import java.util.ArrayList;
-
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.Service;
-import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder;
-
-@RunWith(MockitoJUnitRunner.class)
-public class QueryServiceMarcoHolderTest {
-
- @Test
- public void JSON2_Test()
- {
- Service svc = new Service();
- svc.setModelUUID("0cb9b26a-9820-48a7-86e5-16c510e993d9");
- svc.setModelName("Testing Model One");
- ArrayList<NetworkResourceCustomization> paramList;
- paramList = new ArrayList<>();
- NetworkResourceCustomization d1 = new NetworkResourceCustomization();
- d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
- paramList.add(d1);
- ServiceMacroHolder ret = new ServiceMacroHolder(svc);
- ret.setNetworkResourceCustomization(paramList);
- QueryServiceMacroHolder holder = new QueryServiceMacroHolder(ret);
- String s = holder.JSON2(true, true);
-
- // System.out.println(s);
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- JsonObject obj = respObj.getJsonObject("serviceResources");
- JsonObject obj2 = obj.getJsonObject("modelInfo");
- String modelName = obj2.getString("modelName");
- String modelUuid = obj2.getString("modelUuid");
-
- assertTrue(modelName.equals("Testing Model One"));
- assertTrue(modelUuid.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9"));
- // end
- }
-}
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java
deleted file mode 100644
index 1c855eaa72..0000000000
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.openecomp.mso.adapters.catalogdb.catalogrest;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.StringReader;
-import java.util.ArrayList;
-
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.Service;
-import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder;
-
-@RunWith(MockitoJUnitRunner.class)
-public class QueryServiceNetworksTest {
-
-
- @Test
- public void JSON2_Test()
- {
- ArrayList<NetworkResourceCustomization> paramList;
- paramList = new ArrayList<>();
- NetworkResourceCustomization d1 = new NetworkResourceCustomization();
- d1.setModelInstanceName("0cb9b26a-9820-48a7-86e5-16c510e993d9");
- paramList.add(d1);
- QueryServiceNetworks qsn = new QueryServiceNetworks(paramList);
-
- String s = qsn.JSON2(true, true);
- s = "{" + s + "}";
- System.out.println(s);
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- JsonArray objArr = respObj.getJsonArray("serviceNetworks");
-
- assertTrue(objArr.size() == 1);
-
- JsonObject obj2 = objArr.getJsonObject(0).getJsonObject("modelInfo");
- String modelName = obj2.getString("modelInstanceName");
-
- assertTrue(modelName.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9"));
- // end
- }
-}
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java
deleted file mode 100644
index 8c8fc967da..0000000000
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.openecomp.mso.adapters.catalogdb.catalogrest;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
-
-@RunWith(MockitoJUnitRunner.class)
-public class QueryServiceVnfsTest {
-
- @Test
- public void JSON2_Test()
- {
- List<VnfResourceCustomization> paramList;
- paramList = new ArrayList<>();
- VnfResourceCustomization d1 = new VnfResourceCustomization();
- d1.setModelInstanceName("0cb9b26a-9820-48a7-86e5-16c510e993d9");
- d1.setVnfResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
- paramList.add(d1);
- QueryServiceVnfs qsn = new QueryServiceVnfs(paramList);
-
- String s = qsn.JSON2(true, true);
- s = "{" + s + "}";
- System.out.println(s);
-
- // prepare to inspect response
- JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", "")));
- JsonObject respObj = reader.readObject();
- reader.close();
- JsonArray objArr = respObj.getJsonArray("serviceVnfs");
-
- assertTrue(objArr.size() == 1);
-
- JsonObject obj2 = objArr.getJsonObject(0).getJsonObject("modelInfo");
- String modelName = obj2.getString("modelInstanceName");
-
- assertTrue(modelName.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9"));
- // end
-
- }
-}
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModuleTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModuleTest.java
deleted file mode 100644
index b00b5b7ca8..0000000000
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModuleTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.openecomp.mso.adapters.catalogdb.catalogrest;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.VfModule;
-import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
-import org.openecomp.mso.jsonpath.JsonPathUtil;
-
-public class QueryVfModuleTest {
-
- private static final String VF_MODULE_MODEL_NAME = "vfModelNameTest";
- private static final String VF_MODEL_UUID = "vfModelUuidTest";
- private static final String VF_MODULE_INVARIANT_UUID = "vfModuleInvUuid";
- private static final String VF_MODULE_VERSION = "vfModuleVerTest";
-
- private static final String VF_MODEL_CUSTOMIZATION_UUID = "modelCustomizationUuid";
- private static final String VF_MODEL_CUSTOMIZATION_LABEL = "modelCustomizationLabel";
- private static final int VF_MODEL_CUSTOMIZATION_INITIAL_COUNT = 1;
-
- @Test
- public void convertToJson_successful() {
- QueryVfModule testedObject = new QueryVfModule(createList());
- String jsonResult = testedObject.JSON2(true, false);
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].modelInfo.modelName"))
- .contains(VF_MODULE_MODEL_NAME);
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].modelInfo.modelUuid"))
- .contains(VF_MODEL_UUID);
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].modelInfo.modelInvariantUuid"))
- .contains(VF_MODULE_INVARIANT_UUID);
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].isBase"))
- .contains("true");
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].vfModuleLabel"))
- .contains(VF_MODEL_CUSTOMIZATION_LABEL);
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].initialCount"))
- .contains(String.valueOf(VF_MODEL_CUSTOMIZATION_INITIAL_COUNT));
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].hasVolumeGroup"))
- .contains("false");
- }
-
- @Test
- public void convertToJson_successful_hasVolumeGroupIsTrue() {
- QueryVfModule testedObject = new QueryVfModule(createListWithHeatEnvironmentArtifactUuid());
- String jsonResult = testedObject.JSON2(true, false);
- assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].hasVolumeGroup"))
- .contains("true");
- }
-
- private List<VfModuleCustomization> createList() {
- List<VfModuleCustomization> list = new ArrayList<>();
-
- VfModule vfModule = new VfModule();
- vfModule.setModelName(VF_MODULE_MODEL_NAME);
- vfModule.setModelUUID(VF_MODEL_UUID);
- vfModule.setModelInvariantUuid(VF_MODULE_INVARIANT_UUID);
- vfModule.setVersion(VF_MODULE_VERSION);
- vfModule.setIsBase(1);
-
- VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
- vfModuleCustomization.setVfModule(vfModule);
- vfModuleCustomization.setModelCustomizationUuid(VF_MODEL_CUSTOMIZATION_UUID);
- vfModuleCustomization.setLabel(VF_MODEL_CUSTOMIZATION_LABEL);
- vfModuleCustomization.setInitialCount(VF_MODEL_CUSTOMIZATION_INITIAL_COUNT);
- list.add(vfModuleCustomization);
- return list;
- }
-
- private List<VfModuleCustomization> createListWithHeatEnvironmentArtifactUuid() {
- List<VfModuleCustomization> list = createList();
- list.get(0).setHeatEnvironmentArtifactUuid("heatEnvTest");
- return list;
- }
-
-}