aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java47
-rw-r--r--models-interactions/model-impl/so/src/main/java/org/onap/policy/so/util/Serialization.java7
-rw-r--r--models-interactions/model-impl/so/src/main/java/org/onap/policy/so/util/SoLocalDateTimeTypeAdapter.java68
-rw-r--r--models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java9
-rw-r--r--models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/so/so.immediate.success.json92
-rw-r--r--models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java4
6 files changed, 175 insertions, 52 deletions
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
index 2a00edda4..a26f6a77f 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
@@ -22,15 +22,7 @@ package org.onap.policy.controlloop.actor.so;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import com.google.gson.JsonParseException;
-import com.google.gson.TypeAdapter;
-import com.google.gson.stream.JsonReader;
-import com.google.gson.stream.JsonToken;
-import com.google.gson.stream.JsonWriter;
-import java.io.IOException;
import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -68,6 +60,7 @@ import org.onap.policy.so.SoRequestInfo;
import org.onap.policy.so.SoRequestParameters;
import org.onap.policy.so.SoRequestStatus;
import org.onap.policy.so.SoResponse;
+import org.onap.policy.so.util.SoLocalDateTimeTypeAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -498,44 +491,6 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
return coder;
}
- /*
- * TODO: combine this adapter with existing LocalDateTimeTypeAdapter and eliminate the
- * following two classes.
- */
-
- /**
- * GSON Type Adapter for "LocalDateTime" fields, that uses the standard
- * RFC_1123_DATE_TIME formatter.
- */
- private static class SoLocalDateTimeTypeAdapter extends TypeAdapter<LocalDateTime> {
- private static final DateTimeFormatter FORMATTER = DateTimeFormatter.RFC_1123_DATE_TIME;
-
- @Override
- public LocalDateTime read(JsonReader in) throws IOException {
- try {
- if (in.peek() == JsonToken.NULL) {
- in.nextNull();
- return null;
- } else {
- return LocalDateTime.parse(in.nextString(), FORMATTER);
- }
-
- } catch (DateTimeParseException e) {
- throw new JsonParseException("invalid date", e);
- }
- }
-
- @Override
- public void write(JsonWriter out, LocalDateTime value) throws IOException {
- if (value == null) {
- out.nullValue();
- } else {
- String text = value.format(FORMATTER);
- out.value(text);
- }
- }
- }
-
private static class SoCoder extends StandardCoder {
/**
diff --git a/models-interactions/model-impl/so/src/main/java/org/onap/policy/so/util/Serialization.java b/models-interactions/model-impl/so/src/main/java/org/onap/policy/so/util/Serialization.java
index 7224e665a..78506380d 100644
--- a/models-interactions/model-impl/so/src/main/java/org/onap/policy/so/util/Serialization.java
+++ b/models-interactions/model-impl/so/src/main/java/org/onap/policy/so/util/Serialization.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* mso
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,11 +23,14 @@ package org.onap.policy.so.util;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import java.time.LocalDateTime;
public final class Serialization {
public static final Gson gsonPretty =
- new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create();
+ new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(LocalDateTime.class, new SoLocalDateTimeTypeAdapter())
+ .create();
private Serialization() {
// utility class with explicit private constructor
diff --git a/models-interactions/model-impl/so/src/main/java/org/onap/policy/so/util/SoLocalDateTimeTypeAdapter.java b/models-interactions/model-impl/so/src/main/java/org/onap/policy/so/util/SoLocalDateTimeTypeAdapter.java
new file mode 100644
index 000000000..a0e835ffb
--- /dev/null
+++ b/models-interactions/model-impl/so/src/main/java/org/onap/policy/so/util/SoLocalDateTimeTypeAdapter.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2020 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.util;
+
+import com.google.gson.JsonParseException;
+import com.google.gson.TypeAdapter;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonToken;
+import com.google.gson.stream.JsonWriter;
+import java.io.IOException;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+
+/*
+ * TODO: combine the functionality of this adapter with existing LocalDateTimeTypeAdapter and eliminate this class.
+ */
+
+/**
+ * GSON Type Adapter for "LocalDateTime" fields, that uses the standard RFC_1123_DATE_TIME
+ * formatter.
+ */
+public class SoLocalDateTimeTypeAdapter extends TypeAdapter<LocalDateTime> {
+ private static final DateTimeFormatter FORMATTER = DateTimeFormatter.RFC_1123_DATE_TIME;
+
+ @Override
+ public LocalDateTime read(JsonReader in) throws IOException {
+ try {
+ if (in.peek() == JsonToken.NULL) {
+ in.nextNull();
+ return null;
+ } else {
+ return LocalDateTime.parse(in.nextString(), FORMATTER);
+ }
+
+ } catch (DateTimeParseException e) {
+ throw new JsonParseException("invalid date", e);
+ }
+ }
+
+ @Override
+ public void write(JsonWriter out, LocalDateTime value) throws IOException {
+ if (value == null) {
+ out.nullValue();
+ } else {
+ String text = value.format(FORMATTER);
+ out.value(text);
+ }
+ }
+}
diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java
index d83f5a54e..019d6f116 100644
--- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java
+++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java
@@ -73,7 +73,7 @@ public class SoSimulatorJaxRs {
public String soPostQuery(@PathParam("serviceInstanceId") final String serviceInstanceId,
@PathParam("vnfInstanceId") final String vnfInstanceId) {
- return (requirePolling ? makeStarted() : makeComplete(UUID.randomUUID().toString()));
+ return (requirePolling ? makeStarted() : makeImmediateComplete());
}
/**
@@ -91,7 +91,7 @@ public class SoSimulatorJaxRs {
@PathParam("vnfInstanceId") final String vnfInstanceId,
@PathParam("vfModuleInstanceId") final String vfModuleInstanceId) {
- return (requirePolling ? makeStarted() : makeComplete(UUID.randomUUID().toString()));
+ return (requirePolling ? makeStarted() : makeImmediateComplete());
}
/**
@@ -124,6 +124,11 @@ public class SoSimulatorJaxRs {
return response.replace(REPLACE_ME, requestId);
}
+ private String makeImmediateComplete() {
+ String response = ResourceUtils.getResourceAsString("org/onap/policy/simulators/so/so.immediate.success.json");
+ return response.replace(REPLACE_ME, UUID.randomUUID().toString());
+ }
+
private String makeComplete(String requestId) {
String response = ResourceUtils.getResourceAsString("org/onap/policy/simulators/so/so.complete.success.json");
return response.replace(REPLACE_ME, requestId);
diff --git a/models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/so/so.immediate.success.json b/models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/so/so.immediate.success.json
new file mode 100644
index 000000000..ae40985fa
--- /dev/null
+++ b/models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/so/so.immediate.success.json
@@ -0,0 +1,92 @@
+{
+ "requestReferences": {
+ "requestId": "${replaceMe}",
+ "instanceId": "68804843-18e0-41a3-8838-a6d90a035e1a",
+ "requestSelfLink": "http://so.onap:8080/orchestrationRequests/v7/b789e4e6-0b92-42c3-a723-1879af9c799d"
+ },
+ "request": {
+ "requestId": "${replaceMe}",
+ "startTime": "Fri, 15 May 2020 12:12:50 GMT",
+ "finishTime": "Fri, 15 May 2020 12:14:21 GMT",
+ "requestScope": "vfModule",
+ "requestType": "scaleOut",
+ "requestDetails": {
+ "modelInfo": {
+ "modelInvariantId": "2246ebc9-9b9f-42d0-a5e4-0248324fb884",
+ "modelType": "vfModule",
+ "modelName": "VlbCdsSb00..vdns..module-3",
+ "modelVersion": "1",
+ "modelCustomizationUuid": "3a74410a-6c74-4a32-94b2-71488be6da1a",
+ "modelVersionId": "1f94cedb-f656-4ddb-9f55-60ba1fc7d4b1",
+ "modelCustomizationId": "3a74410a-6c74-4a32-94b2-71488be6da1a",
+ "modelUuid": "1f94cedb-f656-4ddb-9f55-60ba1fc7d4b1",
+ "modelInvariantUuid": "2246ebc9-9b9f-42d0-a5e4-0248324fb884"
+ },
+ "requestInfo": {
+ "source": "POLICY",
+ "instanceName": "vfModuleName",
+ "suppressRollback": false,
+ "requestorId": "policy"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "c14e61b5-1ee6-4925-b4a9-b9c8dbfe3f34",
+ "modelInfo": {
+ "modelInvariantId": "6418bb39-61e1-45fc-a36b-3f211bb846c7",
+ "modelType": "service",
+ "modelName": "vLB_CDS_SB00_02",
+ "modelVersion": "1.0",
+ "modelVersionId": "d01d9dec-afb6-4a53-bd9e-2eb10ca07a51",
+ "modelUuid": "d01d9dec-afb6-4a53-bd9e-2eb10ca07a51",
+ "modelInvariantUuid": "6418bb39-61e1-45fc-a36b-3f211bb846c7"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "6636c4d5-f608-4376-b6d8-7977e98cb16d",
+ "modelInfo": {
+ "modelInvariantId": "827356a9-cb60-4976-9713-c30b4f850b41",
+ "modelType": "vnf",
+ "modelName": "vLB_CDS_SB00",
+ "modelVersion": "1.0",
+ "modelCustomizationUuid": "6478f94b-0b20-4b44-afc0-94e48070586a",
+ "modelVersionId": "ca3c4797-0cdd-4797-8bec-9a3ce78ac4da",
+ "modelCustomizationId": "6478f94b-0b20-4b44-afc0-94e48070586a",
+ "modelUuid": "ca3c4797-0cdd-4797-8bec-9a3ce78ac4da",
+ "modelInvariantUuid": "827356a9-cb60-4976-9713-c30b4f850b41"
+ }
+ }
+ }
+ ],
+ "cloudConfiguration": {
+ "tenantId": "41d6d38489bd40b09ea8a6b6b852dcbd",
+ "tenantName": "Integration-SB-00",
+ "cloudOwner": "CloudOwner",
+ "lcpCloudRegionId": "RegionOne"
+ },
+ "requestParameters": {
+ "usePreload": false
+ },
+ "configurationParameters": [
+ {
+ "ip-addr": "$.vf-module-topology.vf-module-parameters.param[16].value",
+ "oam-ip-addr": "$.vf-module-topology.vf-module-parameters.param[30].value"
+ }
+ ]
+ },
+ "instanceReferences": {
+ "serviceInstanceId": "c14e61b5-1ee6-4925-b4a9-b9c8dbfe3f34",
+ "vnfInstanceId": "6636c4d5-f608-4376-b6d8-7977e98cb16d",
+ "vfModuleInstanceId": "68804843-18e0-41a3-8838-a6d90a035e1a",
+ "vfModuleInstanceName": "vfModuleName"
+ },
+ "requestStatus": {
+ "requestState": "COMPLETE",
+ "statusMessage": "STATUS: ALaCarte-VfModule-scaleOut request was executed correctly. FLOW STATUS: Successfully completed all Building Blocks RESOURCE STATUS: The vf module was found to already exist, thus no new vf module was created in the cloud via this request",
+ "percentProgress": 100,
+ "timestamp": "Fri, 15 May 2020 12:14:21 GMT"
+ }
+ }
+}
diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
index d8613c8b7..fbeb08466 100644
--- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
+++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
@@ -144,7 +144,7 @@ public class SoSimulatorTest {
"username",
"password", new HashMap<>(), "application/json", request);
assertNotNull(httpDetails);
- assertThat(httpDetails.second).contains("\"COMPLETE\"").doesNotContain("requestSelfLink");
+ assertThat(httpDetails.second).contains("\"COMPLETE\"").contains("requestSelfLink");
/*
* Repeat, but set the flag indicating that the request should yield incomplete.
@@ -186,7 +186,7 @@ public class SoSimulatorTest {
"username",
"password", new HashMap<>(), "application/json", request);
assertNotNull(httpDetails);
- assertThat(httpDetails.second).contains("\"COMPLETE\"").doesNotContain("requestSelfLink");
+ assertThat(httpDetails.second).contains("\"COMPLETE\"").contains("requestSelfLink");
/*
* Repeat, but set the flag indicating that the request should yield incomplete.