aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-catalog-db-adapter
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-catalog-db-adapter')
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java554
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java655
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java92
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java31
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java37
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java33
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java33
7 files changed, 725 insertions, 710 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
index f3ee941641..31594905fd 100644
--- 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
@@ -29,9 +29,7 @@ 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;
@@ -57,50 +55,50 @@ import static org.hamcrest.CoreMatchers.instanceOf;
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
+ 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();
- }
+
+ 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);
-
+ 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);
@@ -110,218 +108,225 @@ public class CatalogDbAdapterRestClassTest {
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();
- }
+
+ 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_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_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 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);
+ 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
@@ -330,32 +335,33 @@ public class CatalogDbAdapterRestClassTest {
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");
-
+
+ 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);
+ 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
@@ -364,11 +370,11 @@ public class CatalogDbAdapterRestClassTest {
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");
-
+
+ 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
index 1f80227514..ae5e663777 100644
--- 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
@@ -29,7 +29,6 @@ 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;
@@ -74,7 +73,7 @@ public class CatalogDbAdapterRestHttpTest {
private static final int PORT = 3099;
private static Registry registry;
private static ResteasyProviderFactory factory;
-
+
@BeforeClass
public static void beforeClass() throws Exception {
server = new TJWSEmbeddedJaxrsServer();
@@ -85,75 +84,76 @@ public class CatalogDbAdapterRestHttpTest {
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();
- }
+ 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() {
+ 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
+ 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"));
- }
+ PowerMockito.when(dbMock.getAllVnfsByVnfModelCustomizationUuid(Mockito.anyString())).thenReturn (paramList);
// end
- } catch (Exception e) {
- e.printStackTrace();
- }
+
+ // 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
+ 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");
@@ -161,327 +161,330 @@ public class CatalogDbAdapterRestHttpTest {
d1.setVersion("v1");
d1.setMaxInstances(50);
paramList.add(d1);
- PowerMockito.when(dbMock.getAllVnfsByServiceModelInvariantUuid(Mockito.anyString(), Mockito.anyString())).thenReturn(paramList);
+ 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());
- }
+
+ // 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
+ 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"));
- }
+ PowerMockito.when(dbMock.getAllVnfsByVnfModelCustomizationUuid(Mockito.anyString())).thenReturn (paramList);
// end
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
+
+ // 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
+ 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"));
- }
+ PowerMockito.when(dbMock.getAllNetworksByNetworkModelCustomizationUuid(Mockito.anyString())).thenReturn (paramList);
// end
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
+
+ // 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
+ 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);
+ 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());
- }
- }
-
+
+ // 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
+ 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"));
- }
+ ServiceMacroHolder ret = new ServiceMacroHolder();
+ ret.setNetworkResourceCustomization(paramList);
+ PowerMockito.when(dbMock.getAllResourcesByServiceModelInvariantUuid(Mockito.anyString(),Mockito.anyString())).thenReturn (ret);
// end
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
+
+ // 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
+ 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"));
- }
+ PowerMockito.when(dbMock.getAllAllottedResourcesByArModelCustomizationUuid(Mockito.anyString())).thenReturn (paramList);
// end
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
-
+
+ // 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
+ 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);
+ 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());
- }
+
+ // 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"));
+ 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
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
+
+ // 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();
+ server.stop();
}
}
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
index a7ee7f5ac7..ee2c8db577 100644
--- 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
@@ -43,68 +43,70 @@ import static org.junit.Assert.*;
@RunWith(MockitoJUnitRunner.class)
public class CatalogQueryTest {
-
- @Test
- public void catalogQuerySetTemplateImpl_Test() {
- CatalogQuery mockCatalogQuery = Mockito.mock(CatalogQuery.class);
- Mockito.doCallRealMethod().when(mockCatalogQuery).setTemplate(Mockito.anyString(), Mockito.anyMapOf(String.class, String.class));
-
- Map<String, String> valueMap = new HashMap<>();
- valueMap.put("somekey", "somevalue");
-
- String ret = mockCatalogQuery.setTemplate("<somekey>", valueMap);
-
- assertTrue(ret.equalsIgnoreCase("somevalue"));
- }
-
- @Test
- public void smartToJson_Test() {
+
+ @Test
+ public void catalogQuerySetTemplateImpl_Test(){
+ CatalogQuery mockCatalogQuery = Mockito.mock(CatalogQuery.class);
+ Mockito.doCallRealMethod().when(mockCatalogQuery).setTemplate(Mockito.anyString(), Mockito.anyMapOf(String.class, String.class));
+
+ Map<String,String> valueMap = new HashMap<>();
+ valueMap.put("somekey", "somevalue");
+
+ String ret = mockCatalogQuery.setTemplate("<somekey>", valueMap);
+
+ assertTrue(ret.equalsIgnoreCase("somevalue"));
+ }
+
+ @Test
+ public void smartToJson_Test()
+ {
List<VnfResourceCustomization> 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);
-
+
QueryServiceVnfs qryResp = new QueryServiceVnfs(paramList);
QueryServiceVnfs mockCatalogQuery = Mockito.spy(qryResp);
Mockito.doCallRealMethod().when(mockCatalogQuery).smartToJSON();
- String ret = qryResp.smartToJSON();
- // System.out.println(ret);
-
+ String ret = qryResp.smartToJSON();
+ // System.out.println(ret);
+
JsonReader reader = Json.createReader(new StringReader(ret.replaceAll("\r?\n", "")));
JsonObject respObj = reader.readObject();
reader.close();
JsonArray jArray = respObj.getJsonArray("serviceVnfs");
- assertEquals(jArray.size(), 1);
- assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
- }
-
- @Test
- public void toJsonString_Test() {
- CatalogQueryExtendedTest mockCatalogQuery = Mockito.mock(CatalogQueryExtendedTest.class);
- Mockito.doCallRealMethod().when(mockCatalogQuery).JSON2(Mockito.anyBoolean(), Mockito.anyBoolean());
- String ret = mockCatalogQuery.JSON2(true, true);
-
- // System.out.println(ret);
-
+ assertEquals(jArray.size(), 1);
+ assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
+ }
+
+ @Test
+ public void toJsonString_Test()
+ {
+ CatalogQueryExtendedTest mockCatalogQuery = Mockito.mock(CatalogQueryExtendedTest.class);
+ Mockito.doCallRealMethod().when(mockCatalogQuery).JSON2(Mockito.anyBoolean(), Mockito.anyBoolean());
+ String ret = mockCatalogQuery.JSON2(true, true);
+
+ // System.out.println(ret);
+
JsonReader reader = Json.createReader(new StringReader(ret.replaceAll("\r?\n", "")));
JsonObject respObj = reader.readObject();
reader.close();
JsonArray jArray = respObj.getJsonArray("serviceVnfs");
- assertEquals(jArray.size(), 1);
- assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
- assertEquals(jArray.getJsonObject(0).getString("version"), "v2");
- }
-
- class CatalogQueryExtendedTest extends CatalogQuery {
- @Override
- public String JSON2(boolean isArray, boolean isEmbed) {
- return "{\"serviceVnfs\":[{\"version\":\"v2\",\"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}]}";
- }
-
- }
-
+ assertEquals(jArray.size(), 1);
+ assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
+ assertEquals(jArray.getJsonObject(0).getString("version"), "v2");
+ }
+
+ class CatalogQueryExtendedTest extends CatalogQuery{
+ @Override
+ public String JSON2(boolean isArray, boolean isEmbed) {
+ return "{\"serviceVnfs\":[{\"version\":\"v2\",\"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}]}";
+ }
+
+ }
+
}
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
index fd9e23e9f0..0d86a6cf10 100644
--- 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
@@ -39,28 +39,29 @@ import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
@RunWith(MockitoJUnitRunner.class)
public class QueryAllottedResourceCustomizationTest {
- @Test
- public void JSON2_Test() {
- List<AllottedResourceCustomization> paramList;
+ @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 + "}";
-
+
+ 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");
- }
-
+ 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/QueryServiceMarcoHolderTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java
index 01bb570090..3a767a8609 100644
--- 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
@@ -40,24 +40,25 @@ 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;
+ @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);
+ ServiceMacroHolder ret = new ServiceMacroHolder(svc);
+ ret.setNetworkResourceCustomization(paramList);
+ QueryServiceMacroHolder holder = new QueryServiceMacroHolder(ret);
+ String s = holder.JSON2(true, true);
+
+ // System.out.println(s);
- // System.out.println(s);
-
- // prepare to inspect response
+ // prepare to inspect response
JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", "")));
JsonObject respObj = reader.readObject();
reader.close();
@@ -65,9 +66,9 @@ public class QueryServiceMarcoHolderTest {
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
- }
+
+ 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
index 0d4a4f9254..1c855eaa72 100644
--- 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
@@ -40,32 +40,33 @@ import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder;
@RunWith(MockitoJUnitRunner.class)
public class QueryServiceNetworksTest {
-
- @Test
- public void JSON2_Test() {
- ArrayList<NetworkResourceCustomization> paramList;
+
+ @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
+
+ 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
- }
+
+ 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
index b48d8af66e..8c8fc967da 100644
--- 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
@@ -40,33 +40,34 @@ import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
@RunWith(MockitoJUnitRunner.class)
public class QueryServiceVnfsTest {
- @Test
- public void JSON2_Test() {
- List<VnfResourceCustomization> paramList;
+ @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
+
+ 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
-
- }
+
+ assertTrue(modelName.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9"));
+ // end
+
+ }
}