diff options
author | talio <tali.orenbach@amdocs.com> | 2018-01-29 11:23:39 +0200 |
---|---|---|
committer | Vitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com> | 2018-02-15 14:23:32 +0000 |
commit | 924ba9adf027dd4969896cd905a8a41ba4c30655 (patch) | |
tree | 035e2ba4ef7100bca4f097d6ca10dbf40cf11aa9 /openecomp-be/lib/openecomp-sdc-validation-lib | |
parent | b4c4dbc6bbcd9995387c0716ee57f620c7a701df (diff) |
Add Tosca model healer
create a Tosca model healer for future changes in Tosca structure
Change-Id: I3843e4727b6bbb383576ae6a4fb055c5b6fa001f
Issue-ID: SDC-973
Signed-off-by: talio <tali.orenbach@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib')
-rw-r--r-- | openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/util/MessageContainerUtil.java | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/util/MessageContainerUtil.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/util/MessageContainerUtil.java index 8c78f4942b..aab83837b8 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/util/MessageContainerUtil.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/util/MessageContainerUtil.java @@ -44,7 +44,7 @@ public class MessageContainerUtil { return null; } Map<String, List<ErrorMessage>> filteredMessages = new HashMap<>(); - messages.entrySet().stream().forEach( + messages.entrySet().forEach( entry -> entry.getValue().stream().filter(message -> message.getLevel().equals(level)) .forEach(message -> addMessage(entry.getKey(), message, filteredMessages ))); @@ -53,11 +53,33 @@ public class MessageContainerUtil { private static void addMessage(String fileName, ErrorMessage message, Map<String, List<ErrorMessage>> messages) { - List<ErrorMessage> messageList = messages.get(fileName); - if (messageList == null) { - messageList = new ArrayList<>(); - messages.put(fileName, messageList); - } + List<ErrorMessage> messageList = messages.computeIfAbsent(fileName, k -> new ArrayList<>()); messageList.add(message); } + + public static String getErrorMessagesListAsString(Map<String, List<ErrorMessage>> messages) { + StringBuilder concatErrorMessage = new StringBuilder(); + + for (Map.Entry<String, List<ErrorMessage>> errorMessageEntry : messages.entrySet()) { + appendErrorMessageAsString(concatErrorMessage, errorMessageEntry.getKey(), + errorMessageEntry.getValue()); + } + return concatErrorMessage.toString(); + } + + private static void appendErrorMessageAsString(StringBuilder concatErrorMessage, + String fileName, + List<ErrorMessage> errorMessageList) { + for (ErrorMessage errorMessage : errorMessageList) { + addErrorMessage(concatErrorMessage, fileName, errorMessage); + } + } + + private static void addErrorMessage(StringBuilder concatErrorMessage, + String fileName, + ErrorMessage errorMessage) { + concatErrorMessage.append(fileName).append(" : "); + concatErrorMessage.append(errorMessage.getMessage()); + concatErrorMessage.append("\n"); + } } |