summaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl/appclcm
diff options
context:
space:
mode:
authormmis <michael.morris@ericsson.com>2018-03-27 13:13:57 +0100
committermmis <michael.morris@ericsson.com>2018-03-27 16:00:35 +0100
commit03bded5317a0c50e2a7a3c95f553f612f877ddef (patch)
treeebb1f01121f8842e087a49abf10810705b78dd46 /controlloop/common/model-impl/appclcm
parent0c2b7a2fc65ec7c8252764acafdcc3852db7b411 (diff)
Removed checkstyle warnings
Removed checkstyle warnings from: policy/drools-applications/controlloop/common/model-impl/appc policy/drools-applications/controlloop/common/model-impl/appclcm policy/drools-applications/controlloop/common/model-impl/events including changes to template files due to renamed methods Issue-ID: POLICY-705 Change-Id: Ieb93baf43268aa608f204eef1a610354f2adec32 Signed-off-by: mmis <michael.morris@ericsson.com>
Diffstat (limited to 'controlloop/common/model-impl/appclcm')
-rw-r--r--controlloop/common/model-impl/appclcm/pom.xml41
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseStatus.java107
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmCommonHeader.java (renamed from controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMCommonHeader.java)59
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequest.java (renamed from controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMRequest.java)42
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequestWrapper.java (renamed from controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMRequestWrapper.java)27
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponse.java (renamed from controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponse.java)45
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseCode.java (renamed from controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseCode.java)37
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseStatus.java116
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseWrapper.java (renamed from controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseWrapper.java)29
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmWrapper.java (renamed from controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMWrapper.java)51
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java121
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java136
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LCMResponseTest.java109
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseTest.java113
-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/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/appclcm/TestLcmCommonHeader.java143
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequest.java111
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequestWrapper.java66
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResonseCode.java55
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseStatus.java (renamed from controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseStatus.java)46
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseWrapper.java65
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmWrapper.java115
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/TestSerialization.java51
28 files changed, 1178 insertions, 1061 deletions
diff --git a/controlloop/common/model-impl/appclcm/pom.xml b/controlloop/common/model-impl/appclcm/pom.xml
index 26368ee9a..e84f5f2d7 100644
--- a/controlloop/common/model-impl/appclcm/pom.xml
+++ b/controlloop/common/model-impl/appclcm/pom.xml
@@ -43,4 +43,45 @@
<scope>provided</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>onap-java-style</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <!-- Use Google Java Style Guide:
+ https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
+ with minor changes -->
+ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+ <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
+ <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+ <includeResources>true</includeResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <includeTestResources>true</includeTestResources>
+ <excludes>
+ </excludes>
+ <consoleOutput>true</consoleOutput>
+ <failOnViolation>true</failOnViolation>
+ <violationSeverity>warning</violationSeverity>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>0.1.1</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
</project>
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
deleted file mode 100644
index 1db4e8ef7..000000000
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseStatus.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * appclcm
- * ================================================================================
- * 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 com.google.gson.annotations.SerializedName;
-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() {
- // Create a default LCMResponseStatus instance
- }
-
- /**
- * @return the code
- */
- public int getCode() {
- return code;
- }
-
- /**
- * @param code the code to set
- */
- public void setCode(int code) {
- this.code = code;
- }
-
- /**
- * @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/LCMCommonHeader.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmCommonHeader.java
index a9392b468..dbf8dd0cd 100644
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMCommonHeader.java
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmCommonHeader.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appclcm
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,57 +20,58 @@
package org.onap.policy.appclcm;
+import com.google.gson.annotations.SerializedName;
+
import java.io.Serializable;
import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-import com.google.gson.annotations.SerializedName;
-
-public class LCMCommonHeader implements Serializable {
+public class LcmCommonHeader implements Serializable {
private static final long serialVersionUID = 6581963539127062114L;
- @SerializedName(value="timestamp")
+ @SerializedName(value = "timestamp")
private Instant timeStamp = Instant.now();
- @SerializedName(value="api-ver")
- private String apiVer="2.00";
+ @SerializedName(value = "api-ver")
+ private String apiVer = "2.00";
- @SerializedName(value="originator-id")
+ @SerializedName(value = "originator-id")
private String originatorId;
- @SerializedName(value="request-id")
+ @SerializedName(value = "request-id")
private UUID requestId;
- @SerializedName(value="sub-request-id")
+ @SerializedName(value = "sub-request-id")
private String subRequestId;
- @SerializedName(value="flags")
+ @SerializedName(value = "flags")
private Map<String, String> flags = new HashMap<>();
- public LCMCommonHeader() {
+ public LcmCommonHeader() {
}
/**
* Used to copy a common header.
*
- * @param commonHeader
- * a header that is defined by the lcm api guide that contains
- * information about the request (requestId, flags, etc.)
+ * @param commonHeader a header that is defined by the lcm api guide that contains information
+ * about the request (requestId, flags, etc.)
*/
- public LCMCommonHeader(LCMCommonHeader commonHeader) {
+ public LcmCommonHeader(LcmCommonHeader commonHeader) {
this.originatorId = commonHeader.originatorId;
this.requestId = commonHeader.requestId;
this.subRequestId = commonHeader.subRequestId;
if (commonHeader.flags != null) {
this.flags.putAll(commonHeader.flags);
}
- }
+ }
/**
+ * Get the timestamp.
+ *
* @return the timeStamp
*/
public Instant getTimeStamp() {
@@ -78,6 +79,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Set the timestamp.
+ *
* @param timeStamp the timeStamp to set
*/
public void setTimeStamp(Instant timeStamp) {
@@ -85,6 +88,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Get the API version.
+ *
* @return the apiVer
*/
public String getApiVer() {
@@ -92,6 +97,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Set the API version.
+ *
* @param apiVer the apiVer to set
*/
public void setApiVer(String apiVer) {
@@ -99,6 +106,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Get the originator Id.
+ *
* @return the originatorId
*/
public String getOriginatorId() {
@@ -106,6 +115,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Set the originator Id.
+ *
* @param originatorId the originatorId to set
*/
public void setOriginatorId(String originatorId) {
@@ -113,6 +124,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Get the request Id.
+ *
* @return the requestId
*/
public UUID getRequestId() {
@@ -120,6 +133,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Set the request Id.
+ *
* @param requestId the requestId to set
*/
public void setRequestId(UUID requestId) {
@@ -127,6 +142,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Get the sub request Id.
+ *
* @return the subRequestId
*/
public String getSubRequestId() {
@@ -134,6 +151,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Set the sub request Id.
+ *
* @param subRequestId the subRequestId to set
*/
public void setSubRequestId(String subRequestId) {
@@ -141,6 +160,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Get the flags.
+ *
* @return the flags
*/
public Map<String, String> getFlags() {
@@ -148,6 +169,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Set the flags.
+ *
* @param flags the flags to set
*/
public void setFlags(Map<String, String> flags) {
@@ -184,7 +207,7 @@ public class LCMCommonHeader implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- LCMCommonHeader other = (LCMCommonHeader) obj;
+ LcmCommonHeader other = (LcmCommonHeader) obj;
if (apiVer == null) {
if (other.apiVer != null) {
return false;
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 83442d9bf..afac0dece 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appclcm
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,36 +20,38 @@
package org.onap.policy.appclcm;
+import com.google.gson.annotations.SerializedName;
+
import java.io.Serializable;
import java.util.Map;
-import com.google.gson.annotations.SerializedName;
-
-public class LCMRequest implements Serializable {
+public class LcmRequest implements Serializable {
private static final long serialVersionUID = 219375564922846624L;
- @SerializedName(value="common-header")
- private LCMCommonHeader commonHeader;
+ @SerializedName(value = "common-header")
+ private LcmCommonHeader commonHeader;
- @SerializedName(value="action")
+ @SerializedName(value = "action")
private String action;
- @SerializedName(value="action-identifiers")
+ @SerializedName(value = "action-identifiers")
private Map<String, String> actionIdentifiers;
- @SerializedName(value="payload")
+ @SerializedName(value = "payload")
private String payload;
- public LCMRequest() {
- // Create a default LCM request
+ public LcmRequest() {
+ // Create a default LCM request
}
- public LCMCommonHeader getCommonHeader() {
+ public LcmCommonHeader getCommonHeader() {
return commonHeader;
}
/**
+ * Get the action.
+ *
* @return the action
*/
public String getAction() {
@@ -57,6 +59,8 @@ public class LCMRequest implements Serializable {
}
/**
+ * Set the action.
+ *
* @param action the action to set
*/
public void setAction(String action) {
@@ -64,6 +68,8 @@ public class LCMRequest implements Serializable {
}
/**
+ * Get the action identifiers.
+ *
* @return the actionIdentifiers
*/
public Map<String, String> getActionIdentifiers() {
@@ -71,6 +77,8 @@ public class LCMRequest implements Serializable {
}
/**
+ * Set the action identifiers.
+ *
* @param actionIdentifiers the actionIdentifiers to set
*/
public void setActionIdentifiers(Map<String, String> actionIdentifiers) {
@@ -78,6 +86,8 @@ public class LCMRequest implements Serializable {
}
/**
+ * Get the payload.
+ *
* @return the payload
*/
public String getPayload() {
@@ -85,6 +95,8 @@ public class LCMRequest implements Serializable {
}
/**
+ * Set the payload.
+ *
* @param payload the payload to set
*/
public void setPayload(String payload) {
@@ -92,9 +104,11 @@ public class LCMRequest implements Serializable {
}
/**
+ * Get the common header.
+ *
* @param commonHeader the commonHeader to set
*/
- public void setCommonHeader(LCMCommonHeader commonHeader) {
+ public void setCommonHeader(LcmCommonHeader commonHeader) {
this.commonHeader = commonHeader;
}
@@ -126,7 +140,7 @@ public class LCMRequest implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- LCMRequest other = (LCMRequest) obj;
+ LcmRequest other = (LcmRequest) obj;
if (commonHeader == null) {
if (other.commonHeader != null) {
return false;
diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMRequestWrapper.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequestWrapper.java
index ea7e6762f..b77303ad0 100644
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMRequestWrapper.java
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequestWrapper.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appclcm
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,34 +21,39 @@
package org.onap.policy.appclcm;
import com.google.gson.annotations.SerializedName;
+
import java.io.Serializable;
-public class LCMRequestWrapper extends LCMWrapper implements Serializable {
+public class LcmRequestWrapper extends LcmWrapper implements Serializable {
private static final long serialVersionUID = 424866914715980798L;
-
- @SerializedName(value="body")
- private LCMRequest body;
- public LCMRequestWrapper() {
+ @SerializedName(value = "body")
+ private LcmRequest body;
+
+ public LcmRequestWrapper() {
super();
}
- public LCMRequestWrapper(LCMRequest request) {
+ public LcmRequestWrapper(LcmRequest request) {
body = request;
}
-
+
/**
+ * Get the body.
+ *
* @return the body
*/
- public LCMRequest getBody() {
+ public LcmRequest getBody() {
return body;
}
/**
+ * Set the body.
+ *
* @param body the body to set
*/
- public void setBody(LCMRequest body) {
+ public void setBody(LcmRequest body) {
this.body = body;
}
@@ -76,7 +81,7 @@ public class LCMRequestWrapper extends LCMWrapper implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- LCMRequestWrapper other = (LCMRequestWrapper) obj;
+ LcmRequestWrapper other = (LcmRequestWrapper) obj;
if (body == null) {
if (other.body != null) {
return false;
diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponse.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponse.java
index 82f374868..2a65c9a14 100644
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponse.java
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponse.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appclcm
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,34 +21,33 @@
package org.onap.policy.appclcm;
import com.google.gson.annotations.SerializedName;
+
import java.io.Serializable;
-public class LCMResponse implements Serializable {
+public class LcmResponse implements Serializable {
private static final long serialVersionUID = 6332508597287669750L;
@SerializedName(value = "common-header")
- private LCMCommonHeader commonHeader;
+ private LcmCommonHeader commonHeader;
@SerializedName(value = "status")
- private LCMResponseStatus status = new LCMResponseStatus();
+ private LcmResponseStatus status = new LcmResponseStatus();
@SerializedName(value = "payload")
private String payload;
- public LCMResponse() {
- // EMPTY
+ public LcmResponse() {
+ // EMPTY
}
/**
- * Constructs a response using the common header of the request since they
- * will be the same.
+ * Constructs a response using the common header of the request since they will be the same.
*
- * @param request
- * an appc lcm request object specified by the lcm api guide
+ * @param request an appc lcm request object specified by the lcm api guide
*/
- public LCMResponse(LCMRequest request) {
- this.commonHeader = new LCMCommonHeader(request.getCommonHeader());
+ public LcmResponse(LcmRequest request) {
+ this.commonHeader = new LcmCommonHeader(request.getCommonHeader());
String requestPayload = request.getPayload();
if (requestPayload != null) {
this.payload = requestPayload;
@@ -56,34 +55,44 @@ public class LCMResponse implements Serializable {
}
/**
+ * Get the common header.
+ *
* @return the commonHeader
*/
- public LCMCommonHeader getCommonHeader() {
+ public LcmCommonHeader getCommonHeader() {
return commonHeader;
}
/**
+ * Set the common header.
+ *
* @param commonHeader the commonHeader to set
*/
- public void setCommonHeader(LCMCommonHeader commonHeader) {
+ public void setCommonHeader(LcmCommonHeader commonHeader) {
this.commonHeader = commonHeader;
}
/**
+ * Get the status.
+ *
* @return the status
*/
- public LCMResponseStatus getStatus() {
+ public LcmResponseStatus getStatus() {
return status;
}
/**
+ * Set the status.
+ *
* @param status the status to set
*/
- public void setStatus(LCMResponseStatus status) {
+ public void setStatus(LcmResponseStatus status) {
this.status = status;
}
/**
+ * Get the payload.
+ *
* @return the payload
*/
public String getPayload() {
@@ -91,6 +100,8 @@ public class LCMResponse implements Serializable {
}
/**
+ * Set the payload.
+ *
* @param payload the payload to set
*/
public void setPayload(String payload) {
@@ -123,7 +134,7 @@ public class LCMResponse implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- LCMResponse other = (LCMResponse) obj;
+ LcmResponse other = (LcmResponse) obj;
if (commonHeader == null) {
if (other.commonHeader != null) {
return false;
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 8a7c36d2b..cca69b132 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appclcm
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +20,8 @@
package org.onap.policy.appclcm;
-public class LCMResponseCode {
-
+public class LcmResponseCode {
+
/* These fields define the key to the response code value. */
public static final String ACCEPTED = "ACCEPTED";
public static final String ERROR = "ERROR";
@@ -30,13 +30,13 @@ public class LCMResponseCode {
public static final String FAILURE = "FAILURE";
public static final String PARTIAL_SUCCESS = "PARTIAL SUCCESS";
public static final String PARTIAL_FAILURE = "PARTIAL FAILURE";
-
+
private Integer code;
- protected LCMResponseCode(final int code) {
- this.code = code;
+ protected LcmResponseCode(final int code) {
+ this.code = code;
}
-
+
public int getCode() {
return this.code;
}
@@ -49,31 +49,24 @@ public class LCMResponseCode {
/**
* Translates the code to a string value that represents the meaning of the code.
*
- * @param code
- * the numeric value that is returned by APPC based on success,
- * failure, etc. of the action requested
+ * @param code the numeric value that is returned by APPC based on success, failure, etc. of the
+ * action requested
* @return the string value equivalent of the APPC response code
*/
public static String toResponseValue(int code) {
if (code == 100) {
return ACCEPTED;
- }
- else if (code == 200) {
+ } else if (code == 200) {
return ERROR;
- }
- else if (code >= 300 && code <= 313) {
+ } else if (code >= 300 && code <= 313) {
return REJECT;
- }
- else if (code == 400) {
+ } else if (code == 400) {
return SUCCESS;
- }
- else if (code == 450 || (code >= 401 && code <= 406)) {
+ } else if (code == 450 || (code >= 401 && code <= 406)) {
return FAILURE;
- }
- else if (code == 500) {
+ } else if (code == 500) {
return PARTIAL_SUCCESS;
- }
- else if (code >= 501 && code <= 599) {
+ } else if (code >= 501 && code <= 599) {
return PARTIAL_FAILURE;
}
return null;
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
new file mode 100644
index 000000000..4c044a0a8
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseStatus.java
@@ -0,0 +1,116 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appclcm
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.appclcm;
+
+import com.google.gson.annotations.SerializedName;
+
+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() {
+ // Create a default LCMResponseStatus instance
+ }
+
+ /**
+ * Get the code.
+ *
+ * @return the code
+ */
+ public int getCode() {
+ return code;
+ }
+
+ /**
+ * Set the code.
+ *
+ * @param code the code to set
+ */
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ /**
+ * Get the message.
+ *
+ * @return the message
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Set the 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/LCMResponseWrapper.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseWrapper.java
index 7d9062979..43cc32511 100644
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseWrapper.java
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseWrapper.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appclcm
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,30 +21,35 @@
package org.onap.policy.appclcm;
import com.google.gson.annotations.SerializedName;
+
import java.io.Serializable;
-public class LCMResponseWrapper extends LCMWrapper implements Serializable {
+public class LcmResponseWrapper extends LcmWrapper implements Serializable {
private static final long serialVersionUID = 463937813781086802L;
-
- @SerializedName(value="body")
- private LCMResponse body;
-
- public LCMResponseWrapper() {
+
+ @SerializedName(value = "body")
+ private LcmResponse body;
+
+ public LcmResponseWrapper() {
super();
}
-
+
/**
+ * Get the body.
+ *
* @return the body
*/
- public LCMResponse getBody() {
+ public LcmResponse getBody() {
return body;
}
/**
+ * Set the body.
+ *
* @param body the body to set
*/
- public void setBody(LCMResponse body) {
+ public void setBody(LcmResponse body) {
this.body = body;
}
@@ -52,7 +57,7 @@ public class LCMResponseWrapper extends LCMWrapper implements Serializable {
public String toString() {
return "ResponseWrapper [body=" + body + ", toString()=" + super.toString() + "]";
}
-
+
@Override
public int hashCode() {
final int prime = 31;
@@ -72,7 +77,7 @@ public class LCMResponseWrapper extends LCMWrapper implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- LCMResponseWrapper other = (LCMResponseWrapper) obj;
+ LcmResponseWrapper other = (LcmResponseWrapper) obj;
if (body == null) {
if (other.body != null) {
return false;
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 c70e7423a..322abb015 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appclcm
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,32 +21,35 @@
package org.onap.policy.appclcm;
import com.google.gson.annotations.SerializedName;
+
import java.io.Serializable;
-public class LCMWrapper implements Serializable {
+public class LcmWrapper implements Serializable {
private static final long serialVersionUID = 753005805432396532L;
- @SerializedName(value="version")
+ @SerializedName(value = "version")
private String version;
-
- @SerializedName(value="cambria-partition")
+
+ @SerializedName(value = "cambria-partition")
private String cambriaPartition;
-
- @SerializedName(value="rpc-name")
+
+ @SerializedName(value = "rpc-name")
private String rpcName;
-
- @SerializedName(value="correlation-id")
+
+ @SerializedName(value = "correlation-id")
private String correlationId;
-
- @SerializedName(value="type")
+
+ @SerializedName(value = "type")
private String type;
- public LCMWrapper() {
- // Create a default LCMWrapper instance
+ public LcmWrapper() {
+ // Create a default LCMWrapper instance
}
-
+
/**
+ * Get the version.
+ *
* @return the version
*/
public String getVersion() {
@@ -54,6 +57,8 @@ public class LCMWrapper implements Serializable {
}
/**
+ * Set the version.
+ *
* @param version the version to set
*/
public void setVersion(String version) {
@@ -61,6 +66,8 @@ public class LCMWrapper implements Serializable {
}
/**
+ * Get the cambria partition.
+ *
* @return the cambriaPartition
*/
public String getCambriaPartition() {
@@ -68,6 +75,8 @@ public class LCMWrapper implements Serializable {
}
/**
+ * Set the cambria partition.
+ *
* @param cambriaPartition the cambriaPartition to set
*/
public void setCambriaPartition(String cambriaPartition) {
@@ -75,6 +84,8 @@ public class LCMWrapper implements Serializable {
}
/**
+ * Get the RPN name.
+ *
* @return the rpcName
*/
public String getRpcName() {
@@ -82,6 +93,8 @@ public class LCMWrapper implements Serializable {
}
/**
+ * Set the RPC name.
+ *
* @param rpcName the rpcName to set
*/
public void setRpcName(String rpcName) {
@@ -89,6 +102,8 @@ public class LCMWrapper implements Serializable {
}
/**
+ * Get the correlation Id.
+ *
* @return the correlationId
*/
public String getCorrelationId() {
@@ -96,6 +111,8 @@ public class LCMWrapper implements Serializable {
}
/**
+ * Set the correclation Id.
+ *
* @param correlationId the correlationId to set
*/
public void setCorrelationId(String correlationId) {
@@ -103,6 +120,8 @@ public class LCMWrapper implements Serializable {
}
/**
+ * Get the type.
+ *
* @return the type
*/
public String getType() {
@@ -110,6 +129,8 @@ public class LCMWrapper implements Serializable {
}
/**
+ * Set the type.
+ *
* @param type the type to set
*/
public void setType(String type) {
@@ -145,7 +166,7 @@ public class LCMWrapper implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- LCMWrapper other = (LCMWrapper) obj;
+ LcmWrapper other = (LcmWrapper) obj;
if (cambriaPartition == null) {
if (other.cambriaPartition != null) {
return false;
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 5a5e2e2e6..944d56846 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
@@ -20,12 +20,6 @@
package org.onap.policy.appclcm.util;
-import java.lang.reflect.Type;
-import java.time.Instant;
-
-import org.onap.policy.appclcm.LCMRequest;
-import org.onap.policy.appclcm.LCMResponse;
-
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
@@ -36,79 +30,84 @@ import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
+import java.lang.reflect.Type;
+import java.time.Instant;
+
+import org.onap.policy.appclcm.LcmRequest;
+import org.onap.policy.appclcm.LcmResponse;
+
public final class Serialization {
- private Serialization() {
- }
+ private Serialization() {}
- public static class RequestAdapter implements JsonSerializer<LCMRequest>, JsonDeserializer<LCMRequest> {
+ 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);
+ @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;
- }
+ return input;
+ }
- @Override
- public LCMRequest deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
- return gsonPretty.fromJson(json.getAsJsonObject().get("input"), LCMRequest.class);
- }
- }
+ @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> {
+ 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 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);
- }
- }
+ @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> {
+ 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 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());
- }
+ @Override
+ public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
+ return new JsonPrimitive(src.toString());
+ }
- }
+ }
- public static class InstantJunitAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
+ 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 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());
- }
+ @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 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 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 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 2d58bfd99..cee87077a 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appclcm
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,9 @@
package org.onap.policy.appclcm;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.util.HashMap;
import java.util.UUID;
@@ -33,49 +35,49 @@ import org.slf4j.LoggerFactory;
public class AppcLcmTest {
private static final Logger logger = LoggerFactory.getLogger(AppcLcmTest.class);
-
- private static LCMRequestWrapper dmaapRequest;
- private static LCMResponseWrapper dmaapResponse;
+
+ private static LcmRequestWrapper dmaapRequest;
+ private static LcmResponseWrapper dmaapResponse;
static {
/*
* Construct an APPCLCM Request to be Serialized
*/
- dmaapRequest = new LCMRequestWrapper();
+ dmaapRequest = new LcmRequestWrapper();
dmaapRequest.setCorrelationId("664be3d2-6c12-4f4b-a3e7-c349acced200" + "-" + "1");
dmaapRequest.setRpcName("restart");
dmaapRequest.setType("request");
- dmaapResponse = new LCMResponseWrapper();
+ dmaapResponse = new LcmResponseWrapper();
dmaapResponse.setCorrelationId("664be3d2-6c12-4f4b-a3e7-c349acced200" + "-" + "1");
dmaapResponse.setRpcName("restart");
dmaapResponse.setType("response");
- LCMRequest appcRequest = new LCMRequest();
-
+ LcmRequest appcRequest = new LcmRequest();
+
appcRequest.setAction("restart");
-
+
HashMap<String, String> actionIdentifiers = new HashMap<>();
actionIdentifiers.put("vnf-id", "trial-vnf-003");
actionIdentifiers.put("vserver-id", "08f6c1f9-99e7-49f3-a662-c62b9f200d79");
-
+
appcRequest.setActionIdentifiers(actionIdentifiers);
-
- LCMCommonHeader commonHeader = new LCMCommonHeader();
+
+ LcmCommonHeader commonHeader = new LcmCommonHeader();
commonHeader.setRequestId(UUID.fromString("664be3d2-6c12-4f4b-a3e7-c349acced200"));
commonHeader.setSubRequestId("1");
commonHeader.setOriginatorId("664be3d2-6c12-4f4b-a3e7-c349acced200");
-
+
appcRequest.setCommonHeader(commonHeader);
-
+
appcRequest.setPayload(null);
dmaapRequest.setBody(appcRequest);
-
+
/*
* Construct an APPCLCM Response to be Serialized
*/
- LCMResponse appcResponse = new LCMResponse(appcRequest);
+ LcmResponse appcResponse = new LcmResponse(appcRequest);
appcResponse.getStatus().setCode(400);
appcResponse.getStatus().setMessage("Restart Successful");
appcResponse.setPayload(null);
@@ -85,69 +87,63 @@ public class AppcLcmTest {
@Test
public void testRequestSerialization() {
-
+
/*
* Use the gson serializer to obtain json
*/
- String jsonRequest = Serialization.gson.toJson(dmaapRequest, LCMRequestWrapper.class);
+ String jsonRequest = Serialization.gson.toJson(dmaapRequest, LcmRequestWrapper.class);
assertNotNull(jsonRequest);
-
+
/*
- * The serializer should have added an extra
- * sub-tag called "input" that wraps the request
+ * The serializer should have added an extra sub-tag called "input" that wraps the request
*/
assertTrue(jsonRequest.contains("input"));
-
+
/*
- * The common-header, request-id, and
- * sub-request-id should exist
+ * The common-header, request-id, and sub-request-id should exist
*/
assertTrue(jsonRequest.contains("common-header"));
assertTrue(jsonRequest.contains("request-id"));
assertTrue(jsonRequest.contains("sub-request-id"));
-
+
/*
- * action-identifiers should exist and contain
- * a vnf-id
+ * action-identifiers should exist and contain a vnf-id
*/
assertTrue(jsonRequest.contains("action-identifiers"));
assertTrue(jsonRequest.contains("vnf-id"));
-
+
/*
* The action sub-tag should exist
*/
assertTrue(jsonRequest.contains("action"));
-
+
logger.debug("Request as JSON: " + jsonRequest + "\n\n");
}
@Test
public void testRequestDeserialization() {
-
+
/*
- * Convert the LCM request object into json
- * so we have a string of json to use for testing
+ * Convert the LCM request object into json so we have a string of json to use for testing
*/
- String jsonRequest = Serialization.gson.toJson(dmaapRequest, LCMRequestWrapper.class);
-
+ String jsonRequest = Serialization.gson.toJson(dmaapRequest, LcmRequestWrapper.class);
+
/*
- * Use the serializer to convert the json string
- * into a java object
+ * Use the serializer to convert the json string into a java object
*/
- LCMRequestWrapper dmaapRequest = Serialization.gson.fromJson(jsonRequest, LCMRequestWrapper.class);
+ LcmRequestWrapper dmaapRequest = Serialization.gson.fromJson(jsonRequest, LcmRequestWrapper.class);
assertNotNull(dmaapRequest);
-
+
/*
* The type of the DMAAP wrapper should be request
*/
assertEquals("request", dmaapRequest.getType());
-
+
/*
- * The DMAAP wrapper must have a body as that is
- * the true APPC request
+ * The DMAAP wrapper must have a body as that is the true APPC request
*/
assertNotNull(dmaapRequest.getBody());
- LCMRequest appcRequest = dmaapRequest.getBody();
+ LcmRequest appcRequest = dmaapRequest.getBody();
assertNotNull(appcRequest);
/*
@@ -156,85 +152,77 @@ public class AppcLcmTest {
assertNotNull(appcRequest.getCommonHeader());
/*
- * The action should not be null and should be
- * set to restart
+ * The action should not be null and should be set to restart
*/
assertNotNull(appcRequest.getAction());
assertEquals("restart", appcRequest.getAction());
/*
- * The action-identifiers should not be null
- * and should contain a vnf-id
+ * The action-identifiers should not be null and should contain a vnf-id
*/
assertNotNull(appcRequest.getActionIdentifiers());
assertNotNull(appcRequest.getActionIdentifiers().get("vnf-id"));
-
+
logger.debug("Request as a Java Object: \n" + appcRequest.toString() + "\n\n");
}
@Test
public void testResponseSerialization() {
-
+
/*
* Use the serializer to convert the object into json
*/
- String jsonResponse = Serialization.gson.toJson(dmaapResponse, LCMResponseWrapper.class);
+ String jsonResponse = Serialization.gson.toJson(dmaapResponse, LcmResponseWrapper.class);
assertNotNull(jsonResponse);
-
+
/*
- * The serializer should have added an extra
- * sub-tag called "input" that wraps the request
+ * The serializer should have added an extra sub-tag called "input" that wraps the request
*/
assertTrue(jsonResponse.contains("output"));
-
+
/*
- * The response should contain a common-header,
- * request-id, sub-request-id, and status
+ * The response should contain a common-header, request-id, sub-request-id, and status
*/
assertTrue(jsonResponse.contains("common-header"));
assertTrue(jsonResponse.contains("request-id"));
assertTrue(jsonResponse.contains("sub-request-id"));
assertTrue(jsonResponse.contains("status"));
-
+
logger.debug("Response as JSON: " + jsonResponse + "\n\n");
}
-
+
@Test
public void testResponseDeserialization() {
/*
- * Convert the LCM response object into json
- * so we have a string of json to use for testing
+ * Convert the LCM response object into json so we have a string of json to use for testing
*/
- String jsonResponse = Serialization.gson.toJson(dmaapResponse, LCMResponseWrapper.class);
-
+ String jsonResponse = Serialization.gson.toJson(dmaapResponse, LcmResponseWrapper.class);
+
/*
- * Use the serializer to convert the json string
- * into a java object
+ * Use the serializer to convert the json string into a java object
*/
- LCMResponseWrapper dmaapResponse = Serialization.gson.fromJson(jsonResponse, LCMResponseWrapper.class);
+ LcmResponseWrapper dmaapResponse = Serialization.gson.fromJson(jsonResponse, LcmResponseWrapper.class);
assertNotNull(dmaapResponse);
-
+
/*
* The type of the DMAAP wrapper should be response
*/
assertEquals("response", dmaapResponse.getType());
-
+
/*
- * The DMAAP wrapper must have a body as that is
- * the true APPC response
+ * The DMAAP wrapper must have a body as that is the true APPC response
*/
assertNotNull(dmaapResponse.getBody());
- LCMResponse appcResponse = dmaapResponse.getBody();
+ LcmResponse appcResponse = dmaapResponse.getBody();
assertNotNull(appcResponse);
-
+
/*
* The common header should not be null
*/
assertNotNull(appcResponse.getCommonHeader());
-
+
/*
- * The status should not be null and the
- * status code should be 400
+ * The status should not be null and the status code should be 400
*/
assertNotNull(appcResponse.getStatus());
assertEquals(400, appcResponse.getStatus().getCode());
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LCMResponseTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LCMResponseTest.java
deleted file mode 100644
index 14dee480b..000000000
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LCMResponseTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * appclcm
- * ================================================================================
- * 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 LCMResponseTest {
-
- private static final String PAYLOAD = "payload";
-
- @Test
- public void testHashCode() {
- LCMResponse response = new LCMResponse();
- assertTrue(response.hashCode() != 0);
- response.setCommonHeader(new LCMCommonHeader());
- assertTrue(response.hashCode() != 0);
- response.setPayload(PAYLOAD);
- assertTrue(response.hashCode() != 0);
- response.setStatus(null);
- assertTrue(response.hashCode() != 0);
- }
-
- @Test
- public void testLCMResponse() {
- LCMResponse response = new LCMResponse();
- assertNull(response.getCommonHeader());
- assertNull(response.getPayload());
- assertNotNull(response.getStatus());
- }
-
- @Test
- public void testToString() {
- LCMResponse response = new LCMResponse();
- assertFalse(response.toString().isEmpty());
- }
-
- @Test
- public void testEqualsObject() {
- LCMResponse response = new LCMResponse();
- assertTrue(response.equals(response));
- assertFalse(response.equals(null));
- assertFalse(response.equals(new Object()));
-
- LCMResponse response2 = new LCMResponse();
- assertTrue(response.equals(response2));
-
- response.setCommonHeader(new LCMCommonHeader());
- assertFalse(response.equals(response2));
- response2.setCommonHeader(response.getCommonHeader());
- assertTrue(response.equals(response2));
-
- response.setPayload(PAYLOAD);
- assertFalse(response.equals(response2));
- response2.setPayload(response.getPayload());
- assertTrue(response.equals(response2));
-
- response.setCommonHeader(null);
- assertFalse(response.equals(response2));
- response2.setCommonHeader(null);
- assertTrue(response.equals(response2));
-
- response.setPayload(null);
- assertFalse(response.equals(response2));
- response2.setPayload(response.getPayload());
- assertTrue(response.equals(response2));
-
- response.setStatus(null);
- assertFalse(response.equals(response2));
- response2.setStatus(response.getStatus());
- assertTrue(response.equals(response2));
-
- LCMResponseStatus status = new LCMResponseStatus();
- status.setCode(5);
- response.setStatus(status);
- response2.setStatus(new LCMResponseStatus());
- assertFalse(response.equals(response2));
- }
-
- @Test
- public void testResponseRequest() {
- LCMRequest request = new LCMRequest();
- request.setCommonHeader(new LCMCommonHeader());
- request.setPayload(PAYLOAD);
-
- LCMResponse response = new LCMResponse(request);
-
- assertTrue(response.getPayload().equals(PAYLOAD));
- }
-
-}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseTest.java
new file mode 100644
index 000000000..7583ee0c4
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseTest.java
@@ -0,0 +1,113 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appclcm
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * 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.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class LcmResponseTest {
+
+ private static final String PAYLOAD = "payload";
+
+ @Test
+ public void testHashCode() {
+ LcmResponse response = new LcmResponse();
+ assertTrue(response.hashCode() != 0);
+ response.setCommonHeader(new LcmCommonHeader());
+ assertTrue(response.hashCode() != 0);
+ response.setPayload(PAYLOAD);
+ assertTrue(response.hashCode() != 0);
+ response.setStatus(null);
+ assertTrue(response.hashCode() != 0);
+ }
+
+ @Test
+ public void testLcmResponse() {
+ LcmResponse response = new LcmResponse();
+ assertNull(response.getCommonHeader());
+ assertNull(response.getPayload());
+ assertNotNull(response.getStatus());
+ }
+
+ @Test
+ public void testToString() {
+ LcmResponse response = new LcmResponse();
+ assertFalse(response.toString().isEmpty());
+ }
+
+ @Test
+ public void testEqualsObject() {
+ LcmResponse response = new LcmResponse();
+ assertTrue(response.equals(response));
+ assertFalse(response.equals(null));
+ assertFalse(response.equals(new Object()));
+
+ LcmResponse response2 = new LcmResponse();
+ assertTrue(response.equals(response2));
+
+ response.setCommonHeader(new LcmCommonHeader());
+ assertFalse(response.equals(response2));
+ response2.setCommonHeader(response.getCommonHeader());
+ assertTrue(response.equals(response2));
+
+ response.setPayload(PAYLOAD);
+ assertFalse(response.equals(response2));
+ response2.setPayload(response.getPayload());
+ assertTrue(response.equals(response2));
+
+ response.setCommonHeader(null);
+ assertFalse(response.equals(response2));
+ response2.setCommonHeader(null);
+ assertTrue(response.equals(response2));
+
+ response.setPayload(null);
+ assertFalse(response.equals(response2));
+ response2.setPayload(response.getPayload());
+ assertTrue(response.equals(response2));
+
+ response.setStatus(null);
+ assertFalse(response.equals(response2));
+ response2.setStatus(response.getStatus());
+ assertTrue(response.equals(response2));
+
+ LcmResponseStatus status = new LcmResponseStatus();
+ status.setCode(5);
+ response.setStatus(status);
+ response2.setStatus(new LcmResponseStatus());
+ assertFalse(response.equals(response2));
+ }
+
+ @Test
+ public void testResponseRequest() {
+ LcmRequest request = new LcmRequest();
+ request.setCommonHeader(new LcmCommonHeader());
+ request.setPayload(PAYLOAD);
+
+ LcmResponse response = new LcmResponse(request);
+
+ assertTrue(response.getPayload().equals(PAYLOAD));
+ }
+
+}
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
deleted file mode 100644
index 6921068e5..000000000
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMCommonHeader.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index 223e50147..000000000
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index 0a5205509..000000000
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequestWrapper.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index 59606f8b4..000000000
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResonseCode.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * ============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/TestLCMResponseWrapper.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseWrapper.java
deleted file mode 100644
index d27fbaff3..000000000
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseWrapper.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index 20baf154d..000000000
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMWrapper.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*-
- * ============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/appclcm/TestLcmCommonHeader.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmCommonHeader.java
new file mode 100644
index 000000000..49cc7f7de
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmCommonHeader.java
@@ -0,0 +1,143 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * 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.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+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 testLcmCommonHeader() {
+ 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..ce8b0415e
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequest.java
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * 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.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+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..0f1b85a33
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequestWrapper.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * 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.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+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..cf42845cc
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResonseCode.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * 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.assertEquals;
+import static org.junit.Assert.assertNull;
+
+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
index 0b6cbcf22..b5d4cf3a5 100644
--- 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,27 +20,31 @@
package org.onap.policy.appclcm;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
-public class TestLCMResponseStatus {
+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();
+ @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());
@@ -48,7 +52,7 @@ public class TestLCMResponseStatus {
assertTrue(status.equals(copiedStatus));
assertFalse(status.equals(null));
assertFalse(status.equals("Hello"));
-
+
status.setCode(-1);
assertFalse(status.equals(copiedStatus));
copiedStatus.setCode(-1);
@@ -57,7 +61,7 @@ public class TestLCMResponseStatus {
assertFalse(status.equals(copiedStatus));
copiedStatus.setCode(1234);
assertTrue(status.equals(copiedStatus));
-
+
status.setMessage(null);
assertFalse(status.equals(copiedStatus));
copiedStatus.setMessage(null);
@@ -66,5 +70,5 @@ public class TestLCMResponseStatus {
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..bf448534f
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseWrapper.java
@@ -0,0 +1,65 @@
+/*-
+ * ============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.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+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..d14cb4b24
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmWrapper.java
@@ -0,0 +1,115 @@
+/*-
+ * ============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.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+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/appclcm/util/TestSerialization.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/TestSerialization.java
index 030c8a5fe..4e403ecb4 100644
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/TestSerialization.java
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/TestSerialization.java
@@ -20,39 +20,38 @@
package org.onap.policy.appclcm.util;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
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));
- }
+ @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));
+ }
}