From 4b896fb742ce79793957077450a7ba815bf64a7a Mon Sep 17 00:00:00 2001 From: Lukasz Muszkieta Date: Fri, 19 Nov 2021 16:54:25 +0100 Subject: add junit coverage Issue-ID: SO-3796 Signed-off-by: Lukasz Muszkieta Change-Id: Ic499c0ec10548f1f2297b66f60faa99e6cd6dd6c --- .../onap/so/client/sniro/SniroValidatorTest.java | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 so-optimization-clients/src/test/java/org/onap/so/client/sniro/SniroValidatorTest.java (limited to 'so-optimization-clients/src/test') 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 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 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 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 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"); + } + } +} -- cgit 1.2.3-korg