summaryrefslogtreecommitdiffstats
path: root/adapters/mso-catalog-db-adapter/src/main
diff options
context:
space:
mode:
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>2018-05-07 10:34:43 +0200
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>2018-05-11 13:28:24 +0200
commited47a9897c791d8ce88b188566b09225eadc38a4 (patch)
treeff9fd1e7f9541bf937a26afbc2002ff4898ecefa /adapters/mso-catalog-db-adapter/src/main
parent2bcb1f2bdefa3478031b3c3de7eeb568364c8161 (diff)
Add junit for project mso-catalog-db-adapter
Change-Id: I7b28cc713929400b03b7e567bf9823d82631a1e9 Issue-ID: SO-617 Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
Diffstat (limited to 'adapters/mso-catalog-db-adapter/src/main')
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java4
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java85
2 files changed, 3 insertions, 86 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java
index a8969dd45d..9215c38706 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java
@@ -80,8 +80,9 @@ public class QueryVfModule extends CatalogQuery {
}
@Override
- public String JSON2(boolean isArray, boolean x) {
+ public String JSON2(boolean isArray, boolean isEmbed) {
StringBuilder sb = new StringBuilder();
+ if (!isEmbed && isArray) sb.append("{ ");
if (isArray) sb.append("\"vfModules\": [");
Map<String, String> valueMap = new HashMap<>();
String sep = "";
@@ -112,6 +113,7 @@ public class QueryVfModule extends CatalogQuery {
}
if (!first) sb.append("\n");
if (isArray) sb.append("]");
+ if (!isEmbed && isArray) sb.append("}");
return sb.toString();
}
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java
deleted file mode 100644
index 001a9f496a..0000000000
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.adapters.catalogdb.catalogrest;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.openecomp.mso.db.catalog.beans.VfModule;
-import org.openecomp.mso.logger.MsoLogger;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-@XmlRootElement(name = "vfModules")
-public class QueryVfModules {
- private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
- private List<VfModule> vfModules;
-
- public QueryVfModules() {
- super();
- vfModules = new ArrayList<>();
- }
- public QueryVfModules(List<VfModule> vlist) {
- LOGGER.debug ("QueryVfModules:");
- vfModules = new ArrayList<>();
- for (VfModule o : vlist) {
- LOGGER.debug ("-- o is a vfModules ----");
- LOGGER.debug (o.toString());
- vfModules.add(o);
- LOGGER.debug ("-------------------");
- }
- }
-
- public List<VfModule> getVfModules(){ return this.vfModules; }
-
- public void setVfModules(List<VfModule> v) { this.vfModules = v; }
-
- @Override
- public String toString () {
- StringBuilder sb = new StringBuilder();
-
- boolean first = true;
- int i = 1;
- for (VfModule o : vfModules) {
- sb.append(i).append("\t");
- if (!first) sb.append("\n");
- first = false;
- sb.append(o);
- }
- return sb.toString();
- }
-
- public String toJsonString() {
- String jsonString = null;
- try {
- ObjectMapper mapper = new ObjectMapper();
- jsonString = mapper.writeValueAsString(this);
- LOGGER.debug ("QueryVfModules jsonString: "+jsonString);
- }
- catch (Exception e) {
- LOGGER.debug ("Exception:", e);
- LOGGER.debug ("QueryVfModules jsonString exception:"+e.getMessage());
- }
- return jsonString;
- }
-}