aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl/appclcm/src/main/java
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@ericsson.com>2018-01-17 12:03:50 +0000
committerJorge Hernandez <jh1730@att.com>2018-01-18 19:46:46 +0000
commitbb462937523947c6f0ca622bc0ea3eb505442ad2 (patch)
treefceb4a45cb312f491f812bfd122e57a1b348b443 /controlloop/common/model-impl/appclcm/src/main/java
parentcebad66213ff84469971b253320f72fa3a41b3cd (diff)
Fix Technical Debt, Unit Test for APPCLCM POJOs
Mainly making fields private, fixing field and methods to follow Java guidelines, and adding getter and setter methods. Unit test added for all classes in org.onap.policy.appclcm Issue-ID: POLICY-455 Change-Id: Iae873f94a236cc9faeac5542a9633ca840b696ed Signed-off-by: Liam Fallon <liam.fallon@ericsson.com>
Diffstat (limited to 'controlloop/common/model-impl/appclcm/src/main/java')
-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
5 files changed, 149 insertions, 154 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();
}