diff options
author | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2022-02-21 18:34:47 +0100 |
---|---|---|
committer | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2022-02-21 18:34:47 +0100 |
commit | 5bc16ef8b851d7bf0c2c709ddb6fb2fba21e4867 (patch) | |
tree | b96353cf4a083323545bfbdfe99cbcac862f8062 /so-optimization-clients/src | |
parent | 8b0276d4f5b0d7a1a9167916b027b795f86d44e5 (diff) |
add junit coverage
Issue-ID: SO-3796
Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
Change-Id: I018ecc1b3eb8a8252f8b88dca928d830abb4af14
Diffstat (limited to 'so-optimization-clients/src')
-rw-r--r-- | so-optimization-clients/src/test/java/org/onap/so/client/sniro/SniroValidatorTest.java | 88 |
1 files changed, 88 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 index 8288d70c21..9ad22ce492 100644 --- 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 @@ -59,4 +59,92 @@ public class SniroValidatorTest { assertThat(e.getMessage()).contains("Sniro Managers synchronous response does not contain: request status"); } } + + @Test + public void validateSolution_success() throws BadResponseException { + SniroValidator.validateSolution("{statusMessage:key}"); + } + + @Test + public void validateSolution_emptyResponse() { + try { + SniroValidator.validateSolution(""); + } catch (BadResponseException e) { + assertThat(e.getMessage()).contains("Sniro Managers asynchronous response is empty"); + } + } + + @Test + public void validateSolution_errorResponseWithoutMessage() { + try { + SniroValidator.validateSolution("{\"serviceException\":{\"text\":\"\"}}"); + } catch (BadResponseException e) { + assertThat(e.getMessage()).contains( + "Sniro Managers asynchronous response contains a service exception: error message not provided"); + } + } + + @Test + public void validateSolution_errorResponseWithErrorMessage() { + String message = "An error occurred"; + try { + SniroValidator.validateSolution("{\"serviceException\":{\"text\":\"" + message + "\"}}"); + } catch (BadResponseException e) { + assertThat(e.getMessage()) + .contains("Sniro Managers asynchronous response contains a service exception: " + message); + } + } + + @Test + public void validateReleaseResponse_success() throws BadResponseException { + Map<String, Object> testMap = new LinkedHashMap<>(); + testMap.put("status", "success"); + new SniroValidator().validateReleaseResponse(testMap); + } + + @Test + public void validateReleaseResponse_emptyResponse() { + try { + new SniroValidator().validateReleaseResponse(new LinkedHashMap<>()); + } catch (BadResponseException e) { + assertThat(e.getMessage()).contains("Sniro Conductors response is empty"); + } + } + + @Test + public void validateReleaseResponse_errorResponseWithErrorMessage() { + String message = "An error occurred"; + Map<String, Object> testMap = new LinkedHashMap<>(); + testMap.put("status", "failed"); + testMap.put("message", message); + try { + new SniroValidator().validateReleaseResponse(testMap); + } catch (BadResponseException e) { + assertThat(e.getMessage()).contains("Sniro Conductors synchronous response indicates failed: " + message); + } + } + + @Test + public void validateReleaseResponse_errorResponseWithNoMessage() { + Map<String, Object> testMap = new LinkedHashMap<>(); + testMap.put("status", "failed"); + testMap.put("message", ""); + try { + new SniroValidator().validateReleaseResponse(testMap); + } catch (BadResponseException e) { + assertThat(e.getMessage()) + .contains("Sniro Conductors synchronous response indicates failed: error message not provided"); + } + } + + @Test + public void validateReleaseResponse_responseWithoutStatus() { + Map<String, Object> testMap = new LinkedHashMap<>(); + testMap.put("statusMessage", ""); + try { + new SniroValidator().validateReleaseResponse(testMap); + } catch (BadResponseException e) { + assertThat(e.getMessage()).contains("Sniro Conductors synchronous response does not contain: status"); + } + } } |