aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2021-12-13 23:06:25 +0000
committerGerrit Code Review <gerrit@onap.org>2021-12-13 23:06:25 +0000
commit2b0b48d02171fa096ac5f1847ab8452bb784b468 (patch)
tree950100d72ac29b2c85d0f3b818584bc1c686b46f
parent5724c4f084e48c93004d0c0f3c0ebbffc0f34d52 (diff)
parent495cc9edd0958c675ca4428f6ecfbf9850c9cf2f (diff)
Merge "add junit coverage"
-rw-r--r--so-optimization-clients/src/test/java/org/onap/so/client/oof/OofValidatorTest.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/so-optimization-clients/src/test/java/org/onap/so/client/oof/OofValidatorTest.java b/so-optimization-clients/src/test/java/org/onap/so/client/oof/OofValidatorTest.java
index 5f9be78491..eaea1abeaa 100644
--- a/so-optimization-clients/src/test/java/org/onap/so/client/oof/OofValidatorTest.java
+++ b/so-optimization-clients/src/test/java/org/onap/so/client/oof/OofValidatorTest.java
@@ -20,10 +20,13 @@
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");
+ }
+ }
}