diff options
Diffstat (limited to 'models-interactions/model-impl/sdnr')
14 files changed, 53 insertions, 157 deletions
diff --git a/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciCommonHeader.java b/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciCommonHeader.java index d8555e4a7..ec17da270 100644 --- a/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciCommonHeader.java +++ b/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciCommonHeader.java @@ -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 + "]"; - } } diff --git a/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciRequest.java b/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciRequest.java index 71e4c56e9..04830b08d 100644 --- a/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciRequest.java +++ b/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciRequest.java @@ -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 + "]"; - } } diff --git a/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciRequestWrapper.java b/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciRequestWrapper.java index b4453ad93..1355e9e7b 100644 --- a/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciRequestWrapper.java +++ b/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciRequestWrapper.java @@ -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. @@ -23,29 +23,22 @@ 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() + "]"; - } } diff --git a/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponse.java b/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponse.java index 803f126e0..4fe5c0a7d 100644 --- a/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponse.java +++ b/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponse.java @@ -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 + "]"; - } } diff --git a/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponseCode.java b/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponseCode.java index 90864d42c..f6d2d8cc5 100644 --- a/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponseCode.java +++ b/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponseCode.java @@ -24,8 +24,12 @@ 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() { diff --git a/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponseWrapper.java b/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponseWrapper.java index a41ec90bc..7321e10bd 100644 --- a/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponseWrapper.java +++ b/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponseWrapper.java @@ -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() + "]"; - } } diff --git a/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciWrapper.java b/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciWrapper.java index 3f7ca49e8..cc716b965 100644 --- a/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciWrapper.java +++ b/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciWrapper.java @@ -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 + "]"; - } } diff --git a/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/Status.java b/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/Status.java index 909e5d883..53a38e414 100644 --- a/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/Status.java +++ b/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/Status.java @@ -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 + "]"; - } } diff --git a/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/util/Serialization.java b/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/util/Serialization.java index 90aea71ee..d4179aa84 100644 --- a/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/util/Serialization.java +++ b/models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/util/Serialization.java @@ -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 diff --git a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java index 9d497602f..11f408aeb 100644 --- a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java +++ b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java @@ -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()); diff --git a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java index 0bff14de9..d504dbb7b 100644 --- a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java +++ b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java @@ -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()); diff --git a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java index a5c81bc1a..e44800e4b 100644 --- a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java +++ b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java @@ -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()); diff --git a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java index d496f86fe..f0b6ffb90 100644 --- a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java +++ b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java @@ -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()); diff --git a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java index 91d42a3bf..708363bcc 100644 --- a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java +++ b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java @@ -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()); |