From 677d218e4c337de6faca915723d47390ef4290d0 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Thu, 16 Nov 2017 13:17:29 +0100 Subject: Rework the CldsUserJson Rework the CldsUserJson and associated Unit tests Change-Id: I0be23ef8c6a44bc7cec7f7011b08a32d2662c56f Issue-ID: CLAMP-74 Signed-off-by: Determe, Sebastien (sd378r) --- .../org/onap/clamp/clds/config/CldsUserJsonDecoder.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/main/java/org/onap') diff --git a/src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java b/src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java index ecfb4aa11..15d06b9af 100644 --- a/src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java +++ b/src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java @@ -28,23 +28,29 @@ import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.io.InputStream; +import org.onap.clamp.clds.exception.CldsUsersException; import org.onap.clamp.clds.service.CldsUser; public class CldsUserJsonDecoder { - /** * This method decodes the JSON file provided to a CldsUser Array. The * stream is closed after this call, this is not possible to reuse it. * + * @param cldsUsersFile + * The inputStream containing the users json file * @return CldsUser[] Array containing a list of the user defined in the * JSON file */ - public static CldsUser[] decodeJson(InputStream cldsUsersFile) throws IOException { - // the ObjectMapper readValue method closes the stream no need to do it - return new ObjectMapper().readValue(cldsUsersFile, CldsUser[].class); + public static CldsUser[] decodeJson(InputStream cldsUsersFile) { + try { + // the ObjectMapper readValue method closes the stream no need to do + // it + return new ObjectMapper().readValue(cldsUsersFile, CldsUser[].class); + } catch (IOException e) { + throw new CldsUsersException("Exception occurred during the decoding of the clds-users.json", e); + } } private CldsUserJsonDecoder() { - } } -- cgit 1.2.3-korg