diff options
42 files changed, 2390 insertions, 829 deletions
diff --git a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java b/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java index ad27a0201..64008e7ff 100644 --- a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java +++ b/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java @@ -334,59 +334,59 @@ public class SOActorServiceProvider implements Actor { // Construct SO Request SORequest request = new SORequest(); // request.requestId = onset.requestID; - request.requestDetails = new SORequestDetails(); - request.requestDetails.modelInfo = new SOModelInfo(); - request.requestDetails.cloudConfiguration = new SOCloudConfiguration(); - request.requestDetails.requestInfo = new SORequestInfo(); - request.requestDetails.requestParameters = new SORequestParameters(); - request.requestDetails.requestParameters.userParams = null; + request.setRequestDetails(new SORequestDetails()); + request.getRequestDetails().setModelInfo(new SOModelInfo()); + request.getRequestDetails().setCloudConfiguration(new SOCloudConfiguration()); + request.getRequestDetails().setRequestInfo(new SORequestInfo()); + request.getRequestDetails().setRequestParameters(new SORequestParameters()); + request.getRequestDetails().getRequestParameters().setUserParams(null); // // cloudConfiguration // - request.requestDetails.cloudConfiguration.lcpCloudRegionId = getCloudRegionItemCloudRegionId(); - request.requestDetails.cloudConfiguration.tenantId = getTenantItemTenantId(); + request.getRequestDetails().getCloudConfiguration().setLcpCloudRegionId(getCloudRegionItemCloudRegionId()); + request.getRequestDetails().getCloudConfiguration().setTenantId(getTenantItemTenantId()); // // modelInfo // - request.requestDetails.modelInfo.modelType = "vfModule"; - request.requestDetails.modelInfo.modelInvariantId = getVfModuleItemModelInvariantId(); - request.requestDetails.modelInfo.modelVersionId = getVfModuleItemModelNameVersionId(); - request.requestDetails.modelInfo.modelName = getVfModuleItemModelName(); - request.requestDetails.modelInfo.modelVersion = getVfModuleItemModelVersionId(); + request.getRequestDetails().getModelInfo().setModelType("vfModule"); + request.getRequestDetails().getModelInfo().setModelInvariantId(getVfModuleItemModelInvariantId()); + request.getRequestDetails().getModelInfo().setModelVersionId(getVfModuleItemModelNameVersionId()); + request.getRequestDetails().getModelInfo().setModelName(getVfModuleItemModelName()); + request.getRequestDetails().getModelInfo().setModelVersion(getVfModuleItemModelVersionId()); // // requestInfo // - request.requestDetails.requestInfo.instanceName = getVfModuleItemVfModuleName(); - request.requestDetails.requestInfo.source = "POLICY"; - request.requestDetails.requestInfo.suppressRollback = false; - request.requestDetails.requestInfo.requestorId = "policy"; + request.getRequestDetails().getRequestInfo().setInstanceName(getVfModuleItemVfModuleName()); + request.getRequestDetails().getRequestInfo().setSource("POLICY"); + request.getRequestDetails().getRequestInfo().setSuppressRollback(false); + request.getRequestDetails().getRequestInfo().setRequestorId("policy"); // // relatedInstanceList // SORelatedInstanceListElement relatedInstanceListElement1 = new SORelatedInstanceListElement(); SORelatedInstanceListElement relatedInstanceListElement2 = new SORelatedInstanceListElement(); - relatedInstanceListElement1.relatedInstance = new SORelatedInstance(); - relatedInstanceListElement2.relatedInstance = new SORelatedInstance(); + relatedInstanceListElement1.setRelatedInstance(new SORelatedInstance()); + relatedInstanceListElement2.setRelatedInstance(new SORelatedInstance()); // - relatedInstanceListElement1.relatedInstance.instanceId = getServiceItemServiceInstanceId(); - relatedInstanceListElement1.relatedInstance.modelInfo = new SOModelInfo(); - relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "service"; - relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = getServiceItemModelInvariantId(); - relatedInstanceListElement1.relatedInstance.modelInfo.modelVersionId = getServiceItemModelNameVersionId(); - relatedInstanceListElement1.relatedInstance.modelInfo.modelName = getServiceItemModelName(); - relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = getServiceItemModelVersion(); + relatedInstanceListElement1.getRelatedInstance().setInstanceId(getServiceItemServiceInstanceId()); + relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SOModelInfo()); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("service"); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelInvariantId(getServiceItemModelInvariantId()); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersionId(getServiceItemModelNameVersionId()); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelName(getServiceItemModelName()); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersion(getServiceItemModelVersion()); // - relatedInstanceListElement2.relatedInstance.instanceId = getVnfItemVnfId(); - relatedInstanceListElement2.relatedInstance.modelInfo = new SOModelInfo(); - relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "vnf"; - relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = getVnfItemModelInvariantId(); - relatedInstanceListElement2.relatedInstance.modelInfo.modelVersionId = getVnfItemModelNameVersionId(); - relatedInstanceListElement2.relatedInstance.modelInfo.modelName = getVnfItemModelName(); - relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = getVnfItemModelVersion(); - relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = getVnfItemVnfType(); + relatedInstanceListElement2.getRelatedInstance().setInstanceId(getVnfItemVnfId()); + relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SOModelInfo()); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("vnf"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelInvariantId(getVnfItemModelInvariantId()); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersionId(getVnfItemModelNameVersionId()); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName(getVnfItemModelName()); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersion(getVnfItemModelVersion()); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelCustomizationName(getVnfItemVnfType()); // - request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1); - request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2); + request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1); + request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2); // // print SO request for debug // diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java index 0ce3bc5c3..8edb7ef14 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java @@ -423,13 +423,13 @@ public class ControlLoopOperationManager implements Serializable { } else if (response instanceof SOResponseWrapper) { SOResponseWrapper msoResponse = (SOResponseWrapper) response; - switch (msoResponse.SOResponse.httpResponseCode) { + switch (msoResponse.getSoResponse().getHttpResponseCode()) { case 200: case 202: // // Consider it as success // - this.completeOperation(this.attempts, msoResponse.SOResponse.httpResponseCode + " Success", PolicyResult.SUCCESS); + this.completeOperation(this.attempts, msoResponse.getSoResponse().getHttpResponseCode() + " Success", PolicyResult.SUCCESS); if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) { return null; } @@ -438,7 +438,7 @@ public class ControlLoopOperationManager implements Serializable { // // Consider it as failure // - this.completeOperation(this.attempts, msoResponse.SOResponse.httpResponseCode + " Failed", PolicyResult.FAILURE); + this.completeOperation(this.attempts, msoResponse.getSoResponse().getHttpResponseCode() + " Failed", PolicyResult.FAILURE); if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) { return null; } diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOAsyncRequestStatus.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOAsyncRequestStatus.java index 97978c73f..2cc22f379 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOAsyncRequestStatus.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOAsyncRequestStatus.java @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * mso
+ * so
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -27,37 +27,99 @@ import com.google.gson.annotations.SerializedName; public class SOAsyncRequestStatus implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = -3283942659786236032L;
-
- @SerializedName("correlator")
- public String correlator;
-
- @SerializedName("requestId")
- public String requestId;
-
- @SerializedName("instanceReferences")
- public SOInstanceReferences instanceReferences;
-
- @SerializedName("startTime")
- public LocalDateTime startTime;
-
- @SerializedName("finishTime")
- public LocalDateTime finishTime;
-
- @SerializedName("requestScope")
- public String requestScope;
-
- @SerializedName("requestType")
- public String requestType;
-
- @SerializedName("requestStatus")
- public SORequestStatus requestStatus;
-
-
- public SOAsyncRequestStatus() {
- }
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("correlator")
+ private String correlator;
+
+ @SerializedName("requestId")
+ private String requestId;
+
+ @SerializedName("instanceReferences")
+ private SOInstanceReferences instanceReferences;
+
+ @SerializedName("startTime")
+ private LocalDateTime startTime;
+
+ @SerializedName("finishTime")
+ private LocalDateTime finishTime;
+
+ @SerializedName("requestScope")
+ private String requestScope;
+
+ @SerializedName("requestType")
+ private String requestType;
+
+ @SerializedName("requestStatus")
+ private SORequestStatus requestStatus;
+
+ public SOAsyncRequestStatus() {
+ // required by author
+ }
+
+ public String getCorrelator() {
+ return correlator;
+ }
+
+
+ public LocalDateTime getFinishTime() {
+ return finishTime;
+ }
+
+ public SOInstanceReferences getInstanceReferences() {
+ return instanceReferences;
+ }
+
+ public String getRequestId() {
+ return requestId;
+ }
+
+ public String getRequestScope() {
+ return requestScope;
+ }
+
+ public SORequestStatus getRequestStatus() {
+ return requestStatus;
+ }
+
+ public String getRequestType() {
+ return requestType;
+ }
+
+ public LocalDateTime getStartTime() {
+ return startTime;
+ }
+
+ public void setCorrelator(String correlator) {
+ this.correlator = correlator;
+ }
+
+ public void setFinishTime(LocalDateTime finishTime) {
+ this.finishTime = finishTime;
+ }
+
+ public void setInstanceReferences(SOInstanceReferences instanceReferences) {
+ this.instanceReferences = instanceReferences;
+ }
+
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+ public void setRequestScope(String requestScope) {
+ this.requestScope = requestScope;
+ }
+
+ public void setRequestStatus(SORequestStatus requestStatus) {
+ this.requestStatus = requestStatus;
+ }
+
+ public void setRequestType(String requestType) {
+ this.requestType = requestType;
+ }
+
+ public void setStartTime(LocalDateTime startTime) {
+ this.startTime = startTime;
+ }
}
diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOCloudConfiguration.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOCloudConfiguration.java index 6b817075f..a1233bff1 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOCloudConfiguration.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOCloudConfiguration.java @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * mso
+ * so
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -22,23 +22,36 @@ package org.onap.policy.so; import java.io.Serializable;
-
import com.google.gson.annotations.SerializedName;
public class SOCloudConfiguration implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = -3283942659786236032L;
-
- @SerializedName("lcpCloudRegionId")
- public String lcpCloudRegionId;
-
- @SerializedName("tenantId")
- public String tenantId;
-
- public SOCloudConfiguration() {
- }
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("lcpCloudRegionId")
+ private String lcpCloudRegionId;
+
+ @SerializedName("tenantId")
+ private String tenantId;
+
+ public SOCloudConfiguration() {
+ //required by author
+ }
+
+ public String getLcpCloudRegionId() {
+ return lcpCloudRegionId;
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ public void setLcpCloudRegionId(String lcpCloudRegionId) {
+ this.lcpCloudRegionId = lcpCloudRegionId;
+ }
+
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
}
diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOInstanceReferences.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOInstanceReferences.java index 97abd3950..f2155082d 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOInstanceReferences.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOInstanceReferences.java @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * mso
+ * so
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -22,23 +22,36 @@ package org.onap.policy.so; import java.io.Serializable;
-
import com.google.gson.annotations.SerializedName;
public class SOInstanceReferences implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = -3283942659786236032L;
-
- @SerializedName("requestId")
- public String requestId;
-
- @SerializedName("instanceId")
- public String instanceId;
-
- public SOInstanceReferences() {
- }
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("requestId")
+ private String requestId;
+
+ @SerializedName("instanceId")
+ private String instanceId;
+
+ public SOInstanceReferences() {
+ //requried by author
+ }
+
+ public String getInstanceId() {
+ return instanceId;
+ }
+
+ public String getRequestId() {
+ return requestId;
+ }
+
+ public void setInstanceId(String instanceId) {
+ this.instanceId = instanceId;
+ }
+
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
}
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 e4d8af883..4b1d1d630 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 @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * mso + * so * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ @@ -42,159 +42,176 @@ import com.google.gson.JsonSyntaxException; public final class SOManager { - private static final Logger logger = LoggerFactory.getLogger(SOManager.class); - private static final Logger netLogger = LoggerFactory.getLogger(org.onap.policy.drools.event.comm.Topic.NETWORK_LOGGER); - private static ExecutorService executors = Executors.newCachedThreadPool(); - - public static SOResponse createModuleInstance(String url, String urlBase, String username, String password, SORequest request) { - - // - // Call REST - // - Map<String, String> headers = new HashMap<String, String>(); - //headers.put("X-FromAppId", "POLICY"); - //headers.put("X-TransactionId", requestID.toString()); - headers.put("Accept", "application/json"); - - // - // 201 - CREATED - you are done just return - // - String requestJson = Serialization.gsonPretty.toJson(request); - netLogger.info("[OUT|{}|{}|]{}{}", "SO", url, System.lineSeparator(), requestJson); - Pair<Integer, String> httpDetails = new RESTManager().post(url, username, password, headers, "application/json", requestJson); - - if (httpDetails == null) { - return null; - } - - if (httpDetails.a == 202) { - try { - SOResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, SOResponse.class); - - String body = Serialization.gsonPretty.toJson(response); - logger.debug("***** Response to post:"); - logger.debug(body); - - String requestId = response.requestReferences.requestId; - int attemptsLeft = 20; - - //String getUrl = "/orchestrationRequests/v2/"+requestId; - String urlGet = urlBase + "/orchestrationRequests/v2/"+requestId; - SOResponse responseGet = null; - - while(attemptsLeft-- > 0){ - - Pair<Integer, String> httpDetailsGet = new RESTManager().get(urlGet, username, password, headers); - responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, SOResponse.class); - netLogger.info("[IN|{}|{}|]{}{}", "SO", urlGet, System.lineSeparator(), httpDetailsGet.b); - - body = Serialization.gsonPretty.toJson(responseGet); - logger.debug("***** Response to get:"); - logger.debug(body); - - if(httpDetailsGet.a == 200){ - if(responseGet.request.requestStatus.requestState.equalsIgnoreCase("COMPLETE") || - responseGet.request.requestStatus.requestState.equalsIgnoreCase("FAILED")){ - logger.debug("***** ######## VF Module Creation "+responseGet.request.requestStatus.requestState); - return responseGet; - } - } - Thread.sleep(20000); - } - - if (responseGet != null - && responseGet.request != null - && responseGet.request.requestStatus != null - && responseGet.request.requestStatus.requestState != null) { - logger.warn("***** ######## VF Module Creation timeout. Status: ( {})", responseGet.request.requestStatus.requestState); - } - - return responseGet; - } catch (JsonSyntaxException e) { - logger.error("Failed to deserialize into SOResponse: ", e); - } catch (InterruptedException e) { - logger.error("Interrupted exception: ", e); - Thread.currentThread().interrupt(); - } - } - - - - - return null; - } - - /** - * - * @param wm - * @param url - * @param urlBase - * @param username - * @param password - * @param request - * - * This method makes an asynchronous Rest call to MSO and inserts the response into the Drools working memory - */ - public void asyncSORestCall(String requestID, WorkingMemory wm, String serviceInstanceId, String vnfInstanceId, SORequest request) { - executors.submit(new Runnable() - { - @Override - public void run() - { - try { - String serverRoot = PolicyEngine.manager.getEnvironmentProperty("so.url"); - String username = PolicyEngine.manager.getEnvironmentProperty("so.username"); - String password = PolicyEngine.manager.getEnvironmentProperty("so.password"); - - String url = serverRoot + "/serviceInstances/v5/" + serviceInstanceId + "/vnfs/" + vnfInstanceId + "/vfModules"; - - String auth = username + ":" + password; - - Map<String, String> headers = new HashMap<String, String>(); - byte[] encodedBytes = Base64.getEncoder().encode(auth.getBytes()); - headers.put("Accept", "application/json"); - headers.put("Authorization", "Basic " + new String(encodedBytes)); - - Gson gsonPretty = new GsonBuilder().disableHtmlEscaping() - .setPrettyPrinting() - .create(); - - String soJson = gsonPretty.toJson(request); - - SOResponse so = new SOResponse(); - netLogger.info("[OUT|{}|{}|]{}{}", "SO", url, System.lineSeparator(), soJson); - Pair<Integer, String> httpResponse = new RESTManager().post(url, "policy", "policy", headers, "application/json", soJson); - - if (httpResponse != null ) { - if (httpResponse.b != null && httpResponse.a != null) { - netLogger.info("[IN|{}|{}|]{}{}", url, "SO", System.lineSeparator(), httpResponse.b); - - Gson gson = new Gson(); - so = gson.fromJson(httpResponse.b, SOResponse.class); - so.httpResponseCode = httpResponse.a; - } else { - logger.error("SO Response status/code is null."); - so.httpResponseCode = 999; - } - - } else { - logger.error("SO Response returned null."); - so.httpResponseCode = 999; - } - - SOResponseWrapper SoWrapper = new SOResponseWrapper(so, requestID); - wm.insert(SoWrapper); - logger.info("SOResponse inserted " + gsonPretty.toJson(SoWrapper)); - } catch (Exception e) { - logger.error("Error while performing asyncSORestCall: "+ e.getMessage(),e); - - // create dummy SO object to trigger cleanup - SOResponse so = new SOResponse(); - so.httpResponseCode = 999; - wm.insert(so); - } - } - }); - } + private static final Logger logger = LoggerFactory.getLogger(SOManager.class); + private static final Logger netLogger = + LoggerFactory.getLogger(org.onap.policy.drools.event.comm.Topic.NETWORK_LOGGER); + private static ExecutorService executors = Executors.newCachedThreadPool(); + + static final String MEDIA_TYPE = "application/json"; + + static final String LINE_SEPARATOR = System.lineSeparator(); + + public static SOResponse createModuleInstance(String url, String urlBase, String username, + String password, SORequest request) { + + // + // Call REST + // + Map<String, String> headers = new HashMap<>(); + headers.put("Accept", MEDIA_TYPE); + + // + // 201 - CREATED - you are done just return + // + String requestJson = Serialization.gsonPretty.toJson(request); + netLogger.info("[OUT|{}|{}|]{}{}", "SO", url, LINE_SEPARATOR, requestJson); + Pair<Integer, String> httpDetails = + new RESTManager().post(url, username, password, headers, MEDIA_TYPE, requestJson); + + if (httpDetails == null) { + return null; + } + + if (httpDetails.a == 202) { + try { + SOResponse response = + Serialization.gsonPretty.fromJson(httpDetails.b, SOResponse.class); + + String body = Serialization.gsonPretty.toJson(response); + logger.debug("***** Response to post:"); + logger.debug(body); + + String requestId = response.getRequestReferences().getRequestId(); + int attemptsLeft = 20; + + String urlGet = urlBase + "/orchestrationRequests/v2/" + requestId; + SOResponse responseGet = null; + + while (attemptsLeft-- > 0) { + + Pair<Integer, String> httpDetailsGet = + new RESTManager().get(urlGet, username, password, headers); + responseGet = + Serialization.gsonPretty.fromJson(httpDetailsGet.b, SOResponse.class); + netLogger.info("[IN|{}|{}|]{}{}", "SO", urlGet, LINE_SEPARATOR, + httpDetailsGet.b); + + body = Serialization.gsonPretty.toJson(responseGet); + logger.debug("***** Response to get:"); + logger.debug(body); + + if (httpDetailsGet.a == 200) { + if (responseGet.getRequest().getRequestStatus().getRequestState() + .equalsIgnoreCase("COMPLETE") + || responseGet.getRequest().getRequestStatus().getRequestState() + .equalsIgnoreCase("FAILED")) { + logger.debug("***** ######## VF Module Creation {}", + responseGet.getRequest().getRequestStatus().getRequestState()); + return responseGet; + } + } + Thread.sleep(20000); + } + + if (responseGet != null && responseGet.getRequest() != null + && responseGet.getRequest().getRequestStatus() != null + && responseGet.getRequest().getRequestStatus().getRequestState() != null) { + logger.warn("***** ######## VF Module Creation timeout. Status: ( {})", + responseGet.getRequest().getRequestStatus().getRequestState()); + } + + return responseGet; + } + catch (JsonSyntaxException e) { + logger.error("Failed to deserialize into SOResponse: ", e); + } + catch (InterruptedException e) { + logger.error("Interrupted exception: ", e); + Thread.currentThread().interrupt(); + } + } + + + + return null; + } + + /** + * + * @param wm + * @param url + * @param urlBase + * @param username + * @param password + * @param request + * + * This method makes an asynchronous Rest call to MSO and inserts the response into the + * Drools working memory + */ + public void asyncSORestCall(String requestID, WorkingMemory wm, String serviceInstanceId, + String vnfInstanceId, SORequest request) { + executors.submit(new Runnable() { + @Override + public void run() { + try { + String serverRoot = PolicyEngine.manager.getEnvironmentProperty("so.url"); + String username = PolicyEngine.manager.getEnvironmentProperty("so.username"); + String password = PolicyEngine.manager.getEnvironmentProperty("so.password"); + + String url = serverRoot + "/serviceInstances/v5/" + serviceInstanceId + "/vnfs/" + + vnfInstanceId + "/vfModules"; + + String auth = username + ":" + password; + + Map<String, String> headers = new HashMap<>(); + byte[] encodedBytes = Base64.getEncoder().encode(auth.getBytes()); + headers.put("Accept", MEDIA_TYPE); + headers.put("Authorization", "Basic " + new String(encodedBytes)); + + Gson gsonPretty = + new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create(); + + String soJson = gsonPretty.toJson(request); + + SOResponse so = new SOResponse(); + netLogger.info("[OUT|{}|{}|]{}{}", "SO", url, LINE_SEPARATOR, soJson); + Pair<Integer, String> httpResponse = new RESTManager().post(url, "policy", + "policy", headers, MEDIA_TYPE, soJson); + + if (httpResponse != null) { + if (httpResponse.b != null && httpResponse.a != null) { + netLogger.info("[IN|{}|{}|]{}{}", url, "SO", LINE_SEPARATOR, + httpResponse.b); + + Gson gson = new Gson(); + so = gson.fromJson(httpResponse.b, SOResponse.class); + so.setHttpResponseCode(httpResponse.a); + } + else { + logger.error("SO Response status/code is null."); + so.setHttpResponseCode(999); + } + + } + else { + logger.error("SO Response returned null."); + so.setHttpResponseCode(999); + } + + SOResponseWrapper soWrapper = new SOResponseWrapper(so, requestID); + wm.insert(soWrapper); + logger.info("SOResponse inserted " + gsonPretty.toJson(soWrapper)); + } + catch (Exception e) { + logger.error("Error while performing asyncSORestCall: " + e.getMessage(), e); + + // create dummy SO object to trigger cleanup + SOResponse so = new SOResponse(); + so.setHttpResponseCode(999); + wm.insert(so); + } + } + }); + } } diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOModelInfo.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOModelInfo.java index c6e138a2a..eb257a7e9 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOModelInfo.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOModelInfo.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * mso + * so * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ @@ -22,38 +22,91 @@ package org.onap.policy.so; import java.io.Serializable; - import com.google.gson.annotations.SerializedName; public class SOModelInfo implements Serializable { - /** - * - */ - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("modelType") - public String modelType; - - @SerializedName("modelInvariantId") - public String modelInvariantId; - - @SerializedName("modelVersionId") - public String modelVersionId; - - @SerializedName("modelName") - public String modelName; - - @SerializedName("modelVersion") - public String modelVersion; - - @SerializedName("modelCustomizationName") - public String modelCustomizationName; - - @SerializedName("modelCustomizationId") - public String modelCustomizationId; - - public SOModelInfo() { - } + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("modelType") + private String modelType; + + @SerializedName("modelInvariantId") + private String modelInvariantId; + + @SerializedName("modelVersionId") + private String modelVersionId; + + @SerializedName("modelName") + private String modelName; + + @SerializedName("modelVersion") + private String modelVersion; + + @SerializedName("modelCustomizationName") + private String modelCustomizationName; + + @SerializedName("modelCustomizationId") + private String modelCustomizationId; + + public SOModelInfo() { + //required by author + } + + public String getModelCustomizationId() { + return modelCustomizationId; + } + + public String getModelCustomizationName() { + return modelCustomizationName; + } + + public String getModelInvariantId() { + return modelInvariantId; + } + + public String getModelName() { + return modelName; + } + + public String getModelType() { + return modelType; + } + + public String getModelVersion() { + return modelVersion; + } + + public String getModelVersionId() { + return modelVersionId; + } + + public void setModelCustomizationId(String modelCustomizationId) { + this.modelCustomizationId = modelCustomizationId; + } + + public void setModelCustomizationName(String modelCustomizationName) { + this.modelCustomizationName = modelCustomizationName; + } + + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + public void setModelType(String modelType) { + this.modelType = modelType; + } + + public void setModelVersion(String modelVersion) { + this.modelVersion = modelVersion; + } + + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } } diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOPolicyException.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOPolicyException.java index 150733963..7065feaac 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOPolicyException.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOPolicyException.java @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * mso
+ * so
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -26,18 +26,32 @@ import com.google.gson.annotations.SerializedName; public class SOPolicyException implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = -3283942659786236032L;
-
- @SerializedName("messageId")
- public String messageId;
-
- @SerializedName("text")
- public String text;
-
- public SOPolicyException() {
- }
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("messageId")
+ private String messageId;
+
+ @SerializedName("text")
+ private String text;
+
+ public SOPolicyException() {
+ //required by author
+ }
+
+ public String getMessageId() {
+ return messageId;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setMessageId(String messageId) {
+ this.messageId = messageId;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
}
diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORelatedInstance.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORelatedInstance.java index ac737307c..2bd46e04c 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORelatedInstance.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORelatedInstance.java @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * mso
+ * so
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -22,28 +22,49 @@ package org.onap.policy.so; import java.io.Serializable;
-
-
import com.google.gson.annotations.SerializedName;
public class SORelatedInstance implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = -3283942659786236032L;
-
- @SerializedName("instanceId")
- public String instanceId;
-
- @SerializedName("instanceName")
- public String instanceName;
-
- @SerializedName("modelInfo")
- public SOModelInfo modelInfo;
-
-
- public SORelatedInstance() {
- }
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("instanceId")
+ private String instanceId;
+
+ @SerializedName("instanceName")
+ private String instanceName;
+
+ @SerializedName("modelInfo")
+ private SOModelInfo modelInfo;
+
+ public SORelatedInstance() {
+ //required by author
+ }
+
+ public String getInstanceId() {
+ return instanceId;
+ }
+
+
+ public String getInstanceName() {
+ return instanceName;
+ }
+
+ public SOModelInfo getModelInfo() {
+ return modelInfo;
+ }
+
+ public void setInstanceId(String instanceId) {
+ this.instanceId = instanceId;
+ }
+
+ public void setInstanceName(String instanceName) {
+ this.instanceName = instanceName;
+ }
+
+
+ public void setModelInfo(SOModelInfo modelInfo) {
+ this.modelInfo = modelInfo;
+ }
}
diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORelatedInstanceListElement.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORelatedInstanceListElement.java index c4b85ab52..71fb11949 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORelatedInstanceListElement.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORelatedInstanceListElement.java @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * mso
+ * so
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -22,21 +22,25 @@ package org.onap.policy.so; import java.io.Serializable;
-
import com.google.gson.annotations.SerializedName;
public class SORelatedInstanceListElement implements Serializable {
+
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("relatedInstance")
+ private SORelatedInstance relatedInstance;
+
+ public SORelatedInstanceListElement() {
+ //required by author
+ }
+
+ public SORelatedInstance getRelatedInstance() {
+ return relatedInstance;
+ }
- /**
- *
- */
- private static final long serialVersionUID = -3283942659786236032L;
-
- @SerializedName("relatedInstance")
- public SORelatedInstance relatedInstance;
-
-
- public SORelatedInstanceListElement() {
- }
+ public void setRelatedInstance(SORelatedInstance relatedInstance) {
+ this.relatedInstance = relatedInstance;
+ }
}
diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequest.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequest.java index 3e90ff345..be5ef139a 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequest.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequest.java @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * mso
+ * so
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -28,34 +28,87 @@ import com.google.gson.annotations.SerializedName; public class SORequest implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = -3283942659786236032L;
-
- @SerializedName("requestId")
- public UUID requestId;
-
- @SerializedName("startTime")
- //public LocalDateTime startTime;
- public String startTime;
-
- @SerializedName("finishTime")
- public LocalDateTime finishTime;
-
- @SerializedName("requestScope")
- public String requestScope;
-
- @SerializedName("requestType")
- public String requestType;
-
- @SerializedName("requestDetails")
- public SORequestDetails requestDetails;
-
- @SerializedName("requestStatus")
- public SORequestStatus requestStatus;
-
- public SORequest() {
- }
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("requestId")
+ private UUID requestId;
+
+ @SerializedName("startTime")
+ private String startTime;
+
+ @SerializedName("finishTime")
+ private LocalDateTime finishTime;
+
+ @SerializedName("requestScope")
+ private String requestScope;
+
+ @SerializedName("requestType")
+ private String requestType;
+
+ @SerializedName("requestDetails")
+ private SORequestDetails requestDetails;
+
+ @SerializedName("requestStatus")
+ private SORequestStatus requestStatus;
+
+ public SORequest() {
+ // required by author
+ }
+
+ public LocalDateTime getFinishTime() {
+ return finishTime;
+ }
+
+ public SORequestDetails getRequestDetails() {
+ return requestDetails;
+ }
+
+ public UUID getRequestId() {
+ return requestId;
+ }
+
+ public String getRequestScope() {
+ return requestScope;
+ }
+
+ public SORequestStatus getRequestStatus() {
+ return requestStatus;
+ }
+
+ public String getRequestType() {
+ return requestType;
+ }
+
+ public String getStartTime() {
+ return startTime;
+ }
+
+ public void setFinishTime(LocalDateTime finishTime) {
+ this.finishTime = finishTime;
+ }
+
+ public void setRequestDetails(SORequestDetails requestDetails) {
+ this.requestDetails = requestDetails;
+ }
+
+ public void setRequestId(UUID requestId) {
+ this.requestId = requestId;
+ }
+
+ public void setRequestScope(String requestScope) {
+ this.requestScope = requestScope;
+ }
+
+ public void setRequestStatus(SORequestStatus requestStatus) {
+ this.requestStatus = requestStatus;
+ }
+
+ public void setRequestType(String requestType) {
+ this.requestType = requestType;
+ }
+
+ public void setStartTime(String startTime) {
+ this.startTime = startTime;
+ }
}
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 ab4afc16c..a86418198 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 @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * mso + * so * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ @@ -28,97 +28,143 @@ import com.google.gson.annotations.SerializedName; public class SORequestDetails implements Serializable { - /** - * - */ - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("modelInfo") - public SOModelInfo modelInfo; - - @SerializedName("cloudConfiguration") - public SOCloudConfiguration cloudConfiguration; - - @SerializedName("requestInfo") - public SORequestInfo requestInfo; - - @SerializedName("subscriberInfo") - public SOSubscriberInfo subscriberInfo; - - @SerializedName("relatedInstanceList") - public List<SORelatedInstanceListElement> relatedInstanceList= new LinkedList<SORelatedInstanceListElement>(); - - @SerializedName("requestParameters") - public SORequestParameters requestParameters; - - public SORequestDetails() { - - } - - public SORequestDetails(SORequestDetails soRequestDetails) { - this.modelInfo = soRequestDetails.modelInfo; - this.cloudConfiguration = soRequestDetails.cloudConfiguration; - this.requestInfo = soRequestDetails.requestInfo; - this.relatedInstanceList = soRequestDetails.relatedInstanceList; - this.requestParameters = soRequestDetails.requestParameters; - } - - @Override - public String toString() { - return "SORequestDetails [modelInfo=" + modelInfo - + ", cloudConfiguration=" + cloudConfiguration - + ", requestInfo=" + requestInfo + ", relatedInstanceList=" - + relatedInstanceList + ", requestParameters=" - + requestParameters + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((cloudConfiguration == null) ? 0 : cloudConfiguration.hashCode()); - result = prime * result + ((modelInfo == null) ? 0 : modelInfo.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()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SORequestDetails other = (SORequestDetails) obj; - if (cloudConfiguration == null) { - if (other.cloudConfiguration != null) - return false; - } else if (!cloudConfiguration.equals(other.cloudConfiguration)) - return false; - if (modelInfo == null) { - if (other.modelInfo != null) - return false; - } else if (!modelInfo.equals(other.modelInfo)) - return false; - if (relatedInstanceList == null) { - if (other.relatedInstanceList != null) - return false; - } else if (!relatedInstanceList.equals(other.relatedInstanceList)) - return false; - if (requestInfo == null) { - if (other.requestInfo != null) - return false; - } else if (!requestInfo.equals(other.requestInfo)) - return false; - if (requestParameters == null) { - if (other.requestParameters != null) - return false; - } else if (!requestParameters.equals(other.requestParameters)) - return false; - return true; - } - + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("modelInfo") + private SOModelInfo modelInfo; + + @SerializedName("cloudConfiguration") + private SOCloudConfiguration cloudConfiguration; + + @SerializedName("requestInfo") + private SORequestInfo requestInfo; + + @SerializedName("subscriberInfo") + private SOSubscriberInfo subscriberInfo; + + @SerializedName("relatedInstanceList") + private List<SORelatedInstanceListElement> relatedInstanceList = new LinkedList<>(); + + @SerializedName("requestParameters") + private SORequestParameters requestParameters; + + public SORequestDetails() { + + } + + public SORequestDetails(SORequestDetails soRequestDetails) { + this.modelInfo = soRequestDetails.modelInfo; + this.cloudConfiguration = soRequestDetails.cloudConfiguration; + this.requestInfo = soRequestDetails.requestInfo; + this.relatedInstanceList = soRequestDetails.relatedInstanceList; + this.requestParameters = soRequestDetails.requestParameters; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + SORequestDetails other = (SORequestDetails) obj; + if (cloudConfiguration == null) { + if (other.cloudConfiguration != null) + return false; + } + else if (!cloudConfiguration.equals(other.cloudConfiguration)) + return false; + if (modelInfo == null) { + if (other.modelInfo != null) + return false; + } + else if (!modelInfo.equals(other.modelInfo)) + return false; + if (relatedInstanceList == null) { + if (other.relatedInstanceList != null) + return false; + } + else if (!relatedInstanceList.equals(other.relatedInstanceList)) + return false; + if (requestInfo == null) { + if (other.requestInfo != null) + return false; + } + else if (!requestInfo.equals(other.requestInfo)) + return false; + if (requestParameters == null) { + if (other.requestParameters != null) + return false; + } + else if (!requestParameters.equals(other.requestParameters)) + return false; + return true; + } + + public SOCloudConfiguration getCloudConfiguration() { + return cloudConfiguration; + } + + public SOModelInfo getModelInfo() { + return modelInfo; + } + + public List<SORelatedInstanceListElement> getRelatedInstanceList() { + return relatedInstanceList; + } + + public SORequestInfo getRequestInfo() { + return requestInfo; + } + + public SORequestParameters getRequestParameters() { + return requestParameters; + } + + public SOSubscriberInfo getSubscriberInfo() { + return subscriberInfo; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((cloudConfiguration == null) ? 0 : cloudConfiguration.hashCode()); + result = prime * result + ((modelInfo == null) ? 0 : modelInfo.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()); + return result; + } + + public void setCloudConfiguration(SOCloudConfiguration cloudConfiguration) { + this.cloudConfiguration = cloudConfiguration; + } + + public void setModelInfo(SOModelInfo modelInfo) { + this.modelInfo = modelInfo; + } + + public void setRequestInfo(SORequestInfo requestInfo) { + this.requestInfo = requestInfo; + } + + public void setRequestParameters(SORequestParameters requestParameters) { + this.requestParameters = requestParameters; + } + + public void setSubscriberInfo(SOSubscriberInfo subscriberInfo) { + this.subscriberInfo = subscriberInfo; + } + + @Override + public String toString() { + return "SORequestDetails [modelInfo=" + modelInfo + ", cloudConfiguration=" + + cloudConfiguration + ", requestInfo=" + requestInfo + ", relatedInstanceList=" + + relatedInstanceList + ", requestParameters=" + requestParameters + "]"; + } + } diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestError.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestError.java index d49897c72..c9dad036a 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestError.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestError.java @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * mso
+ * so
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -26,34 +26,32 @@ import com.google.gson.annotations.SerializedName; public class SORequestError implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = -3283942659786236032L;
-
-
- @SerializedName("policyException")
- public SOPolicyException policyException;
-
-
- @SerializedName("serviceException")
- public SOServiceException serviceException;
-
- /*
- @SerializedName("messageId")
- public String messageId;
-
- @SerializedName("text")
- public String text;
-
- @SerializedName("url")
- public String url;
-
- @SerializedName("variables")
- public String variables;
- */
-
- public SORequestError() {
- }
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("policyException")
+ private SOPolicyException policyException;
+
+ @SerializedName("serviceException")
+ private SOServiceException serviceException;
+
+ public SORequestError() {
+ // required by author
+ }
+
+ public SOPolicyException getPolicyException() {
+ return policyException;
+ }
+
+ public SOServiceException getServiceException() {
+ return serviceException;
+ }
+
+ public void setPolicyException(SOPolicyException policyException) {
+ this.policyException = policyException;
+ }
+
+ public void setServiceException(SOServiceException serviceException) {
+ this.serviceException = serviceException;
+ }
}
diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestInfo.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestInfo.java index 2e7beab16..28bc0b87e 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestInfo.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestInfo.java @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * mso
+ * so
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -22,47 +22,124 @@ package org.onap.policy.so; import java.io.Serializable;
-
import com.google.gson.annotations.SerializedName;
public class SORequestInfo implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = -3283942659786236032L;
-
- @SerializedName("instanceName")
- public String instanceName;
-
- @SerializedName("source")
- public String source;
-
- @SerializedName("productFamilyId")
- public String productFamilyId;
-
- @SerializedName("suppressRollback")
- public boolean suppressRollback;
-
- @SerializedName("billingAccountNumber")
- public String billingAccountNumber;
-
- @SerializedName("callbackUrl")
- public String callbackUrl;
-
- @SerializedName("correlator")
- public String correlator;
-
- @SerializedName("orderNumber")
- public String orderNumber;
-
- @SerializedName("orderVersion")
- public Integer orderVersion;
-
- @SerializedName("requestorId")
- public String requestorId;
-
- public SORequestInfo() {
- }
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("instanceName")
+ private String instanceName;
+
+ @SerializedName("source")
+ private String source;
+
+ @SerializedName("productFamilyId")
+ private String productFamilyId;
+
+ @SerializedName("suppressRollback")
+ private boolean suppressRollback;
+
+ @SerializedName("billingAccountNumber")
+ private String billingAccountNumber;
+
+ @SerializedName("callbackUrl")
+ private String callbackUrl;
+
+ @SerializedName("correlator")
+ private String correlator;
+
+ @SerializedName("orderNumber")
+ private String orderNumber;
+
+ @SerializedName("orderVersion")
+ private Integer orderVersion;
+
+ @SerializedName("requestorId")
+ private String requestorId;
+
+ public SORequestInfo() {
+ // required by author
+ }
+
+ public String getBillingAccountNumber() {
+ return billingAccountNumber;
+ }
+
+ public String getCallbackUrl() {
+ return callbackUrl;
+ }
+
+ public String getCorrelator() {
+ return correlator;
+ }
+
+ public String getInstanceName() {
+ return instanceName;
+ }
+
+ public String getOrderNumber() {
+ return orderNumber;
+ }
+
+ public Integer getOrderVersion() {
+ return orderVersion;
+ }
+
+ public String getProductFamilyId() {
+ return productFamilyId;
+ }
+
+ public String getRequestorId() {
+ return requestorId;
+ }
+
+ public String getSource() {
+ return source;
+ }
+
+ public boolean isSuppressRollback() {
+ return suppressRollback;
+ }
+
+ public void setBillingAccountNumber(String billingAccountNumber) {
+ this.billingAccountNumber = billingAccountNumber;
+ }
+
+ public void setCallbackUrl(String callbackUrl) {
+ this.callbackUrl = callbackUrl;
+ }
+
+ public void setCorrelator(String correlator) {
+ this.correlator = correlator;
+ }
+
+ public void setInstanceName(String instanceName) {
+ this.instanceName = instanceName;
+ }
+
+ public void setOrderNumber(String orderNumber) {
+ this.orderNumber = orderNumber;
+ }
+
+ public void setOrderVersion(Integer orderVersion) {
+ this.orderVersion = orderVersion;
+ }
+
+ public void setProductFamilyId(String productFamilyId) {
+ this.productFamilyId = productFamilyId;
+ }
+
+ public void setRequestorId(String requestorId) {
+ this.requestorId = requestorId;
+ }
+
+ public void setSource(String source) {
+ this.source = source;
+ }
+
+ public void setSuppressRollback(boolean suppressRollback) {
+ this.suppressRollback = suppressRollback;
+ }
}
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 c66f0979c..c1a6c7d85 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 @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * mso
+ * so
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -25,23 +25,36 @@ 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;
-
- @SerializedName("subscriptionServiceType")
- public String subscriptionServiceType;
-
- @SerializedName("userParams")
- public List<Map<String, String>> userParams = new LinkedList<Map<String, String>>();
-
- public SORequestParameters() {
- }
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("subscriptionServiceType")
+ private String subscriptionServiceType;
+
+ @SerializedName("userParams")
+ private List<Map<String, String>> userParams = new LinkedList<>();
+
+ public SORequestParameters() {
+ // required by author
+ }
+
+ public String getSubscriptionServiceType() {
+ return subscriptionServiceType;
+ }
+
+ public List<Map<String, String>> getUserParams() {
+ return userParams;
+ }
+
+ public void setSubscriptionServiceType(String subscriptionServiceType) {
+ this.subscriptionServiceType = subscriptionServiceType;
+ }
+
+ public void setUserParams(List<Map<String, String>> userParams) {
+ this.userParams = userParams;
+ }
}
diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestReferences.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestReferences.java index f3e15e1d7..913402db3 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestReferences.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestReferences.java @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * mso
+ * so
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -22,17 +22,32 @@ package org.onap.policy.so; import java.io.Serializable;
-
import com.google.gson.annotations.SerializedName;
public class SORequestReferences implements Serializable {
- private static final long serialVersionUID = -3283942659786236032L;
-
- @SerializedName("instanceId")
- public String instanceId;
-
- @SerializedName("requestId")
- public String requestId;
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("instanceId")
+ private String instanceId;
+
+ @SerializedName("requestId")
+ private String requestId;
+
+ public String getInstanceId() {
+ return instanceId;
+ }
+
+ public String getRequestId() {
+ return requestId;
+ }
+
+ public void setInstanceId(String instanceId) {
+ this.instanceId = instanceId;
+ }
+
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
}
diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestStatus.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestStatus.java index 4b57fc7ba..8c5e7848c 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestStatus.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestStatus.java @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * mso
+ * so
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -26,26 +26,57 @@ import com.google.gson.annotations.SerializedName; public class SORequestStatus implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = -3283942659786236032L;
-
- @SerializedName("percentProgress")
- public int percentProgress;
-
- @SerializedName("requestState")
- public String requestState;
-
- @SerializedName("timestamp")
- //public LocalDateTime timestamp;
- public String timestamp;
-
- @SerializedName("wasRolledBack")
- public boolean wasRolledBack;
-
-
- public SORequestStatus() {
- }
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("percentProgress")
+ private int percentProgress;
+
+ @SerializedName("requestState")
+ private String requestState;
+
+ @SerializedName("timestamp")
+ private String timestamp;
+
+ @SerializedName("wasRolledBack")
+ private boolean wasRolledBack;
+
+ public SORequestStatus() {
+ //required by author
+ }
+
+ public int getPercentProgress() {
+ return percentProgress;
+ }
+
+ public String getRequestState() {
+ return requestState;
+ }
+
+ public String getTimestamp() {
+ return timestamp;
+ }
+
+ public boolean isWasRolledBack() {
+ return wasRolledBack;
+ }
+
+ public void setPercentProgress(int percentProgress) {
+ this.percentProgress = percentProgress;
+ }
+
+ public void setRequestState(String requestState) {
+ this.requestState = requestState;
+ }
+
+ public void setTimestamp(String timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public void setWasRolledBack(boolean wasRolledBack) {
+ this.wasRolledBack = wasRolledBack;
+ }
}
diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOResponse.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOResponse.java index c5c3737b2..20e0c4155 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOResponse.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOResponse.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * mso + * so * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ @@ -26,24 +26,53 @@ import com.google.gson.annotations.SerializedName; public class SOResponse implements Serializable { - /** - * - */ - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("requestReferences") - public SORequestReferences requestReferences; - - @SerializedName("requestError") - public SORequestError requestError; - - @SerializedName("request") - public SORequest request; - - public int httpResponseCode; - - - public SOResponse() { - } + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("requestReferences") + private SORequestReferences requestReferences; + + @SerializedName("requestError") + private SORequestError requestError; + + @SerializedName("request") + private SORequest request; + + private int httpResponseCode; + + public SOResponse() { + // required by author + } + + public int getHttpResponseCode() { + return httpResponseCode; + } + + public SORequest getRequest() { + return request; + } + + public SORequestError getRequestError() { + return requestError; + } + + public SORequestReferences getRequestReferences() { + return requestReferences; + } + + public void setHttpResponseCode(int httpResponseCode) { + this.httpResponseCode = httpResponseCode; + } + + public void setRequest(SORequest request) { + this.request = request; + } + + public void setRequestError(SORequestError requestError) { + this.requestError = requestError; + } + + public void setRequestReferences(SORequestReferences requestReferences) { + this.requestReferences = requestReferences; + } } diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOResponseWrapper.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOResponseWrapper.java index 3b82edf5b..184ae5ef1 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOResponseWrapper.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOResponseWrapper.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * mso + * so * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ @@ -26,30 +26,16 @@ import com.google.gson.annotations.SerializedName; public class SOResponseWrapper implements Serializable { - private static final long serialVersionUID = 7673023687132889069L; - - @SerializedName("SOResponse") - public SOResponse SOResponse; - public transient String requestID; - + private static final long serialVersionUID = 7673023687132889069L; + + @SerializedName("SoResponse") + private SOResponse SoResponse; + + private transient String requestID; public SOResponseWrapper(SOResponse response, String reqID) { - this.SOResponse = response; - this.requestID = reqID; - } - - @Override - public String toString() { - return "SOResponseWrapper [SOResponse=" + SOResponse + ", RequestID=" + requestID + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((SOResponse == null) ? 0 : SOResponse.hashCode()); - result = prime * result + ((requestID == null) ? 0 : requestID.hashCode()); - return result; + this.SoResponse = response; + this.requestID = reqID; } @Override @@ -58,27 +44,59 @@ public class SOResponseWrapper implements Serializable { return true; } if (obj == null) { - return false; + return false; } if (getClass() != obj.getClass()) { return false; } SOResponseWrapper other = (SOResponseWrapper) obj; - if (SOResponse == null) { - if (other.SOResponse != null) { + if (SoResponse == null) { + if (other.SoResponse != null) { return false; } - } else if (!SOResponse.equals(other.SOResponse)) { + } + else if (!SoResponse.equals(other.SoResponse)) { return false; } if (requestID == null) { if (other.requestID != null) { return false; } - } else if (!requestID.equals(other.requestID)) { + } + else if (!requestID.equals(other.requestID)) { return false; } return true; } + public String getRequestID() { + return requestID; + } + + public SOResponse getSoResponse() { + return SoResponse; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((SoResponse == null) ? 0 : SoResponse.hashCode()); + result = prime * result + ((requestID == null) ? 0 : requestID.hashCode()); + return result; + } + + public void setRequestID(String requestID) { + this.requestID = requestID; + } + + public void setSoResponse(SOResponse sOResponse) { + SoResponse = sOResponse; + } + + @Override + public String toString() { + return "SOResponseWrapper [SOResponse=" + SoResponse + ", RequestID=" + requestID + "]"; + } + } diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOServiceException.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOServiceException.java index 58999fd30..3290f2e41 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOServiceException.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOServiceException.java @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * mso
+ * so
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -28,21 +28,39 @@ import com.google.gson.annotations.SerializedName; public class SOServiceException implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = -3283942659786236032L;
-
- @SerializedName("messageId")
- public String messageId;
-
- @SerializedName("text")
- public String text;
-
- @SerializedName("variables")
- public List<String> variables = new LinkedList<String>();
-
- public SOServiceException() {
- }
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("messageId")
+ private String messageId;
+
+ @SerializedName("text")
+ private String text;
+
+ @SerializedName("variables")
+ private List<String> variables = new LinkedList<>();
+
+ public SOServiceException() {
+ // required by author
+ }
+
+ public String getMessageId() {
+ return messageId;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public List<String> getVariables() {
+ return variables;
+ }
+
+ public void setMessageId(String messageId) {
+ this.messageId = messageId;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
}
diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOSubscriberInfo.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOSubscriberInfo.java index 745e237fe..14c46b0c1 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOSubscriberInfo.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOSubscriberInfo.java @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * mso
+ * so
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -22,26 +22,47 @@ package org.onap.policy.so; import java.io.Serializable;
-
import com.google.gson.annotations.SerializedName;
public class SOSubscriberInfo implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = -3283942659786236032L;
-
- @SerializedName("globalSubscriberId")
- public String globalSubscriberId;
-
- @SerializedName("subscriberCommonSiteId")
- public String subscriberCommonSiteId;
-
- @SerializedName("subscriberName")
- public String subscriberName;
-
- public SOSubscriberInfo() {
- }
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("globalSubscriberId")
+ private String globalSubscriberId;
+
+ @SerializedName("subscriberCommonSiteId")
+ private String subscriberCommonSiteId;
+
+ @SerializedName("subscriberName")
+ private String subscriberName;
+
+ public SOSubscriberInfo() {
+ //required by author
+ }
+
+ public String getGlobalSubscriberId() {
+ return globalSubscriberId;
+ }
+
+ public String getSubscriberCommonSiteId() {
+ return subscriberCommonSiteId;
+ }
+
+ public String getSubscriberName() {
+ return subscriberName;
+ }
+
+ public void setGlobalSubscriberId(String globalSubscriberId) {
+ this.globalSubscriberId = globalSubscriberId;
+ }
+
+ public void setSubscriberCommonSiteId(String subscriberCommonSiteId) {
+ this.subscriberCommonSiteId = subscriberCommonSiteId;
+ }
+
+ public void setSubscriberName(String subscriberName) {
+ this.subscriberName = subscriberName;
+ }
}
diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/util/Serialization.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/util/Serialization.java index c9d013ea6..9bcd5e5c9 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/util/Serialization.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/util/Serialization.java @@ -24,9 +24,12 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; public final class Serialization { - - final static public Gson gsonPretty = new GsonBuilder().disableHtmlEscaping() - .setPrettyPrinting() - .create(); + public static final Gson gsonPretty = + new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create(); + + private Serialization() { + // utility class with explicit private constructor + // change if class is more than utility + } } diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestDemo.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestDemo.java index 79f8d9392..1b2cb697a 100644 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestDemo.java +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestDemo.java @@ -37,131 +37,150 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class TestDemo { - private static final Logger logger = LoggerFactory.getLogger(TestDemo.class); - @Test - public void test() { - - SORequest request = new SORequest(); - request.requestDetails = new SORequestDetails(); - request.requestDetails.modelInfo = new SOModelInfo(); - request.requestDetails.cloudConfiguration = new SOCloudConfiguration(); - request.requestDetails.requestInfo = new SORequestInfo(); - request.requestDetails.requestParameters = new SORequestParameters(); - - request.requestDetails.modelInfo.modelType = "vfModule"; - request.requestDetails.modelInfo.modelInvariantId = "ff5256d2-5a33-55df-13ab-12abad84e7ff"; - request.requestDetails.modelInfo.modelVersionId = "fe6478e5-ea33-3346-ac12-ab121484a3fe"; - request.requestDetails.modelInfo.modelName = "vSAMP12..base..module-0"; - request.requestDetails.modelInfo.modelVersion = "1"; - - request.requestDetails.cloudConfiguration.lcpCloudRegionId = "mdt1"; - request.requestDetails.cloudConfiguration.tenantId = "88a6ca3ee0394ade9403f075db23167e"; - - request.requestDetails.requestInfo.instanceName = "SOTEST103a-vSAMP12_base_module-0"; - request.requestDetails.requestInfo.source = "VID"; - request.requestDetails.requestInfo.suppressRollback = true; - - SORelatedInstanceListElement relatedInstanceListElement1 = new SORelatedInstanceListElement(); - SORelatedInstanceListElement relatedInstanceListElement2 = new SORelatedInstanceListElement(); - SORelatedInstanceListElement relatedInstanceListElement3 = new SORelatedInstanceListElement(); - relatedInstanceListElement1.relatedInstance = new SORelatedInstance(); - relatedInstanceListElement2.relatedInstance = new SORelatedInstance(); - relatedInstanceListElement3.relatedInstance = new SORelatedInstance(); - - relatedInstanceListElement1.relatedInstance.instanceId = "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c"; - relatedInstanceListElement1.relatedInstance.instanceName = "SOTESTVOL103a-vSAMP12_base_module-0_vol"; - relatedInstanceListElement1.relatedInstance.modelInfo = new SOModelInfo(); - relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "volumeGroup"; - - relatedInstanceListElement2.relatedInstance.instanceId = "serviceInstanceId"; - relatedInstanceListElement2.relatedInstance.modelInfo = new SOModelInfo(); - relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "service"; - relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = "ff3514e3-5a33-55df-13ab-12abad84e7ff"; - relatedInstanceListElement2.relatedInstance.modelInfo.modelVersionId = "fe6985cd-ea33-3346-ac12-ab121484a3fe"; - relatedInstanceListElement2.relatedInstance.modelInfo.modelName = "parent service model name"; - relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = "1.0"; - - relatedInstanceListElement3.relatedInstance.instanceId = "vnfInstanceId"; - relatedInstanceListElement3.relatedInstance.modelInfo = new SOModelInfo(); - relatedInstanceListElement3.relatedInstance.modelInfo.modelType = "vnf"; - relatedInstanceListElement3.relatedInstance.modelInfo.modelInvariantId = "ff5256d1-5a33-55df-13ab-12abad84e7ff"; - relatedInstanceListElement3.relatedInstance.modelInfo.modelVersionId = "fe6478e4-ea33-3346-ac12-ab121484a3fe"; - relatedInstanceListElement3.relatedInstance.modelInfo.modelName = "vSAMP12"; - relatedInstanceListElement3.relatedInstance.modelInfo.modelVersion = "1.0"; - relatedInstanceListElement3.relatedInstance.modelInfo.modelCustomizationName = "vSAMP12 1"; - - request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1); - request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2); - request.requestDetails.relatedInstanceList.add(relatedInstanceListElement3); - - Map<String, String> userParam1 = new HashMap<>(); - userParam1.put("name1", "value1"); - - Map<String, String> userParam2 = new HashMap<>(); - userParam2.put("name2", "value2"); - - request.requestDetails.requestParameters.userParams.add(userParam1); - request.requestDetails.requestParameters.userParams.add(userParam2); - - logger.debug(Serialization.gsonPretty.toJson(request)); - - } - - @Test - public void testHack() { - - logger.debug("** HACK **"); - - SORequest request = new SORequest(); - // - request.requestDetails = new SORequestDetails(); - request.requestDetails.modelInfo = new SOModelInfo(); - request.requestDetails.cloudConfiguration = new SOCloudConfiguration(); - request.requestDetails.requestInfo = new SORequestInfo(); - request.requestDetails.requestParameters = new SORequestParameters(); - request.requestDetails.requestParameters.userParams = null; - - request.requestDetails.modelInfo.modelType = "vfModule"; - request.requestDetails.modelInfo.modelInvariantId = "a9c4a35a-de48-451a-9e4e-343f2ac52928"; - request.requestDetails.modelInfo.modelVersionId = "e0d98ad1-238d-4555-b439-023d3f9079f6"; - request.requestDetails.modelInfo.modelName = "0d9e0d9d352749f4B3cb..dnsscaling..module-0"; - request.requestDetails.modelInfo.modelVersion = "2.0"; - - request.requestDetails.cloudConfiguration.lcpCloudRegionId = "DFW"; - request.requestDetails.cloudConfiguration.tenantId = "1015548"; - - request.requestDetails.requestInfo.instanceName = "Vfmodule_Ete_Name1eScaling63928f-ccdc-4b34-bdef-9bf64109026e"; - request.requestDetails.requestInfo.source = "POLICY"; - request.requestDetails.requestInfo.suppressRollback = false; - - SORelatedInstanceListElement relatedInstanceListElement1 = new SORelatedInstanceListElement(); - SORelatedInstanceListElement relatedInstanceListElement2 = new SORelatedInstanceListElement(); - relatedInstanceListElement1.relatedInstance = new SORelatedInstance(); - relatedInstanceListElement2.relatedInstance = new SORelatedInstance(); - - String serviceInstanceId = "98af39ce-6408-466b-921f-c2c7a8f59ed6"; - relatedInstanceListElement1.relatedInstance.instanceId = serviceInstanceId; - relatedInstanceListElement1.relatedInstance.modelInfo = new SOModelInfo(); - relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "service"; - relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = "24329a0c-1d57-4210-b1af-a65df64e9d59"; - relatedInstanceListElement1.relatedInstance.modelInfo.modelVersionId = "ac642881-8e7e-4217-bd64-16ad41c42e30"; - relatedInstanceListElement1.relatedInstance.modelInfo.modelName = "5116d67e-0b4f-46bf-a46f"; - relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = "2.0"; - - String vnfInstanceId = "8eb411b8-a936-412f-b01f-9a9a435c0e93"; - relatedInstanceListElement2.relatedInstance.instanceId = vnfInstanceId; - relatedInstanceListElement2.relatedInstance.modelInfo = new SOModelInfo(); - relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "vnf"; - relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = "09fd971e-db5f-475d-997c-cf6704b6b8fe"; - relatedInstanceListElement2.relatedInstance.modelInfo.modelVersionId = "152ed917-6dcc-46ee-bf8a-a775c5aa5a74"; - relatedInstanceListElement2.relatedInstance.modelInfo.modelName = "9e4c31d2-4b25-4d9e-9fb4"; - relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = "2.0"; - relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = "0d9e0d9d-3527-49f4-b3cb 2"; - - request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1); - request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2); - - logger.debug(Serialization.gsonPretty.toJson(request)); - } + private static final Logger logger = LoggerFactory.getLogger(TestDemo.class); + + @Test + public void test() { + + SORequest request = new SORequest(); + request.setRequestDetails(new SORequestDetails()); + request.getRequestDetails().setModelInfo(new SOModelInfo()); + request.getRequestDetails().setCloudConfiguration(new SOCloudConfiguration()); + request.getRequestDetails().setRequestInfo(new SORequestInfo()); + request.getRequestDetails().setRequestParameters(new SORequestParameters()); + + request.getRequestDetails().getModelInfo().setModelType("vfModule"); + request.getRequestDetails().getModelInfo().setModelInvariantId("ff5256d2-5a33-55df-13ab-12abad84e7ff"); + request.getRequestDetails().getModelInfo().setModelVersionId("fe6478e5-ea33-3346-ac12-ab121484a3fe"); + request.getRequestDetails().getModelInfo().setModelName("vSAMP12..base..module-0"); + request.getRequestDetails().getModelInfo().setModelVersion("1"); + + request.getRequestDetails().getCloudConfiguration().setLcpCloudRegionId("mdt1"); + request.getRequestDetails().getCloudConfiguration().setTenantId("88a6ca3ee0394ade9403f075db23167e"); + + request.getRequestDetails().getRequestInfo().setInstanceName("SOTEST103a-vSAMP12_base_module-0"); + request.getRequestDetails().getRequestInfo().setSource("VID"); + request.getRequestDetails().getRequestInfo().setSuppressRollback(true); + + SORelatedInstanceListElement relatedInstanceListElement1 = + new SORelatedInstanceListElement(); + SORelatedInstanceListElement relatedInstanceListElement2 = + new SORelatedInstanceListElement(); + SORelatedInstanceListElement relatedInstanceListElement3 = + new SORelatedInstanceListElement(); + relatedInstanceListElement1.setRelatedInstance(new SORelatedInstance()); + relatedInstanceListElement2.setRelatedInstance(new SORelatedInstance()); + relatedInstanceListElement3.setRelatedInstance(new SORelatedInstance()); + + relatedInstanceListElement1.getRelatedInstance().setInstanceId( + "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c"); + relatedInstanceListElement1.getRelatedInstance().setInstanceName( + "SOTESTVOL103a-vSAMP12_base_module-0_vol"); + relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SOModelInfo()); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("volumeGroup"); + + relatedInstanceListElement2.getRelatedInstance().setInstanceId("serviceInstanceId"); + relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SOModelInfo()); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("service"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelInvariantId( + "ff3514e3-5a33-55df-13ab-12abad84e7ff"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersionId( + "fe6985cd-ea33-3346-ac12-ab121484a3fe"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName( + "parent service model name"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersion("1.0"); + + relatedInstanceListElement3.getRelatedInstance().setInstanceId("vnfInstanceId"); + relatedInstanceListElement3.getRelatedInstance().setModelInfo(new SOModelInfo()); + relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelType("vnf"); + relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelInvariantId( + "ff5256d1-5a33-55df-13ab-12abad84e7ff"); + relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelVersionId( + "fe6478e4-ea33-3346-ac12-ab121484a3fe"); + relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelName("vSAMP12"); + relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelVersion("1.0"); + relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelCustomizationName("vSAMP12 1"); + + request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1); + request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2); + request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement3); + + Map<String, String> userParam1 = new HashMap<>(); + userParam1.put("name1", "value1"); + + Map<String, String> userParam2 = new HashMap<>(); + userParam2.put("name2", "value2"); + + request.getRequestDetails().getRequestParameters().getUserParams().add(userParam1); + request.getRequestDetails().getRequestParameters().getUserParams().add(userParam2); + + logger.debug(Serialization.gsonPretty.toJson(request)); + + } + + @Test + public void testHack() { + + logger.debug("** HACK **"); + + SORequest request = new SORequest(); + + request.setRequestDetails(new SORequestDetails()); + request.getRequestDetails().setModelInfo(new SOModelInfo()); + request.getRequestDetails().setCloudConfiguration(new SOCloudConfiguration()); + request.getRequestDetails().setRequestInfo(new SORequestInfo()); + request.getRequestDetails().setRequestParameters(new SORequestParameters()); + request.getRequestDetails().getRequestParameters().setUserParams(null); + + request.getRequestDetails().getModelInfo().setModelType("vfModule"); + request.getRequestDetails().getModelInfo().setModelInvariantId("a9c4a35a-de48-451a-9e4e-343f2ac52928"); + request.getRequestDetails().getModelInfo().setModelVersionId("e0d98ad1-238d-4555-b439-023d3f9079f6"); + request.getRequestDetails().getModelInfo().setModelName("0d9e0d9d352749f4B3cb..dnsscaling..module-0"); + request.getRequestDetails().getModelInfo().setModelVersion("2.0"); + + request.getRequestDetails().getCloudConfiguration().setLcpCloudRegionId("DFW"); + request.getRequestDetails().getCloudConfiguration().setTenantId("1015548"); + + request.getRequestDetails().getRequestInfo().setInstanceName( + "Vfmodule_Ete_Name1eScaling63928f-ccdc-4b34-bdef-9bf64109026e"); + request.getRequestDetails().getRequestInfo().setSource("POLICY"); + request.getRequestDetails().getRequestInfo().setSuppressRollback(false); + + SORelatedInstanceListElement relatedInstanceListElement1 = + new SORelatedInstanceListElement(); + SORelatedInstanceListElement relatedInstanceListElement2 = + new SORelatedInstanceListElement(); + relatedInstanceListElement1.setRelatedInstance(new SORelatedInstance()); + relatedInstanceListElement2.setRelatedInstance(new SORelatedInstance()); + + String serviceInstanceId = "98af39ce-6408-466b-921f-c2c7a8f59ed6"; + relatedInstanceListElement1.getRelatedInstance().setInstanceId(serviceInstanceId); + relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SOModelInfo()); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("service"); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelInvariantId( + "24329a0c-1d57-4210-b1af-a65df64e9d59"); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersionId( + "ac642881-8e7e-4217-bd64-16ad41c42e30"); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelName("5116d67e-0b4f-46bf-a46f"); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersion("2.0"); + + String vnfInstanceId = "8eb411b8-a936-412f-b01f-9a9a435c0e93"; + relatedInstanceListElement2.getRelatedInstance().setInstanceId(vnfInstanceId); + relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SOModelInfo()); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("vnf"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelInvariantId( + "09fd971e-db5f-475d-997c-cf6704b6b8fe"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersionId( + "152ed917-6dcc-46ee-bf8a-a775c5aa5a74"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName("9e4c31d2-4b25-4d9e-9fb4"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersion("2.0"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelCustomizationName( + "0d9e0d9d-3527-49f4-b3cb 2"); + + request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1); + request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2); + + logger.debug(Serialization.gsonPretty.toJson(request)); + } } diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoAsyncRequestStatus.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoAsyncRequestStatus.java new file mode 100755 index 000000000..119c29121 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoAsyncRequestStatus.java @@ -0,0 +1,78 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * so
+ * ================================================================================
+ *
+ * ================================================================================
+ * 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.policy.so;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.time.LocalDateTime;
+
+import org.junit.Test;
+
+public class TestSoAsyncRequestStatus {
+
+ @Test
+ public void testConstructor() {
+ SOAsyncRequestStatus obj = new SOAsyncRequestStatus();
+
+ assertTrue(obj.getCorrelator() == null);
+ assertTrue(obj.getFinishTime() == null);
+ assertTrue(obj.getInstanceReferences() == null);
+ assertTrue(obj.getRequestId() == null);
+ assertTrue(obj.getRequestScope() == null);
+ assertTrue(obj.getRequestStatus() == null);
+ assertTrue(obj.getStartTime() == null);
+ }
+
+ @Test
+ public void testSetGet() {
+ SOAsyncRequestStatus obj = new SOAsyncRequestStatus();
+
+ obj.setCorrelator("correlator");
+ assertEquals("correlator", obj.getCorrelator());
+
+ LocalDateTime finishTime = LocalDateTime.now();
+ obj.setFinishTime(finishTime);
+ assertEquals(finishTime, obj.getFinishTime());
+
+ SOInstanceReferences instanceReferences = new SOInstanceReferences();
+ obj.setInstanceReferences(instanceReferences);
+ assertEquals(instanceReferences, obj.getInstanceReferences());
+
+ obj.setRequestId("requestId");
+ assertEquals("requestId", obj.getRequestId());
+
+ obj.setRequestScope("requestScope");
+ assertEquals("requestScope", obj.getRequestScope());
+
+ SORequestStatus requestStatus = new SORequestStatus();
+ obj.setRequestStatus(requestStatus);
+ assertEquals(requestStatus, obj.getRequestStatus());
+
+ obj.setRequestType("requestType");
+ assertEquals("requestType", obj.getRequestType());
+
+ LocalDateTime startTime = LocalDateTime.now();
+ obj.setStartTime(startTime);
+ assertEquals(startTime, obj.getStartTime());
+
+ }
+}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoCloudConfiguration.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoCloudConfiguration.java new file mode 100755 index 000000000..f05912985 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoCloudConfiguration.java @@ -0,0 +1,48 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * so
+ * ================================================================================
+ *
+ * ================================================================================
+ * 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.policy.so;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class TestSoCloudConfiguration {
+
+ @Test
+ public void testConstructor() {
+ SOCloudConfiguration obj = new SOCloudConfiguration();
+
+ assertTrue(obj.getLcpCloudRegionId() == null);
+ assertTrue(obj.getTenantId() == null);
+ }
+
+ @Test
+ public void testSetGet() {
+ SOCloudConfiguration obj = new SOCloudConfiguration();
+
+ obj.setLcpCloudRegionId("lcpCloudRegionId");
+ assertEquals("lcpCloudRegionId", obj.getLcpCloudRegionId());
+
+ obj.setTenantId("tenantId");
+ assertEquals("tenantId", obj.getTenantId());
+ }
+}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoInstanceReferences.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoInstanceReferences.java new file mode 100755 index 000000000..8c63e9c65 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoInstanceReferences.java @@ -0,0 +1,48 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * so
+ * ================================================================================
+ *
+ * ================================================================================
+ * 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.policy.so;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class TestSoInstanceReferences {
+
+ @Test
+ public void testConstructor() {
+ SOInstanceReferences obj = new SOInstanceReferences();
+
+ assertTrue(obj.getInstanceId() == null);
+ assertTrue(obj.getRequestId() == null);
+ }
+
+ @Test
+ public void testSetGet() {
+ SOInstanceReferences obj = new SOInstanceReferences();
+
+ obj.setInstanceId("instanceId");
+ assertEquals("instanceId", obj.getInstanceId());
+
+ obj.setRequestId("requestId");
+ assertEquals("requestId", obj.getRequestId());
+ }
+}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoModelInfo.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoModelInfo.java new file mode 100755 index 000000000..99f829fc7 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoModelInfo.java @@ -0,0 +1,69 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * so
+ * ================================================================================
+ *
+ * ================================================================================
+ * 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.policy.so;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class TestSoModelInfo {
+
+ @Test
+ public void testConstructor() {
+ SOModelInfo obj = new SOModelInfo();
+
+ assertTrue(obj.getModelCustomizationId() == null);
+ assertTrue(obj.getModelCustomizationName() == null);
+ assertTrue(obj.getModelInvariantId() == null);
+ assertTrue(obj.getModelName() == null);
+ assertTrue(obj.getModelType() == null);
+ assertTrue(obj.getModelVersion() == null);
+ assertTrue(obj.getModelVersionId() == null);
+ }
+
+ @Test
+ public void testSetGet() {
+ SOModelInfo obj = new SOModelInfo();
+
+ obj.setModelCustomizationId("modelCustomizationId");
+ assertEquals("modelCustomizationId", obj.getModelCustomizationId());
+
+ obj.setModelCustomizationName("modelCustomizationName");
+ assertEquals("modelCustomizationName", obj.getModelCustomizationName());
+
+ obj.setModelInvariantId("modelInvariantId");
+ assertEquals("modelInvariantId", obj.getModelInvariantId());
+
+ obj.setModelName("modelName");
+ assertEquals("modelName", obj.getModelName());
+
+ obj.setModelType("modelType");
+ assertEquals("modelType", obj.getModelType());
+
+ obj.setModelVersion("modelVersion");
+ assertEquals("modelVersion", obj.getModelVersion());
+
+ obj.setModelVersionId("modelVersionId");
+ assertEquals("modelVersionId", obj.getModelVersionId());
+
+ }
+}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoPolicyException.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoPolicyException.java new file mode 100755 index 000000000..b2ba7f4d0 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoPolicyException.java @@ -0,0 +1,48 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * so
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.so;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class TestSoPolicyException {
+
+ @Test
+ public void testConstructor() {
+ SOPolicyException obj = new SOPolicyException();
+
+ assertTrue(obj.getMessageId() == null);
+ assertTrue(obj.getText() == null);
+ }
+
+ @Test
+ public void testSetGet() {
+ SOPolicyException obj = new SOPolicyException();
+
+ obj.setMessageId("messageId");
+ assertEquals("messageId", obj.getMessageId());
+
+ obj.setText("text");
+ assertEquals("text", obj.getText());
+ }
+}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstance.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstance.java new file mode 100755 index 000000000..a8e94b8e2 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstance.java @@ -0,0 +1,53 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * so
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.so;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class TestSoRelatedInstance {
+
+ @Test
+ public void testConstructor() {
+ SORelatedInstance obj = new SORelatedInstance();
+
+ assertTrue(obj.getInstanceId() == null);
+ assertTrue(obj.getInstanceName() == null);
+ assertTrue(obj.getModelInfo() == null);
+ }
+
+ @Test
+ public void testSetGet() {
+ SORelatedInstance obj = new SORelatedInstance();
+
+ obj.setInstanceId("instanceId");
+ assertEquals("instanceId", obj.getInstanceId());
+
+ obj.setInstanceName("instanceName");
+ assertEquals("instanceName", obj.getInstanceName());
+
+ SOModelInfo modelInfo = new SOModelInfo();
+ obj.setModelInfo(modelInfo);
+ assertEquals(modelInfo, obj.getModelInfo());
+ }
+}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstanceListElement.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstanceListElement.java new file mode 100755 index 000000000..17abd06e3 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstanceListElement.java @@ -0,0 +1,45 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * so
+ * ================================================================================
+ *
+ * ================================================================================
+ * 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.policy.so;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class TestSoRelatedInstanceListElement {
+
+ @Test
+ public void testConstructor() {
+ SORelatedInstanceListElement obj = new SORelatedInstanceListElement();
+
+ assertTrue(obj.getRelatedInstance() == null);
+ }
+
+ @Test
+ public void testSetGet() {
+ SORelatedInstanceListElement obj = new SORelatedInstanceListElement();
+
+ SORelatedInstance relatedInstance = new SORelatedInstance();
+ obj.setRelatedInstance(relatedInstance);
+ assertEquals(relatedInstance, obj.getRelatedInstance());
+ }
+}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequest.java new file mode 100755 index 000000000..229765a72 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequest.java @@ -0,0 +1,72 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * so
+ * ================================================================================
+ *
+ * ================================================================================
+ * 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.policy.so;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.time.LocalDateTime;
+import java.util.UUID;
+
+import org.junit.Test;
+
+public class TestSoRequest {
+
+ @Test
+ public void testConstructor() {
+ SORequest obj = new SORequest();
+
+ assertTrue(obj.getFinishTime() == null);
+ assertTrue(obj.getRequestDetails() == null);
+ assertTrue(obj.getRequestId() == null);
+ assertTrue(obj.getRequestScope() == null);
+ assertTrue(obj.getRequestStatus() == null);
+ assertTrue(obj.getRequestType() == null);
+ assertTrue(obj.getStartTime() == null);
+ }
+
+ @Test
+ public void testSetGet() {
+ SORequest obj = new SORequest();
+
+ LocalDateTime finishTime = LocalDateTime.now();
+ obj.setFinishTime(finishTime);
+ assertEquals(finishTime, obj.getFinishTime());
+
+ UUID uuid = UUID.randomUUID();
+ obj.setRequestId(uuid);
+ assertEquals(uuid, obj.getRequestId());
+
+ obj.setRequestScope("requestScope");
+ assertEquals("requestScope", obj.getRequestScope());
+
+ SORequestStatus requestStatus = new SORequestStatus();
+ obj.setRequestStatus(requestStatus);
+ assertEquals(requestStatus, obj.getRequestStatus());
+
+ obj.setRequestType("requestType");
+ assertEquals("requestType", obj.getRequestType());
+
+ LocalDateTime startTime = LocalDateTime.now();
+ obj.setStartTime(startTime.toString());
+ assertEquals(startTime.toString(), obj.getStartTime());
+ }
+}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestDetails.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestDetails.java new file mode 100755 index 000000000..5c3c1a411 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestDetails.java @@ -0,0 +1,68 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * so
+ * ================================================================================
+ *
+ * ================================================================================
+ * 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.policy.so;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class TestSoRequestDetails {
+
+ @Test
+ public void testConstructor() {
+ SORequestDetails obj = new SORequestDetails();
+
+ assertTrue(obj.getCloudConfiguration() == null);
+ assertTrue(obj.getModelInfo() == null);
+ assertTrue(obj.getRequestInfo() == null);
+ assertTrue(obj.getRequestParameters() == null);
+ assertTrue(obj.getSubscriberInfo() == null);
+
+ assertTrue(obj.getRelatedInstanceList() != null);
+ assertEquals(0, obj.getRelatedInstanceList().size());
+ }
+
+ @Test
+ public void testSetGet() {
+ SORequestDetails obj = new SORequestDetails();
+
+ SOCloudConfiguration cloudConfiguration = new SOCloudConfiguration();
+ obj.setCloudConfiguration(cloudConfiguration);
+ assertEquals(cloudConfiguration, obj.getCloudConfiguration());
+
+ SOModelInfo modelInfo = new SOModelInfo();
+ obj.setModelInfo(modelInfo);
+ assertEquals(modelInfo, obj.getModelInfo());
+
+ SORequestInfo requestInfo = new SORequestInfo();
+ obj.setRequestInfo(requestInfo);
+ assertEquals(requestInfo, obj.getRequestInfo());
+
+ SORequestParameters requestParameters = new SORequestParameters();
+ obj.setRequestParameters(requestParameters);
+ assertEquals(requestParameters, obj.getRequestParameters());
+
+ SOSubscriberInfo subscriberInfo = new SOSubscriberInfo();
+ obj.setSubscriberInfo(subscriberInfo);
+ assertEquals(subscriberInfo, obj.getSubscriberInfo());
+ }
+}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestError.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestError.java new file mode 100755 index 000000000..31f3b6c54 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestError.java @@ -0,0 +1,50 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * so
+ * ================================================================================
+ *
+ * ================================================================================
+ * 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.policy.so;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class TestSoRequestError {
+
+ @Test
+ public void testConstructor() {
+ SORequestError obj = new SORequestError();
+
+ assertTrue(obj.getPolicyException() == null);
+ assertTrue(obj.getServiceException() == null);
+ }
+
+ @Test
+ public void testSetGet() {
+ SORequestError obj = new SORequestError();
+
+ SOPolicyException policyException = new SOPolicyException();
+ obj.setPolicyException(policyException);
+ assertEquals(policyException, obj.getPolicyException());
+
+ SOServiceException serviceException = new SOServiceException();
+ obj.setServiceException(serviceException);
+ assertEquals(serviceException, obj.getServiceException());
+ }
+}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestInfo.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestInfo.java new file mode 100755 index 000000000..d1b7f247c --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestInfo.java @@ -0,0 +1,81 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * so
+ * ================================================================================
+ *
+ * ================================================================================
+ * 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.policy.so;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class TestSoRequestInfo {
+
+ @Test
+ public void testConstructor() {
+ SORequestInfo obj = new SORequestInfo();
+
+ assertTrue(obj.getBillingAccountNumber() == null);
+ assertTrue(obj.getCallbackUrl() == null);
+ assertTrue(obj.getCorrelator() == null);
+ assertTrue(obj.getInstanceName() == null);
+ assertTrue(obj.getOrderNumber() == null);
+ assertTrue(obj.getOrderVersion() == null);
+ assertTrue(obj.getProductFamilyId() == null);
+ assertTrue(obj.getRequestorId() == null);
+ assertTrue(obj.getSource() == null);
+ assertTrue(obj.isSuppressRollback() == false);
+ }
+
+ @Test
+ public void testSetGet() {
+ SORequestInfo obj = new SORequestInfo();
+
+ obj.setBillingAccountNumber("billingAccountNumber");
+ assertEquals("billingAccountNumber", obj.getBillingAccountNumber());
+
+ obj.setCallbackUrl("callbackUrl");
+ assertEquals("callbackUrl", obj.getCallbackUrl());
+
+ obj.setCorrelator("correlator");
+ assertEquals("correlator", obj.getCorrelator());
+
+ obj.setInstanceName("instanceName");
+ assertEquals("instanceName", obj.getInstanceName());
+
+ obj.setOrderNumber("orderNumber");
+ assertEquals("orderNumber", obj.getOrderNumber());
+
+ int orderVersion = 2008;
+ obj.setOrderVersion(orderVersion);
+ assertEquals((Integer) orderVersion, obj.getOrderVersion());
+
+ obj.setProductFamilyId("productFamilyId");
+ assertEquals("productFamilyId", obj.getProductFamilyId());
+
+ obj.setRequestorId("requestorId");
+ assertEquals("requestorId", obj.getRequestorId());
+
+ obj.setSource("source");
+ assertEquals("source", obj.getSource());
+
+ obj.setSuppressRollback(true);
+ assertEquals(true, obj.isSuppressRollback());
+ }
+}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestParameters.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestParameters.java new file mode 100755 index 000000000..cb32be531 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestParameters.java @@ -0,0 +1,46 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * so
+ * ================================================================================
+ *
+ * ================================================================================
+ * 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.policy.so;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class TestSoRequestParameters {
+
+ @Test
+ public void testConstructor() {
+ SORequestParameters obj = new SORequestParameters();
+
+ assertTrue(obj.getSubscriptionServiceType() == null);
+ assertTrue(obj.getUserParams() != null);
+ assertEquals(0, obj.getUserParams().size());
+ }
+
+ @Test
+ public void testSetGet() {
+ SORequestParameters obj = new SORequestParameters();
+
+ obj.setSubscriptionServiceType("subscriptionServiceType");
+ assertEquals("subscriptionServiceType", obj.getSubscriptionServiceType());
+ }
+}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestReferences.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestReferences.java new file mode 100755 index 000000000..e212ba1c3 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestReferences.java @@ -0,0 +1,48 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * so
+ * ================================================================================
+ *
+ * ================================================================================
+ * 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.policy.so;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class TestSoRequestReferences {
+
+ @Test
+ public void testConstructor() {
+ SORequestReferences obj = new SORequestReferences();
+
+ assertTrue(obj.getInstanceId() == null);
+ assertTrue(obj.getRequestId() == null);
+ }
+
+ @Test
+ public void testSetGet() {
+ SORequestReferences obj = new SORequestReferences();
+
+ obj.setInstanceId("instanceId");
+ assertEquals("instanceId", obj.getInstanceId());
+
+ obj.setRequestId("requestId");
+ assertEquals("requestId", obj.getRequestId());
+ }
+}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestStatus.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestStatus.java new file mode 100755 index 000000000..9fa0b9741 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestStatus.java @@ -0,0 +1,57 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * so
+ * ================================================================================
+ *
+ * ================================================================================
+ * 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.policy.so;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class TestSoRequestStatus {
+
+ @Test
+ public void testConstructor() {
+ SORequestStatus obj = new SORequestStatus();
+
+ assertEquals(0, obj.getPercentProgress());
+ assertTrue(obj.getRequestState() == null);
+ assertTrue(obj.getTimestamp() == null);
+ assertFalse(obj.isWasRolledBack());
+ }
+
+ @Test
+ public void testSetGet() {
+ SORequestStatus obj = new SORequestStatus();
+
+ obj.setPercentProgress(2008);
+ assertEquals(2008, obj.getPercentProgress());
+
+ obj.setRequestState("requestState");
+ assertEquals("requestState", obj.getRequestState());
+
+ obj.setTimestamp("timestamp");
+ assertEquals("timestamp", obj.getTimestamp());
+
+ obj.setWasRolledBack(true);
+ assertTrue(obj.isWasRolledBack());
+ }
+}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponse.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponse.java new file mode 100755 index 000000000..edac2fa0d --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponse.java @@ -0,0 +1,59 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * so
+ * ================================================================================
+ *
+ * ================================================================================
+ * 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.policy.so;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class TestSoResponse {
+
+ @Test
+ public void testConstructor() {
+ SOResponse obj = new SOResponse();
+
+ assertEquals(0, obj.getHttpResponseCode());
+ assertTrue(obj.getRequest() == null);
+ assertTrue(obj.getRequestError() == null);
+ assertTrue(obj.getRequestReferences() == null);
+ }
+
+ @Test
+ public void testSetGet() {
+ SOResponse obj = new SOResponse();
+
+ obj.setHttpResponseCode(2008);
+ assertEquals(2008, obj.getHttpResponseCode());
+
+ SORequest request = new SORequest();
+ obj.setRequest(request);
+ assertEquals(request, obj.getRequest());
+
+ SORequestError requestError = new SORequestError();
+ obj.setRequestError(requestError);
+ assertEquals(requestError, obj.getRequestError());
+
+ SORequestReferences requestReferences = new SORequestReferences();
+ obj.setRequestReferences(requestReferences);
+ assertEquals(requestReferences, obj.getRequestReferences());
+ }
+}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponseWrapper.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponseWrapper.java new file mode 100755 index 000000000..93549a21d --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponseWrapper.java @@ -0,0 +1,51 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * so
+ * ================================================================================
+ *
+ * ================================================================================
+ * 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.policy.so;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class TestSoResponseWrapper {
+
+ @Test
+ public void testConstructor() {
+ SOResponse response = new SOResponse();
+ SOResponseWrapper obj = new SOResponseWrapper(response, "reqID");
+
+ assertEquals(response, obj.getSoResponse());
+ assertEquals("reqID", obj.getRequestID());
+ }
+
+ @Test
+ public void testSetGet() {
+ SOResponse response = new SOResponse();
+ SOResponseWrapper obj = new SOResponseWrapper(response, "reqID");
+
+ SOResponse response2 = new SOResponse();
+ response2.setHttpResponseCode(2008);
+ obj.setSoResponse(response2);
+ assertEquals(response2, obj.getSoResponse());
+
+ obj.setRequestID("id2");
+ assertEquals("id2", obj.getRequestID());
+ }
+}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoServiceException.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoServiceException.java new file mode 100755 index 000000000..cae8d1955 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoServiceException.java @@ -0,0 +1,50 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * so
+ * ================================================================================
+ *
+ * ================================================================================
+ * 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.policy.so;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class TestSoServiceException {
+
+ @Test
+ public void testConstructor() {
+ SOServiceException obj = new SOServiceException();
+
+ assertTrue(obj.getMessageId() == null);
+ assertTrue(obj.getText() == null);
+ assertTrue(obj.getVariables() != null);
+ assertEquals(0, obj.getVariables().size());
+ }
+
+ @Test
+ public void testSetGet() {
+ SOServiceException obj = new SOServiceException();
+
+ obj.setMessageId("messageId");
+ assertEquals("messageId", obj.getMessageId());
+
+ obj.setText("text");
+ assertEquals("text", obj.getText());
+ }
+}
diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoSubscriberInfo.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoSubscriberInfo.java new file mode 100755 index 000000000..0bff38c5c --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoSubscriberInfo.java @@ -0,0 +1,52 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * so
+ * ================================================================================
+ *
+ * ================================================================================
+ * 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.policy.so;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class TestSoSubscriberInfo {
+
+ @Test
+ public void testConstructor() {
+ SOSubscriberInfo obj = new SOSubscriberInfo();
+
+ assertTrue(obj.getGlobalSubscriberId() == null);
+ assertTrue(obj.getSubscriberCommonSiteId() == null);
+ assertTrue(obj.getSubscriberName() == null);
+ }
+
+ @Test
+ public void testSetGet() {
+ SOSubscriberInfo obj = new SOSubscriberInfo();
+
+ obj.setGlobalSubscriberId("globalSubscriberId");
+ assertEquals("globalSubscriberId", obj.getGlobalSubscriberId());
+
+ obj.setSubscriberCommonSiteId("subscriberCommonSiteId");
+ assertEquals("subscriberCommonSiteId", obj.getSubscriberCommonSiteId());
+
+ obj.setSubscriberName("subscriberName");
+ assertEquals("subscriberName", obj.getSubscriberName());
+ }
+}
diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java index 8054d214a..8ea0062cc 100644 --- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java +++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java @@ -69,34 +69,34 @@ public class SoSimulatorTest { // Construct SO Request final SORequest request = new SORequest(); - request.requestId = UUID.randomUUID(); - request.requestDetails = new SORequestDetails(); - request.requestDetails.modelInfo = new SOModelInfo(); - request.requestDetails.cloudConfiguration = new SOCloudConfiguration(); - request.requestDetails.requestInfo = new SORequestInfo(); - request.requestDetails.requestParameters = new SORequestParameters(); - request.requestDetails.requestParameters.userParams = null; + request.setRequestId(UUID.randomUUID()); + request.setRequestDetails(new SORequestDetails()); + request.getRequestDetails().setModelInfo(new SOModelInfo()); + request.getRequestDetails().setCloudConfiguration(new SOCloudConfiguration()); + request.getRequestDetails().setRequestInfo(new SORequestInfo()); + request.getRequestDetails().setRequestParameters(new SORequestParameters()); + request.getRequestDetails().getRequestParameters().setUserParams(null); // // cloudConfiguration // - request.requestDetails.cloudConfiguration.lcpCloudRegionId = "DFW"; - request.requestDetails.cloudConfiguration.tenantId = "1015548"; + request.getRequestDetails().getCloudConfiguration().setLcpCloudRegionId("DFW"); + request.getRequestDetails().getCloudConfiguration().setTenantId("1015548"); // // modelInfo // - request.requestDetails.modelInfo.modelType = "vfModule"; - request.requestDetails.modelInfo.modelInvariantId = "f32568ec-2f1c-458a-864b-0593d53d141a"; - request.requestDetails.modelInfo.modelVersionId = "69615025-879d-4f0d-afe3-b7d1a7eeed1f"; - request.requestDetails.modelInfo.modelName = "C15ce9e1E9144c8fB8bb..dnsscaling..module-1"; - request.requestDetails.modelInfo.modelVersion = "1.0"; + request.getRequestDetails().getModelInfo().setModelType("vfModule"); + request.getRequestDetails().getModelInfo().setModelInvariantId("f32568ec-2f1c-458a-864b-0593d53d141a"); + request.getRequestDetails().getModelInfo().setModelVersionId("69615025-879d-4f0d-afe3-b7d1a7eeed1f"); + request.getRequestDetails().getModelInfo().setModelName("C15ce9e1E9144c8fB8bb..dnsscaling..module-1"); + request.getRequestDetails().getModelInfo().setModelVersion("1.0"); // // requestInfo // - request.requestDetails.requestInfo.instanceName = - "vDNS_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8"; - request.requestDetails.requestInfo.source = "POLICY"; - request.requestDetails.requestInfo.suppressRollback = false; - request.requestDetails.requestInfo.requestorId = "policy"; + request.getRequestDetails().getRequestInfo().setInstanceName( + "vDNS_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8"); + request.getRequestDetails().getRequestInfo().setSource("POLICY"); + request.getRequestDetails().getRequestInfo().setSuppressRollback(false); + request.getRequestDetails().getRequestInfo().setRequestorId("policy"); // // relatedInstanceList // @@ -104,33 +104,33 @@ public class SoSimulatorTest { new SORelatedInstanceListElement(); final SORelatedInstanceListElement relatedInstanceListElement2 = new SORelatedInstanceListElement(); - relatedInstanceListElement1.relatedInstance = new SORelatedInstance(); - relatedInstanceListElement2.relatedInstance = new SORelatedInstance(); + relatedInstanceListElement1.setRelatedInstance(new SORelatedInstance()); + relatedInstanceListElement2.setRelatedInstance(new SORelatedInstance()); // - relatedInstanceListElement1.relatedInstance.instanceId = "cf8426a6-0b53-4e3d-bfa6-4b2f4d5913a5"; - relatedInstanceListElement1.relatedInstance.modelInfo = new SOModelInfo(); - relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "service"; - relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = - "4fcbc1c0-7793-46d8-8aa1-fa1c2ed9ec7b"; - relatedInstanceListElement1.relatedInstance.modelInfo.modelVersionId = - "5c996219-b2e2-4c76-9b43-7e8672a33c1d"; - relatedInstanceListElement1.relatedInstance.modelInfo.modelName = "8330e932-2a23-4943-8606"; - relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = "1.0"; + relatedInstanceListElement1.getRelatedInstance().setInstanceId("cf8426a6-0b53-4e3d-bfa6-4b2f4d5913a5"); + relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SOModelInfo()); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("service"); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelInvariantId( + "4fcbc1c0-7793-46d8-8aa1-fa1c2ed9ec7b"); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersionId( + "5c996219-b2e2-4c76-9b43-7e8672a33c1d"); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelName("8330e932-2a23-4943-8606"); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersion("1.0"); // - relatedInstanceListElement2.relatedInstance.instanceId = "594e2fe0-48b8-41ff-82e2-3d4bab69b192"; - relatedInstanceListElement2.relatedInstance.modelInfo = new SOModelInfo(); - relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "vnf"; - relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = - "033a32ed-aa65-4764-a736-36f2942f1aa0"; - relatedInstanceListElement2.relatedInstance.modelInfo.modelVersionId = - "d4d072dc-4e21-4a03-9524-628985819a8e"; - relatedInstanceListElement2.relatedInstance.modelInfo.modelName = "c15ce9e1-e914-4c8f-b8bb"; - relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = "1"; - relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = - "c15ce9e1-e914-4c8f-b8bb 1"; + relatedInstanceListElement2.getRelatedInstance().setInstanceId("594e2fe0-48b8-41ff-82e2-3d4bab69b192"); + relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SOModelInfo()); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("vnf"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelInvariantId( + "033a32ed-aa65-4764-a736-36f2942f1aa0"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersionId( + "d4d072dc-4e21-4a03-9524-628985819a8e"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName("c15ce9e1-e914-4c8f-b8bb"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersion("1"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelCustomizationName( + "c15ce9e1-e914-4c8f-b8bb 1"); // - request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1); - request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2); + request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1); + request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2); return request; } |