diff options
Diffstat (limited to 'bpmn/MSORESTClient/src/test/java')
-rw-r--r-- | bpmn/MSORESTClient/src/test/java/org/onap/so/rest/APIResponseTest.java (renamed from bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/APIResponseTest.java) | 36 | ||||
-rw-r--r-- | bpmn/MSORESTClient/src/test/java/org/onap/so/rest/HttpHeaderTest.java | 40 | ||||
-rw-r--r-- | bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java | 195 | ||||
-rw-r--r-- | bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTConfigTest.java | 42 | ||||
-rw-r--r-- | bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTExceptionTest.java | 40 | ||||
-rw-r--r-- | bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/HttpHeaderTest.java | 34 | ||||
-rw-r--r-- | bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTClientTest.java | 50 | ||||
-rw-r--r-- | bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTConfigTest.java | 42 | ||||
-rw-r--r-- | bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTExceptionTest.java | 37 |
9 files changed, 335 insertions, 181 deletions
diff --git a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/APIResponseTest.java b/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/APIResponseTest.java index 166a2ff52f..2c81fda32b 100644 --- a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/APIResponseTest.java +++ b/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/APIResponseTest.java @@ -1,24 +1,24 @@ /* * ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= */ -package org.openecomp.mso.rest; +package org.onap.so.rest; import static org.junit.Assert.assertEquals; @@ -54,4 +54,4 @@ public class APIResponseTest { assertEquals(1, apiResponse.getAllHeaders().length); assertEquals(49, apiResponse.getResponseBodyAsByteArray().length); } -}
\ No newline at end of file +} diff --git a/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/HttpHeaderTest.java b/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/HttpHeaderTest.java new file mode 100644 index 0000000000..bc096687b7 --- /dev/null +++ b/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/HttpHeaderTest.java @@ -0,0 +1,40 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.so.rest; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class HttpHeaderTest { + + @Test + public void test() { + HttpHeader hth= new HttpHeader("name", "value"); + assertEquals("name", hth.getName()); + assertEquals("value", hth.getValue()); + } + + @Test (expected = IllegalArgumentException.class) + public void testException() { + HttpHeader httpHeader = new HttpHeader(null, "value"); //null + } +} diff --git a/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java b/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java new file mode 100644 index 0000000000..bbdaa94581 --- /dev/null +++ b/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java @@ -0,0 +1,195 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.so.rest; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.delete; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.patch; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.spy; + +import org.json.JSONObject; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.springframework.http.HttpStatus; + +import com.github.tomakehurst.wiremock.junit.WireMockRule; + +public class RESTClientTest { + + private RESTClient restClient; + private JSONObject jsonPayload; + private JSONObject jsonResponse; + private String jsonObjectAsString; + private String jsonResponseAsString; + + @Rule + public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(28090)); + + @Before + public void before() throws Exception { + jsonPayload = new JSONObject(); + jsonPayload.put("firstName", "firstName1"); + jsonPayload.put("lastName", "lastName1"); + jsonObjectAsString = jsonPayload.toString(); + jsonResponse = new JSONObject(); + jsonResponse.put("response", "responseValue"); + jsonResponseAsString = jsonResponse.toString(); + restClient = new RESTClient("http://localhost:28090/example", "localhost", 28090); + } + + @Test + public void testHeadersParameters() throws Exception { + restClient.setHeader("name", "value"); + restClient.setParameter("name", "value"); + assertEquals("[value]", restClient.getParameters().get("name").toString()); + assertEquals("[value]", restClient.getHeaders().get("name").toString()); + restClient.setHeader("name", "value2"); + assertEquals("[value2]", restClient.getHeaders().get("name").toString()); + restClient.setParameter("name", "value2"); + assertEquals("[value2]", restClient.getParameters().get("name").toString()); + restClient.addParameter("name", "value"); + assertEquals(1, restClient.getParameters().size()); + restClient.addAuthorizationHeader("token"); + assertEquals("[token]", restClient.getHeaders().get("Authorization").toString()); + assertEquals("http://localhost:28090/example", restClient.getURL()); + restClient = new RESTClient("http://localhost:28090/example1"); + assertEquals("http://localhost:28090/example1", restClient.getURL()); + } + + @Test + public void testHttpPost() throws Exception { + RESTClient restClientMock = mock(RESTClient.class); + restClientMock = spy(restClient); + wireMockRule.stubFor(post(urlPathMatching("/example/*")) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + APIResponse apiResponse = restClientMock.httpPost(jsonObjectAsString); + assertEquals(200, apiResponse.getStatusCode()); + assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); + assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); + verify(restClientMock, times(2)).getURL(); + } + + @Test + public void testPost() throws Exception { + wireMockRule.stubFor(post(urlPathMatching("/example/*")) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + APIResponse apiResponse = restClient.post(); + assertEquals(200, apiResponse.getStatusCode()); + assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); + assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); + } + + @Test + public void testHttpPut() throws Exception { + wireMockRule.stubFor(put(urlPathMatching("/example/*")) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + restClient.setParameter("name", "value"); + APIResponse apiResponse = restClient.httpPut(jsonObjectAsString); + assertEquals(200, apiResponse.getStatusCode()); + assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); + assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); + + } + + @Test + public void testHttpPatch() throws Exception { + wireMockRule.stubFor(patch(urlPathMatching("/example/*")) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + APIResponse apiResponse = restClient.httpPatch(jsonObjectAsString); + assertEquals(200, apiResponse.getStatusCode()); + assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); + assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); + } + + @Test + public void testPatch_withParameter() throws Exception { + wireMockRule.stubFor(patch(urlPathMatching("/example/*")) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + restClient.setParameter("name", "value"); + APIResponse apiResponse = restClient.patch(jsonObjectAsString); + assertEquals(200, apiResponse.getStatusCode()); + assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); + assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); + } + + @Test + public void testHttpDelete_withPayload() throws Exception { + wireMockRule.stubFor(delete(urlPathMatching("/example/*")) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + APIResponse apiResponse = restClient.httpDelete(jsonObjectAsString); + assertEquals(200, apiResponse.getStatusCode()); + assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); + assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); + } + + @Test + public void testHttpDelete() throws Exception { + wireMockRule.stubFor(delete(urlPathMatching("/example/*")) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + APIResponse apiResponse = restClient.httpDelete(); + assertEquals(200, apiResponse.getStatusCode()); + assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); + assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); + } + + @Test + public void testDelete() throws Exception { + wireMockRule.stubFor(delete(urlPathMatching("/example/*")) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + APIResponse apiResponse = restClient.delete(); + assertEquals(200, apiResponse.getStatusCode()); + assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); + assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); + } + + @Test + public void testHttpGet() throws Exception { + wireMockRule.stubFor(get(urlPathMatching("/example/*")) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + APIResponse apiResponse = restClient.httpGet(); + assertEquals(200, apiResponse.getStatusCode()); + assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); + assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); + } + + @Test + public void testGet_withParameter() throws Exception { + wireMockRule.stubFor(get(urlPathMatching("/example/*")) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + restClient.setParameter("name", "value"); + restClient.setParameter("type", "valueType"); + APIResponse apiResponse = restClient.get(); + assertEquals(200, apiResponse.getStatusCode()); + assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); + assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); + } + +} diff --git a/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTConfigTest.java b/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTConfigTest.java new file mode 100644 index 0000000000..82c3c37be0 --- /dev/null +++ b/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTConfigTest.java @@ -0,0 +1,42 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.so.rest; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import org.junit.Test; + +public class RESTConfigTest { + + @Test + public void test() { + RESTConfig rcfg=mock(RESTConfig.class); + RESTConfig rcf=new RESTConfig("URL"); + RESTConfig rcfi=new RESTConfig("URL", true); + RESTConfig rcfo=new RESTConfig("URL", "10.2.3.101", 5020); + RESTConfig rcfn=new RESTConfig("URL", "10.2.3.101", 5020, true); + assert(rcfo.getProxyHost().equals("10.2.3.101")); + assertEquals(5020,rcfn.getProxyPort()); + assert(rcf.getURL().equals("URL")); + assertTrue(rcfn.trustAllCerts()); + } +} diff --git a/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTExceptionTest.java b/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTExceptionTest.java new file mode 100644 index 0000000000..19339a187d --- /dev/null +++ b/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTExceptionTest.java @@ -0,0 +1,40 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.so.rest; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import org.junit.Test; + +public class RESTExceptionTest { + + @Test + public void test() { + RESTException rexm=mock(RESTException.class); + RESTException rex=new RESTException("Error"); + RESTException recpt=new RESTException(200, "Error"); + assert(rex.getErrorMessage().equals("Error")); + assertEquals(200,recpt.getStatusCode()); + Throwable throwable = mock(Throwable.class); + RESTException restException = new RESTException(throwable); + assertEquals(-1, restException.getStatusCode()); + } +} diff --git a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/HttpHeaderTest.java b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/HttpHeaderTest.java deleted file mode 100644 index 29b7e15364..0000000000 --- a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/HttpHeaderTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= -*/ - -package org.openecomp.mso.rest; - -import static org.junit.Assert.assertEquals; -import org.junit.Test; - -public class HttpHeaderTest { - - @Test - public void test() { - HttpHeader hth= new HttpHeader("name", "value"); - assertEquals("name", hth.getName()); - assertEquals("value", hth.getValue()); - } -} diff --git a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTClientTest.java b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTClientTest.java deleted file mode 100644 index d3fd4f9ea5..0000000000 --- a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTClientTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= -*/ - -package org.openecomp.mso.rest; - -import static org.mockito.Mockito.mock; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import org.apache.http.HttpResponse; -import org.apache.http.message.AbstractHttpMessage; -import org.junit.Test; - -public class RESTClientTest { - - @Test - public void test()throws Exception{ - APIResponse apr=mock(APIResponse.class); - HttpResponse response=mock(HttpResponse.class); - AbstractHttpMessage httpMsg=mock(AbstractHttpMessage.class); - RESTClient cle=mock(RESTClient.class); - RESTClient rcl=new RESTClient("URL"); - RESTClient rcle=new RESTClient("URL", "10.5.3.126", 5020); - LinkedHashMap<String, List<String>> headers=new LinkedHashMap<>() ; - List<String>list=new ArrayList<>(); - list.add("value"); - headers.put("name", list); - rcle.setHeader("name", "value"); - rcle.setParameter("name", "value"); - assert(rcle.getHeaders()!=null); - assert(rcle.getParameters()!=null); - } -} diff --git a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTConfigTest.java b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTConfigTest.java deleted file mode 100644 index a64f112234..0000000000 --- a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTConfigTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= -*/ - -package org.openecomp.mso.rest; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import org.junit.Test; - -public class RESTConfigTest { - - @Test - public void test() { - RESTConfig rcfg=mock(RESTConfig.class); - RESTConfig rcf=new RESTConfig("URL"); - RESTConfig rcfi=new RESTConfig("URL", true); - RESTConfig rcfo=new RESTConfig("URL", "10.2.3.101", 5020); - RESTConfig rcfn=new RESTConfig("URL", "10.2.3.101", 5020, true); - assert(rcfo.getProxyHost().equals("10.2.3.101")); - assertEquals(5020,rcfn.getProxyPort()); - assert(rcf.getURL().equals("URL")); - assertTrue(rcfn.trustAllCerts()); - } -} diff --git a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTExceptionTest.java b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTExceptionTest.java deleted file mode 100644 index de2cd0f608..0000000000 --- a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTExceptionTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= -*/ - -package org.openecomp.mso.rest; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import org.junit.Test; - -public class RESTExceptionTest { - - @Test - public void test() { - RESTException rexm=mock(RESTException.class); - RESTException rex=new RESTException("Error"); - RESTException recpt=new RESTException(200, "Error"); - assert(rex.getErrorMessage().equals("Error")); - assertEquals(200,recpt.getStatusCode()); - } -} |