diff options
author | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2021-11-19 16:54:25 +0100 |
---|---|---|
committer | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2021-11-19 16:54:25 +0100 |
commit | 4b896fb742ce79793957077450a7ba815bf64a7a (patch) | |
tree | 096e389b4573226fea851a4a65971109d0280d89 /so-optimization-clients/src/test/java | |
parent | 469cd2266c732713b01ebbe4d31b2e7640f91dd7 (diff) |
add junit coverage
Issue-ID: SO-3796
Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
Change-Id: Ic499c0ec10548f1f2297b66f60faa99e6cd6dd6c
Diffstat (limited to 'so-optimization-clients/src/test/java')
-rw-r--r-- | so-optimization-clients/src/test/java/org/onap/so/client/sniro/SniroValidatorTest.java | 62 |
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"); + } + } +} |