summaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/model-impl')
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMRequest.java2
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseCode.java6
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseStatus.java144
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMWrapper.java2
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java149
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java8
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMCommonHeader.java159
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequest.java107
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequestWrapper.java62
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResonseCode.java54
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseStatus.java70
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseWrapper.java61
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMWrapper.java111
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/applcm/util/TestSerialization.java58
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java118
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java163
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java84
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java20
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java6
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java4
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java33
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java37
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java73
-rw-r--r--controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java182
-rwxr-xr-xcontrolloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestGet.java52
-rwxr-xr-xcontrolloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPair.java42
-rwxr-xr-xcontrolloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPost.java42
-rw-r--r--controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGRequest.java19
-rw-r--r--controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGStream.java22
-rw-r--r--controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGStreams.java18
-rw-r--r--controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/util/Serialization.java9
-rw-r--r--controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java39
32 files changed, 1549 insertions, 407 deletions
diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMRequest.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMRequest.java
index 51db7fef0..83442d9bf 100644
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMRequest.java
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMRequest.java
@@ -42,7 +42,7 @@ public class LCMRequest implements Serializable {
private String payload;
public LCMRequest() {
-
+ // Create a default LCM request
}
public LCMCommonHeader getCommonHeader() {
diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseCode.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseCode.java
index 85427c468..8a7c36d2b 100644
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseCode.java
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseCode.java
@@ -33,10 +33,10 @@ public class LCMResponseCode {
private Integer code;
- private LCMResponseCode(int code) {
- this.code = code;
+ protected LCMResponseCode(final int code) {
+ this.code = code;
}
-
+
public int getCode() {
return this.code;
}
diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseStatus.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseStatus.java
index 131e331bf..1db4e8ef7 100644
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseStatus.java
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseStatus.java
@@ -25,83 +25,83 @@ import java.io.Serializable;
public class LCMResponseStatus implements Serializable {
- private static final long serialVersionUID = 974891505135467199L;
-
- @SerializedName(value="code")
- private int code;
-
- @SerializedName(value="message")
- private String message;
-
- public LCMResponseStatus() {
-
- }
+ private static final long serialVersionUID = 974891505135467199L;
- /**
- * @return the code
- */
- public int getCode() {
- return code;
- }
-
- /**
- * @param code the code to set
- */
- public void setCode(int code) {
- this.code = code;
- }
+ @SerializedName(value="code")
+ private int code;
- /**
- * @return the message
- */
- public String getMessage() {
- return message;
- }
+ @SerializedName(value="message")
+ private String message;
- /**
- * @param message the message to set
- */
- public void setMessage(String message) {
- this.message = message;
- }
+ public LCMResponseStatus() {
+ // Create a default LCMResponseStatus instance
+ }
- @Override
- public String toString() {
- return "ResponseStatus [code=" + code + ", message=" + message + "]";
- }
+ /**
+ * @return the code
+ */
+ public int getCode() {
+ return code;
+ }
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + code;
- result = prime * result + ((message == null) ? 0 : message.hashCode());
- return result;
- }
+ /**
+ * @param code the code to set
+ */
+ public void setCode(int code) {
+ this.code = code;
+ }
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- LCMResponseStatus other = (LCMResponseStatus) obj;
- if (code != other.code) {
- return false;
- }
- if (message == null) {
- if (other.message != null) {
- return false;
- }
- } else if (!message.equals(other.message)) {
- return false;
- }
- return true;
- }
+ /**
+ * @return the message
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * @param message the message to set
+ */
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ @Override
+ public String toString() {
+ return "ResponseStatus [code=" + code + ", message=" + message + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + code;
+ result = prime * result + ((message == null) ? 0 : message.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;
+ }
+ LCMResponseStatus other = (LCMResponseStatus) obj;
+ if (code != other.code) {
+ return false;
+ }
+ if (message == null) {
+ if (other.message != null) {
+ return false;
+ }
+ } else if (!message.equals(other.message)) {
+ return false;
+ }
+ return true;
+ }
}
diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMWrapper.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMWrapper.java
index c9f72c2e2..c70e7423a 100644
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMWrapper.java
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMWrapper.java
@@ -43,7 +43,7 @@ public class LCMWrapper implements Serializable {
private String type;
public LCMWrapper() {
-
+ // Create a default LCMWrapper instance
}
/**
diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java
index e41fa3653..5a5e2e2e6 100644
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java
@@ -32,88 +32,83 @@ import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
public final class Serialization {
+ private Serialization() {
+ }
- public static class RequestAdapter implements JsonSerializer<LCMRequest>, JsonDeserializer<LCMRequest> {
-
- @Override
- public JsonElement serialize(LCMRequest src, Type typeOfSrc, JsonSerializationContext context) {
- JsonElement requestJson = gsonPretty.toJsonTree(src, LCMRequest.class);
- JsonObject input = new JsonObject();
- input.add("input", requestJson);
-
- return input;
- }
-
- @Override
- public LCMRequest deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
- throws JsonParseException {
- LCMRequest request = gsonPretty.fromJson(json.getAsJsonObject().get("input"), LCMRequest.class);
- return request;
- }
- }
-
- public static class ResponseAdapter implements JsonSerializer<LCMResponse>, JsonDeserializer<LCMResponse> {
-
- @Override
- public JsonElement serialize(LCMResponse src, Type typeOfSrc, JsonSerializationContext context) {
- JsonElement responseJson = gsonPretty.toJsonTree(src, LCMResponse.class);
- JsonObject output = new JsonObject();
- output.add("output", responseJson);
- return output;
- }
-
- @Override
- public LCMResponse deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
- throws JsonParseException {
- LCMResponse response = gsonPretty.fromJson(json.getAsJsonObject().get("output"), LCMResponse.class);
- return response;
- }
- }
-
- public static class InstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
-
- @Override
- public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
- throws JsonParseException {
- return Instant.parse(json.getAsString());
- }
-
- @Override
- public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
- return new JsonPrimitive(src.toString());
- }
-
- }
-
- public static class InstantJunitAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
-
- @Override
- public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
- throws JsonParseException {
- return Instant.ofEpochMilli(json.getAsLong());
- }
-
- @Override
- public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
- return new JsonPrimitive(src.toEpochMilli());
- }
-
- }
-
- public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
- .registerTypeAdapter(Instant.class, new InstantAdapter()).create();
-
- public static final Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
- .registerTypeAdapter(LCMRequest.class, new RequestAdapter())
- .registerTypeAdapter(LCMResponse.class, new ResponseAdapter()).create();
-
- public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
- .registerTypeAdapter(Instant.class, new InstantJunitAdapter()).create();
+ public static class RequestAdapter implements JsonSerializer<LCMRequest>, JsonDeserializer<LCMRequest> {
+
+ @Override
+ public JsonElement serialize(LCMRequest src, Type typeOfSrc, JsonSerializationContext context) {
+ JsonElement requestJson = gsonPretty.toJsonTree(src, LCMRequest.class);
+ JsonObject input = new JsonObject();
+ input.add("input", requestJson);
+
+ return input;
+ }
+
+ @Override
+ public LCMRequest deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
+ return gsonPretty.fromJson(json.getAsJsonObject().get("input"), LCMRequest.class);
+ }
+ }
+
+ public static class ResponseAdapter implements JsonSerializer<LCMResponse>, JsonDeserializer<LCMResponse> {
+
+ @Override
+ public JsonElement serialize(LCMResponse src, Type typeOfSrc, JsonSerializationContext context) {
+ JsonElement responseJson = gsonPretty.toJsonTree(src, LCMResponse.class);
+ JsonObject output = new JsonObject();
+ output.add("output", responseJson);
+ return output;
+ }
+
+ @Override
+ public LCMResponse deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
+ return gsonPretty.fromJson(json.getAsJsonObject().get("output"), LCMResponse.class);
+ }
+ }
+
+ public static class InstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
+
+ @Override
+ public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
+ return Instant.parse(json.getAsString());
+ }
+
+ @Override
+ public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
+ return new JsonPrimitive(src.toString());
+ }
+
+ }
+
+ public static class InstantJunitAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
+
+ @Override
+ public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
+ return Instant.ofEpochMilli(json.getAsLong());
+ }
+
+ @Override
+ public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
+ return new JsonPrimitive(src.toEpochMilli());
+ }
+
+ }
+
+ public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(Instant.class, new InstantAdapter()).create();
+
+ public static final Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(LCMRequest.class, new RequestAdapter())
+ .registerTypeAdapter(LCMResponse.class, new ResponseAdapter()).create();
+
+ public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(Instant.class, new InstantJunitAdapter()).create();
}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java
index 41bafe498..2d58bfd99 100644
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java
@@ -140,7 +140,7 @@ public class AppcLcmTest {
/*
* The type of the DMAAP wrapper should be request
*/
- assertEquals(dmaapRequest.getType(), "request");
+ assertEquals("request", dmaapRequest.getType());
/*
* The DMAAP wrapper must have a body as that is
@@ -160,7 +160,7 @@ public class AppcLcmTest {
* set to restart
*/
assertNotNull(appcRequest.getAction());
- assertEquals(appcRequest.getAction(), "restart");
+ assertEquals("restart", appcRequest.getAction());
/*
* The action-identifiers should not be null
@@ -217,7 +217,7 @@ public class AppcLcmTest {
/*
* The type of the DMAAP wrapper should be response
*/
- assertEquals(dmaapResponse.getType(), "response");
+ assertEquals("response", dmaapResponse.getType());
/*
* The DMAAP wrapper must have a body as that is
@@ -237,7 +237,7 @@ public class AppcLcmTest {
* status code should be 400
*/
assertNotNull(appcResponse.getStatus());
- assertEquals(appcResponse.getStatus().getCode(), 400);
+ assertEquals(400, appcResponse.getStatus().getCode());
logger.debug("Response as a Java Object: \n" + appcResponse.toString() + "\n\n");
}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMCommonHeader.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMCommonHeader.java
new file mode 100644
index 000000000..6921068e5
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMCommonHeader.java
@@ -0,0 +1,159 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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=========================================================
+ */
+
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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.appclcm;
+
+import static org.junit.Assert.*;
+
+import java.time.Instant;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.junit.Test;
+
+public class TestLCMCommonHeader {
+
+ @Test
+ public void testLCMLCMCommonHeader() {
+ LCMCommonHeader commonHeader = new LCMCommonHeader();
+ assertNotNull(commonHeader);
+ assertNotNull(new LCMCommonHeader(commonHeader));
+ assertNotEquals(0, commonHeader.hashCode());
+
+ commonHeader.setApiVer("Kansas");
+ assertEquals("Kansas", commonHeader.getApiVer());
+
+ Map<String, String> flagMap = new HashMap<>();
+ commonHeader.setFlags(flagMap);
+ assertEquals(flagMap, commonHeader.getFlags());
+
+ commonHeader.setOriginatorId("Dorothy");
+ assertEquals("Dorothy", commonHeader.getOriginatorId());
+
+ UUID requestId = UUID.randomUUID();
+ commonHeader.setRequestId(requestId);
+ assertEquals(requestId, commonHeader.getRequestId());
+
+ commonHeader.setSubRequestId("Can I go home?");
+ assertEquals("Can I go home?", commonHeader.getSubRequestId());
+
+ Instant timestamp = Instant.now();
+ commonHeader.setTimeStamp(timestamp);
+ assertEquals(timestamp, commonHeader.getTimeStamp());
+
+ assertNotEquals(0, commonHeader.hashCode());
+
+ assertEquals("CommonHeader [timeStamp=", commonHeader.toString().substring(0, 24));
+
+ LCMCommonHeader copiedLCMCommonHeader = new LCMCommonHeader();
+ copiedLCMCommonHeader.setApiVer(commonHeader.getApiVer());
+ copiedLCMCommonHeader.setFlags(commonHeader.getFlags());
+ copiedLCMCommonHeader.setOriginatorId(commonHeader.getOriginatorId());
+ copiedLCMCommonHeader.setRequestId(commonHeader.getRequestId());
+ copiedLCMCommonHeader.setSubRequestId(commonHeader.getSubRequestId());
+ copiedLCMCommonHeader.setTimeStamp(commonHeader.getTimeStamp());
+
+ assertTrue(commonHeader.equals(commonHeader));
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+ assertFalse(commonHeader.equals(null));
+ assertFalse(commonHeader.equals("Hello"));
+
+ LCMCommonHeader clonedLCMCommonHeader = new LCMCommonHeader(commonHeader);
+ clonedLCMCommonHeader.setApiVer(commonHeader.getApiVer());
+ clonedLCMCommonHeader.setTimeStamp(commonHeader.getTimeStamp());
+
+ assertTrue(commonHeader.equals(clonedLCMCommonHeader));
+
+ commonHeader.setApiVer(null);
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setApiVer(null);
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+ commonHeader.setApiVer("Kansas");
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setApiVer("Kansas");
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+
+ commonHeader.setFlags(null);
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setFlags(null);
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+ commonHeader.setFlags(flagMap);
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setFlags(flagMap);
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+
+ commonHeader.setOriginatorId(null);
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setOriginatorId(null);
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+ commonHeader.setOriginatorId("Dorothy");
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setOriginatorId("Dorothy");
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+
+ commonHeader.setRequestId(null);
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setRequestId(null);
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+ commonHeader.setRequestId(requestId);
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setRequestId(requestId);
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+
+ commonHeader.setSubRequestId(null);
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setSubRequestId(null);
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+ commonHeader.setSubRequestId("Can I go home?");
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setSubRequestId("Can I go home?");
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+
+ commonHeader.setTimeStamp(null);
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setTimeStamp(null);
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+ commonHeader.setTimeStamp(timestamp);
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setTimeStamp(timestamp);
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequest.java
new file mode 100644
index 000000000..223e50147
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequest.java
@@ -0,0 +1,107 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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.appclcm;
+
+import static org.junit.Assert.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+public class TestLCMRequest {
+
+ @Test
+ public void testLCMRequest() {
+ LCMRequest request = new LCMRequest();
+ assertNotNull(request);
+ assertNotEquals(0, request.hashCode());
+
+ LCMCommonHeader commonHeader = new LCMCommonHeader();
+
+ request.setCommonHeader(commonHeader);
+ assertEquals(commonHeader, request.getCommonHeader());
+
+ request.setAction("Go to Oz");
+ assertEquals("Go to Oz", request.getAction());
+
+ Map<String, String> actionIdentifiers = new HashMap<>();
+ actionIdentifiers.put("North", "Good Witch");
+ actionIdentifiers.put("West", "Bad Witch");
+
+ request.setActionIdentifiers(actionIdentifiers);
+ assertEquals(actionIdentifiers, request.getActionIdentifiers());
+
+ request.setPayload("The Emerald City");
+ assertEquals("The Emerald City", request.getPayload());
+
+ assertNotEquals(0, request.hashCode());
+
+ assertEquals("Request [commonHeader=CommonHeader [timeStamp=", request.toString().substring(0, 46));
+
+ LCMRequest copiedLCMRequest = new LCMRequest();
+ copiedLCMRequest.setCommonHeader(request.getCommonHeader());
+ copiedLCMRequest.setAction(request.getAction());
+ copiedLCMRequest.setActionIdentifiers(request.getActionIdentifiers());
+ copiedLCMRequest.setPayload(request.getPayload());
+
+ assertTrue(request.equals(request));
+ assertTrue(request.equals(copiedLCMRequest));
+ assertFalse(request.equals(null));
+ assertFalse(request.equals("Hello"));
+
+ request.setCommonHeader(null);
+ assertFalse(request.equals(copiedLCMRequest));
+ copiedLCMRequest.setCommonHeader(null);
+ assertTrue(request.equals(copiedLCMRequest));
+ request.setCommonHeader(commonHeader);
+ assertFalse(request.equals(copiedLCMRequest));
+ copiedLCMRequest.setCommonHeader(commonHeader);
+ assertTrue(request.equals(copiedLCMRequest));
+
+ request.setAction(null);
+ assertFalse(request.equals(copiedLCMRequest));
+ copiedLCMRequest.setAction(null);
+ assertTrue(request.equals(copiedLCMRequest));
+ request.setAction("Go to Oz");
+ assertFalse(request.equals(copiedLCMRequest));
+ copiedLCMRequest.setAction("Go to Oz");
+ assertTrue(request.equals(copiedLCMRequest));
+
+ request.setActionIdentifiers(null);
+ assertFalse(request.equals(copiedLCMRequest));
+ copiedLCMRequest.setActionIdentifiers(null);
+ assertTrue(request.equals(copiedLCMRequest));
+ request.setActionIdentifiers(actionIdentifiers);
+ assertFalse(request.equals(copiedLCMRequest));
+ copiedLCMRequest.setActionIdentifiers(actionIdentifiers);
+ assertTrue(request.equals(copiedLCMRequest));
+
+ request.setPayload(null);
+ assertFalse(request.equals(copiedLCMRequest));
+ copiedLCMRequest.setPayload(null);
+ assertTrue(request.equals(copiedLCMRequest));
+ request.setPayload("The Emerald City");
+ assertFalse(request.equals(copiedLCMRequest));
+ copiedLCMRequest.setPayload("The Emerald City");
+ assertTrue(request.equals(copiedLCMRequest));
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequestWrapper.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequestWrapper.java
new file mode 100644
index 000000000..0a5205509
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequestWrapper.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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.appclcm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class TestLCMRequestWrapper {
+
+ @Test
+ public void testLCMRequestWrapperWrapper() {
+ assertNotNull(new LCMRequestWrapper(new LCMRequest()));
+ LCMRequestWrapper requestWrapper = new LCMRequestWrapper();
+ assertNotNull(requestWrapper);
+ assertNotEquals(0, requestWrapper.hashCode());
+
+ LCMRequest request = new LCMRequest();
+
+ requestWrapper.setBody(request);
+ assertEquals(request, requestWrapper.getBody());
+
+ assertNotEquals(0, requestWrapper.hashCode());
+
+ assertEquals("RequestWrapper [body=Request [commonHeader=nul", requestWrapper.toString().substring(0, 46));
+
+ LCMRequestWrapper copiedLCMRequestWrapper = new LCMRequestWrapper();
+ copiedLCMRequestWrapper.setBody(requestWrapper.getBody());
+
+ assertTrue(requestWrapper.equals(requestWrapper));
+ assertTrue(requestWrapper.equals(copiedLCMRequestWrapper));
+ assertFalse(requestWrapper.equals(null));
+ assertFalse(requestWrapper.equals("Hello"));
+
+ requestWrapper.setBody(null);
+ assertFalse(requestWrapper.equals(copiedLCMRequestWrapper));
+ copiedLCMRequestWrapper.setBody(null);
+ assertTrue(requestWrapper.equals(copiedLCMRequestWrapper));
+ requestWrapper.setBody(request);
+ assertFalse(requestWrapper.equals(copiedLCMRequestWrapper));
+ copiedLCMRequestWrapper.setBody(request);
+ assertTrue(requestWrapper.equals(copiedLCMRequestWrapper));
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResonseCode.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResonseCode.java
new file mode 100644
index 000000000..59606f8b4
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResonseCode.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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.appclcm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class TestLCMResonseCode {
+
+ @Test
+ public void testLCMResponseCode() {
+ assertNull(LCMResponseCode.toResponseValue(0));
+
+ assertEquals(LCMResponseCode.ACCEPTED, LCMResponseCode.toResponseValue(100));
+ assertEquals(LCMResponseCode.ERROR, LCMResponseCode.toResponseValue(200));
+ assertEquals(LCMResponseCode.REJECT, LCMResponseCode.toResponseValue(300));
+ assertEquals(LCMResponseCode.SUCCESS, LCMResponseCode.toResponseValue(400));
+ assertEquals(LCMResponseCode.FAILURE, LCMResponseCode.toResponseValue(450));
+ assertEquals(LCMResponseCode.FAILURE, LCMResponseCode.toResponseValue(401));
+ assertEquals(LCMResponseCode.FAILURE, LCMResponseCode.toResponseValue(406));
+ assertEquals(LCMResponseCode.PARTIAL_SUCCESS, LCMResponseCode.toResponseValue(500));
+ assertEquals(LCMResponseCode.PARTIAL_FAILURE, LCMResponseCode.toResponseValue(501));
+ assertEquals(LCMResponseCode.PARTIAL_FAILURE, LCMResponseCode.toResponseValue(599));
+
+ assertEquals("100", new LCMResponseCode(100).toString());
+ assertEquals("200", new LCMResponseCode(200).toString());
+ assertEquals("300", new LCMResponseCode(300).toString());
+ assertEquals("400", new LCMResponseCode(400).toString());
+ assertEquals("450", new LCMResponseCode(450).toString());
+ assertEquals("500", new LCMResponseCode(500).toString());
+ assertEquals("510", new LCMResponseCode(510).toString());
+
+ assertEquals(300, new LCMResponseCode(300).getCode());
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseStatus.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseStatus.java
new file mode 100644
index 000000000..0b6cbcf22
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseStatus.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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.appclcm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class TestLCMResponseStatus {
+
+ @Test
+ public void testResonseStatus() {
+ LCMResponseStatus status = new LCMResponseStatus();
+ assertNotNull(status);
+ assertNotEquals(0, status.hashCode());
+
+ status.setCode(1234);
+ assertEquals(1234, status.getCode());
+
+ status.setMessage("The wonderful land of Oz");
+ assertEquals("The wonderful land of Oz", status.getMessage());
+
+ assertEquals("ResponseStatus [code=1234, message=The wonderfu", status.toString().substring(0, 47));
+
+ LCMResponseStatus copiedStatus = new LCMResponseStatus();
+ copiedStatus.setCode(status.getCode());
+ copiedStatus.setMessage(status.getMessage());
+
+ assertTrue(status.equals(status));
+ assertTrue(status.equals(copiedStatus));
+ assertFalse(status.equals(null));
+ assertFalse(status.equals("Hello"));
+
+ status.setCode(-1);
+ assertFalse(status.equals(copiedStatus));
+ copiedStatus.setCode(-1);
+ assertTrue(status.equals(copiedStatus));
+ status.setCode(1234);
+ assertFalse(status.equals(copiedStatus));
+ copiedStatus.setCode(1234);
+ assertTrue(status.equals(copiedStatus));
+
+ status.setMessage(null);
+ assertFalse(status.equals(copiedStatus));
+ copiedStatus.setMessage(null);
+ assertTrue(status.equals(copiedStatus));
+ status.setMessage("The wonderful land of Oz");
+ assertFalse(status.equals(copiedStatus));
+ copiedStatus.setMessage("The wonderful land of Oz");
+ assertTrue(status.equals(copiedStatus));
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseWrapper.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseWrapper.java
new file mode 100644
index 000000000..d27fbaff3
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseWrapper.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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.appclcm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class TestLCMResponseWrapper {
+
+ @Test
+ public void testLCMResponseWrapperWrapper() {
+ LCMResponseWrapper responseWrapper = new LCMResponseWrapper();
+ assertNotNull(responseWrapper);
+ assertNotEquals(0, responseWrapper.hashCode());
+
+ LCMResponse response = new LCMResponse();
+
+ responseWrapper.setBody(response);
+ assertEquals(response, responseWrapper.getBody());
+
+ assertNotEquals(0, responseWrapper.hashCode());
+
+ assertEquals("ResponseWrapper [body=Response [commonHeader=n", responseWrapper.toString().substring(0, 46));
+
+ LCMResponseWrapper copiedLCMResponseWrapper = new LCMResponseWrapper();
+ copiedLCMResponseWrapper.setBody(responseWrapper.getBody());
+
+ assertTrue(responseWrapper.equals(responseWrapper));
+ assertTrue(responseWrapper.equals(copiedLCMResponseWrapper));
+ assertFalse(responseWrapper.equals(null));
+ assertFalse(responseWrapper.equals("Hello"));
+
+ responseWrapper.setBody(null);
+ assertFalse(responseWrapper.equals(copiedLCMResponseWrapper));
+ copiedLCMResponseWrapper.setBody(null);
+ assertTrue(responseWrapper.equals(copiedLCMResponseWrapper));
+ responseWrapper.setBody(response);
+ assertFalse(responseWrapper.equals(copiedLCMResponseWrapper));
+ copiedLCMResponseWrapper.setBody(response);
+ assertTrue(responseWrapper.equals(copiedLCMResponseWrapper));
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMWrapper.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMWrapper.java
new file mode 100644
index 000000000..20baf154d
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMWrapper.java
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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.appclcm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class TestLCMWrapper {
+
+ @Test
+ public void testLCMWrapper() {
+ LCMWrapper wrapper = new LCMWrapper();
+ assertNotNull(wrapper);
+ assertNotEquals(0, wrapper.hashCode());
+
+ wrapper.setVersion("19.3.9");
+ assertEquals("19.3.9", wrapper.getVersion());
+
+ wrapper.setCambriaPartition("The Emerald City");
+ assertEquals("The Emerald City", wrapper.getCambriaPartition());
+
+ wrapper.setRpcName("Tornado");
+ assertEquals("Tornado", wrapper.getRpcName());
+
+ wrapper.setCorrelationId("YellowBrickRoad");
+ assertEquals("YellowBrickRoad", wrapper.getCorrelationId());
+
+ wrapper.setType("Munchkin");
+ assertEquals("Munchkin", wrapper.getType());
+
+ assertNotEquals(0, wrapper.hashCode());
+
+ assertEquals("Wrapper [version=19.3.9, cambriaPartition=The ", wrapper.toString().substring(0, 46));
+
+ LCMWrapper copiedLCMWrapper = new LCMWrapper();
+ copiedLCMWrapper.setVersion(wrapper.getVersion());
+ copiedLCMWrapper.setCambriaPartition(wrapper.getCambriaPartition());
+ copiedLCMWrapper.setRpcName(wrapper.getRpcName());
+ copiedLCMWrapper.setCorrelationId(wrapper.getCorrelationId());
+ copiedLCMWrapper.setType(wrapper.getType());
+
+ assertTrue(wrapper.equals(wrapper));
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+ assertFalse(wrapper.equals(null));
+ assertFalse(wrapper.equals("Hello"));
+
+ wrapper.setVersion(null);
+ assertFalse(wrapper.equals(copiedLCMWrapper));
+ copiedLCMWrapper.setVersion(null);
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+ wrapper.setVersion("19.3.9");
+ assertFalse(wrapper.equals(copiedLCMWrapper));
+ copiedLCMWrapper.setVersion("19.3.9");
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+
+ wrapper.setCambriaPartition(null);
+ assertFalse(wrapper.equals(copiedLCMWrapper));
+ copiedLCMWrapper.setCambriaPartition(null);
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+ wrapper.setCambriaPartition("The Emerald City");
+ assertFalse(wrapper.equals(copiedLCMWrapper));
+ copiedLCMWrapper.setCambriaPartition("The Emerald City");
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+
+ wrapper.setRpcName(null);
+ assertFalse(wrapper.equals(copiedLCMWrapper));
+ copiedLCMWrapper.setRpcName(null);
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+ wrapper.setRpcName("Tornado");
+ assertFalse(wrapper.equals(copiedLCMWrapper));
+ copiedLCMWrapper.setRpcName("Tornado");
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+
+ wrapper.setCorrelationId(null);
+ assertFalse(wrapper.equals(copiedLCMWrapper));
+ copiedLCMWrapper.setCorrelationId(null);
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+ wrapper.setCorrelationId("YellowBrickRoad");
+ assertFalse(wrapper.equals(copiedLCMWrapper));
+ copiedLCMWrapper.setCorrelationId("YellowBrickRoad");
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+
+ wrapper.setType(null);
+ assertFalse(wrapper.equals(copiedLCMWrapper));
+ copiedLCMWrapper.setType(null);
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+ wrapper.setType("Munchkin");
+ assertFalse(wrapper.equals(copiedLCMWrapper));
+ copiedLCMWrapper.setType("Munchkin");
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/applcm/util/TestSerialization.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/applcm/util/TestSerialization.java
new file mode 100644
index 000000000..c7167f509
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/applcm/util/TestSerialization.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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.applcm.util;
+
+import static org.junit.Assert.*;
+
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+
+import org.junit.Test;
+import org.onap.policy.appclcm.util.Serialization;
+
+public class TestSerialization {
+
+ @Test
+ public void test() {
+ String nameString = "Dorothy";
+ String jsonName = Serialization.gsonPretty.toJson(nameString, String.class);
+ assertEquals("\"Dorothy\"", jsonName);
+ String jsonInOutName = Serialization.gsonPretty.fromJson(jsonName, String.class);
+ assertEquals("Dorothy", jsonInOutName);
+
+ Instant instant0 = Instant.ofEpochMilli(1516127215000L);
+ String instantString0 = Serialization.gsonPretty.toJson(instant0, Instant.class);
+ assertEquals("\"2018-01-16T18:26:55Z\"", instantString0);
+ Instant outInstant0 = Serialization.gsonPretty.fromJson(instantString0, Instant.class);
+ assertEquals(instant0, outInstant0);
+
+ Instant instant1 = Instant.ofEpochMilli(1516127215000L);
+ String instantString1 = Serialization.gsonJunit.toJson(instant1, Instant.class);
+ assertEquals("1516127215000", instantString1);
+ Instant outInstant1 = Serialization.gsonJunit.fromJson(instantString1, Instant.class);
+ assertEquals(instant1, outInstant1);
+
+ ZonedDateTime zdt = ZonedDateTime.ofInstant(instant0, ZoneId.of("UTC"));
+ String zdtString = Serialization.gsonPretty.toJson(zdt, ZonedDateTime.class);
+ assertEquals("{\n \"dateTime\": {\n \"date\":", zdtString.substring(0, 29));
+ }
+}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
index df099ed5e..1d85ccb77 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
@@ -27,17 +27,17 @@ public abstract class ControlLoopEvent implements Serializable {
private static final long serialVersionUID = 2391252138583119195L;
- public String closedLoopControlName;
- public String version = "1.0.2";
- public UUID requestID;
- public String closedLoopEventClient;
- public ControlLoopTargetType target_type;
- public String target;
- public String from;
- public String policyScope;
- public String policyName;
- public String policyVersion;
- public ControlLoopEventStatus closedLoopEventStatus;
+ private String closedLoopControlName;
+ private String version = "1.0.2";
+ private UUID requestID;
+ private String closedLoopEventClient;
+ private ControlLoopTargetType targetType;
+ private String target;
+ private String from;
+ private String policyScope;
+ private String policyName;
+ private String policyVersion;
+ private ControlLoopEventStatus closedLoopEventStatus;
public ControlLoopEvent() {
@@ -50,7 +50,7 @@ public abstract class ControlLoopEvent implements Serializable {
this.closedLoopControlName = event.closedLoopControlName;
this.requestID = event.requestID;
this.closedLoopEventClient = event.closedLoopEventClient;
- this.target_type = event.target_type;
+ this.targetType = event.targetType;
this.target = event.target;
this.from = event.from;
this.policyScope = event.policyScope;
@@ -59,11 +59,95 @@ public abstract class ControlLoopEvent implements Serializable {
this.closedLoopEventStatus = event.closedLoopEventStatus;
}
- public boolean isEventStatusValid() {
- if (this.closedLoopEventStatus == null) {
- return false;
- }
- return true;
+ public boolean isEventStatusValid() {
+ return this.closedLoopEventStatus != null;
+ }
+
+ public String getClosedLoopControlName() {
+ return closedLoopControlName;
+ }
+
+ public void setClosedLoopControlName(String closedLoopControlName) {
+ this.closedLoopControlName = closedLoopControlName;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public UUID getRequestID() {
+ return requestID;
+ }
+
+ public void setRequestID(UUID requestID) {
+ this.requestID = requestID;
+ }
+
+ public String getClosedLoopEventClient() {
+ return closedLoopEventClient;
+ }
+
+ public void setClosedLoopEventClient(String closedLoopEventClient) {
+ this.closedLoopEventClient = closedLoopEventClient;
+ }
+
+ public ControlLoopTargetType getTargetType() {
+ return targetType;
+ }
+
+ public void setTargetType(ControlLoopTargetType targetType) {
+ this.targetType = targetType;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public String getFrom() {
+ return from;
+ }
+
+ public void setFrom(String from) {
+ this.from = from;
+ }
+
+ public String getPolicyScope() {
+ return policyScope;
+ }
+
+ public void setPolicyScope(String policyScope) {
+ this.policyScope = policyScope;
}
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
+ public String getPolicyVersion() {
+ return policyVersion;
+ }
+
+ public void setPolicyVersion(String policyVersion) {
+ this.policyVersion = policyVersion;
+ }
+
+ public ControlLoopEventStatus getClosedLoopEventStatus() {
+ return closedLoopEventStatus;
+ }
+
+ public void setClosedLoopEventStatus(ControlLoopEventStatus closedLoopEventStatus) {
+ this.closedLoopEventStatus = closedLoopEventStatus;
+ }
}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
index 8e29b1de3..8e7a50fac 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
@@ -31,32 +31,155 @@ public abstract class ControlLoopNotification implements Serializable {
private static final long serialVersionUID = 7538596984567127915L;
- public String closedLoopControlName;
- public String version = "1.0.2";
- public UUID requestID;
- public String closedLoopEventClient;
- public ControlLoopTargetType target_type;
- public String target;
- public String from;
- public String policyScope;
- public String policyName;
- public String policyVersion;
- public ControlLoopNotificationType notification;
- public String message;
- public ZonedDateTime notificationTime = ZonedDateTime.now(ZoneOffset.UTC);;
- public Integer OPS_CL_timer;
- public List<ControlLoopOperation> history = new LinkedList<ControlLoopOperation>();
+ private String closedLoopControlName;
+ private String version = "1.0.2";
+ private UUID requestID;
+ private String closedLoopEventClient;
+ private ControlLoopTargetType targetType;
+ private String target;
+ private String from;
+ private String policyScope;
+ private String policyName;
+ private String policyVersion;
+ private ControlLoopNotificationType notification;
+ private String message;
+ private ZonedDateTime notificationTime = ZonedDateTime.now(ZoneOffset.UTC);
+ private Integer opsCLTimer;
+ private List<ControlLoopOperation> history = new LinkedList<>();
public ControlLoopNotification() {
}
public ControlLoopNotification(ControlLoopEvent event) {
- this.closedLoopControlName = event.closedLoopControlName;
- this.requestID = event.requestID;
- this.closedLoopEventClient = event.closedLoopEventClient;
- this.target_type = event.target_type;
- this.target = event.target;
+ if (event == null) {
+ return;
+ }
+
+ this.setClosedLoopControlName(event.getClosedLoopControlName());
+ this.setRequestID(event.getRequestID());
+ this.setClosedLoopEventClient(event.getClosedLoopEventClient());
+ this.setTargetType(event.getTargetType());
+ this.setTarget(event.getTarget());
+ }
+
+ public String getClosedLoopControlName() {
+ return closedLoopControlName;
+ }
+
+ public void setClosedLoopControlName(String closedLoopControlName) {
+ this.closedLoopControlName = closedLoopControlName;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public UUID getRequestID() {
+ return requestID;
+ }
+
+ public void setRequestID(UUID requestID) {
+ this.requestID = requestID;
+ }
+
+ public String getClosedLoopEventClient() {
+ return closedLoopEventClient;
+ }
+
+ public void setClosedLoopEventClient(String closedLoopEventClient) {
+ this.closedLoopEventClient = closedLoopEventClient;
+ }
+
+ public ControlLoopTargetType getTargetType() {
+ return targetType;
+ }
+
+ public void setTargetType(ControlLoopTargetType targetType) {
+ this.targetType = targetType;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public String getFrom() {
+ return from;
+ }
+
+ public void setFrom(String from) {
+ this.from = from;
+ }
+
+ public String getPolicyScope() {
+ return policyScope;
+ }
+
+ public void setPolicyScope(String policyScope) {
+ this.policyScope = policyScope;
+ }
+
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
+ public String getPolicyVersion() {
+ return policyVersion;
+ }
+
+ public void setPolicyVersion(String policyVersion) {
+ this.policyVersion = policyVersion;
+ }
+
+ public ControlLoopNotificationType getNotification() {
+ return notification;
+ }
+
+ public void setNotification(ControlLoopNotificationType notification) {
+ this.notification = notification;
}
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public ZonedDateTime getNotificationTime() {
+ return notificationTime;
+ }
+
+ public void setNotificationTime(ZonedDateTime notificationTime) {
+ this.notificationTime = notificationTime;
+ }
+
+ public Integer getOpsCLTimer() {
+ return opsCLTimer;
+ }
+
+ public void setOpsCLTimer(Integer opsCLTimer) {
+ this.opsCLTimer = opsCLTimer;
+ }
+
+ public List<ControlLoopOperation> getHistory() {
+ return history;
+ }
+
+ public void setHistory(List<ControlLoopOperation> history) {
+ this.history = history;
+ }
}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java
index ce721b43d..d024b7cec 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java
@@ -30,20 +30,24 @@ public class ControlLoopOperation implements Serializable {
*/
private static final long serialVersionUID = 8662706581293017099L;
- public String actor;
- public String operation;
- public String target;
- public Instant start = Instant.now();
- public Instant end;
- public String subRequestId;
- public String outcome;
- public String message;
+ private String actor;
+ private String operation;
+ private String target;
+ private Instant start = Instant.now();
+ private Instant end;
+ private String subRequestId;
+ private String outcome;
+ private String message;
public ControlLoopOperation() {
}
public ControlLoopOperation(ControlLoopOperation op) {
+ if (op == null) {
+ return;
+ }
+
this.actor = op.actor;
this.operation = op.operation;
this.target = op.target;
@@ -62,6 +66,70 @@ public class ControlLoopOperation implements Serializable {
return "actor="+actor+",operation="+operation+",target="+target+",start="+start+",end="+end+",subRequestId="+subRequestId+",outcome="+outcome+",message="+message;
}
+ public String getActor() {
+ return actor;
+ }
+
+ public void setActor(String actor) {
+ this.actor = actor;
+ }
+
+ public String getOperation() {
+ return operation;
+ }
+
+ public void setOperation(String operation) {
+ this.operation = operation;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public Instant getStart() {
+ return start;
+ }
+
+ public void setStart(Instant start) {
+ this.start = start;
+ }
+
+ public Instant getEnd() {
+ return end;
+ }
+
+ public void setEnd(Instant end) {
+ this.end = end;
+ }
+
+ public String getSubRequestId() {
+ return subRequestId;
+ }
+
+ public void setSubRequestId(String subRequestId) {
+ this.subRequestId = subRequestId;
+ }
+
+ public String getOutcome() {
+ return outcome;
+ }
+
+ public void setOutcome(String outcome) {
+ this.outcome = outcome;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
@Override
public String toString() {
return "ControlLoopOperation [actor=" + actor + ", operation=" + operation + ", target=" + target + ", start="
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java
index fb3942b63..f957808d1 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java
@@ -24,8 +24,8 @@ import java.util.UUID;
public class ControlLoopOperationWrapper {
- public UUID requestID;
- public ControlLoopOperation operation;
+ private UUID requestID;
+ private ControlLoopOperation operation;
public ControlLoopOperationWrapper() {
@@ -35,4 +35,20 @@ public class ControlLoopOperationWrapper {
this.requestID = requestID;
this.operation = operation;
}
+
+ public UUID getRequestID() {
+ return requestID;
+ }
+
+ public void setRequestID(UUID requestID) {
+ this.requestID = requestID;
+ }
+
+ public ControlLoopOperation getOperation() {
+ return operation;
+ }
+
+ public void setOperation(ControlLoopOperation operation) {
+ this.operation = operation;
+ }
}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java
index aca072eaa..12ced939e 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java
@@ -21,10 +21,6 @@
package org.onap.policy.controlloop;
public class PhysicalControlLoopEvent extends ControlLoopEvent {
-
- /**
- *
- */
private static final long serialVersionUID = -7282930271094849487L;
public PhysicalControlLoopEvent() {
@@ -36,6 +32,4 @@ public class PhysicalControlLoopEvent extends ControlLoopEvent {
return;
}
}
-
-
}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java
index c904d6740..9c63665ae 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java
@@ -21,10 +21,6 @@
package org.onap.policy.controlloop;
public class PhysicalControlLoopNotification extends ControlLoopNotification {
-
- /**
- *
- */
private static final long serialVersionUID = 8105197217140032892L;
public PhysicalControlLoopNotification() {
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java
index 932da84fc..c512b6796 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java
@@ -30,9 +30,9 @@ public class VirtualControlLoopEvent extends ControlLoopEvent {
*
*/
private static final long serialVersionUID = -5752405682246066226L;
- public Instant closedLoopAlarmStart;
- public Instant closedLoopAlarmEnd;
- public Map<String, String> AAI = new HashMap<>();
+ private Instant closedLoopAlarmStart;
+ private Instant closedLoopAlarmEnd;
+ private Map<String, String> aai = new HashMap<>();
public VirtualControlLoopEvent() {
}
@@ -42,11 +42,34 @@ public class VirtualControlLoopEvent extends ControlLoopEvent {
if (event == null) {
return;
}
- if (event.AAI != null) {
- this.AAI = new HashMap<>(event.AAI);
+ if (event.aai != null) {
+ this.aai = new HashMap<>(event.aai);
}
this.closedLoopAlarmStart = event.closedLoopAlarmStart;
this.closedLoopAlarmEnd = event.closedLoopAlarmEnd;
}
+ public Instant getClosedLoopAlarmStart() {
+ return closedLoopAlarmStart;
+ }
+
+ public void setClosedLoopAlarmStart(Instant closedLoopAlarmStart) {
+ this.closedLoopAlarmStart = closedLoopAlarmStart;
+ }
+
+ public Instant getClosedLoopAlarmEnd() {
+ return closedLoopAlarmEnd;
+ }
+
+ public void setClosedLoopAlarmEnd(Instant closedLoopAlarmEnd) {
+ this.closedLoopAlarmEnd = closedLoopAlarmEnd;
+ }
+
+ public Map<String, String> getAAI() {
+ return aai;
+ }
+
+ public void setAAI(Map<String, String> aai) {
+ this.aai = aai;
+ }
}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java
index 7415fccf0..c99e3a1b0 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java
@@ -31,9 +31,9 @@ public class VirtualControlLoopNotification extends ControlLoopNotification {
*/
private static final long serialVersionUID = 5354756047932144017L;
- public Map<String, String> AAI = new HashMap<>();
- public Instant closedLoopAlarmStart;
- public Instant closedLoopAlarmEnd;
+ private Map<String, String> aai = new HashMap<>();
+ private Instant closedLoopAlarmStart;
+ private Instant closedLoopAlarmEnd;
public VirtualControlLoopNotification() {
}
@@ -43,11 +43,34 @@ public class VirtualControlLoopNotification extends ControlLoopNotification {
if (event == null) {
return;
}
- if (event.AAI != null) {
- this.AAI = new HashMap<>(event.AAI);
+ if (event.getAAI() != null) {
+ this.setAAI(new HashMap<>(event.getAAI()));
}
- this.closedLoopAlarmStart = event.closedLoopAlarmStart;
- this.closedLoopAlarmEnd = event.closedLoopAlarmEnd;
+ this.closedLoopAlarmStart = event.getClosedLoopAlarmStart();
+ this.closedLoopAlarmEnd = event.getClosedLoopAlarmEnd();
}
+ public Map<String, String> getAAI() {
+ return aai;
+ }
+
+ public void setAAI(Map<String, String> aAI) {
+ this.aai = aAI;
+ }
+
+ public Instant getClosedLoopAlarmStart() {
+ return closedLoopAlarmStart;
+ }
+
+ public void setClosedLoopAlarmStart(Instant closedLoopAlarmStart) {
+ this.closedLoopAlarmStart = closedLoopAlarmStart;
+ }
+
+ public Instant getClosedLoopAlarmEnd() {
+ return closedLoopAlarmEnd;
+ }
+
+ public void setClosedLoopAlarmEnd(Instant closedLoopAlarmEnd) {
+ this.closedLoopAlarmEnd = closedLoopAlarmEnd;
+ }
}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
index 858dc82b9..d2a51f770 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
@@ -35,17 +35,15 @@ import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
-import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
-
public final class Serialization {
+ private Serialization() {
+ }
- public static class notificationTypeAdapter implements JsonSerializer<ControlLoopNotificationType>, JsonDeserializer<ControlLoopNotificationType> {
-
-
+ public static class NotificationTypeAdapter implements JsonSerializer<ControlLoopNotificationType>, JsonDeserializer<ControlLoopNotificationType> {
@Override
public JsonElement serialize(ControlLoopNotificationType src, Type typeOfSrc,
JsonSerializationContext context) {
@@ -54,14 +52,12 @@ public final class Serialization {
@Override
public ControlLoopNotificationType deserialize(JsonElement json, Type typeOfT,
- JsonDeserializationContext context) throws JsonParseException {
+ JsonDeserializationContext context) {
return ControlLoopNotificationType.toType(json.getAsString());
}
-
}
-
- public static class targetTypeAdapter implements JsonSerializer<ControlLoopTargetType>, JsonDeserializer<ControlLoopTargetType> {
+ public static class TargetTypeAdapter implements JsonSerializer<ControlLoopTargetType>, JsonDeserializer<ControlLoopTargetType> {
@Override
public JsonElement serialize(ControlLoopTargetType src, Type typeOfSrc,
JsonSerializationContext context) {
@@ -70,19 +66,17 @@ public final class Serialization {
@Override
public ControlLoopTargetType deserialize(JsonElement json, Type typeOfT,
- JsonDeserializationContext context) throws JsonParseException {
+ JsonDeserializationContext context) {
return ControlLoopTargetType.toType(json.getAsString());
}
-
}
-
- public static class gsonUTCAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
- private static final Logger logger = LoggerFactory.getLogger(gsonUTCAdapter.class);
+
+ public static class GSONUTCAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
+ private static final Logger logger = LoggerFactory.getLogger(GSONUTCAdapter.class);
public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
- @Override
- public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context)
- throws JsonParseException {
+ @Override
+ public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context) {
try {
return ZonedDateTime.parse(element.getAsString(), format);
} catch (Exception e) {
@@ -91,17 +85,16 @@ public final class Serialization {
return null;
}
- @Override
+ @Override
public JsonElement serialize(ZonedDateTime datetime, Type type, JsonSerializationContext context) {
return new JsonPrimitive(datetime.format(format));
}
}
-
- public static class gsonInstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
+
+ public static class GSONInstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
@Override
- public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
- throws JsonParseException {
+ public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
return Instant.ofEpochMilli(json.getAsLong());
}
@@ -109,30 +102,30 @@ public final class Serialization {
public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
return new JsonPrimitive(src.toEpochMilli());
}
-
+
}
-
- final static public Gson gson = new GsonBuilder().disableHtmlEscaping()
- .registerTypeAdapter(ZonedDateTime.class, new gsonUTCAdapter())
- .registerTypeAdapter(Instant.class, new gsonInstantAdapter())
- .registerTypeAdapter(ControlLoopNotificationType.class, new notificationTypeAdapter())
- .registerTypeAdapter(ControlLoopTargetType.class, new targetTypeAdapter())
+
+ public static final Gson gson = new GsonBuilder().disableHtmlEscaping()
+ .registerTypeAdapter(ZonedDateTime.class, new GSONUTCAdapter())
+ .registerTypeAdapter(Instant.class, new GSONInstantAdapter())
+ .registerTypeAdapter(ControlLoopNotificationType.class, new NotificationTypeAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter())
.create();
-
- final static public Gson gsonPretty = new GsonBuilder().disableHtmlEscaping()
+
+ public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping()
.setPrettyPrinting()
- .registerTypeAdapter(ZonedDateTime.class, new gsonUTCAdapter())
- .registerTypeAdapter(Instant.class, new gsonInstantAdapter())
- .registerTypeAdapter(ControlLoopNotificationType.class, new notificationTypeAdapter())
- .registerTypeAdapter(ControlLoopTargetType.class, new targetTypeAdapter())
+ .registerTypeAdapter(ZonedDateTime.class, new GSONUTCAdapter())
+ .registerTypeAdapter(Instant.class, new GSONInstantAdapter())
+ .registerTypeAdapter(ControlLoopNotificationType.class, new NotificationTypeAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter())
.create();
-
- final static public Gson gsonJunit = new GsonBuilder().disableHtmlEscaping()
+
+ public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping()
.setPrettyPrinting()
- .registerTypeAdapter(ZonedDateTime.class, new gsonUTCAdapter())
- .registerTypeAdapter(Instant.class, new gsonInstantAdapter())
- .registerTypeAdapter(ControlLoopTargetType.class, new targetTypeAdapter())
+ .registerTypeAdapter(ZonedDateTime.class, new GSONUTCAdapter())
+ .registerTypeAdapter(Instant.class, new GSONInstantAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter())
.create();
}
diff --git a/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java b/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java
index c74a75cbe..2540cb27a 100644
--- a/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java
+++ b/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java
@@ -22,6 +22,7 @@ package org.onap.policy.rest;
import java.io.IOException;
import java.util.Map;
+import java.util.Map.Entry;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
@@ -39,89 +40,100 @@ import org.slf4j.LoggerFactory;
public class RESTManager {
- private static final Logger logger = LoggerFactory.getLogger(RESTManager.class);
-
- public class Pair<A, B> {
- public final A a;
- public final B b;
-
- public Pair(A a, B b) {
- this.a = a;
- this.b = b;
- }
- }
-
- public Pair<Integer, String> post(String url, String username, String password, Map<String, String> headers, String contentType, String body) {
- CredentialsProvider credentials = new BasicCredentialsProvider();
- credentials.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
-
- logger.debug("HTTP REQUEST: {} -> {} {} -> {}", url, username, ((password!=null)?password.length():"-"), contentType);
- if (headers != null) {
- logger.debug("Headers: ");
- headers.forEach((name, value) -> {
- logger.debug("{} -> {}", name, value);
- });
- }
- logger.debug(body);
-
- try (CloseableHttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(credentials).build()) {
-
- HttpPost post = new HttpPost(url);
- if (headers != null) {
- for (String key : headers.keySet()) {
- post.addHeader(key, headers.get(key));
- }
- }
- post.addHeader("Content-Type", contentType);
-
- StringEntity input = new StringEntity(body);
- input.setContentType(contentType);
- post.setEntity(input);
-
- HttpResponse response = client.execute(post);
- if (response != null) {
- String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8");
- logger.debug("HTTP POST Response Status Code: {}", response.getStatusLine().getStatusCode());
- logger.debug("HTTP POST Response Body:");
- logger.debug(returnBody);
-
- return new Pair<Integer, String>(response.getStatusLine().getStatusCode(), returnBody);
- } else {
- logger.error("Response from {} is null", url);
- return null;
- }
- } catch (Exception e) {
- logger.error("Failed to POST to {}",url,e);
- return null;
- }
- }
-
- public Pair<Integer, String> get(String url, String username, String password, Map<String, String> headers) {
-
- CredentialsProvider credentials = new BasicCredentialsProvider();
- credentials.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
-
- try (CloseableHttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(credentials).build()) {
-
- HttpGet get = new HttpGet(url);
- if (headers != null) {
- for (String key : headers.keySet()) {
- get.addHeader(key, headers.get(key));
- }
- }
-
- HttpResponse response = client.execute(get);
-
- String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8");
-
- logger.debug("HTTP GET Response Status Code: {}", response.getStatusLine().getStatusCode());
- logger.debug("HTTP GET Response Body:");
- logger.debug(returnBody);
-
- return new Pair<Integer, String>(response.getStatusLine().getStatusCode(), returnBody);
- } catch (IOException e) {
- logger.error("Failed to GET to {}",url,e);
- return null;
- }
- }
+ private static final Logger logger = LoggerFactory.getLogger(RESTManager.class);
+
+ public class Pair<A, B> {
+ public final A a;
+ public final B b;
+
+ public Pair(A a, B b) {
+ this.a = a;
+ this.b = b;
+ }
+ }
+
+ public Pair<Integer, String> post(String url, String username, String password,
+ Map<String, String> headers, String contentType, String body) {
+ CredentialsProvider credentials = new BasicCredentialsProvider();
+ credentials.setCredentials(AuthScope.ANY,
+ new UsernamePasswordCredentials(username, password));
+
+ logger.debug("HTTP REQUEST: {} -> {} {} -> {}", url, username,
+ ((password != null) ? password.length() : "-"), contentType);
+ if (headers != null) {
+ logger.debug("Headers: ");
+ headers.forEach((name, value) -> logger.debug("{} -> {}", name, value));
+ }
+ logger.debug(body);
+
+ try (CloseableHttpClient client =
+ HttpClientBuilder.create().setDefaultCredentialsProvider(credentials).build()) {
+
+ HttpPost post = new HttpPost(url);
+ if (headers != null) {
+ for (Entry<String, String> entry : headers.entrySet()) {
+ post.addHeader(entry.getKey(), headers.get(entry.getKey()));
+ }
+ }
+ post.addHeader("Content-Type", contentType);
+
+ StringEntity input = new StringEntity(body);
+ input.setContentType(contentType);
+ post.setEntity(input);
+
+ HttpResponse response = client.execute(post);
+ if (response != null) {
+ String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8");
+ logger.debug("HTTP POST Response Status Code: {}",
+ response.getStatusLine().getStatusCode());
+ logger.debug("HTTP POST Response Body:");
+ logger.debug(returnBody);
+
+ return new Pair<>(response.getStatusLine().getStatusCode(),
+ returnBody);
+ }
+ else {
+ logger.error("Response from {} is null", url);
+ return null;
+ }
+ }
+ catch (Exception e) {
+ logger.error("Failed to POST to {}", url, e);
+ return null;
+ }
+ }
+
+ public Pair<Integer, String> get(String url, String username, String password,
+ Map<String, String> headers) {
+
+ CredentialsProvider credentials = new BasicCredentialsProvider();
+ credentials.setCredentials(AuthScope.ANY,
+ new UsernamePasswordCredentials(username, password));
+
+ try (CloseableHttpClient client =
+ HttpClientBuilder.create().setDefaultCredentialsProvider(credentials).build()) {
+
+ HttpGet get = new HttpGet(url);
+ if (headers != null) {
+ for (Entry<String, String> entry : headers.entrySet()) {
+ get.addHeader(entry.getKey(), headers.get(entry.getKey()));
+ }
+ }
+
+ HttpResponse response = client.execute(get);
+
+ String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8");
+
+ logger.debug("HTTP GET Response Status Code: {}",
+ response.getStatusLine().getStatusCode());
+ logger.debug("HTTP GET Response Body:");
+ logger.debug(returnBody);
+
+ return new Pair<>(response.getStatusLine().getStatusCode(), returnBody);
+ }
+ catch (IOException e) {
+ logger.error("Failed to GET to {}", url, e);
+ return null;
+ }
+ }
}
diff --git a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestGet.java b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestGet.java
new file mode 100755
index 000000000..96dec30db
--- /dev/null
+++ b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestGet.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * rest
+ * ================================================================================
+ *
+ * ================================================================================
+ * 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.rest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.onap.policy.rest.RESTManager.Pair;
+
+public class TestGet {
+
+ @Test(expected = NullPointerException.class)
+ public void testUrlNull() {
+ RESTManager mgr = new RESTManager();
+ mgr.get(null, "user", null, null);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testUsernameNull() {
+ RESTManager mgr = new RESTManager();
+ mgr.get("nothing", null, null, null);
+ }
+
+ @Test
+ public void testUrlExampleOrg() {
+ RESTManager mgr = new RESTManager();
+
+ Pair<Integer, String> result = mgr.get("http://www.example.org", "user", null, null);
+ assertEquals((Integer)200, result.a);
+ assertTrue(result.b != null);
+ assertTrue(result.b.length() > 0);
+ }
+} \ No newline at end of file
diff --git a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPair.java b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPair.java
new file mode 100755
index 000000000..3ada0a74e
--- /dev/null
+++ b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPair.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * rest
+ * ================================================================================
+ *
+ * ================================================================================
+ * 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.rest;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.onap.policy.rest.RESTManager.Pair;
+
+public class TestPair {
+
+ @Test
+ public void testPair() {
+ RESTManager mgr = new RESTManager();
+
+ Pair<Integer, Integer> pii = mgr.new Pair<>(1, 2);
+ assertEquals((Integer) 1, (Integer) pii.a);
+ assertEquals((Integer) 2, (Integer) pii.b);
+
+ Pair<Integer, String> pis = mgr.new Pair<>(1, "test");
+ assertEquals((Integer) 1, (Integer) pis.a);
+ assertEquals("test", pis.b);
+ }
+}
diff --git a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPost.java b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPost.java
new file mode 100755
index 000000000..40f1b3089
--- /dev/null
+++ b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPost.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * rest
+ * ================================================================================
+ *
+ * ================================================================================
+ * 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.rest;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.onap.policy.rest.RESTManager.Pair;
+
+public class TestPost {
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testUsernameNull() {
+ RESTManager mgr = new RESTManager();
+ mgr.post("nothing", null, null, null, null, null);
+ }
+
+ @Test
+ public void testBodyNull() {
+ RESTManager mgr = new RESTManager();
+ Pair<Integer, String> result = mgr.post("http://www.example.org", "user", null, null, null, null);
+ assertEquals(null, result);
+ }
+}
diff --git a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGRequest.java b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGRequest.java
index d08d9422e..7bbaf3cbf 100644
--- a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGRequest.java
+++ b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGRequest.java
@@ -22,20 +22,19 @@ package org.onap.policy.vnf.trafficgenerator;
import java.io.Serializable;
-
import com.google.gson.annotations.SerializedName;
public class PGRequest implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = -3283942659786236032L;
-
- @SerializedName("pg-streams")
- public PGStreams pgStreams;
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
- public PGRequest() {
- }
+ @SerializedName("pg-streams")
+ public PGStreams pgStreams;
+ public PGRequest() {
+ //required by author
+ }
}
diff --git a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGStream.java b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGStream.java
index de5a2c37d..a606eee4c 100644
--- a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGStream.java
+++ b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGStream.java
@@ -26,17 +26,17 @@ import com.google.gson.annotations.SerializedName;
public class PGStream implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 5567635677419358210L;
-
- @SerializedName("id")
- public String streamId;
- @SerializedName("is-enabled")
- public String isEnabled;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5567635677419358210L;
- public PGStream() {
- }
+ @SerializedName("id")
+ public String streamId;
+ @SerializedName("is-enabled")
+ public String isEnabled;
+ public PGStream() {
+ //required by author
+ }
}
diff --git a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGStreams.java b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGStreams.java
index dc0d4084f..2264c20a9 100644
--- a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGStreams.java
+++ b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGStreams.java
@@ -28,15 +28,15 @@ import com.google.gson.annotations.SerializedName;
public class PGStreams implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 5567635677419358210L;
-
- @SerializedName("pg-stream")
- public List<PGStream> pgStream= new LinkedList<PGStream>();
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5567635677419358210L;
- public PGStreams() {
- }
+ @SerializedName("pg-stream")
+ public List<PGStream> pgStream = new LinkedList<>();
+ public PGStreams() {
+ // required by author
+ }
}
diff --git a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/util/Serialization.java b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/util/Serialization.java
index 9bfe2ffe6..3443bfcdf 100644
--- a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/util/Serialization.java
+++ b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/util/Serialization.java
@@ -25,11 +25,8 @@ import com.google.gson.GsonBuilder;
public final class Serialization {
- private Serialization(){
- }
+ public static final Gson gsonPretty =
+ new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create();
- final static public Gson gsonPretty = new GsonBuilder().disableHtmlEscaping()
- .setPrettyPrinting()
-// .registerTypeAdapter(AAIQueryParameters.class, new notificationTypeAdapter())
- .create();
+ private Serialization() {}
}
diff --git a/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java b/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java
index 4b3599d43..0ae5f134e 100644
--- a/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java
+++ b/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java
@@ -30,24 +30,25 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TestDemo {
- private static final Logger logger = LoggerFactory.getLogger(TestDemo.class);
- @Test
- public void test() {
- PGRequest request = new PGRequest();
- request.pgStreams = new PGStreams();
-
- PGStream pgStream;
- for(int i = 0; i < 5; i++){
- pgStream = new PGStream();
- pgStream.streamId = "fw_udp"+(i+1);
- pgStream.isEnabled = "true";
- request.pgStreams.pgStream.add(pgStream);
- }
-
- String body = Serialization.gsonPretty.toJson(request);
- logger.debug(body);
-
- // fail("Not yet implemented");
- }
+ private static final Logger logger = LoggerFactory.getLogger(TestDemo.class);
+
+ @Test
+ public void test() {
+ PGRequest request = new PGRequest();
+ request.pgStreams = new PGStreams();
+
+ PGStream pgStream;
+ for (int i = 0; i < 5; i++) {
+ pgStream = new PGStream();
+ pgStream.streamId = "fw_udp" + (i + 1);
+ pgStream.isEnabled = "true";
+ request.pgStreams.pgStream.add(pgStream);
+ }
+
+ String body = Serialization.gsonPretty.toJson(request);
+ logger.debug(body);
+
+ // fail("Not yet implemented");
+ }
}