summaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl/so
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2018-08-27 15:32:14 -0400
committerJim Hahn <jrh3@att.com>2018-08-28 10:56:27 -0400
commitf43b3e32fdf4cdb3361c584491730af18ef46baf (patch)
treed3e6434d66c3e5e8d6371581d64039b79c6ad584 /controlloop/common/model-impl/so
parent57ac9eac8ac0f8236ddb52e5226f475368d4de33 (diff)
use new SO API for scale-out
Updated licenses and serialization IDs. Moved hashCode() and equals() methods to be in same location as in the original code so it can be more easily compared. Changed vDNS yaml timeout and retry to 1200 and 0, respectively, to match the original values. Removed extra newline from yaml, to match original yaml. Reformatted source to wrap lines at 120 characters and removing trailing white space. Change-Id: I3f5e59a1f44750347de49164f587d4ffefdee8b4 Issue-ID: POLICY-962 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop/common/model-impl/so')
-rw-r--r--controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java67
-rw-r--r--controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestDetails.java58
-rw-r--r--controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestParameters.java20
-rw-r--r--controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSOManager.java102
-rw-r--r--controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoDummyServer.java87
5 files changed, 170 insertions, 164 deletions
diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java
index ae43f5bd9..92d52f4c2 100644
--- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java
+++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java
@@ -7,9 +7,9 @@
* 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.
@@ -22,14 +22,12 @@ package org.onap.policy.so;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
-
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-
import org.drools.core.WorkingMemory;
import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.rest.RESTManager;
@@ -40,15 +38,15 @@ import org.slf4j.LoggerFactory;
/**
- * This class handles the interface towards SO (Service Orchestrator) for the ONAP Policy Framework.
- * The SO API is defined at this link:
+ * This class handles the interface towards SO (Service Orchestrator) for the ONAP Policy
+ * Framework. The SO API is defined at this link:
* http://onap.readthedocs.io/en/latest/submodules/so.git/docs/SO_R1_Interface.html#get-orchestration-request
- *
+ *
*/
public final class SOManager {
private static final Logger logger = LoggerFactory.getLogger(SOManager.class);
private static final Logger netLogger =
- LoggerFactory.getLogger(org.onap.policy.common.endpoints.event.comm.Topic.NETWORK_LOGGER);
+ LoggerFactory.getLogger(org.onap.policy.common.endpoints.event.comm.Topic.NETWORK_LOGGER);
private static ExecutorService executors = Executors.newCachedThreadPool();
private static final int SO_RESPONSE_ERROR = 999;
@@ -73,7 +71,7 @@ public final class SOManager {
/**
* Create a service instance in SO.
- *
+ *
* @param url the SO URL
* @param urlBase the base URL
* @param username user name on SO
@@ -82,13 +80,13 @@ public final class SOManager {
* @return
*/
public SOResponse createModuleInstance(final String url, final String urlBase, final String username,
- final String password, final SORequest request) {
+ final String password, final SORequest request) {
// Issue the HTTP POST request to SO to create the service instance
String requestJson = Serialization.gsonPretty.toJson(request);
netLogger.info("[OUT|{}|{}|{}|{}|{}|{}|]{}{}", "SO", url, username, password, createSimpleHeaders(), MEDIA_TYPE,
- LINE_SEPARATOR, requestJson);
+ LINE_SEPARATOR, requestJson);
Pair<Integer, String> httpResponse =
- restManager.post(url, username, password, createSimpleHeaders(), MEDIA_TYPE, requestJson);
+ restManager.post(url, username, password, createSimpleHeaders(), MEDIA_TYPE, requestJson);
// Process the response from SO
SOResponse response = waitForSOOperationCompletion(urlBase, username, password, url, httpResponse);
@@ -100,9 +98,9 @@ public final class SOManager {
}
/**
- * This method makes an asynchronous Rest call to MSO and inserts the response into Drools
- * working memory.
- *
+ * This method makes an asynchronous Rest call to MSO and inserts the response into
+ * Drools working memory.
+ *
* @param wm the Drools working memory
* @param url the URL to use on the POST request
* @param urlBase the SO base URL
@@ -112,7 +110,7 @@ public final class SOManager {
* @return a concurrent Future for the thread that handles the request
*/
public Future<SOResponse> asyncSORestCall(final String requestID, final WorkingMemory wm,
- final String serviceInstanceId, final String vnfInstanceId, final SORequest request) {
+ final String serviceInstanceId, final String vnfInstanceId, final SORequest request) {
return executors.submit(new AsyncSORestCallThread(requestID, wm, serviceInstanceId, vnfInstanceId, request));
}
@@ -128,7 +126,7 @@ public final class SOManager {
/**
* Constructor, sets the context of the request.
- *
+ *
* @param requestID The request ID
* @param wm reference to the Drools working memory
* @param serviceInstanceId the service instance in SO to use
@@ -136,7 +134,7 @@ public final class SOManager {
* @param request the request itself
*/
private AsyncSORestCallThread(final String requestID, final WorkingMemory wm, final String serviceInstanceId,
- final String vnfInstanceId, final SORequest request) {
+ final String vnfInstanceId, final SORequest request) {
this.requestID = requestID;
this.wm = wm;
this.serviceInstanceId = serviceInstanceId;
@@ -154,15 +152,15 @@ public final class SOManager {
String password = PolicyEngine.manager.getEnvironmentProperty("so.password");
// The URL of the request we will POST
- String url =
- urlBase + "/serviceInstances/v5/" + serviceInstanceId + "/vnfs/" + vnfInstanceId + "/vfModules";
+ String url = urlBase + "/serviceInstantiation/v7/" + serviceInstanceId + "/vnfs/" + vnfInstanceId
+ + "/vfModules/scaleOut";
// Create a JSON representation of the request
String soJson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create().toJson(request);
netLogger.info("[OUT|{}|{}|]{}{}", "SO", url, LINE_SEPARATOR, soJson);
Pair<Integer, String> httpResponse =
- restManager.post(url, username, password, createSimpleHeaders(), MEDIA_TYPE, soJson);
+ restManager.post(url, username, password, createSimpleHeaders(), MEDIA_TYPE, soJson);
// Process the response from SO
SOResponse response = waitForSOOperationCompletion(urlBase, username, password, url, httpResponse);
@@ -177,7 +175,7 @@ public final class SOManager {
/**
* Wait for the SO operation we have ordered to complete.
- *
+ *
* @param urlBaseSO The base URL for SO
* @param username user name on SO
* @param password password on SO
@@ -186,7 +184,8 @@ public final class SOManager {
* @return The parsed final response of SO to the request
*/
private SOResponse waitForSOOperationCompletion(final String urlBaseSO, final String username,
- final String password, final String initialRequestURL, final Pair<Integer, String> initialHTTPResponse) {
+ final String password, final String initialRequestURL,
+ final Pair<Integer, String> initialHTTPResponse) {
// Process the initial response from SO, the response to a post
SOResponse response = processSOResponse(initialRequestURL, initialHTTPResponse);
if (SO_RESPONSE_ERROR == response.getHttpResponseCode()) {
@@ -201,7 +200,8 @@ public final class SOManager {
// Wait for the response from SO
for (int attemptsLeft = GET_REQUESTS_BEFORE_TIMEOUT; attemptsLeft >= 0; attemptsLeft--) {
- // The SO request may have completed even on the first request so we check the response
+ // The SO request may have completed even on the first request so we check the
+ // response
// here before
// issuing any other requests
if (isRequestStateFinished(latestHTTPResponse, response)) {
@@ -220,7 +220,7 @@ public final class SOManager {
// Issue a GET to find the current status of our request
netLogger.info("[OUT|{}|{}|{}|{}|{}|{}|]{}", "SO", urlGet, username, password, createSimpleHeaders(),
- MEDIA_TYPE, LINE_SEPARATOR);
+ MEDIA_TYPE, LINE_SEPARATOR);
Pair<Integer, String> httpResponse = restManager.get(urlGet, username, password, createSimpleHeaders());
// Get our response
@@ -240,7 +240,7 @@ public final class SOManager {
/**
* Parse the response message from SO into a SOResponse object.
- *
+ *
* @param requestURL The URL of the HTTP request
* @param httpDetails The HTTP message returned from SO
* @return The parsed response
@@ -248,7 +248,8 @@ public final class SOManager {
private SOResponse processSOResponse(final String requestURL, final Pair<Integer, String> httpResponse) {
SOResponse response = new SOResponse();
- // A null httpDetails indicates a HTTP problem, a valid response from SO must be either 200
+ // A null httpDetails indicates a HTTP problem, a valid response from SO must be
+ // either 200
// or 202
if (!httpResultIsNullFree(httpResponse) || (httpResponse.a != 200 && httpResponse.a != 202)) {
logger.error("Invalid HTTP response received from SO");
@@ -282,7 +283,7 @@ public final class SOManager {
/**
* Method to allow tuning of REST get timeout.
- *
+ *
* @param restGetTimeout the timeout value
*/
protected void setRestGetTimeout(final long restGetTimeout) {
@@ -291,18 +292,18 @@ public final class SOManager {
/**
* Check that the request state of a response is defined.
- *
+ *
* @param response The response to check
* @return true if the request for the response is defined
*/
private boolean isRequestStateDefined(final SOResponse response) {
return response != null && response.getRequest() != null && response.getRequest().getRequestStatus() != null
- && response.getRequest().getRequestStatus().getRequestState() != null;
+ && response.getRequest().getRequestStatus().getRequestState() != null;
}
/**
* Check that the request state of a response is finished.
- *
+ *
* @param latestHTTPDetails the HTTP details of the response
* @param response The response to check
* @return true if the request for the response is finished
@@ -318,7 +319,7 @@ public final class SOManager {
/**
* Check that a HTTP operation result has no nulls.
- *
+ *
* @param httpOperationResult the result to check
* @return true if no nulls are found
*/
@@ -328,7 +329,7 @@ public final class SOManager {
/**
* Create simple HTTP headers for unauthenticated requests to SO.
- *
+ *
* @return the HTTP headers
*/
private Map<String, String> createSimpleHeaders() {
diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestDetails.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestDetails.java
index 72e35d96e..13d25cf81 100644
--- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestDetails.java
+++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestDetails.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* so
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,7 +23,7 @@ package org.onap.policy.so;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
-
+import java.util.Map;
import com.google.gson.annotations.SerializedName;
public class SORequestDetails implements Serializable {
@@ -48,6 +48,9 @@ public class SORequestDetails implements Serializable {
@SerializedName("requestParameters")
private SORequestParameters requestParameters;
+ @SerializedName("configurationParameters")
+ private List<Map<String, String>> configurationParameters = new LinkedList<>();
+
public SORequestDetails() {
}
@@ -73,38 +76,37 @@ public class SORequestDetails implements Serializable {
if (cloudConfiguration == null) {
if (other.cloudConfiguration != null)
return false;
- }
- else if (!cloudConfiguration.equals(other.cloudConfiguration))
+ } else if (!cloudConfiguration.equals(other.cloudConfiguration))
+ return false;
+ if (configurationParameters == null) {
+ if (other.configurationParameters != null)
+ return false;
+ } else if (!configurationParameters.equals(other.configurationParameters))
return false;
if (modelInfo == null) {
if (other.modelInfo != null)
return false;
- }
- else if (!modelInfo.equals(other.modelInfo))
+ } else if (!modelInfo.equals(other.modelInfo))
return false;
if (relatedInstanceList == null) {
if (other.relatedInstanceList != null)
return false;
- }
- else if (!relatedInstanceList.equals(other.relatedInstanceList))
+ } else if (!relatedInstanceList.equals(other.relatedInstanceList))
return false;
if (requestInfo == null) {
if (other.requestInfo != null)
return false;
- }
- else if (!requestInfo.equals(other.requestInfo))
+ } else if (!requestInfo.equals(other.requestInfo))
return false;
if (requestParameters == null) {
if (other.requestParameters != null)
return false;
- }
- else if (!requestParameters.equals(other.requestParameters))
+ } else if (!requestParameters.equals(other.requestParameters))
return false;
if (subscriberInfo == null) {
if (other.subscriberInfo != null)
return false;
- }
- else if (!subscriberInfo.equals(other.subscriberInfo))
+ } else if (!subscriberInfo.equals(other.subscriberInfo))
return false;
return true;
}
@@ -129,6 +131,10 @@ public class SORequestDetails implements Serializable {
return requestParameters;
}
+ public List<Map<String, String>> getConfigurationParameters() {
+ return configurationParameters;
+ }
+
public SOSubscriberInfo getSubscriberInfo() {
return subscriberInfo;
}
@@ -137,13 +143,13 @@ public class SORequestDetails implements Serializable {
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result
- + ((cloudConfiguration == null) ? 0 : cloudConfiguration.hashCode());
+ result = prime * result + ((cloudConfiguration == null) ? 0 : cloudConfiguration.hashCode());
+ result = prime * result + ((configurationParameters == null) ? 0 : configurationParameters.hashCode());
result = prime * result + ((modelInfo == null) ? 0 : modelInfo.hashCode());
- result = prime * result
- + ((relatedInstanceList == null) ? 0 : relatedInstanceList.hashCode());
+ result = prime * result + ((relatedInstanceList == null) ? 0 : relatedInstanceList.hashCode());
result = prime * result + ((requestInfo == null) ? 0 : requestInfo.hashCode());
result = prime * result + ((requestParameters == null) ? 0 : requestParameters.hashCode());
+ result = prime * result + ((subscriberInfo == null) ? 0 : subscriberInfo.hashCode());
return result;
}
@@ -163,6 +169,10 @@ public class SORequestDetails implements Serializable {
this.requestParameters = requestParameters;
}
+ public void setConfigurationParameters(List<Map<String, String>> configurationParameters) {
+ this.configurationParameters = configurationParameters;
+ }
+
public void setSubscriberInfo(SOSubscriberInfo subscriberInfo) {
this.subscriberInfo = subscriberInfo;
}
@@ -173,10 +183,10 @@ public class SORequestDetails implements Serializable {
@Override
public String toString() {
- return "SORequestDetails [modelInfo=" + modelInfo + ", cloudConfiguration="
- + cloudConfiguration + ", requestInfo=" + requestInfo + ", relatedInstanceList="
- + relatedInstanceList + ", requestParameters=" + requestParameters +
- ", subscriberInfo=" + subscriberInfo + "]";
+ return "SORequestDetails [modelInfo=" + modelInfo + ", cloudConfiguration=" + cloudConfiguration
+ + ", requestInfo=" + requestInfo + ", subscriberInfo=" + subscriberInfo
+ + ", relatedInstanceList=" + relatedInstanceList + ", requestParameters=" + requestParameters
+ + ", configurationParameters=" + configurationParameters + "]";
}
}
diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestParameters.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestParameters.java
index 169752057..7ea20defd 100644
--- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestParameters.java
+++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestParameters.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* so
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,16 +24,18 @@ import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-
import com.google.gson.annotations.SerializedName;
public class SORequestParameters implements Serializable {
- private static final long serialVersionUID = -3283942659786236032L;
+ private static final long serialVersionUID = -3283942659786236033L;
@SerializedName("subscriptionServiceType")
private String subscriptionServiceType;
+ @SerializedName("usePreload")
+ private boolean usePreload;
+
@SerializedName("userParams")
private List<Map<String, String>> userParams = new LinkedList<>();
@@ -45,6 +47,10 @@ public class SORequestParameters implements Serializable {
return subscriptionServiceType;
}
+ public boolean isUsePreload() {
+ return usePreload;
+ }
+
public List<Map<String, String>> getUserParams() {
return userParams;
}
@@ -53,6 +59,10 @@ public class SORequestParameters implements Serializable {
this.subscriptionServiceType = subscriptionServiceType;
}
+ public void setUsePreload(boolean usePreload) {
+ this.usePreload = usePreload;
+ }
+
public void setUserParams(List<Map<String, String>> userParams) {
this.userParams = userParams;
}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSOManager.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSOManager.java
index 864362649..4a7fdda8d 100644
--- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSOManager.java
+++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSOManager.java
@@ -7,9 +7,9 @@
* 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.
@@ -24,12 +24,10 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-
import java.io.IOException;
import java.net.URI;
import java.util.UUID;
import java.util.concurrent.Future;
-
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
@@ -46,14 +44,14 @@ import org.junit.Test;
import org.onap.policy.drools.system.PolicyEngine;
public class TestSOManager {
- private static final String BASE_URI = "http://localhost:46553/TestSOManager";
+ private static final String BASE_URI = "http://localhost:46553/TestSOManager";
private static final String BASE_SO_URI = BASE_URI + "/SO";
private static HttpServer server;
@BeforeClass
public static void setUp() {
final ResourceConfig rc = new ResourceConfig(TestSoDummyServer.class);
- server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);
+ server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);
}
@AfterClass
@@ -77,13 +75,16 @@ public class TestSOManager {
assertNotNull(manager);
manager.setRestGetTimeout(100);
- SOResponse response = manager.createModuleInstance("http:/localhost:99999999", BASE_SO_URI, "sean", "citizen", null);
+ SOResponse response =
+ manager.createModuleInstance("http:/localhost:99999999", BASE_SO_URI, "sean", "citizen", null);
assertNull(response);
- response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstances/v5", BASE_SO_URI, "sean", "citizen", null);
+ response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean",
+ "citizen", null);
assertNull(response);
- response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstances/v5", BASE_SO_URI, "sean", "citizen", new SORequest());
+ response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean",
+ "citizen", new SORequest());
assertNull(response);
SORequest request = new SORequest();
@@ -94,16 +95,19 @@ public class TestSOManager {
request.setRequestStatus(new SORequestStatus());
request.getRequestStatus().setRequestState("ONGOING");
- response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstances/v5", BASE_SO_URI, "sean", "citizen", request);
+ response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean",
+ "citizen", request);
assertNull(response);
request.setRequestType("ReturnCompleted");
- response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstances/v5", BASE_SO_URI, "sean", "citizen", request);
+ response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean",
+ "citizen", request);
assertNotNull(response);
assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState());
request.setRequestType("ReturnFailed");
- response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstances/v5", BASE_SO_URI, "sean", "citizen", request);
+ response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean",
+ "citizen", request);
assertNotNull(response);
assertEquals("FAILED", response.getRequest().getRequestStatus().getRequestState());
@@ -111,14 +115,16 @@ public class TestSOManager {
request.setRequestType("ReturnOnging200");
request.setRequestScope(new Integer(10).toString());
- response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstances/v5", BASE_SO_URI, "sean", "citizen", request);
+ response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean",
+ "citizen", request);
assertNotNull(response);
assertNotNull(response.getRequest());
assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState());
request.setRequestType("ReturnOnging202");
request.setRequestScope(new Integer(20).toString());
- response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstances/v5", BASE_SO_URI, "sean", "citizen", request);
+ response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean",
+ "citizen", request);
assertNotNull(response);
assertNotNull(response.getRequest());
assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState());
@@ -126,13 +132,15 @@ public class TestSOManager {
// Test timeout after 20 attempts for a response
request.setRequestType("ReturnOnging202");
request.setRequestScope(new Integer(21).toString());
- response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstances/v5", BASE_SO_URI, "sean", "citizen", request);
+ response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean",
+ "citizen", request);
assertNull(response);
// Test bad response after 3 attempts for a response
request.setRequestType("ReturnBadAfterWait");
request.setRequestScope(new Integer(3).toString());
- response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstances/v5", BASE_SO_URI, "sean", "citizen", request);
+ response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean",
+ "citizen", request);
assertNull(response);
}
@@ -148,31 +156,31 @@ public class TestSOManager {
WorkingMemory wm = new DummyWorkingMemory();
PolicyEngine.manager.setEnvironmentProperty("so.url", "http:/localhost:99999999");
- Future<SOResponse> asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), null);
+ Future<SOResponse> asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm,
+ UUID.randomUUID().toString(), UUID.randomUUID().toString(), null);
try {
SOResponse response = asyncRestCallFuture.get();
assertEquals(999, response.getHttpResponseCode());
- }
- catch (Exception e) {
+ } catch (Exception e) {
fail("test should not throw an exception");
}
-
+
PolicyEngine.manager.setEnvironmentProperty("so.url", BASE_SO_URI);
- asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), null);
+ asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(),
+ UUID.randomUUID().toString(), null);
try {
SOResponse response = asyncRestCallFuture.get();
assertEquals(999, response.getHttpResponseCode());
- }
- catch (Exception e) {
+ } catch (Exception e) {
fail("test should not throw an exception");
}
- asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), new SORequest());
+ asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(),
+ UUID.randomUUID().toString(), new SORequest());
try {
SOResponse response = asyncRestCallFuture.get();
assertEquals(999, response.getHttpResponseCode());
- }
- catch (Exception e) {
+ } catch (Exception e) {
fail("test should not throw an exception");
}
@@ -184,33 +192,33 @@ public class TestSOManager {
request.setRequestStatus(new SORequestStatus());
request.getRequestStatus().setRequestState("ONGOING");
- asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request);
+ asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(),
+ UUID.randomUUID().toString(), request);
try {
SOResponse response = asyncRestCallFuture.get();
assertEquals(999, response.getHttpResponseCode());
- }
- catch (Exception e) {
+ } catch (Exception e) {
fail("test should not throw an exception");
}
request.setRequestType("ReturnCompleted");
- asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request);
+ asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(),
+ UUID.randomUUID().toString(), request);
try {
SOResponse response = asyncRestCallFuture.get();
assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState());
- }
- catch (Exception e) {
+ } catch (Exception e) {
fail("test should not throw an exception");
}
request.setRequestType("ReturnFailed");
- asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request);
+ asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(),
+ UUID.randomUUID().toString(), request);
try {
SOResponse response = asyncRestCallFuture.get();
assertEquals("FAILED", response.getRequest().getRequestStatus().getRequestState());
- }
- catch (Exception e) {
+ } catch (Exception e) {
fail("test should not throw an exception");
}
@@ -218,49 +226,49 @@ public class TestSOManager {
request.setRequestType("ReturnOnging200");
request.setRequestScope(new Integer(10).toString());
- asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request);
+ asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(),
+ UUID.randomUUID().toString(), request);
try {
SOResponse response = asyncRestCallFuture.get();
assertNotNull(response.getRequest());
assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState());
- }
- catch (Exception e) {
+ } catch (Exception e) {
fail("test should not throw an exception");
}
request.setRequestType("ReturnOnging202");
request.setRequestScope(new Integer(20).toString());
- asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request);
+ asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(),
+ UUID.randomUUID().toString(), request);
try {
SOResponse response = asyncRestCallFuture.get();
assertNotNull(response.getRequest());
assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState());
- }
- catch (Exception e) {
+ } catch (Exception e) {
fail("test should not throw an exception");
}
// Test timeout after 20 attempts for a response
request.setRequestType("ReturnOnging202");
request.setRequestScope(new Integer(21).toString());
- asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request);
+ asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(),
+ UUID.randomUUID().toString(), request);
try {
SOResponse response = asyncRestCallFuture.get();
assertEquals(999, response.getHttpResponseCode());
- }
- catch (Exception e) {
+ } catch (Exception e) {
fail("test should not throw an exception");
}
// Test bad response after 3 attempts for a response
request.setRequestType("ReturnBadAfterWait");
request.setRequestScope(new Integer(3).toString());
- asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request);
+ asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(),
+ UUID.randomUUID().toString(), request);
try {
SOResponse response = asyncRestCallFuture.get();
assertEquals(999, response.getHttpResponseCode());
- }
- catch (Exception e) {
+ } catch (Exception e) {
fail("test should not throw an exception");
}
}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoDummyServer.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoDummyServer.java
index 907ca69bc..348523140 100644
--- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoDummyServer.java
+++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoDummyServer.java
@@ -4,12 +4,14 @@
* ================================================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2018 AT&T. 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.
@@ -22,13 +24,11 @@ package org.onap.policy.so;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
-
import com.google.gson.Gson;
@Path("/SO")
@@ -45,7 +45,8 @@ public class TestSoDummyServer {
@Path("/Stats")
public Response serviceGetStats() {
statMessagesReceived++;
- return Response.status(200).entity("{\"GET\": " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + ",\"POST\": " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build();
+ return Response.status(200).entity("{\"GET\": " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived
+ + ",\"POST\": " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build();
}
@GET
@@ -56,7 +57,7 @@ public class TestSoDummyServer {
}
@POST
- @Path("/serviceInstances/v5")
+ @Path("/serviceInstantiation/v7")
public Response servicePostRequest(final String jsonString) {
postMessagesReceived++;
@@ -67,8 +68,7 @@ public class TestSoDummyServer {
SORequest request = null;
try {
request = new Gson().fromJson(jsonString, SORequest.class);
- }
- catch (Exception e) {
+ } catch (Exception e) {
return Response.status(400).build();
}
@@ -82,8 +82,10 @@ public class TestSoDummyServer {
if ("ReturnBadJson".equals(request.getRequestType())) {
return Response.status(200)
- .entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + ",\"POST\": , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}")
- .build();
+ .entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived
+ + ",\"POST\": , " + postMessagesReceived + ",\"PUT\": "
+ + putMessagesReceived + "}")
+ .build();
}
SOResponse response = new SOResponse();
@@ -95,18 +97,14 @@ public class TestSoDummyServer {
response.getRequest().getRequestStatus().setRequestState("COMPLETE");
response.setHttpResponseCode(200);
String responseString = new Gson().toJson(response, SOResponse.class);
- return Response.status(response.getHttpResponseCode())
- .entity(responseString)
- .build();
+ return Response.status(response.getHttpResponseCode()).entity(responseString).build();
}
if ("ReturnFailed".equals(request.getRequestType())) {
response.getRequest().getRequestStatus().setRequestState("FAILED");
response.setHttpResponseCode(200);
String responseString = new Gson().toJson(response, SOResponse.class);
- return Response.status(response.getHttpResponseCode())
- .entity(responseString)
- .build();
+ return Response.status(response.getHttpResponseCode()).entity(responseString).build();
}
if ("ReturnOnging202".equals(request.getRequestType())) {
@@ -115,9 +113,7 @@ public class TestSoDummyServer {
response.getRequest().getRequestStatus().setRequestState("ONGOING");
response.setHttpResponseCode(202);
String responseString = new Gson().toJson(response, SOResponse.class);
- return Response.status(response.getHttpResponseCode())
- .entity(responseString)
- .build();
+ return Response.status(response.getHttpResponseCode()).entity(responseString).build();
}
if ("ReturnOnging200".equals(request.getRequestType())) {
@@ -126,9 +122,7 @@ public class TestSoDummyServer {
response.getRequest().getRequestStatus().setRequestState("ONGOING");
response.setHttpResponseCode(200);
String responseString = new Gson().toJson(response, SOResponse.class);
- return Response.status(response.getHttpResponseCode())
- .entity(responseString)
- .build();
+ return Response.status(response.getHttpResponseCode()).entity(responseString).build();
}
@@ -138,20 +132,16 @@ public class TestSoDummyServer {
response.getRequest().getRequestStatus().setRequestState("ONGOING");
response.setHttpResponseCode(200);
String responseString = new Gson().toJson(response, SOResponse.class);
- return Response.status(response.getHttpResponseCode())
- .entity(responseString)
- .build();
+ return Response.status(response.getHttpResponseCode()).entity(responseString).build();
}
return null;
}
@POST
- @Path("/serviceInstances/v5/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules")
- public Response servicePostRequestVfModules(
- @PathParam("serviceInstanceId") final String serviceInstanceId,
- @PathParam("vnfInstanceId") final String vnfInstanceId,
- final String jsonString) {
+ @Path("/serviceInstantiation/v7/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/scaleOut")
+ public Response servicePostRequestVfModules(@PathParam("serviceInstanceId") final String serviceInstanceId,
+ @PathParam("vnfInstanceId") final String vnfInstanceId, final String jsonString) {
postMessagesReceived++;
if (jsonString == null) {
@@ -161,8 +151,7 @@ public class TestSoDummyServer {
SORequest request = null;
try {
request = new Gson().fromJson(jsonString, SORequest.class);
- }
- catch (Exception e) {
+ } catch (Exception e) {
return Response.status(400).build();
}
@@ -176,8 +165,10 @@ public class TestSoDummyServer {
if ("ReturnBadJson".equals(request.getRequestType())) {
return Response.status(200)
- .entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + ",\"POST\": , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}")
- .build();
+ .entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived
+ + ",\"POST\": , " + postMessagesReceived + ",\"PUT\": "
+ + putMessagesReceived + "}")
+ .build();
}
SOResponse response = new SOResponse();
@@ -189,18 +180,14 @@ public class TestSoDummyServer {
response.getRequest().getRequestStatus().setRequestState("COMPLETE");
response.setHttpResponseCode(200);
String responseString = new Gson().toJson(response, SOResponse.class);
- return Response.status(response.getHttpResponseCode())
- .entity(responseString)
- .build();
+ return Response.status(response.getHttpResponseCode()).entity(responseString).build();
}
if ("ReturnFailed".equals(request.getRequestType())) {
response.getRequest().getRequestStatus().setRequestState("FAILED");
response.setHttpResponseCode(200);
String responseString = new Gson().toJson(response, SOResponse.class);
- return Response.status(response.getHttpResponseCode())
- .entity(responseString)
- .build();
+ return Response.status(response.getHttpResponseCode()).entity(responseString).build();
}
if ("ReturnOnging202".equals(request.getRequestType())) {
@@ -209,9 +196,7 @@ public class TestSoDummyServer {
response.getRequest().getRequestStatus().setRequestState("ONGOING");
response.setHttpResponseCode(202);
String responseString = new Gson().toJson(response, SOResponse.class);
- return Response.status(response.getHttpResponseCode())
- .entity(responseString)
- .build();
+ return Response.status(response.getHttpResponseCode()).entity(responseString).build();
}
if ("ReturnOnging200".equals(request.getRequestType())) {
@@ -220,9 +205,7 @@ public class TestSoDummyServer {
response.getRequest().getRequestStatus().setRequestState("ONGOING");
response.setHttpResponseCode(200);
String responseString = new Gson().toJson(response, SOResponse.class);
- return Response.status(response.getHttpResponseCode())
- .entity(responseString)
- .build();
+ return Response.status(response.getHttpResponseCode()).entity(responseString).build();
}
@@ -232,9 +215,7 @@ public class TestSoDummyServer {
response.getRequest().getRequestStatus().setRequestState("ONGOING");
response.setHttpResponseCode(200);
String responseString = new Gson().toJson(response, SOResponse.class);
- return Response.status(response.getHttpResponseCode())
- .entity(responseString)
- .build();
+ return Response.status(response.getHttpResponseCode()).entity(responseString).build();
}
return null;
@@ -250,9 +231,7 @@ public class TestSoDummyServer {
if (--iterationsLeft > 0) {
response.getRequest().setRequestScope(new Integer(iterationsLeft).toString());
String responseString = new Gson().toJson(response, SOResponse.class);
- return Response.status(response.getHttpResponseCode())
- .entity(responseString)
- .build();
+ return Response.status(response.getHttpResponseCode()).entity(responseString).build();
}
ongoingRequestMap.remove(nsInstanceId);
@@ -265,8 +244,6 @@ public class TestSoDummyServer {
response.getRequest().setRequestScope("0");
response.setHttpResponseCode(200);
String responseString = new Gson().toJson(response, SOResponse.class);
- return Response.status(response.getHttpResponseCode())
- .entity(responseString)
- .build();
+ return Response.status(response.getHttpResponseCode()).entity(responseString).build();
}
}