Use lombok annotations for sdnr, simulators 22/122022/1
authorJim Hahn <jrh3@att.com>
Thu, 17 Jun 2021 19:39:34 +0000 (15:39 -0400)
committerJim Hahn <jrh3@att.com>
Thu, 17 Jun 2021 19:58:25 +0000 (15:58 -0400)
Issue-ID: POLICY-3396
Change-Id: I16787f72b0529417c58b9e83a21880baaba92a3d
Signed-off-by: Jim Hahn <jrh3@att.com>
15 files changed:
models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciCommonHeader.java
models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciRequest.java
models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciRequestWrapper.java
models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponse.java
models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponseCode.java
models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponseWrapper.java
models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciWrapper.java
models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/Status.java
models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/util/Serialization.java
models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java
models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java
models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java
models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java
models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java
models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java

index d8555e4..ec17da2 100644 (file)
@@ -4,7 +4,7 @@
  * ================================================================================
  * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2021 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.
@@ -30,11 +30,15 @@ import java.util.Map;
 import java.util.UUID;
 import lombok.EqualsAndHashCode;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 import lombok.Setter;
+import lombok.ToString;
 
 @Getter
 @Setter
 @EqualsAndHashCode
+@NoArgsConstructor
+@ToString
 public class PciCommonHeader implements Serializable {
 
     private static final long serialVersionUID = 5435363539127062114L;
@@ -57,10 +61,6 @@ public class PciCommonHeader implements Serializable {
     @SerializedName(value = "Flags")
     private Map<String, String> flags = new HashMap<>();
 
-    public PciCommonHeader() {
-
-    }
-
     /**
      * Used to copy a pci common header.
      *
@@ -79,11 +79,4 @@ public class PciCommonHeader implements Serializable {
             this.flags.putAll(commonHeader.flags);
         }
     }
-
-    @Override
-    public String toString() {
-        return "CommonHeader [timeStamp=" + timeStamp + ", apiVer=" + apiVer
-                   + ", requestId=" + requestId + ", subRequestId=" + subRequestId + ", requestTrack=" + requestTrack
-                   + ", flags=" + flags + "]";
-    }
 }
index 71e4c56..04830b0 100644 (file)
@@ -4,7 +4,7 @@
  * ================================================================================
  * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2021 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.
@@ -27,10 +27,12 @@ import java.io.Serializable;
 import lombok.EqualsAndHashCode;
 import lombok.Getter;
 import lombok.Setter;
+import lombok.ToString;
 
 @Getter
 @Setter
 @EqualsAndHashCode
+@ToString
 public class PciRequest implements Serializable {
 
     private static final long serialVersionUID = 323235565922846624L;
@@ -43,61 +45,4 @@ public class PciRequest implements Serializable {
 
     @SerializedName(value = "Payload")
     private String payload;
-
-    public PciRequest() {
-        // Create a default PCI request
-    }
-
-    public PciCommonHeader getCommonHeader() {
-        return commonHeader;
-    }
-
-    public void setCommonHeader(PciCommonHeader commonHeader) {
-        this.commonHeader = commonHeader;
-    }
-
-    /**
-     * Get the action.
-     *
-     * @return the action
-     */
-    public String getAction() {
-        return action;
-    }
-
-    /**
-     * Set the action.
-     *
-     * @param action
-     *            the action to set
-     */
-    public void setAction(String action) {
-        this.action = action;
-    }
-
-    /**
-     * Get the payload.
-     *
-     * @return the payload
-     */
-
-    public String getPayload() {
-        return payload;
-    }
-
-    /**
-     * Set the payload.
-     *
-     * @param payload
-     *            the payload to set
-     */
-
-    public void setPayload(String payload) {
-        this.payload = payload;
-    }
-
-    @Override
-    public String toString() {
-        return "PciRequest[commonHeader=" + commonHeader + ", action=" + action + ", payload=" + payload + "]";
-    }
 }
index b4453ad..1355e9e 100644 (file)
@@ -4,7 +4,7 @@
  * ================================================================================
  * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020-2021 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.
 package org.onap.policy.sdnr;
 
 import java.io.Serializable;
+import lombok.AllArgsConstructor;
 import lombok.EqualsAndHashCode;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 import lombok.Setter;
+import lombok.ToString;
 
 @Getter
 @Setter
 @EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@ToString(callSuper = true)
 public class PciRequestWrapper extends PciWrapper implements Serializable {
 
     private static final long serialVersionUID = 879766924715980798L;
 
     private PciRequest body;
-
-    public PciRequestWrapper() {
-        super();
-    }
-
-    public PciRequestWrapper(PciRequest request) {
-        body = request;
-    }
-
-    @Override
-    public String toString() {
-        return "RequestWrapper [body=" + body + ", toString()=" + super.toString() + "]";
-    }
 }
index 803f126..4fe5c0a 100644 (file)
@@ -4,7 +4,7 @@
  * ================================================================================
  * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020-2021 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.
@@ -26,11 +26,15 @@ import com.google.gson.annotations.SerializedName;
 import java.io.Serializable;
 import lombok.EqualsAndHashCode;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 import lombok.Setter;
+import lombok.ToString;
 
 @Getter
 @Setter
 @EqualsAndHashCode
+@NoArgsConstructor
+@ToString
 public class PciResponse implements Serializable {
 
     private static final long serialVersionUID = 8375708697287669750L;
@@ -44,10 +48,6 @@ public class PciResponse implements Serializable {
     @SerializedName(value = "Payload")
     private String payload;
 
-    public PciResponse() {
-        // EMPTY
-    }
-
     /**
      * Constructs a response using the common header of the request since they will
      * be the same.
@@ -58,10 +58,4 @@ public class PciResponse implements Serializable {
     public PciResponse(PciRequest request) {
         this.commonHeader = new PciCommonHeader(request.getCommonHeader());
     }
-
-    @Override
-    public String toString() {
-        return "PciResponse[CommonHeader=" + commonHeader + ", Status=" + status + ", Payload="
-                + payload + "]";
-    }
 }
index 90864d4..f6d2d8c 100644 (file)
 package org.onap.policy.sdnr;
 
 import java.io.Serializable;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
 import org.onap.policy.sdnr.util.StatusCodeEnum;
 
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
 public class PciResponseCode implements Serializable {
 
     /* These fields define the key to the response code value. */
@@ -38,15 +42,8 @@ public class PciResponseCode implements Serializable {
     public static final String PARTIAL_FAILURE = "PARTIAL FAILURE";
     private static final long serialVersionUID = -5371924429933449763L;
 
-    private final Integer code;
-
-    protected PciResponseCode(final int code) {
-        this.code = code;
-    }
-
-    public int getCode() {
-        return this.code;
-    }
+    @Getter
+    private final int code;
 
     @Override
     public String toString() {
index a41ec90..7321e10 100644 (file)
@@ -4,7 +4,7 @@
  * ================================================================================
  * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020-2021 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.
@@ -26,22 +26,15 @@ import java.io.Serializable;
 import lombok.EqualsAndHashCode;
 import lombok.Getter;
 import lombok.Setter;
+import lombok.ToString;
 
 @Getter
 @Setter
 @EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
 public class PciResponseWrapper extends PciWrapper implements Serializable {
 
     private static final long serialVersionUID = 109837814781086802L;
 
     private PciResponse body;
-
-    public PciResponseWrapper() {
-        super();
-    }
-
-    @Override
-    public String toString() {
-        return "ResponseWrapper [body=" + body + ", toString()=" + super.toString() + "]";
-    }
 }
index 3f7ca49..cc716b9 100644 (file)
@@ -4,7 +4,7 @@
  * ================================================================================
  * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020-2021 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.
@@ -27,10 +27,12 @@ import java.io.Serializable;
 import lombok.EqualsAndHashCode;
 import lombok.Getter;
 import lombok.Setter;
+import lombok.ToString;
 
 @Getter
 @Setter
 @EqualsAndHashCode
+@ToString
 public class PciWrapper implements Serializable {
 
     private static final long serialVersionUID = 375215806432396532L;
@@ -47,14 +49,4 @@ public class PciWrapper implements Serializable {
     private String correlationId;
 
     private String type;
-
-    public PciWrapper() {
-        // Create a default PciWrapper instance
-    }
-
-    @Override
-    public String toString() {
-        return "Wrapper [version=" + version + ", cambriaPartition=" + cambriaPartition + ", rpcName=" + rpcName
-            + ", correlationId=" + correlationId + ", type=" + type + "]";
-    }
 }
index 909e5d8..53a38e4 100644 (file)
@@ -4,7 +4,7 @@
  * ================================================================================
  * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020-2021 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.
@@ -24,13 +24,19 @@ package org.onap.policy.sdnr;
 
 import com.google.gson.annotations.SerializedName;
 import java.io.Serializable;
+import lombok.AllArgsConstructor;
 import lombok.EqualsAndHashCode;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 import lombok.Setter;
+import lombok.ToString;
 
 @Getter
 @Setter
 @EqualsAndHashCode
+@NoArgsConstructor
+@AllArgsConstructor
+@ToString
 public class Status implements Serializable {
 
     private static final long serialVersionUID = 877641506135467199L;
@@ -40,23 +46,4 @@ public class Status implements Serializable {
 
     @SerializedName(value = "Value")
     private String value;
-
-    public Status() {
-        // Create a default PciResponseStatus instance
-    }
-
-    /**
-     * Constructor for the class Status.
-     *
-     */
-    public Status(int code, String value) {
-        super();
-        this.code = code;
-        this.value = value;
-    }
-
-    @Override
-    public String toString() {
-        return "Status [code = " + code + ", value = " + value + "]";
-    }
 }
index 90aea71..d4179aa 100644 (file)
@@ -32,11 +32,14 @@ import com.google.gson.JsonSerializationContext;
 import com.google.gson.JsonSerializer;
 import java.lang.reflect.Type;
 import java.time.Instant;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import org.onap.policy.common.gson.InstantAsMillisTypeAdapter;
 import org.onap.policy.common.gson.InstantTypeAdapter;
 import org.onap.policy.sdnr.PciRequest;
 import org.onap.policy.sdnr.PciResponse;
 
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
 public final class Serialization {
     public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
             .registerTypeAdapter(Instant.class, new InstantTypeAdapter()).create();
@@ -48,10 +51,6 @@ public final class Serialization {
     public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
             .registerTypeAdapter(Instant.class, new InstantAsMillisTypeAdapter()).create();
 
-    private Serialization() {
-        // Private constructor to prevent subclassing
-    }
-
     public static class RequestAdapter implements JsonSerializer<PciRequest>, JsonDeserializer<PciRequest> {
 
         @Override
index 9d49760..11f408a 100644 (file)
@@ -69,7 +69,7 @@ public class PciCommonHeaderTest {
 
         assertNotEquals(0, commonHeader.hashCode());
 
-        assertEquals("CommonHeader [timeStamp=", commonHeader.toString().substring(0, 24));
+        assertEquals("PciCommonHeader(timeStamp=", commonHeader.toString().substring(0, 26));
 
         PciCommonHeader copiedPciCommonHeader = new PciCommonHeader();
         copiedPciCommonHeader.setApiVer(commonHeader.getApiVer());
index 0bff14d..d504dbb 100644 (file)
@@ -4,7 +4,7 @@
  * ================================================================================
  * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2021 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.
@@ -52,7 +52,7 @@ public class PciRequestTest {
 
         assertNotEquals(0, request.hashCode());
 
-        assertEquals("PciRequest[commonHeader=CommonHeader [timeStamp=", request.toString().substring(0, 48));
+        assertEquals("PciRequest(commonHeader=PciCommonHeader(timeStamp=", request.toString().substring(0, 50));
 
         PciRequest copiedPciRequest = new PciRequest();
         copiedPciRequest.setCommonHeader(request.getCommonHeader());
index a5c81bc..e44800e 100644 (file)
@@ -4,7 +4,7 @@
  * ================================================================================
  * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020-2021 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.
@@ -22,6 +22,7 @@
 
 package org.onap.policy.sdnr;
 
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
@@ -44,7 +45,9 @@ public class PciRequestWrapperTest {
 
         assertNotEquals(0, requestWrapper.hashCode());
 
-        assertEquals("RequestWrapper [body=PciRequest[commonHeader=nul", requestWrapper.toString().substring(0, 48));
+        assertThat(requestWrapper.toString())
+            .startsWith("PciRequestWrapper(")
+            .contains("body=PciRequest(commonHeader=nul");
 
         PciRequestWrapper copiedPciRequestWrapper = new PciRequestWrapper();
         copiedPciRequestWrapper.setBody(requestWrapper.getBody());
index d496f86..f0b6ffb 100644 (file)
@@ -4,7 +4,7 @@
  * ================================================================================
  * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2021 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.
@@ -44,7 +44,7 @@ public class PciStatusTest {
         status.setValue(THE_WONDERFUL_LAND_OF_OZ);
         assertEquals(THE_WONDERFUL_LAND_OF_OZ, status.getValue());
 
-        assertEquals("Status [code = 1234, value = The wonderfu", status.toString().substring(0, 41));
+        assertEquals("Status(code=1234, value=The wonderful", status.toString().substring(0, 37));
 
         Status copiedStatus = new Status();
         copiedStatus.setCode(status.getCode());
index 91d42a3..708363b 100644 (file)
@@ -60,7 +60,7 @@ public class PciWrapperTest {
 
         assertNotEquals(0, wrapper.hashCode());
 
-        assertEquals("Wrapper [version=19.3.9, cambriaPartition=The ", wrapper.toString().substring(0, 46));
+        assertEquals("PciWrapper(version=19.3.9, cambriaPartition=The ", wrapper.toString().substring(0, 48));
 
         PciWrapper copiedPciWrapper = new PciWrapper();
         copiedPciWrapper.setVersion(wrapper.getVersion());
index 51f2f9d..8b85262 100644 (file)
@@ -22,6 +22,8 @@
 package org.onap.policy.simulators;
 
 import java.io.IOException;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import org.onap.policy.common.endpoints.http.server.HttpServletServer;
 import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
 import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
@@ -34,7 +36,8 @@ import org.onap.policy.models.sim.dmaap.parameters.DmaapSimParameterGroup;
 import org.onap.policy.models.sim.dmaap.provider.DmaapSimProvider;
 import org.onap.policy.models.sim.dmaap.rest.DmaapSimRestServer;
 
-public class Util {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class Util {
     public static final String AAISIM_SERVER_NAME = "aaiSim";
     public static final String SOSIM_SERVER_NAME = "soSim";
     public static final String VFCSIM_SERVER_NAME = "vfcSim";
@@ -53,10 +56,6 @@ public class Util {
     private static final String CANNOT_CONNECT = "cannot connect to port ";
     public static final String LOCALHOST = "localhost";
 
-    private Util() {
-        // Prevent instantiation of this class
-    }
-
     /**
      * Build an A&AI simulator.
      *