X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=common%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fso%2Fclient%2Faai%2FAAIClientResponseExceptionMapperTest.java;h=7af36b0bdd58354f2f98a70ddcd9e10829be3b73;hb=f47919f1fe367b612fa9c96d34c59f01a541e882;hp=981a4ddacc2830d4378421e3b76273a6fd020fbb;hpb=54452b80a1cf4d22ef750bc1377f8c1b05431d57;p=so.git diff --git a/common/src/test/java/org/onap/so/client/aai/AAIClientResponseExceptionMapperTest.java b/common/src/test/java/org/onap/so/client/aai/AAIClientResponseExceptionMapperTest.java index 981a4ddacc..7af36b0bdd 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIClientResponseExceptionMapperTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIClientResponseExceptionMapperTest.java @@ -21,50 +21,48 @@ package org.onap.so.client.aai; import static org.junit.Assert.assertEquals; - import java.util.Arrays; import java.util.List; - import org.junit.Before; import org.junit.Test; import org.onap.so.client.aai.entities.AAIError; import org.onap.so.client.aai.entities.RequestError; import org.onap.so.client.aai.entities.ServiceException; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; public class AAIClientResponseExceptionMapperTest { - AAIClientResponseExceptionMapper mapper; - String errorMsg; - - @Before - public void before() { - mapper = new AAIClientResponseExceptionMapper(); - errorMsg = "Error calling A&AI. Request-Id=" + mapper.getRequestId() + " "; - } - - @Test - public void testExtractMessageWithEntity() throws JsonProcessingException { - ServiceException svcException = new ServiceException(); - svcException.setText("test %1 message - %2"); - svcException.setVariables(Arrays.asList("error", "service exception %1 test")); - - RequestError requestError = new RequestError(); - requestError.setServiceException(svcException); - - AAIError error = new AAIError(); - error.setRequestError(requestError); - - ObjectMapper objMapper = new ObjectMapper(); - String strRequestError = objMapper.writeValueAsString(error); + AAIClientResponseExceptionMapper mapper; + String errorMsg; + + @Before + public void before() { + mapper = new AAIClientResponseExceptionMapper(); + errorMsg = "Error calling A&AI. Request-Id=" + mapper.getRequestId() + " "; + } + + @Test + public void testExtractMessageWithEntity() throws JsonProcessingException { + ServiceException svcException = new ServiceException(); + svcException.setText("test %1 message - %2"); + svcException.setVariables(Arrays.asList("error", "service exception %1 test")); + + RequestError requestError = new RequestError(); + requestError.setServiceException(svcException); + + AAIError error = new AAIError(); + error.setRequestError(requestError); + + ObjectMapper objMapper = new ObjectMapper(); + String strRequestError = objMapper.writeValueAsString(error); + + assertEquals(errorMsg + "test error message - service exception error test", + mapper.extractMessage(strRequestError).get()); + } - assertEquals(errorMsg + "test error message - service exception error test", mapper.extractMessage(strRequestError).get()); - } - - @Test - public void testExtractMessageWithoutEntity() { - assertEquals(errorMsg, mapper.extractMessage("").get()); - } + @Test + public void testExtractMessageWithoutEntity() { + assertEquals(errorMsg, mapper.extractMessage("").get()); + } }