diff options
Diffstat (limited to 'adapters/mso-sdnc-adapter/src')
3 files changed, 62 insertions, 8 deletions
diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java index 97f30bea6b..45d5944c7d 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java @@ -197,7 +197,7 @@ public class SDNCRestClient implements Runnable { //default sdncResp.setRespCode(HttpURLConnection.HTTP_INTERNAL_ERROR); String respMsg = "Error processing request to SDNC. "; - String sdncErrMsg = ""; + StringBuilder sdncErrMsg = new StringBuilder(); if (e instanceof java.net.SocketTimeoutException ) { @@ -229,7 +229,7 @@ public class SDNCRestClient implements Runnable { String eType = null; try { eType = xpath.evaluate("error-type", error); - sdncErrMsg = ". SDNC Returned-[error-type:" + eType; + sdncErrMsg = new StringBuilder(". SDNC Returned-[error-type:" + eType); } catch (Exception e3) { msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-type", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3); } @@ -237,7 +237,7 @@ public class SDNCRestClient implements Runnable { String eTag = null; try { eTag = xpath.evaluate( "error-tag", error); - sdncErrMsg = sdncErrMsg + ", error-tag:" + eTag; + sdncErrMsg.append(", error-tag:").append(eTag); } catch (Exception e3) { msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-tag", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3); } @@ -245,7 +245,7 @@ public class SDNCRestClient implements Runnable { String eMsg = null; try { eMsg = xpath.evaluate("error-message", error); - sdncErrMsg = sdncErrMsg + ", error-message:" + eMsg + "]"; + sdncErrMsg.append(", error-message:").append(eMsg).append("]"); } catch (Exception e3) { msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-message", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3); } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java index 262d23bd09..be0466af73 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java @@ -257,7 +257,7 @@ public abstract class SDNCConnector { // </error> // </errors> - String output = null; + StringBuilder output = null; try { XPathFactory xpathFactory = XPathFactory.newInstance(); @@ -306,9 +306,9 @@ public abstract class SDNCConnector { if (!info.isEmpty()) { if (output == null) { - output = "[" + info + "]"; + output = new StringBuilder("[" + info + "]"); } else { - output += " [" + info + "]"; + output.append(" [").append(info).append("]"); } } } @@ -317,6 +317,6 @@ public abstract class SDNCConnector { MsoLogger.ErrorCode.DataError, "Exception while analyzing errors", e); } - return output; + return output.toString(); } } diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequestTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequestTest.java new file mode 100644 index 0000000000..fa96b7983e --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequestTest.java @@ -0,0 +1,54 @@ +/*- + * ============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.sdnc; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.openecomp.mso.adapters.sdnc.SDNCAdapterRequest; +import org.openecomp.mso.adapters.sdnc.RequestHeader; + + +public class SDNCAdapterRequestTest { + + static Object sd= new SDNCAdapterRequest(); + static RequestHeader rh=new RequestHeader(); + + @BeforeClass + public static final void RHeader() + { + rh.setCallbackUrl("callback"); + rh.setMsoAction ("action"); + rh.setRequestId ("reqid"); + rh.setSvcAction ("svcAction"); + rh.setSvcInstanceId ("svcId"); + rh.setSvcOperation ("op"); + } + @Test + public final void testtoString(){ + ((SDNCAdapterRequest) sd).setRequestData("data"); + ((SDNCAdapterRequest) sd).setRequestHeader(rh); + assert (((SDNCAdapterRequest) sd).getRequestData()!= null) ; + assert(((SDNCAdapterRequest) sd).getRequestData().equals("data")); + assert(((SDNCAdapterRequest) sd).getRequestHeader().equals(rh)); + } + +} |