summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--prh-aai-client/src/main/java/org/onap/dcaegen2/services/config/AAIClientConfiguration.java (renamed from prh-aai-client/src/main/java/org/onap/dcaegen2/services/config/AAIHttpClientConfiguration.java)3
-rw-r--r--prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIClient.java (renamed from prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIHttpClient.java)2
-rw-r--r--prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIClientImpl.java (renamed from prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIHttpClientImpl.java)10
-rw-r--r--prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIConsumerClient.java133
-rw-r--r--prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIProducerClient.java (renamed from prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIExtendedHttpClientImpl.java)73
-rw-r--r--prh-aai-client/src/main/java/org/onap/dcaegen2/services/utils/HttpRequestDetails.java5
-rw-r--r--prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIConsumerClientTest.java92
-rw-r--r--prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIHttpClientImplTest.java10
-rw-r--r--prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIProducerClientTest.java (renamed from prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIExtendedHttpClientImplTest.java)98
-rw-r--r--prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/config/AAIHttpClientConfigurationTest.java8
-rw-r--r--prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/utils/HttpRequestDetailsTest.java10
-rw-r--r--prh-app-server/pom.xml5
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java164
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java4
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java73
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java1
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java1
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTask.java30
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskImpl.java89
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTask.java (renamed from prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTask.java)2
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImpl.java (renamed from prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskImpl.java)37
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java5
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java5
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java14
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/IT/ScheduledXmlContextITest.java11
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java10
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskSpy.java44
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskSpy.java16
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduleControllerSpy.java7
29 files changed, 642 insertions, 320 deletions
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/config/AAIHttpClientConfiguration.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/config/AAIClientConfiguration.java
index f9cbeb19..60a022b4 100644
--- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/config/AAIHttpClientConfiguration.java
+++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/config/AAIClientConfiguration.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.dcaegen2.services.config;
@@ -30,7 +31,7 @@ import org.springframework.stereotype.Component;
@Value.Immutable(prehash = true)
@Value.Style(builder = "new")
@Gson.TypeAdapters
-public abstract class AAIHttpClientConfiguration implements Serializable {
+public abstract class AAIClientConfiguration implements Serializable {
private static final long serialVersionUID = 1L;
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIHttpClient.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIClient.java
index c60027c2..33a8d644 100644
--- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIHttpClient.java
+++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIClient.java
@@ -23,7 +23,7 @@ package org.onap.dcaegen2.services.service;
import org.apache.http.impl.client.CloseableHttpClient;
@FunctionalInterface
-public interface AAIHttpClient {
+public interface AAIClient {
CloseableHttpClient getAAIHttpClient();
}
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIHttpClientImpl.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIClientImpl.java
index 90b551db..c2b40b9a 100644
--- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIHttpClientImpl.java
+++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIClientImpl.java
@@ -31,7 +31,7 @@ import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.ssl.TrustStrategy;
-import org.onap.dcaegen2.services.config.AAIHttpClientConfiguration;
+import org.onap.dcaegen2.services.config.AAIClientConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -40,14 +40,14 @@ import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
-public class AAIHttpClientImpl implements AAIHttpClient {
+public class AAIClientImpl implements AAIClient {
- Logger logger = LoggerFactory.getLogger(AAIHttpClientImpl.class);
+ Logger logger = LoggerFactory.getLogger(AAIClientImpl.class);
- private AAIHttpClientConfiguration aaiHttpClientConfig;
+ private AAIClientConfiguration aaiHttpClientConfig;
@Autowired
- public AAIHttpClientImpl(AAIHttpClientConfiguration aaiHttpClientConfiguration) {
+ public AAIClientImpl(AAIClientConfiguration aaiHttpClientConfiguration) {
this.aaiHttpClientConfig = aaiHttpClientConfiguration;
}
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIConsumerClient.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIConsumerClient.java
new file mode 100644
index 00000000..24790be2
--- /dev/null
+++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIConsumerClient.java
@@ -0,0 +1,133 @@
+/*-
+ * ============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.apache.http.HttpEntity;
+import org.apache.http.client.ResponseHandler;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.util.EntityUtils;
+import org.onap.dcaegen2.services.config.AAIClientConfiguration;
+import org.onap.dcaegen2.services.utils.HttpRequestDetails;
+import org.onap.dcaegen2.services.utils.HttpUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Optional;
+
+public class AAIConsumerClient implements AAIExtendedHttpClient {
+
+ Logger logger = LoggerFactory.getLogger(AAIConsumerClient.class);
+
+ private final CloseableHttpClient closeableHttpClient;
+ private final String aaiHost;
+ private final String aaiProtocol;
+ private final Integer aaiHostPortNumber;
+
+
+ public AAIConsumerClient(AAIClientConfiguration aaiHttpClientConfiguration) {
+ final AAIClient aaiClient = new AAIClientImpl(aaiHttpClientConfiguration);
+ closeableHttpClient = aaiClient.getAAIHttpClient();
+ aaiHost = aaiHttpClientConfiguration.aaiHost();
+ aaiProtocol = aaiHttpClientConfiguration.aaiProtocol();
+ aaiHostPortNumber = aaiHttpClientConfiguration.aaiHostPortNumber();
+ }
+
+ @Override
+ public Optional<String> getHttpResponse(HttpRequestDetails requestDetails) {
+
+ Optional<String> extendedDetails = Optional.empty();
+ Optional<HttpRequestBase> request = createRequest(requestDetails);
+
+ try {
+ extendedDetails = closeableHttpClient.execute(request.get(), aaiResponseHandler());
+ } catch (IOException e) {
+ logger.error("Exception while executing HTTP request: {}", e);
+ }
+
+ return extendedDetails;
+ }
+
+
+ private URI createAAIExtendedURI(final String path, String pnfName) {
+
+ URI extendedURI = null;
+
+ final URIBuilder uriBuilder = new URIBuilder()
+ .setScheme(aaiProtocol)
+ .setHost(aaiHost)
+ .setPort(aaiHostPortNumber)
+ .setPath(path + "/" + pnfName);
+
+ try {
+ extendedURI = uriBuilder.build();
+ logger.info("Building extended URI: {}", extendedURI);
+ } catch (URISyntaxException e) {
+ logger.error("Exception while building extended URI: {}", e);
+ }
+
+ return extendedURI;
+ }
+
+ private ResponseHandler<Optional<String>> aaiResponseHandler() {
+ return httpResponse -> {
+ final int responseCode = httpResponse.getStatusLine().getStatusCode();
+ logger.info("Status code of operation: {}", responseCode);
+ final HttpEntity responseEntity = httpResponse.getEntity();
+
+ if (HttpUtils.isSuccessfulResponseCode(responseCode) ) {
+ logger.info("HTTP response successful.");
+ final String aaiResponse = EntityUtils.toString(responseEntity);
+ return Optional.of(aaiResponse);
+ } else {
+ String aaiResponse = responseEntity != null ? EntityUtils.toString(responseEntity) : "";
+ logger.error("HTTP response not successful : {}", aaiResponse);
+ return Optional.of("" + responseCode);
+ }
+ };
+ }
+
+ private HttpRequestBase createHttpRequest(URI extendedURI) {
+
+ if (isExtendedURINotNull(extendedURI)) {
+ return new HttpGet(extendedURI);
+ } else {
+ return null;
+ }
+ }
+
+ private Boolean isExtendedURINotNull(URI extendedURI) {
+ return extendedURI != null;
+ }
+
+ private Optional<HttpRequestBase> createRequest(HttpRequestDetails requestDetails) {
+
+ final URI extendedURI = createAAIExtendedURI(requestDetails.aaiAPIPath(), requestDetails.pnfName());
+ HttpRequestBase request = createHttpRequest(extendedURI);
+ requestDetails.headers().forEach(request::addHeader);
+ return Optional.of(request);
+ }
+}
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIExtendedHttpClientImpl.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIProducerClient.java
index 20ae8d0b..0b82578a 100644
--- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIExtendedHttpClientImpl.java
+++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIProducerClient.java
@@ -17,38 +17,32 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.dcaegen2.services.service;
-import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
import org.apache.http.client.ResponseHandler;
-import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPatch;
-import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
-import org.onap.dcaegen2.services.config.AAIHttpClientConfiguration;
+import org.onap.dcaegen2.services.config.AAIClientConfiguration;
import org.onap.dcaegen2.services.utils.HttpRequestDetails;
import org.onap.dcaegen2.services.utils.HttpUtils;
-import org.onap.dcaegen2.services.utils.RequestVerbs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.lang.NonNull;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.Iterator;
-import java.util.Map;
import java.util.Optional;
-public class AAIExtendedHttpClientImpl implements AAIExtendedHttpClient {
-
- Logger logger = LoggerFactory.getLogger(AAIExtendedHttpClientImpl.class);
+public class AAIProducerClient implements AAIExtendedHttpClient {
+ Logger logger = LoggerFactory.getLogger(AAIProducerClient.class);
private final CloseableHttpClient closeableHttpClient;
private final String aaiHost;
@@ -56,8 +50,8 @@ public class AAIExtendedHttpClientImpl implements AAIExtendedHttpClient {
private final Integer aaiHostPortNumber;
- public AAIExtendedHttpClientImpl (AAIHttpClientConfiguration aaiHttpClientConfiguration) {
- final AAIHttpClient aaiHttpClient = new AAIHttpClientImpl(aaiHttpClientConfiguration);
+ public AAIProducerClient(AAIClientConfiguration aaiHttpClientConfiguration) {
+ final AAIClient aaiHttpClient = new AAIClientImpl(aaiHttpClientConfiguration);
closeableHttpClient = aaiHttpClient.getAAIHttpClient();
aaiHost = aaiHttpClientConfiguration.aaiHost();
aaiProtocol = aaiHttpClientConfiguration.aaiProtocol();
@@ -79,18 +73,15 @@ public class AAIExtendedHttpClientImpl implements AAIExtendedHttpClient {
return extendedDetails;
}
- private URI createAAIExtendedURI(final String path, Map<String, String> queryParams) {
+ private URI createAAIExtendedURI(final String path, final String pnfName) {
URI extendedURI = null;
- final URIBuilder uriBuilder = new URIBuilder().setScheme(this.aaiProtocol).setHost(this.aaiHost)
- .setPort(this.aaiHostPortNumber)
- .setPath(path);
- final String customQuery = createCustomQuery(queryParams);
-
- if (StringUtils.isNoneBlank(customQuery)) {
- uriBuilder.setCustomQuery(customQuery);
- }
+ final URIBuilder uriBuilder = new URIBuilder()
+ .setScheme(aaiProtocol)
+ .setHost(aaiHost)
+ .setPort(aaiHostPortNumber)
+ .setPath(path + "/" + pnfName);
try {
extendedURI = uriBuilder.build();
@@ -102,45 +93,25 @@ public class AAIExtendedHttpClientImpl implements AAIExtendedHttpClient {
return extendedURI;
}
- private String createCustomQuery(@NonNull final Map<String, String> queryParams) {
- final StringBuilder queryStringBuilder = new StringBuilder("");
- final Iterator<Map.Entry<String, String>> queryParamIterator = queryParams.entrySet().iterator();
-
- while (queryParamIterator.hasNext()) {
- final Map.Entry<String, String> queryParamsEntry = queryParamIterator.next();
- queryStringBuilder.append(queryParamsEntry.getKey()).append("=").append(queryParamsEntry.getValue());
- if (queryParamIterator.hasNext()) {
- queryStringBuilder.append("&");
- }
- }
-
- return queryStringBuilder.toString();
- }
-
private ResponseHandler<Optional<String>> aaiResponseHandler() {
- return httpResponse -> {
+ return (HttpResponse httpResponse) -> {
final int responseCode = httpResponse.getStatusLine().getStatusCode();
+ logger.info("Status code of operation: {}", responseCode);
final HttpEntity responseEntity = httpResponse.getEntity();
- if (HttpUtils.isSuccessfulResponseCode(responseCode) && responseEntity != null) {
+ if (HttpUtils.isSuccessfulResponseCode(responseCode)) {
logger.info("HTTP response successful.");
- final String aaiResponse = EntityUtils.toString(responseEntity);
- return Optional.of(aaiResponse);
+ return Optional.of("" + responseCode);
} else {
String aaiResponse = responseEntity != null ? EntityUtils.toString(responseEntity) : "";
logger.error("HTTP response not successful : {}", aaiResponse);
- return Optional.empty();
+ return Optional.of("" + responseCode);
}
};
}
private HttpRequestBase createHttpRequest(URI extendedURI, HttpRequestDetails httpRequestDetails) {
- if (isExtendedURINotNull(extendedURI) && (httpRequestDetails.requestVerb().equals(RequestVerbs.GET))) {
- return new HttpGet(extendedURI);
- } else if (isExtendedURINotNull(extendedURI) && (httpRequestDetails.requestVerb().equals(RequestVerbs.PUT))) {
- return new HttpPut(extendedURI);
- } else if (isExtendedURINotNull(extendedURI) &&
- isPatchRequestValid(httpRequestDetails.requestVerb(),httpRequestDetails.jsonBody())) {
+ if (isExtendedURINotNull(extendedURI) && httpRequestDetails.jsonBody().isPresent()) {
return createHttpPatch(extendedURI, httpRequestDetails.jsonBody());
} else {
return null;
@@ -174,13 +145,9 @@ public class AAIExtendedHttpClientImpl implements AAIExtendedHttpClient {
return stringEntity;
}
- private Boolean isPatchRequestValid(RequestVerbs requestVerb, Optional<String> jsonBody) {
- return requestVerb == RequestVerbs.PATCH && jsonBody.isPresent();
- }
-
private Optional<HttpRequestBase> createRequest(HttpRequestDetails requestDetails) {
- final URI extendedURI = createAAIExtendedURI(requestDetails.aaiAPIPath(), requestDetails.queryParameters());
+ final URI extendedURI = createAAIExtendedURI(requestDetails.aaiAPIPath(), requestDetails.pnfName());
HttpRequestBase request = createHttpRequest(extendedURI, requestDetails);
requestDetails.headers().forEach(request::addHeader);
return Optional.of(request);
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/utils/HttpRequestDetails.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/utils/HttpRequestDetails.java
index 574cb22f..37e6b860 100644
--- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/utils/HttpRequestDetails.java
+++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/utils/HttpRequestDetails.java
@@ -39,11 +39,8 @@ public abstract class HttpRequestDetails implements Serializable {
public abstract Optional<String> jsonBody();
@Value.Parameter
- public abstract Map<String,String> queryParameters();
+ public abstract String pnfName();
@Value.Parameter
public abstract Map<String,String> headers();
-
- @Value.Parameter
- public abstract RequestVerbs requestVerb();
}
diff --git a/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIConsumerClientTest.java b/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIConsumerClientTest.java
new file mode 100644
index 00000000..b95cc8d6
--- /dev/null
+++ b/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIConsumerClientTest.java
@@ -0,0 +1,92 @@
+/*-
+ * ============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.apache.http.client.ResponseHandler;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.onap.dcaegen2.services.config.AAIClientConfiguration;
+import org.onap.dcaegen2.services.utils.HttpRequestDetails;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AAIConsumerClientTest {
+
+ private static AAIConsumerClient testedObject;
+ private static AAIClientConfiguration aaiHttpClientConfigurationMock = mock(AAIClientConfiguration.class);
+ private static CloseableHttpClient closeableHttpClientMock = mock(CloseableHttpClient.class);
+ private static HttpRequestDetails httpRequestDetailsMock = mock(HttpRequestDetails.class);
+ private static final String JSON_MESSAGE = "{ \"pnf-id\": \"example-pnf-id-val-22343\", \"regional-resource-zone\":null, \"ipaddress-v4-oam\": \"11.22.33.44\" }";
+
+ @BeforeAll
+ public static void setup() throws NoSuchFieldException, IllegalAccessException {
+
+ Map<String, String> aaiHeaders = new HashMap<>();
+ aaiHeaders.put("X-FromAppId", "prh");
+ aaiHeaders.put("X-TransactionId", "9999");
+ aaiHeaders.put("Accept", "application/json");
+ aaiHeaders.put("authentication", "Basic QUFJOkFBSQ==");
+ aaiHeaders.put("Real-Time", "true");
+ aaiHeaders.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");
+ when(httpRequestDetailsMock.headers()).thenReturn(aaiHeaders);
+ when(httpRequestDetailsMock.pnfName()).thenReturn("pnf-nokia-45fsfcx");
+ when(httpRequestDetailsMock.jsonBody()).thenReturn(Optional.of(JSON_MESSAGE));
+
+ testedObject = new AAIConsumerClient(aaiHttpClientConfigurationMock);
+ setField();
+ }
+
+
+ @Test
+ public void getExtendedDetails_returnsSuccess() throws IOException {
+
+ when(closeableHttpClientMock.execute(any(HttpGet.class), any(ResponseHandler.class))).
+ thenReturn(Optional.of(JSON_MESSAGE));
+ Optional<String> actualResult = testedObject.getHttpResponse(httpRequestDetailsMock);
+ Assertions.assertEquals(Optional.of(JSON_MESSAGE),actualResult);
+ }
+
+
+ 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
index fd13f1e7..cfe1a7f6 100644
--- 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
@@ -21,7 +21,7 @@ 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 org.onap.dcaegen2.services.config.AAIClientConfiguration;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.mock;
@@ -30,13 +30,13 @@ import static org.mockito.Mockito.when;
public class AAIHttpClientImplTest {
- private static AAIHttpClientImpl testedObject;
- private static AAIHttpClientConfiguration aaiHttpClientConfigurationMock;
+ private static AAIClientImpl testedObject;
+ private static AAIClientConfiguration aaiHttpClientConfigurationMock;
@BeforeAll
public static void setup() {
- aaiHttpClientConfigurationMock = mock(AAIHttpClientConfiguration.class);
+ aaiHttpClientConfigurationMock = mock(AAIClientConfiguration.class);
when(aaiHttpClientConfigurationMock.aaiHost()).thenReturn("54.45.33.2");
when(aaiHttpClientConfigurationMock.aaiProtocol()).thenReturn("https");
when(aaiHttpClientConfigurationMock.aaiHostPortNumber()).thenReturn(1234);
@@ -44,7 +44,7 @@ public class AAIHttpClientImplTest {
when(aaiHttpClientConfigurationMock.aaiUserPassword()).thenReturn("PNF");
when(aaiHttpClientConfigurationMock.aaiIgnoreSSLCertificateErrors()).thenReturn(true);
- testedObject = new AAIHttpClientImpl(aaiHttpClientConfigurationMock);
+ testedObject = new AAIClientImpl(aaiHttpClientConfigurationMock);
}
@Test
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/AAIProducerClientTest.java
index 9ff34b8e..7f3978bd 100644
--- 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/AAIProducerClientTest.java
@@ -1,4 +1,4 @@
-/*-
+/*
* ============LICENSE_START=======================================================
* PNF-REGISTRATION-HANDLER
* ================================================================================
@@ -20,113 +20,69 @@
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 org.apache.http.client.ResponseHandler;
+import org.apache.http.client.methods.HttpPatch;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.onap.dcaegen2.services.config.AAIClientConfiguration;
+import org.onap.dcaegen2.services.utils.HttpRequestDetails;
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.HttpPatch;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.immutables.value.internal.$processor$.meta.$GsonMirrors;
-import org.junit.Ignore;
-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 {
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AAIProducerClientTest {
- private static AAIExtendedHttpClientImpl testedObject;
- private static AAIHttpClientConfiguration aaiHttpClientConfigurationMock = mock(AAIHttpClientConfiguration.class);
+ private static AAIProducerClient testedObject;
+ private static AAIClientConfiguration aaiHttpClientConfigurationMock = mock(AAIClientConfiguration.class);
private static CloseableHttpClient closeableHttpClientMock = mock(CloseableHttpClient.class);
private static HttpRequestDetails httpRequestDetailsMock = mock(HttpRequestDetails.class);
- private static Optional<String> expectedResult = Optional.empty();
- private static final String JSON_MESSAGE = "{ \"ipaddress-v4-oam\": \"11.22.33.44\" }";
- private static final String PNF_ID = "NOKQTFCOC540002E";
+ private static final String JsonBody = "{\"ipaddress-v4-oam\":\"11.22.33.155\"}";
+ private static final String SUCCESS = "200";
+ private static final String PNF_NAME = "nokia-pnf-nhfsadhff";
@BeforeAll
public static void init() throws NoSuchFieldException, IllegalAccessException {
- Map<String, String> queryParams = new HashMap<>();
- queryParams.put("pnf-id", PNF_ID);
-
Map<String, String> aaiHeaders = new HashMap<>();
aaiHeaders.put("X-FromAppId", "prh");
aaiHeaders.put("X-TransactionId", "vv-temp");
aaiHeaders.put("Accept", "application/json");
aaiHeaders.put("Real-Time", "true");
- aaiHeaders.put("Content-Type", "application/json");
+ aaiHeaders.put("Content-Type", "application/merge-patch+json");
- when(aaiHttpClientConfigurationMock.aaiHost()).thenReturn("54.45.33.2");
+ when(aaiHttpClientConfigurationMock.aaiHost()).thenReturn("eucalyptus.es-si-eu-dhn-20.eecloud.nsn-net.net");
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");
+
when(httpRequestDetailsMock.headers()).thenReturn(aaiHeaders);
- when(httpRequestDetailsMock.queryParameters()).thenReturn(queryParams);
- when(httpRequestDetailsMock.jsonBody()).thenReturn(Optional.of(JSON_MESSAGE));
+ when(httpRequestDetailsMock.pnfName()).thenReturn(PNF_NAME);
+ when(httpRequestDetailsMock.jsonBody()).thenReturn(Optional.of(JsonBody));
- testedObject = new AAIExtendedHttpClientImpl(aaiHttpClientConfigurationMock);
+ testedObject = new AAIProducerClient(aaiHttpClientConfigurationMock);
setField();
}
- @AfterAll
- public static void teardown() {
- testedObject = null;
- aaiHttpClientConfigurationMock = null;
- closeableHttpClientMock = null;
- httpRequestDetailsMock = null;
- expectedResult = null;
- }
-
@Test
public void getHttpResponsePatch_success() throws IOException {
- when(httpRequestDetailsMock.requestVerb()).thenReturn(RequestVerbs.PATCH);
-
- expectedResult = Optional.of(JSON_MESSAGE);
when(closeableHttpClientMock.execute(any(HttpPatch.class), any(ResponseHandler.class)))
- .thenReturn(expectedResult);
+ .thenReturn(Optional.of(SUCCESS));
Optional<String> 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<String> 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<String> actualResult = testedObject.getHttpResponse(httpRequestDetailsMock);
- Assertions.assertEquals(Optional.empty(),actualResult);
- }
-
- @Test
- public void getHttpResponsePut_failure() {
- when(httpRequestDetailsMock.requestVerb()).thenReturn(RequestVerbs.PUT);
-
+ Assertions.assertEquals(SUCCESS, actualResult.get());
}
private static void setField() throws NoSuchFieldException, IllegalAccessException {
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
index 76c2969a..29a00927 100644
--- 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
@@ -23,12 +23,12 @@ 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;
+import org.onap.dcaegen2.services.config.AAIClientConfiguration;
+import org.onap.dcaegen2.services.config.ImmutableAAIClientConfiguration;
public class AAIHttpClientConfigurationTest {
- private static AAIHttpClientConfiguration client;
+ private static AAIClientConfiguration 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";
@@ -36,7 +36,7 @@ public class AAIHttpClientConfigurationTest {
@BeforeAll
public static void init() {
- client = new ImmutableAAIHttpClientConfiguration.Builder()
+ client = new ImmutableAAIClientConfiguration.Builder()
.aaiHost(AAI_HOST)
.aaiHostPortNumber(PORT)
.aaiProtocol(PROTOCOL)
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
index 563e6921..0deb8adb 100644
--- 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
@@ -36,19 +36,16 @@ public class HttpRequestDetailsTest {
private static HttpRequestDetails testObject;
private static final String AAI_PATH = "aaiPathTest";
- private static final RequestVerbs HTTP_VERB = RequestVerbs.PATCH;
- 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";
private static final String JSON_MESSAGE = "{\"dare_to\": \"dream_big\"}";
+ private static final String PNF_NAME = "pnf-nokia-5454885485";
@BeforeAll
public static void init() {
testObject = ImmutableHttpRequestDetails.builder()
.aaiAPIPath(AAI_PATH)
- .requestVerb(HTTP_VERB)
- .putQueryParameters(QUERY_KEY1,QUERY_VALUE1)
+ .pnfName(PNF_NAME)
.putHeaders(HEADERS_KEY1,HEADERS_VALUE1)
.jsonBody(JSON_MESSAGE)
.build();
@@ -58,8 +55,7 @@ public class HttpRequestDetailsTest {
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.PATCH, testObject.requestVerb());
+ Assertions.assertEquals(PNF_NAME, testObject.pnfName());
Assertions.assertEquals(Optional.of(JSON_MESSAGE), testObject.jsonBody());
}
}
diff --git a/prh-app-server/pom.xml b/prh-app-server/pom.xml
index e804c3e6..cb85db11 100644
--- a/prh-app-server/pom.xml
+++ b/prh-app-server/pom.xml
@@ -232,6 +232,11 @@
<artifactId>prh-dmaap-client</artifactId>
<version>${project.parent.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.dcaegen2.services.prh</groupId>
+ <artifactId>prh-aai-client</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
<dependencyManagement>
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java
index 76633d26..15db50e1 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java
@@ -19,17 +19,13 @@
*/
package org.onap.dcaegen2.services.prh.configuration;
-import java.util.Optional;
-import org.onap.dcaegen2.services.config.AAIHttpClientConfiguration;
-import org.onap.dcaegen2.services.config.DmaapConsumerConfiguration;
-import org.onap.dcaegen2.services.config.DmaapPublisherConfiguration;
-import org.onap.dcaegen2.services.config.ImmutableAAIHttpClientConfiguration;
-import org.onap.dcaegen2.services.config.ImmutableDmaapConsumerConfiguration;
-import org.onap.dcaegen2.services.config.ImmutableDmaapPublisherConfiguration;
+import org.onap.dcaegen2.services.config.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
+import java.util.Optional;
+
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/9/18
*/
@@ -38,26 +34,26 @@ import org.springframework.stereotype.Component;
@Configuration
public class AppConfig extends PrhAppConfig {
- @Value("${dmaap.dmaapConsumerConfiguration.dmmapHostName:}")
- public String consumerDmmapHostName;
+ @Value("${dmaap.dmaapConsumerConfiguration.dmaapHostName:}")
+ public String consumerDmaapHostName;
- @Value("${dmaap.dmaapConsumerConfiguration.dmmapPortNumber:}")
- public Integer consumerDmmapPortNumber;
+ @Value("${dmaap.dmaapConsumerConfiguration.dmaapPortNumber:}")
+ public Integer consumerDmaapPortNumber;
- @Value("${dmaap.dmaapConsumerConfiguration.dmmapTopicName:}")
- public String consumerDmmapTopicName;
+ @Value("${dmaap.dmaapConsumerConfiguration.dmaapTopicName:}")
+ public String consumerDmaapTopicName;
- @Value("${dmaap.dmaapConsumerConfiguration.dmmapProtocol:}")
- public String consumerDmmapProtocol;
+ @Value("${dmaap.dmaapConsumerConfiguration.dmaapProtocol:}")
+ public String consumerDmaapProtocol;
- @Value("${dmaap.dmaapConsumerConfiguration.dmmapUserName:}")
- public String consumerDmmapUserName;
+ @Value("${dmaap.dmaapConsumerConfiguration.dmaapUserName:}")
+ public String consumerDmaapUserName;
- @Value("${dmaap.dmaapConsumerConfiguration.dmmapUserPassword:}")
- public String consumerDmmapUserPassword;
+ @Value("${dmaap.dmaapConsumerConfiguration.dmaapUserPassword:}")
+ public String consumerDmaapUserPassword;
- @Value("${dmaap.dmaapConsumerConfiguration.dmmapContentType:}")
- public String consumerDmmapContentType;
+ @Value("${dmaap.dmaapConsumerConfiguration.dmaapContentType:}")
+ public String consumerDmaapContentType;
@Value("${dmaap.dmaapConsumerConfiguration.consumerId:}")
public String consumerId;
@@ -71,26 +67,26 @@ public class AppConfig extends PrhAppConfig {
@Value("${dmaap.dmaapConsumerConfiguration.message-limit:}")
public Integer consumerMessageLimit;
- @Value("${dmaap.dmaapProducerConfiguration.dmmapHostName:}")
- public String producerDmmapHostName;
+ @Value("${dmaap.dmaapProducerConfiguration.dmaapHostName:}")
+ public String producerDmaapHostName;
- @Value("${dmaap.dmaapProducerConfiguration.dmmapPortNumber:}")
- public Integer producerDmmapPortNumber;
+ @Value("${dmaap.dmaapProducerConfiguration.dmaapPortNumber:}")
+ public Integer producerDmaapPortNumber;
- @Value("${dmaap.dmaapProducerConfiguration.dmmapTopicName:}")
- public String producerDmmapTopicName;
+ @Value("${dmaap.dmaapProducerConfiguration.dmaapTopicName:}")
+ public String producerDmaapTopicName;
- @Value("${dmaap.dmaapProducerConfiguration.dmmapProtocol:}")
- public String producerDmmapProtocol;
+ @Value("${dmaap.dmaapProducerConfiguration.dmaapProtocol:}")
+ public String producerDmaapProtocol;
- @Value("${dmaap.dmaapProducerConfiguration.dmmapUserName:}")
- public String producerDmmapUserName;
+ @Value("${dmaap.dmaapProducerConfiguration.dmaapUserName:}")
+ public String producerDmaapUserName;
- @Value("${dmaap.dmaapProducerConfiguration.dmmapUserPassword:}")
- public String producerDmmapUserPassword;
+ @Value("${dmaap.dmaapProducerConfiguration.dmaapUserPassword:}")
+ public String producerDmaapUserPassword;
- @Value("${dmaap.dmaapProducerConfiguration.dmmapContentType:}")
- public String producerDmmapContentType;
+ @Value("${dmaap.dmaapProducerConfiguration.dmaapContentType:}")
+ public String producerDmaapContentType;
@Value("${aai.aaiHttpClientConfiguration.aaiHost:}")
public String aaiHost;
@@ -113,63 +109,63 @@ public class AppConfig extends PrhAppConfig {
@Override
public DmaapConsumerConfiguration getDmaapConsumerConfiguration() {
return new ImmutableDmaapConsumerConfiguration.Builder()
- .dmaapUserPassword(
- Optional.ofNullable(consumerDmmapUserPassword).orElse(dmaapConsumerConfiguration.dmaapUserPassword()))
- .dmaapUserName(
- Optional.ofNullable(consumerDmmapUserName).orElse(dmaapConsumerConfiguration.dmaapUserName()))
- .dmaapHostName(
- Optional.ofNullable(consumerDmmapHostName).orElse(dmaapConsumerConfiguration.dmaapHostName()))
- .dmaapPortNumber(
- Optional.ofNullable(consumerDmmapPortNumber).orElse(dmaapConsumerConfiguration.dmaapPortNumber()))
- .dmaapProtocol(
- Optional.ofNullable(consumerDmmapProtocol).orElse(dmaapConsumerConfiguration.dmaapProtocol()))
- .dmaapContentType(
- Optional.ofNullable(consumerDmmapContentType).orElse(dmaapConsumerConfiguration.dmaapContentType()))
- .dmaapTopicName(
- Optional.ofNullable(consumerDmmapTopicName).orElse(dmaapConsumerConfiguration.dmaapTopicName()))
- .messageLimit(
- Optional.ofNullable(consumerMessageLimit).orElse(dmaapConsumerConfiguration.messageLimit()))
- .timeoutMS(Optional.ofNullable(consumerTimeoutMS).orElse(dmaapConsumerConfiguration.timeoutMS()))
- .consumerGroup(Optional.ofNullable(consumerGroup).orElse(dmaapConsumerConfiguration.consumerGroup()))
- .consumerId(Optional.ofNullable(consumerId).orElse(dmaapConsumerConfiguration.consumerId()))
- .build();
+ .dmaapUserPassword(
+ Optional.ofNullable(consumerDmaapUserPassword).orElse(dmaapConsumerConfiguration.dmaapUserPassword()))
+ .dmaapUserName(
+ Optional.ofNullable(consumerDmaapUserName).orElse(dmaapConsumerConfiguration.dmaapUserName()))
+ .dmaapHostName(
+ Optional.ofNullable(consumerDmaapHostName).orElse(dmaapConsumerConfiguration.dmaapHostName()))
+ .dmaapPortNumber(
+ Optional.ofNullable(consumerDmaapPortNumber).orElse(dmaapConsumerConfiguration.dmaapPortNumber()))
+ .dmaapProtocol(
+ Optional.ofNullable(consumerDmaapProtocol).orElse(dmaapConsumerConfiguration.dmaapProtocol()))
+ .dmaapContentType(
+ Optional.ofNullable(consumerDmaapContentType).orElse(dmaapConsumerConfiguration.dmaapContentType()))
+ .dmaapTopicName(
+ Optional.ofNullable(consumerDmaapTopicName).orElse(dmaapConsumerConfiguration.dmaapTopicName()))
+ .messageLimit(
+ Optional.ofNullable(consumerMessageLimit).orElse(dmaapConsumerConfiguration.messageLimit()))
+ .timeoutMS(Optional.ofNullable(consumerTimeoutMS).orElse(dmaapConsumerConfiguration.timeoutMS()))
+ .consumerGroup(Optional.ofNullable(consumerGroup).orElse(dmaapConsumerConfiguration.consumerGroup()))
+ .consumerId(Optional.ofNullable(consumerId).orElse(dmaapConsumerConfiguration.consumerId()))
+ .build();
}
@Override
- public AAIHttpClientConfiguration getAAIHttpClientConfiguration() {
- return new ImmutableAAIHttpClientConfiguration.Builder()
- .aaiHost(Optional.ofNullable(aaiHost).orElse(aaiHttpClientConfiguration.aaiHost()))
- .aaiHostPortNumber(
- Optional.ofNullable(aaiHostPortNumber).orElse(aaiHttpClientConfiguration.aaiHostPortNumber()))
- .aaiIgnoreSSLCertificateErrors(
- Optional.ofNullable(aaiIgnoreSSLCertificateErrors)
- .orElse(aaiHttpClientConfiguration.aaiIgnoreSSLCertificateErrors()))
- .aaiProtocol(Optional.ofNullable(aaiProtocol).orElse(aaiHttpClientConfiguration.aaiProtocol()))
- .aaiUserName(
- Optional.ofNullable(aaiUserName).orElse(aaiHttpClientConfiguration.aaiUserName()))
- .aaiUserPassword(Optional.ofNullable(
- aaiUserPassword).orElse(aaiHttpClientConfiguration.aaiUserPassword()))
- .build();
+ public AAIClientConfiguration getAAIClientConfiguration() {
+ return new ImmutableAAIClientConfiguration.Builder()
+ .aaiHost(Optional.ofNullable(aaiHost).orElse(aaiClientConfiguration.aaiHost()))
+ .aaiHostPortNumber(
+ Optional.ofNullable(aaiHostPortNumber).orElse(aaiClientConfiguration.aaiHostPortNumber()))
+ .aaiIgnoreSSLCertificateErrors(
+ Optional.ofNullable(aaiIgnoreSSLCertificateErrors)
+ .orElse(aaiClientConfiguration.aaiIgnoreSSLCertificateErrors()))
+ .aaiProtocol(Optional.ofNullable(aaiProtocol).orElse(aaiClientConfiguration.aaiProtocol()))
+ .aaiUserName(
+ Optional.ofNullable(aaiUserName).orElse(aaiClientConfiguration.aaiUserName()))
+ .aaiUserPassword(Optional.ofNullable(
+ aaiUserPassword).orElse(aaiClientConfiguration.aaiUserPassword()))
+ .build();
}
@Override
public DmaapPublisherConfiguration getDmaapPublisherConfiguration() {
return new ImmutableDmaapPublisherConfiguration.Builder()
- .dmaapContentType(
- Optional.ofNullable(producerDmmapContentType).orElse(dmaapPublisherConfiguration.dmaapContentType()))
- .dmaapHostName(
- Optional.ofNullable(producerDmmapHostName).orElse(dmaapPublisherConfiguration.dmaapHostName()))
- .dmaapPortNumber(
- Optional.ofNullable(producerDmmapPortNumber).orElse(dmaapPublisherConfiguration.dmaapPortNumber()))
- .dmaapProtocol(
- Optional.ofNullable(producerDmmapProtocol).orElse(dmaapPublisherConfiguration.dmaapProtocol()))
- .dmaapTopicName(
- Optional.ofNullable(producerDmmapTopicName).orElse(dmaapPublisherConfiguration.dmaapTopicName()))
- .dmaapUserName(
- Optional.ofNullable(producerDmmapUserName).orElse(dmaapPublisherConfiguration.dmaapUserName()))
- .dmaapUserPassword(
- Optional.ofNullable(producerDmmapUserPassword).orElse(dmaapPublisherConfiguration.dmaapUserPassword()))
- .build();
+ .dmaapContentType(
+ Optional.ofNullable(producerDmaapContentType).orElse(dmaapPublisherConfiguration.dmaapContentType()))
+ .dmaapHostName(
+ Optional.ofNullable(producerDmaapHostName).orElse(dmaapPublisherConfiguration.dmaapHostName()))
+ .dmaapPortNumber(
+ Optional.ofNullable(producerDmaapPortNumber).orElse(dmaapPublisherConfiguration.dmaapPortNumber()))
+ .dmaapProtocol(
+ Optional.ofNullable(producerDmaapProtocol).orElse(dmaapPublisherConfiguration.dmaapProtocol()))
+ .dmaapTopicName(
+ Optional.ofNullable(producerDmaapTopicName).orElse(dmaapPublisherConfiguration.dmaapTopicName()))
+ .dmaapUserName(
+ Optional.ofNullable(producerDmaapUserName).orElse(dmaapPublisherConfiguration.dmaapUserName()))
+ .dmaapUserPassword(
+ Optional.ofNullable(producerDmaapUserPassword).orElse(dmaapPublisherConfiguration.dmaapUserPassword()))
+ .build();
}
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java
index 8dd2bf3b..605a1bd7 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java
@@ -19,7 +19,7 @@
*/
package org.onap.dcaegen2.services.prh.configuration;
-import org.onap.dcaegen2.services.config.AAIHttpClientConfiguration;
+import org.onap.dcaegen2.services.config.AAIClientConfiguration;
import org.onap.dcaegen2.services.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.services.config.DmaapPublisherConfiguration;
@@ -30,7 +30,7 @@ public interface Config {
DmaapConsumerConfiguration getDmaapConsumerConfiguration();
- AAIHttpClientConfiguration getAAIHttpClientConfiguration();
+ AAIClientConfiguration getAAIClientConfiguration();
DmaapPublisherConfiguration getDmaapPublisherConfiguration();
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java
index 8720cf47..0473c1aa 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java
@@ -19,24 +19,8 @@
*/
package org.onap.dcaegen2.services.prh.configuration;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonSyntaxException;
-import com.google.gson.TypeAdapterFactory;
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.ServiceLoader;
-import javax.validation.constraints.NotEmpty;
-import javax.validation.constraints.NotNull;
-import org.onap.dcaegen2.services.config.AAIHttpClientConfiguration;
+import com.google.gson.*;
+import org.onap.dcaegen2.services.config.AAIClientConfiguration;
import org.onap.dcaegen2.services.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.services.config.DmaapPublisherConfiguration;
import org.slf4j.Logger;
@@ -45,6 +29,13 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.io.*;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.ServiceLoader;
+
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/9/18
*/
@@ -63,7 +54,7 @@ public abstract class PrhAppConfig implements Config {
private static final Logger logger = LoggerFactory.getLogger(PrhAppConfig.class);
private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
- AAIHttpClientConfiguration aaiHttpClientConfiguration;
+ AAIClientConfiguration aaiClientConfiguration;
DmaapConsumerConfiguration dmaapConsumerConfiguration;
@@ -79,8 +70,8 @@ public abstract class PrhAppConfig implements Config {
}
@Override
- public AAIHttpClientConfiguration getAAIHttpClientConfiguration() {
- return aaiHttpClientConfiguration;
+ public AAIClientConfiguration getAAIClientConfiguration() {
+ return aaiClientConfiguration;
}
@Override
@@ -99,41 +90,41 @@ public abstract class PrhAppConfig implements Config {
JsonElement rootElement = parser.parse(new InputStreamReader(inputStream));
if (rootElement.isJsonObject()) {
jsonObject = rootElement.getAsJsonObject();
- aaiHttpClientConfiguration = deserializeType(gsonBuilder,
- jsonObject.getAsJsonObject(CONFIG).getAsJsonObject(AAI).getAsJsonObject(AAI_CONFIG),
- AAIHttpClientConfiguration.class);
+ aaiClientConfiguration = deserializeType(gsonBuilder,
+ jsonObject.getAsJsonObject(CONFIG).getAsJsonObject(AAI).getAsJsonObject(AAI_CONFIG),
+ AAIClientConfiguration.class);
dmaapConsumerConfiguration = deserializeType(gsonBuilder,
- jsonObject.getAsJsonObject(CONFIG).getAsJsonObject(DMAAP).getAsJsonObject(DMAAP_CONSUMER),
- DmaapConsumerConfiguration.class);
+ jsonObject.getAsJsonObject(CONFIG).getAsJsonObject(DMAAP).getAsJsonObject(DMAAP_CONSUMER),
+ DmaapConsumerConfiguration.class);
dmaapPublisherConfiguration = deserializeType(gsonBuilder,
- jsonObject.getAsJsonObject(CONFIG).getAsJsonObject(DMAAP).getAsJsonObject(DMAAP_PRODUCER),
- DmaapPublisherConfiguration.class);
+ jsonObject.getAsJsonObject(CONFIG).getAsJsonObject(DMAAP).getAsJsonObject(DMAAP_PRODUCER),
+ DmaapPublisherConfiguration.class);
}
} catch (FileNotFoundException e) {
logger
- .error(
- "Configuration PrhAppConfig initFileStreamReader()::FileNotFoundException :: Execution Time - {}:{}",
- dateTimeFormatter.format(
- LocalDateTime.now()), e);
+ .error(
+ "Configuration PrhAppConfig initFileStreamReader()::FileNotFoundException :: Execution Time - {}:{}",
+ dateTimeFormatter.format(
+ LocalDateTime.now()), e);
} catch (IOException e) {
logger
- .error(
- "Configuration PrhAppConfig initFileStreamReader()::IOException :: Execution Time - {}:{}",
- dateTimeFormatter.format(
- LocalDateTime.now()), e);
+ .error(
+ "Configuration PrhAppConfig initFileStreamReader()::IOException :: Execution Time - {}:{}",
+ dateTimeFormatter.format(
+ LocalDateTime.now()), e);
} catch (JsonSyntaxException e) {
logger
- .error(
- "Configuration PrhAppConfig initFileStreamReader()::JsonSyntaxException :: Execution Time - {}:{}",
- dateTimeFormatter.format(
- LocalDateTime.now()), e);
+ .error(
+ "Configuration PrhAppConfig initFileStreamReader()::JsonSyntaxException :: Execution Time - {}:{}",
+ dateTimeFormatter.format(
+ LocalDateTime.now()), e);
}
}
private <T> T deserializeType(@NotNull GsonBuilder gsonBuilder, @NotNull JsonObject jsonObject,
- @NotNull Class<T> type) {
+ @NotNull Class<T> type) {
return gsonBuilder.create().fromJson(jsonObject, type);
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java
index 95b360e1..b91b56c5 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java
@@ -21,6 +21,7 @@ package org.onap.dcaegen2.services.prh.controllers;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
+
import org.onap.dcaegen2.services.prh.configuration.PrhAppConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java
index 6f08dd8a..733b7dfc 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java
@@ -24,6 +24,7 @@ import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ScheduledFuture;
+
import org.onap.dcaegen2.services.prh.configuration.PrhAppConfig;
import org.onap.dcaegen2.services.prh.tasks.ScheduledTasks;
import org.slf4j.Logger;
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTask.java
new file mode 100644
index 00000000..5a3afd86
--- /dev/null
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTask.java
@@ -0,0 +1,30 @@
+/*-
+ * ============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.prh.tasks;
+
+import org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException;
+
+public abstract class AAIConsumerTask<T> extends Task {
+
+ protected abstract void consume() throws AAINotFoundException;
+
+ protected abstract T resolveConfiguration();
+}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskImpl.java
new file mode 100644
index 00000000..64ccad5c
--- /dev/null
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskImpl.java
@@ -0,0 +1,89 @@
+/*-
+ * ============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.prh.tasks;
+
+import org.onap.dcaegen2.services.config.AAIClientConfiguration;
+import org.onap.dcaegen2.services.prh.configuration.AppConfig;
+import org.onap.dcaegen2.services.prh.configuration.Config;
+import org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException;
+import org.onap.dcaegen2.services.service.AAIProducerClient;
+import org.onap.dcaegen2.services.utils.HttpRequestDetails;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Optional;
+
+@Component
+public class AAIConsumerTaskImpl extends AAIConsumerTask<AAIClientConfiguration> {
+
+ private static final Logger logger = LoggerFactory.getLogger(ScheduledTasks.class);
+ private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
+
+ private final Config prhAppConfig;
+ private final HttpRequestDetails requestDetails;
+ private AAIProducerClient producerClient;
+ public Optional<String> response;
+
+ @Autowired
+ public AAIConsumerTaskImpl(AppConfig prhAppConfig, HttpRequestDetails requestDetails) {
+ this.prhAppConfig = prhAppConfig;
+ this.requestDetails = requestDetails;
+ }
+
+ @Override
+ protected void consume() throws AAINotFoundException {
+ logger.debug("Start task AAIConsumerTask::publish() :: Execution Time - {}", dateTimeFormatter.format(
+ LocalDateTime.now()));
+
+
+ producerClient = new AAIProducerClient(prhAppConfig.getAAIClientConfiguration());
+
+ response = producerClient.getHttpResponse(requestDetails);
+
+ logger.debug("End task AAIConsumerTask::publish() :: Execution Time - {}", dateTimeFormatter.format(
+ LocalDateTime.now()));
+
+ }
+
+ @Override
+ public ResponseEntity execute(Object object) throws AAINotFoundException {
+ logger.debug("Start task AAIProducerTaskImpl::execute() :: Execution Time - {}", dateTimeFormatter.format(
+ LocalDateTime.now()));
+ consume();
+ logger.debug("End task AAIPublisherTaskImpl::execute() :: Execution Time - {}", dateTimeFormatter.format(
+ LocalDateTime.now()));
+ return null;
+ }
+
+ @Override
+ void initConfigs() {
+ }
+
+ @Override
+ protected AAIClientConfiguration resolveConfiguration() {
+ return prhAppConfig.getAAIClientConfiguration();
+ }
+}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTask.java
index 8ea4ac8f..787e614d 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTask.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTask.java
@@ -24,7 +24,7 @@ import org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
*/
-public abstract class AAIPublisherTask<T> extends Task {
+public abstract class AAIProducerTask<T> extends Task {
protected abstract void publish() throws AAINotFoundException;
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImpl.java
index aa452047..a5d173ba 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImpl.java
@@ -19,48 +19,61 @@
*/
package org.onap.dcaegen2.services.prh.tasks;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-import org.onap.dcaegen2.services.config.AAIHttpClientConfiguration;
+import org.onap.dcaegen2.services.config.AAIClientConfiguration;
import org.onap.dcaegen2.services.prh.configuration.AppConfig;
import org.onap.dcaegen2.services.prh.configuration.Config;
import org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException;
+import org.onap.dcaegen2.services.service.AAIProducerClient;
+import org.onap.dcaegen2.services.utils.HttpRequestDetails;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Optional;
+
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
*/
@Component
-public class AAIPublisherTaskImpl extends AAIPublisherTask<AAIHttpClientConfiguration> {
+public class AAIProducerTaskImpl extends AAIProducerTask<AAIClientConfiguration> {
private static final Logger logger = LoggerFactory.getLogger(ScheduledTasks.class);
private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
private final Config prhAppConfig;
+ private AAIProducerClient producerClient;
+ private HttpRequestDetails requestDetails;
+ private String jsonBody = "{\"ipaddress-v4-oam\":\"11.22.33.155\"}";
+ private String pnfName = "example-pnf-name-val-40510"; // pnf name received from dmaap required for URI
+ public Optional<String> response;
@Autowired
- public AAIPublisherTaskImpl(AppConfig prhAppConfig) {
+ public AAIProducerTaskImpl(AppConfig prhAppConfig, HttpRequestDetails requestDetails) {
this.prhAppConfig = prhAppConfig;
-
+ this.requestDetails = requestDetails;
}
@Override
protected void publish() throws AAINotFoundException {
- logger.debug("Start task DmaapConsumerTask::publish() :: Execution Time - {}", dateTimeFormatter.format(
+ logger.debug("Start task AAIConsumerTask::publish() :: Execution Time - {}", dateTimeFormatter.format(
LocalDateTime.now()));
- prhAppConfig.getAAIHttpClientConfiguration();
- logger.debug("End task DmaapConsumerTask::publish() :: Execution Time - {}", dateTimeFormatter.format(
+
+ producerClient = new AAIProducerClient(prhAppConfig.getAAIClientConfiguration());
+
+ response = producerClient.getHttpResponse(requestDetails);
+
+ logger.debug("End task AAIConsumerTask::publish() :: Execution Time - {}", dateTimeFormatter.format(
LocalDateTime.now()));
}
@Override
public ResponseEntity execute(Object object) throws AAINotFoundException {
- logger.debug("Start task AAIPublisherTaskImpl::execute() :: Execution Time - {}", dateTimeFormatter.format(
+ logger.debug("Start task AAIProducerTaskImpl::execute() :: Execution Time - {}", dateTimeFormatter.format(
LocalDateTime.now()));
publish();
logger.debug("End task AAIPublisherTaskImpl::execute() :: Execution Time - {}", dateTimeFormatter.format(
@@ -73,8 +86,8 @@ public class AAIPublisherTaskImpl extends AAIPublisherTask<AAIHttpClientConfigur
}
@Override
- protected AAIHttpClientConfiguration resolveConfiguration() {
- return prhAppConfig.getAAIHttpClientConfiguration();
+ protected AAIClientConfiguration resolveConfiguration() {
+ return prhAppConfig.getAAIClientConfiguration();
}
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
index 0db49f7c..eb66361d 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
@@ -19,8 +19,6 @@
*/
package org.onap.dcaegen2.services.prh.tasks;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
import org.onap.dcaegen2.services.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.services.prh.configuration.AppConfig;
import org.onap.dcaegen2.services.prh.configuration.Config;
@@ -30,6 +28,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
*/
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
index 072f9c7d..ff5f5893 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
@@ -19,8 +19,6 @@
*/
package org.onap.dcaegen2.services.prh.tasks;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
import org.onap.dcaegen2.services.config.DmaapPublisherConfiguration;
import org.onap.dcaegen2.services.prh.configuration.AppConfig;
import org.onap.dcaegen2.services.prh.configuration.Config;
@@ -30,6 +28,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
*/
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java
index c051afbc..2922da1a 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java
@@ -39,14 +39,16 @@ public class ScheduledTasks {
private final Task dmaapConsumerTask;
private final Task dmaapProducerTask;
- private final Task aaiPublisherTask;
+ private final Task aaiProducerTask;
+ private final Task aaiConsumerTask;
@Autowired
public ScheduledTasks(DmaapConsumerTask dmaapConsumerTask, DmaapPublisherTask dmaapPublisherTask,
- AAIPublisherTask aaiPublisherTask) {
+ AAIProducerTask aaiPublisherTask, AAIConsumerTask aaiConsumerTask) {
this.dmaapConsumerTask = dmaapConsumerTask;
this.dmaapProducerTask = dmaapPublisherTask;
- this.aaiPublisherTask = aaiPublisherTask;
+ this.aaiProducerTask = aaiPublisherTask;
+ this.aaiConsumerTask = aaiConsumerTask;
}
public void scheduleMainPrhEventTask() {
@@ -65,8 +67,10 @@ public class ScheduledTasks {
}
private void setTaskExecutionFlow() {
- dmaapConsumerTask.setNext(aaiPublisherTask);
- aaiPublisherTask.setNext(dmaapProducerTask);
+ dmaapConsumerTask.setNext(aaiProducerTask);
+ aaiProducerTask.setNext(dmaapProducerTask);
+ aaiConsumerTask.setNext(aaiConsumerTask);
+ dmaapProducerTask.setNext(dmaapConsumerTask);
}
}
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/IT/ScheduledXmlContextITest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/IT/ScheduledXmlContextITest.java
index faecec4d..8094c993 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/IT/ScheduledXmlContextITest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/IT/ScheduledXmlContextITest.java
@@ -23,19 +23,15 @@ import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.FutureTask;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.onap.dcaegen2.services.prh.IT.junit5.mockito.MockitoExtension;
import org.onap.dcaegen2.services.prh.configuration.PrhAppConfig;
-import org.onap.dcaegen2.services.prh.exceptions.PrhTaskException;
import org.onap.dcaegen2.services.prh.tasks.ScheduledTasks;
+import org.onap.dcaegen2.services.utils.HttpRequestDetails;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
@@ -77,6 +73,11 @@ class ServiceMockProvider {
public PrhAppConfig getPrhAppConfig() {
return mock(PrhAppConfig.class);
}
+
+ @Bean
+ public HttpRequestDetails getRequestDetails() {
+ return mock(HttpRequestDetails.class);
+ }
}
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java
index 764bafec..e7d55419 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java
@@ -88,13 +88,13 @@ class PrhAppConfigTest {
prhAppConfig.initFileStreamReader();
appConfig.dmaapConsumerConfiguration = prhAppConfig.getDmaapConsumerConfiguration();
appConfig.dmaapPublisherConfiguration = prhAppConfig.getDmaapPublisherConfiguration();
- appConfig.aaiHttpClientConfiguration = prhAppConfig.getAAIHttpClientConfiguration();
+ appConfig.aaiClientConfiguration = prhAppConfig.getAAIClientConfiguration();
//
// Then
//
verify(prhAppConfig, times(1)).setFilepath(anyString());
verify(prhAppConfig, times(1)).initFileStreamReader();
- Assertions.assertNotNull(prhAppConfig.getAAIHttpClientConfiguration());
+ Assertions.assertNotNull(prhAppConfig.getAAIClientConfiguration());
Assertions.assertNotNull(prhAppConfig.getDmaapConsumerConfiguration());
Assertions.assertNotNull(prhAppConfig.getDmaapPublisherConfiguration());
Assertions
@@ -102,7 +102,7 @@ class PrhAppConfigTest {
Assertions
.assertEquals(appConfig.getDmaapConsumerConfiguration(), prhAppConfig.getDmaapConsumerConfiguration());
Assertions
- .assertEquals(appConfig.getAAIHttpClientConfiguration(), prhAppConfig.getAAIHttpClientConfiguration());
+ .assertEquals(appConfig.getAAIClientConfiguration(), prhAppConfig.getAAIClientConfiguration());
}
@@ -122,7 +122,7 @@ class PrhAppConfigTest {
//
verify(prhAppConfig, times(1)).setFilepath(anyString());
verify(prhAppConfig, times(1)).initFileStreamReader();
- Assertions.assertNull(prhAppConfig.getAAIHttpClientConfiguration());
+ Assertions.assertNull(prhAppConfig.getAAIClientConfiguration());
Assertions.assertNull(prhAppConfig.getDmaapConsumerConfiguration());
Assertions.assertNull(prhAppConfig.getDmaapPublisherConfiguration());
@@ -147,7 +147,7 @@ class PrhAppConfigTest {
//
verify(prhAppConfig, times(1)).setFilepath(anyString());
verify(prhAppConfig, times(1)).initFileStreamReader();
- Assertions.assertNotNull(prhAppConfig.getAAIHttpClientConfiguration());
+ Assertions.assertNotNull(prhAppConfig.getAAIClientConfiguration());
Assertions.assertNotNull(prhAppConfig.getDmaapConsumerConfiguration());
Assertions.assertNull(prhAppConfig.getDmaapPublisherConfiguration());
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskSpy.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskSpy.java
new file mode 100644
index 00000000..57c3ce21
--- /dev/null
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskSpy.java
@@ -0,0 +1,44 @@
+/*
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * 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.prh.tasks;
+
+import org.onap.dcaegen2.services.config.AAIClientConfiguration;
+
+import org.onap.dcaegen2.services.prh.configuration.AppConfig;
+import org.onap.dcaegen2.services.utils.HttpRequestDetails;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+
+import static org.mockito.Mockito.*;
+
+
+@Configuration
+public class AAIConsumerTaskSpy {
+
+ @Bean
+ @Primary
+ public AAIConsumerTask registerSimpleAAIPublisherTask() {
+ AppConfig appConfig = mock(AppConfig.class);
+ HttpRequestDetails requestDetails = mock(HttpRequestDetails.class);
+ when(appConfig.getAAIClientConfiguration()).thenReturn(mock(AAIClientConfiguration.class));
+ return spy(new AAIConsumerTaskImpl(appConfig, requestDetails));
+ }
+} \ No newline at end of file
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskSpy.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskSpy.java
index c27c8813..8da7f85d 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskSpy.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskSpy.java
@@ -19,16 +19,15 @@
*/
package org.onap.dcaegen2.services.prh.tasks;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import org.onap.dcaegen2.services.config.AAIHttpClientConfiguration;
+import org.onap.dcaegen2.services.config.AAIClientConfiguration;
import org.onap.dcaegen2.services.prh.configuration.AppConfig;
+import org.onap.dcaegen2.services.utils.HttpRequestDetails;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
+import static org.mockito.Mockito.*;
+
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
*/
@@ -37,9 +36,10 @@ public class AAIPublisherTaskSpy {
@Bean
@Primary
- public AAIPublisherTask registerSimpleAAIPublisherTask() {
+ public AAIProducerTask registerSimpleAAIPublisherTask() {
AppConfig appConfig = mock(AppConfig.class);
- when(appConfig.getAAIHttpClientConfiguration()).thenReturn(mock(AAIHttpClientConfiguration.class));
- return spy(new AAIPublisherTaskImpl(appConfig));
+ HttpRequestDetails requestDetails = mock(HttpRequestDetails.class);
+ when(appConfig.getAAIClientConfiguration()).thenReturn(mock(AAIClientConfiguration.class));
+ return spy(new AAIProducerTaskImpl(appConfig, requestDetails));
}
}
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduleControllerSpy.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduleControllerSpy.java
index 2d599b23..606b0cb8 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduleControllerSpy.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduleControllerSpy.java
@@ -40,11 +40,14 @@ public class ScheduleControllerSpy {
private DmaapPublisherTask dmaapPublisherTaskImplSpy;
@Autowired
- private AAIPublisherTask aaiPublisherTaskImplSpy;
+ private AAIProducerTask aaiPublisherTaskImplSpy;
+
+ @Autowired
+ private AAIConsumerTask aaiConsumerTaskImplSpy;
@Bean
@Primary
public ScheduledTasks registerSimpleScheduledTask() {
- return spy(new ScheduledTasks(dmaapConsumerTaskImplSpy, dmaapPublisherTaskImplSpy, aaiPublisherTaskImplSpy));
+ return spy(new ScheduledTasks(dmaapConsumerTaskImplSpy, dmaapPublisherTaskImplSpy, aaiPublisherTaskImplSpy, aaiConsumerTaskImplSpy));
}
}