From 9725138e6882182c50cbac79ace5d66774a17619 Mon Sep 17 00:00:00 2001 From: pwielebs Date: Tue, 3 Apr 2018 12:12:43 +0200 Subject: Http put added Change-Id: Id21b799a35b531c30f0c1b5df5c6daac6fd56e92 Issue-ID: DCAEGEN2-407 Signed-off-by: pwielebs --- .../service/AAIExtendedHttpClientImplTest.java | 131 +++++++++++++++++++++ .../services/service/AAIHttpClientImplTest.java | 57 +++++++++ .../config/AAIHttpClientConfigurationTest.java | 58 +++++++++ .../service/utils/HttpRequestDetailsTest.java | 60 ++++++++++ .../services/service/utils/HttpUtilsTest.java | 42 +++++++ .../service/AAIExtendedHttpClientImplTest.java | 84 ------------- .../services/service/AAIHttpClientImplTest.java | 56 --------- .../services/service/utils/HTTPConfiguration.java | 62 ---------- .../java/services/service/utils/HttpUtilsTest.java | 42 ------- 9 files changed, 348 insertions(+), 244 deletions(-) create mode 100644 prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIExtendedHttpClientImplTest.java create mode 100644 prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIHttpClientImplTest.java create mode 100644 prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/config/AAIHttpClientConfigurationTest.java create mode 100644 prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/utils/HttpRequestDetailsTest.java create mode 100644 prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/utils/HttpUtilsTest.java delete mode 100644 prh-aai-client/src/test/java/services/service/AAIExtendedHttpClientImplTest.java delete mode 100644 prh-aai-client/src/test/java/services/service/AAIHttpClientImplTest.java delete mode 100644 prh-aai-client/src/test/java/services/service/utils/HTTPConfiguration.java delete mode 100644 prh-aai-client/src/test/java/services/service/utils/HttpUtilsTest.java (limited to 'prh-aai-client/src/test/java') diff --git a/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIExtendedHttpClientImplTest.java b/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIExtendedHttpClientImplTest.java new file mode 100644 index 00000000..e114bbfd --- /dev/null +++ b/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIExtendedHttpClientImplTest.java @@ -0,0 +1,131 @@ +/*- + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2018 NOKIA 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.onap.dcaegen2.services.service; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import org.apache.http.client.ResponseHandler; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPut; +import org.apache.http.impl.client.CloseableHttpClient; +import org.junit.jupiter.api.*; +import org.onap.dcaegen2.services.config.AAIHttpClientConfiguration; +import org.onap.dcaegen2.services.utils.HttpRequestDetails; +import org.onap.dcaegen2.services.utils.RequestVerbs; + +public class AAIExtendedHttpClientImplTest { + + private static AAIExtendedHttpClientImpl testedObject; + private static AAIHttpClientConfiguration aaiHttpClientConfigurationMock = mock(AAIHttpClientConfiguration.class); + private static CloseableHttpClient closeableHttpClientMock = mock(CloseableHttpClient.class); + private static HttpRequestDetails httpRequestDetailsMock = mock(HttpRequestDetails.class); + private static Optional expectedResult = Optional.empty(); + + @BeforeAll + public static void init() throws NoSuchFieldException, IllegalAccessException { + + Map queryParams = new HashMap<>(); + queryParams.put("ipaddress-v4-oam", "11.22.33.44"); + + Map AAI_HEADERS = new HashMap<>(); + AAI_HEADERS.put("X-FromAppId", "prh"); + AAI_HEADERS.put("X-TransactionId", "vv-temp"); + AAI_HEADERS.put("Accept", "application/json"); + AAI_HEADERS.put("Real-Time", "true"); + AAI_HEADERS.put("Content-Type", "application/json"); + + when(aaiHttpClientConfigurationMock.aaiHost()).thenReturn("54.45.33.2"); + when(aaiHttpClientConfigurationMock.aaiProtocol()).thenReturn("https"); + when(aaiHttpClientConfigurationMock.aaiHostPortNumber()).thenReturn(1234); + when(aaiHttpClientConfigurationMock.aaiUserName()).thenReturn("PRH"); + when(aaiHttpClientConfigurationMock.aaiUserPassword()).thenReturn("PRH"); + + when(httpRequestDetailsMock.aaiAPIPath()).thenReturn("/aai/v11/network/pnfs/pnf/NOKQTFCOC540002E"); + when(httpRequestDetailsMock.headers()).thenReturn(AAI_HEADERS); + when(httpRequestDetailsMock.queryParameters()).thenReturn(queryParams); + + testedObject = new AAIExtendedHttpClientImpl(aaiHttpClientConfigurationMock); + setField(); + } + + @AfterAll + public static void teardown() { + testedObject = null; + aaiHttpClientConfigurationMock = null; + closeableHttpClientMock = null; + httpRequestDetailsMock = null; + expectedResult = null; + } + + @Test + public void getHttpResponseGet_success() throws IOException { + when(httpRequestDetailsMock.requestVerb()).thenReturn(RequestVerbs.GET); + + expectedResult = Optional.of("getExtendedDetailsOK"); + + when(closeableHttpClientMock.execute(any(HttpGet.class), any(ResponseHandler.class))). + thenReturn(expectedResult); + Optional actualResult = testedObject.getHttpResponse(httpRequestDetailsMock); + + Assertions.assertEquals(expectedResult.get(), actualResult.get()); + } + + @Test + public void getHttpResponsePut_success() throws IOException { + when(httpRequestDetailsMock.requestVerb()).thenReturn(RequestVerbs.PUT); + + expectedResult = Optional.of("getExtendedDetailsOK"); + + when(closeableHttpClientMock.execute(any(HttpPut.class), any(ResponseHandler.class))). + thenReturn(expectedResult); + Optional actualResult = testedObject.getHttpResponse(httpRequestDetailsMock); + + Assertions.assertEquals(expectedResult.get(), actualResult.get()); + } + + @Test + public void getExtendedDetails_returnsNull() throws IOException { + when(httpRequestDetailsMock.requestVerb()).thenReturn(RequestVerbs.GET); + when(closeableHttpClientMock.execute(any(HttpGet.class), any(ResponseHandler.class))). + thenReturn(Optional.empty()); + Optional actualResult = testedObject.getHttpResponse(httpRequestDetailsMock); + Assertions.assertEquals(Optional.empty(),actualResult); + } + + @Test + public void getHttpResponsePut_failure() { + when(httpRequestDetailsMock.requestVerb()).thenReturn(RequestVerbs.PUT); + + } + + private static void setField() throws NoSuchFieldException, IllegalAccessException { + Field field = testedObject.getClass().getDeclaredField("closeableHttpClient"); + field.setAccessible(true); + field.set(testedObject, closeableHttpClientMock); + } +} diff --git a/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIHttpClientImplTest.java b/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIHttpClientImplTest.java new file mode 100644 index 00000000..d26e6afa --- /dev/null +++ b/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIHttpClientImplTest.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2018 NOKIA 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.onap.dcaegen2.services.service; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.onap.dcaegen2.services.config.AAIHttpClientConfiguration; + +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + + +public class AAIHttpClientImplTest { + + private static AAIHttpClientImpl testedObject; + private static AAIHttpClientConfiguration aaiHttpClientConfigurationMock; + + + @BeforeAll + public static void setup() { + aaiHttpClientConfigurationMock = mock(AAIHttpClientConfiguration.class); + when(aaiHttpClientConfigurationMock.aaiHost()).thenReturn("54.45.33.2"); + when(aaiHttpClientConfigurationMock.aaiProtocol()).thenReturn("https"); + when(aaiHttpClientConfigurationMock.aaiHostPortNumber()).thenReturn(1234); + when(aaiHttpClientConfigurationMock.aaiUserName()).thenReturn("PNF"); + when(aaiHttpClientConfigurationMock.aaiUserPassword()).thenReturn("PNF"); + when(aaiHttpClientConfigurationMock.aaiIgnoreSSLCertificateErrors()).thenReturn(true); + + + testedObject = new AAIHttpClientImpl(aaiHttpClientConfigurationMock); + } + + @Test + public void getAAIHttpClientObject_shouldNotBeNull() { + testedObject.getAAIHttpClient(); + assertNotNull(testedObject.getAAIHttpClient()); + } +} + diff --git a/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/config/AAIHttpClientConfigurationTest.java b/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/config/AAIHttpClientConfigurationTest.java new file mode 100644 index 00000000..a759aca5 --- /dev/null +++ b/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/config/AAIHttpClientConfigurationTest.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2018 NOKIA 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.onap.dcaegen2.services.service.config; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.onap.dcaegen2.services.config.AAIHttpClientConfiguration; +import org.onap.dcaegen2.services.config.ImmutableAAIHttpClientConfiguration; + +public class AAIHttpClientConfigurationTest { + + private static AAIHttpClientConfiguration client; + private static final String AAI_HOST = "/aai/v11/network/pnfs/pnf/NOKQTFCOC540002E"; + private static final Integer PORT = 1234; + private static final String PROTOCOL = "https"; + private static final String USER_NAME_PASSWORD = "PRH"; + + @BeforeAll + public static void init() { + client = ImmutableAAIHttpClientConfiguration.builder() + .aaiHost(AAI_HOST) + .aaiHostPortNumber(PORT) + .aaiProtocol(PROTOCOL) + .aaiUserName(USER_NAME_PASSWORD) + .aaiUserPassword(USER_NAME_PASSWORD) + .aaiIgnoreSSLCertificateErrors(true) + .build(); + } + + @Test + public void testGetters_success() { + Assertions.assertEquals(AAI_HOST,client.aaiHost()); + Assertions.assertEquals(PORT, client.aaiHostPortNumber()); + Assertions.assertEquals(PROTOCOL,client.aaiProtocol()); + Assertions.assertEquals(USER_NAME_PASSWORD, client.aaiUserName()); + Assertions.assertEquals(USER_NAME_PASSWORD, client.aaiUserPassword()); + Assertions.assertEquals(true, client.aaiIgnoreSSLCertificateErrors()); + } +} diff --git a/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/utils/HttpRequestDetailsTest.java b/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/utils/HttpRequestDetailsTest.java new file mode 100644 index 00000000..36105d05 --- /dev/null +++ b/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/utils/HttpRequestDetailsTest.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2018 NOKIA 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.onap.dcaegen2.services.service.utils; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import org.onap.dcaegen2.services.utils.HttpRequestDetails; +import org.onap.dcaegen2.services.utils.ImmutableHttpRequestDetails; +import org.onap.dcaegen2.services.utils.RequestVerbs; + + +public class HttpRequestDetailsTest { + + private static HttpRequestDetails testObject; + + private static final String AAI_PATH = "aaiPathTest"; + private static final RequestVerbs HTTP_VERB = RequestVerbs.GET; + private static final String QUERY_KEY1 = "queryKey1"; + private static final String QUERY_VALUE1 = "queryValue1"; + private static final String HEADERS_KEY1 = "headersKey1"; + private static final String HEADERS_VALUE1 = "headersValue1"; + + @BeforeAll + public static void init() { + testObject = ImmutableHttpRequestDetails.builder() + .aaiAPIPath(AAI_PATH) + .requestVerb(HTTP_VERB) + .putQueryParameters(QUERY_KEY1,QUERY_VALUE1) + .putHeaders(HEADERS_KEY1,HEADERS_VALUE1) + .build(); + } + + @Test + public void testGetters_success() { + Assertions.assertEquals(AAI_PATH, testObject.aaiAPIPath()); + Assertions.assertEquals(HEADERS_VALUE1, testObject.headers().get(HEADERS_KEY1)); + Assertions.assertEquals(QUERY_VALUE1, testObject.queryParameters().get(QUERY_KEY1)); + Assertions.assertEquals(RequestVerbs.GET, testObject.requestVerb()); + } +} diff --git a/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/utils/HttpUtilsTest.java b/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/utils/HttpUtilsTest.java new file mode 100644 index 00000000..53b31da2 --- /dev/null +++ b/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/utils/HttpUtilsTest.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2018 NOKIA 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.onap.dcaegen2.services.service.utils; + +import org.apache.http.HttpStatus; +import org.junit.Test; +import org.onap.dcaegen2.services.utils.HttpUtils; + +import static junit.framework.TestCase.assertFalse; +import static junit.framework.TestCase.assertTrue; + + +public class HttpUtilsTest { + + @Test + public void isSuccessfulResponseCode_shouldReturnTrue() { + assertTrue(HttpUtils.isSuccessfulResponseCode(HttpUtils.SC_ACCEPTED)); + } + + @Test + public void isSuccessfulResponseCode_shouldReturnFalse() { + assertFalse(HttpUtils.isSuccessfulResponseCode(HttpStatus.SC_BAD_GATEWAY)); + } +} \ No newline at end of file diff --git a/prh-aai-client/src/test/java/services/service/AAIExtendedHttpClientImplTest.java b/prh-aai-client/src/test/java/services/service/AAIExtendedHttpClientImplTest.java deleted file mode 100644 index c46e034c..00000000 --- a/prh-aai-client/src/test/java/services/service/AAIExtendedHttpClientImplTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 NOKIA 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 services.service; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import org.apache.http.client.ResponseHandler; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import services.config.AAIHttpClientConfiguration; - -public class AAIExtendedHttpClientImplTest { - - private AAIExtendedHttpClientImpl testedObject; - private AAIHttpClientConfiguration aaiHttpClientConfigurationMock = mock(AAIHttpClientConfiguration.class); - private CloseableHttpClient closeableHttpClientMock = mock(CloseableHttpClient.class); - - @Before - public void init() throws NoSuchFieldException, IllegalAccessException { - when(aaiHttpClientConfigurationMock.aaiHost()).thenReturn("hostTest"); - when(aaiHttpClientConfigurationMock.aaiProtocol()).thenReturn("https"); - when(aaiHttpClientConfigurationMock.aaiHostPortNumber()).thenReturn(1234); - testedObject = new AAIExtendedHttpClientImpl(aaiHttpClientConfigurationMock); - setField(); - } - - @Test - public void getExtendedDetails_success() throws IOException { - String expectedResult = "getExtendedDetailsOK"; - Map queryParams = new HashMap<>(); - queryParams.put("key1", "value1"); - Map headers = new HashMap<>(); - headers.put("headerKey", "headerValue"); - - when(closeableHttpClientMock.execute(any(HttpGet.class), any(ResponseHandler.class))). - thenReturn(Optional.of(expectedResult)); - String actualResult = testedObject.getExtendedDetails("testPath", queryParams, headers); - Assert.assertEquals(expectedResult, actualResult); - } - - @Test - public void getExtendedDetails_returnsNull() throws IOException { - when(closeableHttpClientMock.execute(any(HttpGet.class), any(ResponseHandler.class))). - thenReturn(Optional.empty()); - String actualResult = testedObject.getExtendedDetails("testPath", new HashMap<>(), new HashMap<>()); - Assert.assertNull(actualResult); - } - - private void setField() throws NoSuchFieldException, IllegalAccessException { - Field field = testedObject.getClass().getDeclaredField("closeableHttpClient"); - field.setAccessible(true); - field.set(testedObject, closeableHttpClientMock); - } - - -} diff --git a/prh-aai-client/src/test/java/services/service/AAIHttpClientImplTest.java b/prh-aai-client/src/test/java/services/service/AAIHttpClientImplTest.java deleted file mode 100644 index 242e56d4..00000000 --- a/prh-aai-client/src/test/java/services/service/AAIHttpClientImplTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 NOKIA 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 services.service; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import services.config.AAIHttpClientConfiguration; -import services.service.utils.HTTPConfiguration; - -import static org.junit.Assert.assertNotNull; - - -public class AAIHttpClientImplTest { - - private AAIHttpClientImpl aaiHttpClientImpl; - private AAIHttpClientConfiguration aaiHttpClientConfiguration; - - - @Before - public void setup() { - aaiHttpClientConfiguration = new HTTPConfiguration(); - aaiHttpClientImpl = new AAIHttpClientImpl(aaiHttpClientConfiguration); - } - - @After - public void teaDown() { - aaiHttpClientImpl = null; - } - - @Test - public void getAAIHttpClientObject_shouldNotBeNull() { - aaiHttpClientImpl.getAAIHttpClient(); - assertNotNull(aaiHttpClientImpl.getAAIHttpClient()); - } - -} - diff --git a/prh-aai-client/src/test/java/services/service/utils/HTTPConfiguration.java b/prh-aai-client/src/test/java/services/service/utils/HTTPConfiguration.java deleted file mode 100644 index 82f656d9..00000000 --- a/prh-aai-client/src/test/java/services/service/utils/HTTPConfiguration.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 NOKIA 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 services.service.utils; - -import services.config.AAIHttpClientConfiguration; - -public class HTTPConfiguration extends AAIHttpClientConfiguration { - - private static final String AAI_HOST_NAME = "1.2.3.4"; - private static final Integer AAI_HOST_PORT_NUMBER = 1234; - private static final String AAI_HOST_PROTOCOL = "https"; - private static final String AAI_USER_NAME = "PRH"; - private static final String AAI_USER_PASS = "PRH"; - - @Override - public String aaiHost() { - return AAI_HOST_NAME; - } - - @Override - public Integer aaiHostPortNumber() { - return AAI_HOST_PORT_NUMBER; - } - - @Override - public String aaiProtocol() { - return AAI_HOST_PROTOCOL; - } - - @Override - public String aaiUserName() { - return AAI_USER_NAME; - } - - @Override - public String aaiUserPassword() { - return AAI_USER_PASS; - } - - @Override - public Boolean aaiIgnoreSSLCertificateErrors() { - return true; - } -} \ No newline at end of file diff --git a/prh-aai-client/src/test/java/services/service/utils/HttpUtilsTest.java b/prh-aai-client/src/test/java/services/service/utils/HttpUtilsTest.java deleted file mode 100644 index d54b335b..00000000 --- a/prh-aai-client/src/test/java/services/service/utils/HttpUtilsTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 NOKIA 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 services.service.utils; - -import org.apache.http.HttpStatus; -import org.junit.Test; -import services.utils.HttpUtils; - -import static junit.framework.TestCase.assertFalse; -import static junit.framework.TestCase.assertTrue; - - -public class HttpUtilsTest { - - @Test - public void isSuccessfulResponseCode_shouldReturnTrue() { - assertTrue(HttpUtils.isSuccessfulResponseCode(HttpUtils.SC_ACCEPTED)); - } - - @Test - public void isSuccessfulResponseCode_shouldReturnFalse() { - assertFalse(HttpUtils.isSuccessfulResponseCode(HttpStatus.SC_BAD_GATEWAY)); - } -} \ No newline at end of file -- cgit 1.2.3-korg