From a79579d14a4446d4a6f67bd48f650bfa8ed05486 Mon Sep 17 00:00:00 2001 From: Lukasz Muszkieta Date: Thu, 28 Dec 2017 14:19:52 +0100 Subject: refactoring - adding junit coverage Change-Id: I712afd8ff4e403829ee51b87d76ed38dda027ace Issue-ID: SO-360 Signed-off-by: Lukasz Muszkieta --- .../openecomp/mso/adapters/json/MapDeserializer.java | 18 ++++++------------ .../mso/adapters/tenantrest/RollbackTenantError.java | 4 ---- .../adapters/tenantrest/TenantExceptionResponse.java | 6 ------ 3 files changed, 6 insertions(+), 22 deletions(-) (limited to 'adapters/mso-adapters-rest-interface/src/main/java/org') diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapDeserializer.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapDeserializer.java index f51cb0dd64..2a3a64ce1b 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapDeserializer.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapDeserializer.java @@ -21,7 +21,6 @@ package org.openecomp.mso.adapters.json; import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.JsonParser; -import org.codehaus.jackson.JsonProcessingException; import org.codehaus.jackson.map.DeserializationContext; import org.codehaus.jackson.map.JsonDeserializer; import org.codehaus.jackson.map.ObjectMapper; @@ -48,27 +47,22 @@ import java.util.Map; * */ public class MapDeserializer extends JsonDeserializer> { + @Override public Map deserialize(JsonParser parser, - DeserializationContext context) throws IOException, - JsonProcessingException { + DeserializationContext context) throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode tree = mapper.readTree(parser); - Map map = new LinkedHashMap<>(); - Iterator iterator = tree.iterator(); - - while (iterator.hasNext()) { - JsonNode element = iterator.next(); - Iterator arrayIterator = element.iterator(); - while (arrayIterator.hasNext()) { - JsonNode arrayElement = arrayIterator.next(); + if (tree == null) + return map; + for (JsonNode element : tree) { + for (JsonNode arrayElement : element) { String key = arrayElement.get("key").getTextValue(); String value = arrayElement.get("value").getTextValue(); map.put(key, value); } } - return map; } } diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantError.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantError.java index 83c31336bb..2d359e059f 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantError.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantError.java @@ -37,10 +37,6 @@ public class RollbackTenantError implements Serializable { public RollbackTenantError () {} - public RollbackTenantError (String message) { - this.message = message; - } - public RollbackTenantError (String message, MsoExceptionCategory category, boolean rolledBack) { this.message = message; this.category = category; diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantExceptionResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantExceptionResponse.java index d7b02e028a..c5105aa683 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantExceptionResponse.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantExceptionResponse.java @@ -20,8 +20,6 @@ package org.openecomp.mso.adapters.tenantrest; - - import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; import java.io.Serializable; import javax.xml.bind.annotation.XmlRootElement; @@ -39,10 +37,6 @@ public class TenantExceptionResponse implements Serializable { public TenantExceptionResponse () {} - public TenantExceptionResponse (String message) { - this.message = message; - } - public TenantExceptionResponse (String message, MsoExceptionCategory category, boolean rolledBack) { this.message = message; this.category = category; -- cgit 1.2.3-korg