aboutsummaryrefslogtreecommitdiffstats
path: root/so-optimization-clients/src/test
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2022-01-20 10:32:21 +0000
committerGerrit Code Review <gerrit@onap.org>2022-01-20 10:32:21 +0000
commit0da0a72c8ea247aeca0f3afe280c9e6d8f87bdb6 (patch)
treece4e429c012e856d19d9936429752c93877bcd1f /so-optimization-clients/src/test
parentf65448561b7c062c73c5d562e196c82b0e94e207 (diff)
parent4b896fb742ce79793957077450a7ba815bf64a7a (diff)
Merge "add junit coverage"
Diffstat (limited to 'so-optimization-clients/src/test')
-rw-r--r--so-optimization-clients/src/test/java/org/onap/so/client/sniro/SniroValidatorTest.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/so-optimization-clients/src/test/java/org/onap/so/client/sniro/SniroValidatorTest.java b/so-optimization-clients/src/test/java/org/onap/so/client/sniro/SniroValidatorTest.java
new file mode 100644
index 0000000000..8288d70c21
--- /dev/null
+++ b/so-optimization-clients/src/test/java/org/onap/so/client/sniro/SniroValidatorTest.java
@@ -0,0 +1,62 @@
+package org.onap.so.client.sniro;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.junit.Test;
+import org.onap.so.client.exception.BadResponseException;
+
+public class SniroValidatorTest {
+
+ @Test
+ public void validateDemandsResponse_success() throws BadResponseException {
+ Map<String, Object> testMap = new LinkedHashMap<>();
+ testMap.put("requestStatus", "accepted");
+ new SniroValidator().validateDemandsResponse(testMap);
+ }
+
+ @Test
+ public void validateDemandsResponse_emptyResponse() {
+ try {
+ new SniroValidator().validateDemandsResponse(new LinkedHashMap<>());
+ } catch (BadResponseException e) {
+ assertThat(e.getMessage()).contains("Sniro Managers synchronous response is empty");
+ }
+ }
+
+ @Test
+ public void validateDemandsResponse_responseWithErrorMessage() {
+ String message = "An error occurred";
+ Map<String, Object> testMap = new LinkedHashMap<>();
+ testMap.put("requestStatus", "not_accepted");
+ testMap.put("statusMessage", message);
+ try {
+ new SniroValidator().validateDemandsResponse(testMap);
+ } catch (BadResponseException e) {
+ assertThat(e.getMessage()).contains("Sniro Managers synchronous response indicates failed: " + message);
+ }
+ }
+
+ @Test
+ public void validateDemandsResponse_responseWithoutMessage() {
+ Map<String, Object> testMap = new LinkedHashMap<>();
+ testMap.put("requestStatus", "not_accepted");
+ testMap.put("statusMessage", "");
+ try {
+ new SniroValidator().validateDemandsResponse(testMap);
+ } catch (BadResponseException e) {
+ assertThat(e.getMessage()).contains("error message not provided");
+ }
+ }
+
+ @Test
+ public void validateDemandsResponse_responseWithoutRequestStatus() {
+ Map<String, Object> testMap = new LinkedHashMap<>();
+ testMap.put("statusMessage", "");
+ try {
+ new SniroValidator().validateDemandsResponse(testMap);
+ } catch (BadResponseException e) {
+ assertThat(e.getMessage()).contains("Sniro Managers synchronous response does not contain: request status");
+ }
+ }
+}