summaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipe.java40
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandlerTest.java67
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandlerTestException.java35
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImplTest.java63
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResourceTest.java26
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java2
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java13
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java2
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfPluginAdapterImpl.java20
9 files changed, 170 insertions, 98 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipe.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipe.java
index 5be6970554..7d6aed4785 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipe.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipe.java
@@ -24,6 +24,10 @@ import java.util.Map;
import org.openecomp.mso.db.catalog.beans.Recipe;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+
/**
* serivce csar query support
* <br>
@@ -41,16 +45,6 @@ public class QueryResourceRecipe extends CatalogQuery{
this.resourceRecipe =resourceRecipe;
}
- private final String template =
- "\t{\n"+
- "\t\t\"id\" : <ID>,\n"+
- "\t\t\"action\" : <ACTION>,\n"+
- "\t\t\"orchestrationUri\" : <ORCHESTRATION_URI>,\n"+
- "\t\t\"recipeTimeout\" : <RECIPE_TIMEOUT>,\n"+
- "\t\t\"paramXSD\" : <PARAM_XSD>,\n"+
- "\t\t\"description\" : <DESCRIPTION>\n"+
- "\t}";
-
@Override
public String toString() {
@@ -58,15 +52,25 @@ public class QueryResourceRecipe extends CatalogQuery{
}
@Override
- public String JSON2(boolean isArray, boolean isEmbed) {
+ public String JSON2(boolean isArray, boolean isEmbed) {
+
Map<String, String> valueMap = new HashMap<>();
- put(valueMap, "ID", null == resourceRecipe ? null : resourceRecipe.getId());
- put(valueMap, "ACTION", null == resourceRecipe ? null : resourceRecipe.getAction());
- put(valueMap, "ORCHESTRATION_URI", null == resourceRecipe ? null : resourceRecipe.getOrchestrationUri());
- put(valueMap, "RECIPE_TIMEOUT", null == resourceRecipe ? null : resourceRecipe.getRecipeTimeout());
- put(valueMap, "PARAM_XSD", null == resourceRecipe ? null : resourceRecipe.getParamXSD());
- put(valueMap, "DESCRIPTION", null == resourceRecipe ? null : resourceRecipe.getDescription());
- return this.setTemplate(template, valueMap);
+ valueMap.put("id", null == resourceRecipe ? null :String.valueOf(resourceRecipe.getId()));
+ valueMap.put("action", null == resourceRecipe ? null :resourceRecipe.getAction());
+ valueMap.put("orchestrationUri", null == resourceRecipe ? null : resourceRecipe.getOrchestrationUri());
+ valueMap.put("recipeTimeout", null == resourceRecipe ? null : String.valueOf(resourceRecipe.getRecipeTimeout()));
+ valueMap.put("paramXSD", null == resourceRecipe ? null : resourceRecipe.getParamXSD());
+ valueMap.put("description", null == resourceRecipe ? null : resourceRecipe.getDescription());
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
+ String jsonStr = "";
+ try {
+ jsonStr = mapper.writeValueAsString(valueMap);
+ } catch(JsonProcessingException e) {
+
+ e.printStackTrace();
+ }
+ return jsonStr;
}
}
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandlerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandlerTest.java
new file mode 100644
index 0000000000..87e2a87138
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandlerTest.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 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.requestsdb;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openecomp.mso.HealthCheckUtils;
+import org.openecomp.mso.logger.MsoLogger;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import javax.ws.rs.core.Response;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(HealthCheckHandler.class)
+public class HealthCheckHandlerTest {
+
+ HealthCheckHandler hcH;
+
+ @Before
+ public void init(){
+
+ hcH = new HealthCheckHandler();
+ }
+
+ @Test
+ public void testNoServiceResp() {
+
+ HealthCheckUtils test = PowerMockito.mock(HealthCheckUtils.class);
+ try {
+ PowerMockito.whenNew(HealthCheckUtils.class).withNoArguments().thenReturn(test);
+ when(test.siteStatusCheck(any(MsoLogger.class))).thenReturn(true);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ Response response = hcH.healthcheck("request");
+ assertEquals(503,response.getStatus());
+ }
+
+}
+
+
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandlerTestException.java b/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandlerTestException.java
deleted file mode 100644
index 994ce5dbb3..0000000000
--- a/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandlerTestException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 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.requestsdb;
-
-import org.junit.Test;
-
-public class HealthCheckHandlerTestException {
-
- @Test(expected = NullPointerException.class)
- public void testHealthCheckSiteNameNull() {
-
- HealthCheckHandler hcH = new HealthCheckHandler();
- hcH.healthcheck("request");
- }
-}
-
-
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImplTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImplTest.java
index 6e05402736..98b368f5fa 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImplTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImplTest.java
@@ -20,43 +20,60 @@
package org.openecomp.mso.adapters.sdnc.impl;
-import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openecomp.mso.HealthCheckUtils;
+import org.openecomp.mso.logger.MsoLogger;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import javax.ws.rs.core.Response;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(SDNCAdapterRestImpl.class)
public class SDNCAdapterRestImplTest {
- SDNCAdapterRestImpl test = new SDNCAdapterRestImpl();
+ SDNCAdapterRestImpl test;
- /*Need to revist this .. commenting for now to proceed
- @Test(expected = ClassFormatError.class)
- public void testMSORequestException() {
+ @Before
+ public void init(){
- test.MSORequest("reqXML");
- Assert.assertFalse(true);
-
+ test = new SDNCAdapterRestImpl();
}
- @Test(expected = NoClassDefFoundError.class)
- public void testHealthCheckException() {
+ @Test
+ public void testBadReqNoServiceRsp() {
- test.healthcheck("1a25a7c0-4c91-4f74-9a78-8c11b7a57f1a");
- Assert.assertFalse(true);
- }
+ HealthCheckUtils hCU = PowerMockito.mock(HealthCheckUtils.class);
+ try {
+ PowerMockito.whenNew(HealthCheckUtils.class).withNoArguments().thenReturn(hCU);
+ when(hCU.siteStatusCheck(any(MsoLogger.class))).thenReturn(true);
- @Test(expected = ClassFormatError.class)
- public void testglobalHealthcheckException() {
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
- test.globalHealthcheck(true);
- Assert.assertFalse(true);
- }
+ String reqXML = "<xml>test</xml>";
+
+ Response response = test.MSORequest(reqXML);
+ assertEquals(400,response.getStatus());
+
+ response = test.healthcheck("1a25a7c0-4c91-4f74-9a78-8c11b7a57f1a");
+ assertEquals(503,response.getStatus());
+ response = test.globalHealthcheck(true);
+ assertEquals(503,response.getStatus());
- @Test(expected = NoClassDefFoundError.class)
- public void testNodeHealthCheckException() {
+ response = test.nodeHealthcheck();
+ assertEquals(503,response.getStatus());
- test.nodeHealthcheck();
- Assert.assertFalse(true);
- }*/
+ }
}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResourceTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResourceTest.java
index a62f42af5a..75cd360663 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResourceTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResourceTest.java
@@ -24,6 +24,9 @@ import org.junit.Test;
import org.mockito.Mock;
import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import static org.junit.Assert.assertEquals;
public class SDNCNotifyResourceTest {
@@ -31,16 +34,19 @@ public class SDNCNotifyResourceTest {
HttpServletRequest httpServletRequest;
SDNCNotifyResource test = new SDNCNotifyResource();
-//These tests need a recheck for the class cast exception
- /* @Test(expected = ClassFormatError.class)
- public void testPrintMessageException() {
- test.printMessage();
- test.printMessageParam("msg");
- }
- @Test(expected = ClassFormatError.class)
- public void testSDNCNotifyException() {
- test.SDNCNotify("reqXML", httpServletRequest);
+ @Test
+ public void testPrintMessage() {
+
+ Response response = test.printMessage();
+ assertEquals(200, response.getStatus());
- }*/
+ response = test.printMessageParam("msg");
+ assertEquals(200, response.getStatus());
+
+ String reqXML = "<xml>test</xml>";
+ response = test.SDNCNotify(reqXML, httpServletRequest);
+ assertEquals(400, response.getStatus());
+
+ }
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java
index 8e16d1c22f..0673af2f14 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java
@@ -88,7 +88,7 @@ public class VfcManager {
public RestfulResponse createNs(NSResourceInputParameter segInput) throws ApplicationException {
// Step1: get service template by node type
- String csarId = segInput.getNsOperationKey().getNodeTemplateUUID();
+ String csarId = segInput.getNsServiceModelUUID();
// nsdId for NFVO is "id" in the response, while for SDNO is "servcice template id"
LOGGER.info("serviceTemplateId is {}, id is {}", csarId);
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java
index 765ee52069..d46844364f 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java
@@ -45,6 +45,8 @@ public class NSResourceInputParameter {
private String nsServiceName;
private String nsServiceDescription;
+
+ private String nsServiceModelUUID;
private NsParameters nsParameters;
@@ -136,4 +138,15 @@ public class NSResourceInputParameter {
public void setNsScaleParameters(NsScaleParameters nsScaleParameters) {
this.nsScaleParameters = nsScaleParameters;
}
+
+
+ public String getNsServiceModelUUID() {
+ return nsServiceModelUUID;
+ }
+
+
+ public void setNsServiceModelUUID(String nsServiceModelUUID) {
+ this.nsServiceModelUUID = nsServiceModelUUID;
+ }
+
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java
index fcbbf8515a..0bedd12eb1 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java
@@ -83,7 +83,7 @@ public class RestfulUtil {
msbPort = msoPropertiesFactory.getMsoJavaProperties("MSO_PROP_TOPOLOGY").getProperty("msb-port", DEFAULT_MSB_PORT);
}
} catch(MsoPropertiesException e) {
- LOGGER.error(MessageEnum.RA_NS_EXC, "VFC Adapter", "", MsoLogger.ErrorCode.AvailabilityError, "Get msb properties failed");
+ LOGGER.error(MessageEnum.RA_NS_EXC, "VFC Adapter", "", MsoLogger.ErrorCode.AvailabilityError, "Get msb properties failed",e);
e.printStackTrace();
}
return "http://" + msbIp + ":" + msbPort;
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfPluginAdapterImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfPluginAdapterImpl.java
index a817a6b427..0b9ffd9468 100644
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfPluginAdapterImpl.java
+++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfPluginAdapterImpl.java
@@ -381,7 +381,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
return Integer.valueOf(inputValue);
}
catch (Exception e) {
- LOGGER.debug("Unable to convert " + inputValue + " to an integer!");
+ LOGGER.debug("Unable to convert " + inputValue + " to an integer!" , e);
return null;
}
} else if (type.equalsIgnoreCase("json")) {
@@ -390,7 +390,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
return jsonNode;
}
catch (Exception e) {
- LOGGER.debug("Unable to convert " + inputValue + " to a JsonNode!");
+ LOGGER.debug("Unable to convert " + inputValue + " to a JsonNode!", e);
return null;
}
} else if (type.equalsIgnoreCase("boolean")) {
@@ -411,28 +411,28 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
String str = "" + stackOutputs.get(key);
stringOutputs.put(key, str);
} catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs");
+ LOGGER.debug("Unable to add " + key + " to outputs", e);
}
} else if (stackOutputs.get(key) instanceof JsonNode) {
try {
String str = this.convertNode((JsonNode) stackOutputs.get(key));
stringOutputs.put(key, str);
} catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs - exception converting JsonNode");
+ LOGGER.debug("Unable to add " + key + " to outputs - exception converting JsonNode", e);
}
} else if (stackOutputs.get(key) instanceof java.util.LinkedHashMap) {
try {
String str = JSON_MAPPER.writeValueAsString(stackOutputs.get(key));
stringOutputs.put(key, str);
} catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap");
+ LOGGER.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap", e);
}
} else {
try {
String str = stackOutputs.get(key).toString();
stringOutputs.put(key, str);
} catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage());
+ LOGGER.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage(), e);
}
}
}
@@ -510,7 +510,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
String str = this.convertNode((JsonNode) obj);
stringMap.put(key, str);
} catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode "+ key);
+ LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode "+ key, e);
//okay in this instance - only string values (fqdn) are expected to be needed
}
} else if (obj instanceof java.util.LinkedHashMap) {
@@ -519,21 +519,21 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
String str = JSON_MAPPER.writeValueAsString(obj);
stringMap.put(key, str);
} catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap "+ key);
+ LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap "+ key, e);
}
} else if (obj instanceof Integer) {
try {
String str = "" + obj;
stringMap.put(key, str);
} catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for Integer "+ key);
+ LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for Integer "+ key, e);
}
} else {
try {
String str = obj.toString();
stringMap.put(key, str);
} catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value "+ key + " (" + e.getMessage() + ")");
+ LOGGER.debug("DANGER WILL ROBINSON: unable to convert value "+ key + " (" + e.getMessage() + ")", e);
}
}
}