diff options
author | Tomasz Gwozdecki <tomasz.gwozdecki@nokia.com> | 2018-04-16 08:22:40 -0400 |
---|---|---|
committer | Randa Maher <rx196w@att.com> | 2018-04-25 00:57:41 +0000 |
commit | 250db09d1ed3475ea7a03cbd21b244b523a64814 (patch) | |
tree | 1672eeebe225d404480dfe017f7fce6ecf6243d3 /appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main | |
parent | 91e81944dd410196c5cd3fde32fed746ec5de466 (diff) |
ChefAdapterImpl junits
-Added junit tests for fetchResults method
-Support for Michal Kabaj as part of APPC-437
Change-Id: I3219a5ec0ffd530338ce364f608a9706d5a92c03
Issue-ID: APPC-858
Signed-off-by: Tomasz Gwozdecki <tomasz.gwozdecki@nokia.com>
Diffstat (limited to 'appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main')
-rw-r--r-- | appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java index d26c85c44..64aedcc24 100644 --- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java +++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java @@ -28,6 +28,7 @@ import com.att.eelf.configuration.EELFManager; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.Optional; import org.apache.commons.lang.StringUtils; import org.json.JSONException; import org.json.JSONObject; @@ -288,12 +289,13 @@ public class ChefAdapterImpl implements ChefAdapter { allNodeData = allNodeData.getJSONObject("normal"); String attribute = "PushJobOutput"; - String resultData = allNodeData.optString(attribute); + String resultData = allNodeData.optString(attribute, null); if (resultData == null) { - resultData = allNodeData.optJSONObject(attribute).toString(); - + resultData = Optional.ofNullable(allNodeData.optJSONObject(attribute)) + .map(p -> p.toString()).orElse(null); if (resultData == null) { - resultData = allNodeData.optJSONArray(attribute).toString(); + resultData = Optional.ofNullable(allNodeData.optJSONArray(attribute)) + .map(p -> p.toString()).orElse(null); if (resultData == null) { code = 500; @@ -653,4 +655,4 @@ public class ChefAdapterImpl implements ChefAdapter { throw new SvcLogicException("Chef Adapter error:" + cutMessage); } -} +}
\ No newline at end of file |