From 8727de26783eb496703bb82280ddad0e328964cb Mon Sep 17 00:00:00 2001 From: Bartosz Gardziejewski Date: Tue, 15 Dec 2020 11:59:21 +0100 Subject: Fix validation of error messages. Signed-off-by: Bartosz Gardziejewski Change-Id: Id0e83041823558a56932286895363503f77f6de4 Issue-ID: VNFSDK-715 --- .../cli/OnapCliValidationResponseWrapper.java | 26 ++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/csarvalidation/src/test/java/org/onap/functional/cli/OnapCliValidationResponseWrapper.java b/csarvalidation/src/test/java/org/onap/functional/cli/OnapCliValidationResponseWrapper.java index d011a6e..f48e3cf 100644 --- a/csarvalidation/src/test/java/org/onap/functional/cli/OnapCliValidationResponseWrapper.java +++ b/csarvalidation/src/test/java/org/onap/functional/cli/OnapCliValidationResponseWrapper.java @@ -17,8 +17,10 @@ package org.onap.functional.cli; +import java.util.Arrays; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; public class OnapCliValidationResponseWrapper { @@ -72,13 +74,33 @@ public class OnapCliValidationResponseWrapper { public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - return o.hashCode() == this.hashCode(); + List m1 = prepareMessages((ValidationErrorWrapper) o); + List m2 = prepareMessages(this); + return o.hashCode() == this.hashCode() && m1.containsAll(m2); + } + + private List prepareMessages(ValidationErrorWrapper other) { + return Arrays.stream(other.message.split(" ")) + .map(it -> it.replaceAll("[\\[\\](){},]", "")) + .collect(Collectors.toList()); } @Override public int hashCode() { - return Objects.hash(vnfreqNo, code, message, file, lineNumber); + return Objects.hash(vnfreqNo, code, file, lineNumber); + } + + @Override + public String toString() { + return "ValidationErrorWrapper{" + + "vnfreqNo='" + vnfreqNo + '\'' + + ", code='" + code + '\'' + + ", message='" + message + '\'' + + ", file='" + file + '\'' + + ", lineNumber='" + lineNumber + '\'' + + '}'; } + } } } -- cgit 1.2.3-korg