add junit coverage 90/125290/1
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>
Sun, 24 Oct 2021 17:59:03 +0000 (19:59 +0200)
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>
Sun, 24 Oct 2021 17:59:46 +0000 (19:59 +0200)
Issue-ID: SO-3796
Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
Change-Id: Iaf63f2e80da64795b2c4be107e2288bc36db228b

so-optimization-clients/src/test/java/org/onap/so/client/oof/OofValidatorTest.java

index 5f9be78..eaea1ab 100644 (file)
 
 package org.onap.so.client.oof;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
+import org.apache.logging.log4j.util.Strings;
 import org.junit.Test;
 import org.onap.so.client.exception.BadResponseException;
 
@@ -55,4 +58,41 @@ public class OofValidatorTest {
         map.put("statusMessage", "a");
         new OofValidator().validateDemandsResponse(map);
     }
+
+    @Test
+    public void validateSolution_success() throws Exception {
+        String json = "{\"value\" : \"test1\"}";
+        new OofValidator().validateSolution(json);
+    }
+
+    @Test
+    public void validateSolution_EmptyResponse() {
+        try {
+            new OofValidator().validateSolution("");
+        } catch (BadResponseException e) {
+            assertThat(e.getMessage()).contains("oofs asynchronous response is empty");
+        }
+    }
+
+    @Test
+    public void validateSolution_serviceExceptionWithMessage() {
+        String json = "{\"serviceException\" : {\"text\" : \"serviceExceptionOccurred\"}}";
+        try {
+            new OofValidator().validateSolution(json);
+            fail("Exception should be thrown");
+        } catch (BadResponseException e) {
+            assertThat(e.getMessage()).contains("serviceExceptionOccurred");
+        }
+    }
+
+    @Test
+    public void validateSolution_serviceExceptionWithEmptyMessage() {
+        String json = "{\"serviceException\" : {\"text\" : \"\"}}";
+        try {
+            new OofValidator().validateSolution(json);
+            fail("Exception should be thrown");
+        } catch (BadResponseException e) {
+            assertThat(e.getMessage()).contains("error message not provided");
+        }
+    }
 }