summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-impl
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions/model-impl')
-rw-r--r--models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java157
-rw-r--r--models-interactions/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java80
-rw-r--r--models-interactions/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java72
-rw-r--r--models-interactions/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java47
-rw-r--r--models-interactions/model-impl/cds/src/test/java/org/onap/policy/cds/client/CdsProcessorGrpcClientTest.java5
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java6
-rw-r--r--models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java38
-rw-r--r--models-interactions/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java6
-rw-r--r--models-interactions/model-impl/sdc/src/main/java/org/onap/policy/sdc/Service.java6
-rw-r--r--models-interactions/model-impl/sdc/src/main/java/org/onap/policy/sdc/ServiceInstance.java6
-rw-r--r--models-interactions/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/DemoTest.java5
-rw-r--r--models-interactions/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncManagerTest.java46
-rw-r--r--models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciCommonHeader.java71
-rw-r--r--models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciRequest.java47
-rw-r--r--models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciRequestWrapper.java30
-rw-r--r--models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponse.java46
-rw-r--r--models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponseWrapper.java30
-rw-r--r--models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciWrapper.java62
-rw-r--r--models-interactions/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/Status.java34
-rw-r--r--models-interactions/model-impl/so/src/main/java/org/onap/policy/so/SoRequestDetails.java78
-rw-r--r--models-interactions/model-impl/so/src/test/resources/logback-test.xml38
-rw-r--r--models-interactions/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java43
22 files changed, 218 insertions, 735 deletions
diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java
index 92af217de..1e14e0704 100644
--- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java
+++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java
@@ -100,100 +100,115 @@ public class AaiCqResponse implements Serializable {
resultsArray = (JSONArray) responseObj.get("results");
}
for (int i = 0; i < resultsArray.length(); i++) {
- // Object is a vserver
- if (resultsArray.getJSONObject(i).has("vserver")) {
+ final JSONObject resultObject = resultsArray.getJSONObject(i);
+
+ extractVserver(resultObject);
+ extractGenericVnf(resultObject);
+ extractServiceInstance(resultObject);
+ extractVfModule(resultObject);
+ extractCloudRegion(resultObject);
+ extractTenant(resultObject);
+ extractModelVer(resultObject);
+ }
+ }
- // Create the StreamSource by creating StringReader using the
- // JSON input
- StreamSource json = new StreamSource(
- new StringReader(resultsArray.getJSONObject(i).getJSONObject("vserver").toString()));
+ private void extractVserver(final JSONObject resultObject) {
+ if (resultObject.has("vserver")) {
- // Getting the vserver pojo again from the json
- Vserver vserver = this.getAaiObject(json, Vserver.class);
- this.inventoryResponseItems.add(vserver);
- }
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultObject.getJSONObject("vserver").toString()));
- // Object is a Generic VNF
- if (resultsArray.getJSONObject(i).has(GENERIC_VNF)) {
- // Create the StreamSource by creating StringReader using the
- // JSON input
- StreamSource json = new StreamSource(
- new StringReader(resultsArray.getJSONObject(i).getJSONObject(GENERIC_VNF).toString()));
+ // Getting the vserver pojo again from the json
+ Vserver vserver = this.getAaiObject(json, Vserver.class);
+ this.inventoryResponseItems.add(vserver);
+ }
+ }
- // Getting the generic vnf pojo again from the json
- GenericVnf genericVnf = this.getAaiObject(json, GenericVnf.class);
+ private void extractGenericVnf(final JSONObject resultObject) {
+ if (resultObject.has(GENERIC_VNF)) {
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultObject.getJSONObject(GENERIC_VNF).toString()));
- this.inventoryResponseItems.add(genericVnf);
- }
+ // Getting the generic vnf pojo again from the json
+ GenericVnf genericVnf = this.getAaiObject(json, GenericVnf.class);
- // Object is a Service Instance
- if (resultsArray.getJSONObject(i).has("service-instance")) {
+ this.inventoryResponseItems.add(genericVnf);
+ }
+ }
- // Create the StreamSource by creating StringReader using the
- // JSON input
- StreamSource json = new StreamSource(
- new StringReader(resultsArray.getJSONObject(i).getJSONObject("service-instance").toString()));
+ private void extractServiceInstance(final JSONObject resultObject) {
+ if (resultObject.has("service-instance")) {
- // Getting the employee pojo again from the json
- ServiceInstance serviceInstance = this.getAaiObject(json, ServiceInstance.class);
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultObject.getJSONObject("service-instance").toString()));
- this.inventoryResponseItems.add(serviceInstance);
- }
+ // Getting the employee pojo again from the json
+ ServiceInstance serviceInstance = this.getAaiObject(json, ServiceInstance.class);
- // Object is a VF Module
- if (resultsArray.getJSONObject(i).has(VF_MODULE)) {
- // Create the StreamSource by creating StringReader using the
- // JSON input
- StreamSource json = new StreamSource(
- new StringReader(resultsArray.getJSONObject(i).getJSONObject(VF_MODULE).toString()));
+ this.inventoryResponseItems.add(serviceInstance);
+ }
+ }
- // Getting the vf module pojo again from the json
- VfModule vfModule = this.getAaiObject(json, VfModule.class);
+ private void extractVfModule(final JSONObject resultObject) {
+ if (resultObject.has(VF_MODULE)) {
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultObject.getJSONObject(VF_MODULE).toString()));
- this.inventoryResponseItems.add(vfModule);
- }
+ // Getting the vf module pojo again from the json
+ VfModule vfModule = this.getAaiObject(json, VfModule.class);
- // Object is a CloudRegion
- if (resultsArray.getJSONObject(i).has("cloud-region")) {
- // Create the StreamSource by creating StringReader using the
- // JSON input
- StreamSource json = new StreamSource(
- new StringReader(resultsArray.getJSONObject(i).getJSONObject("cloud-region").toString()));
+ this.inventoryResponseItems.add(vfModule);
+ }
+ }
- // Getting the cloud region pojo again from the json
- CloudRegion cloudRegion = this.getAaiObject(json, CloudRegion.class);
+ private void extractCloudRegion(final JSONObject resultObject) {
+ if (resultObject.has("cloud-region")) {
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultObject.getJSONObject("cloud-region").toString()));
- this.inventoryResponseItems.add(cloudRegion);
- }
+ // Getting the cloud region pojo again from the json
+ CloudRegion cloudRegion = this.getAaiObject(json, CloudRegion.class);
- // Object is a Tenant
- if (resultsArray.getJSONObject(i).has("tenant")) {
- // Create the StreamSource by creating StringReader using the
- // JSON input
- StreamSource json = new StreamSource(
- new StringReader(resultsArray.getJSONObject(i).getJSONObject("tenant").toString()));
+ this.inventoryResponseItems.add(cloudRegion);
+ }
+ }
- // Getting the tenant pojo again from the json
- Tenant tenant = this.getAaiObject(json, Tenant.class);
+ private void extractTenant(final JSONObject resultObject) {
+ if (resultObject.has("tenant")) {
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultObject.getJSONObject("tenant").toString()));
- this.inventoryResponseItems.add(tenant);
- }
+ // Getting the tenant pojo again from the json
+ Tenant tenant = this.getAaiObject(json, Tenant.class);
- // Object is a ModelVer
- if (resultsArray.getJSONObject(i).has("model-ver")) {
- // Create the StreamSource by creating StringReader using the
- // JSON input
- StreamSource json = new StreamSource(
- new StringReader(resultsArray.getJSONObject(i).getJSONObject("model-ver").toString()));
+ this.inventoryResponseItems.add(tenant);
+ }
+ }
- // Getting the ModelVer pojo again from the json
- ModelVer modelVer = this.getAaiObject(json, ModelVer.class);
+ private void extractModelVer(final JSONObject resultObject) {
+ if (resultObject.has("model-ver")) {
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultObject.getJSONObject("model-ver").toString()));
- this.inventoryResponseItems.add(modelVer);
- }
+ // Getting the ModelVer pojo again from the json
+ ModelVer modelVer = this.getAaiObject(json, ModelVer.class);
+ this.inventoryResponseItems.add(modelVer);
}
-
}
private <T> T getAaiObject(StreamSource json, final Class<T> classOfResponse) {
diff --git a/models-interactions/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java b/models-interactions/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java
index f0419efe9..058323412 100644
--- a/models-interactions/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java
+++ b/models-interactions/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,12 +29,13 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.UUID;
-
+import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
+@EqualsAndHashCode
public class CommonHeader implements Serializable {
private static final long serialVersionUID = -3581658269910980336L;
@@ -88,79 +89,4 @@ public class CommonHeader implements Serializable {
+ ", RequestId=" + requestId + ", SubrequestId=" + subRequestId + ", RequestTrack=" + requestTrack
+ ", Flags=" + flags + "]";
}
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((apiVer == null) ? 0 : apiVer.hashCode());
- result = prime * result + ((flags == null) ? 0 : flags.hashCode());
- result = prime * result + ((originatorId == null) ? 0 : originatorId.hashCode());
- result = prime * result + ((requestId == null) ? 0 : requestId.hashCode());
- result = prime * result + ((requestTrack == null) ? 0 : requestTrack.hashCode());
- result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode());
- result = prime * result + ((timeStamp == null) ? 0 : timeStamp.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;
- }
- CommonHeader other = (CommonHeader) obj;
- if (apiVer == null) {
- if (other.apiVer != null) {
- return false;
- }
- } else if (!apiVer.equals(other.apiVer)) {
- return false;
- }
- if (flags == null) {
- if (other.flags != null) {
- return false;
- }
- } else if (!flags.equals(other.flags)) {
- return false;
- }
- if (originatorId == null) {
- if (other.originatorId != null) {
- return false;
- }
- } else if (!originatorId.equals(other.originatorId)) {
- return false;
- }
- if (requestId == null) {
- if (other.requestId != null) {
- return false;
- }
- } else if (!requestId.equals(other.requestId)) {
- return false;
- }
- if (requestTrack == null) {
- if (other.requestTrack != null) {
- return false;
- }
- } else if (!requestTrack.equals(other.requestTrack)) {
- return false;
- }
- if (subRequestId == null) {
- if (other.subRequestId != null) {
- return false;
- }
- } else if (!subRequestId.equals(other.subRequestId)) {
- return false;
- }
- if (timeStamp == null) {
- return other.timeStamp == null;
- } else {
- return timeStamp.equals(other.timeStamp);
- }
- }
}
diff --git a/models-interactions/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java b/models-interactions/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java
index e340360af..08cc163c0 100644
--- a/models-interactions/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java
+++ b/models-interactions/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,11 +26,13 @@ import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
+import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
+@EqualsAndHashCode
public class Request implements Serializable {
private static final long serialVersionUID = -3912323643990646431L;
@@ -54,74 +56,6 @@ public class Request implements Serializable {
}
@Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((action == null) ? 0 : action.hashCode());
- result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode());
- result = prime * result + ((objectId == null) ? 0 : objectId.hashCode());
- result = prime * result + ((payload == null) ? 0 : payload.hashCode());
- result = prime * result + ((targetId == null) ? 0 : targetId.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;
- }
-
- Request other = (Request) obj;
- if (action == null) {
- if (other.action != null) {
- return false;
- }
- } else if (!action.equals(other.action)) {
- return false;
- }
-
- if (commonHeader == null) {
- if (other.commonHeader != null) {
- return false;
- }
- } else if (!commonHeader.equals(other.commonHeader)) {
- return false;
- }
-
- if (objectId == null) {
- if (other.objectId != null) {
- return false;
- }
- } else if (!objectId.equals(other.objectId)) {
- return false;
- }
-
- if (payload == null) {
- if (other.payload != null) {
- return false;
- }
- } else if (!payload.equals(other.payload)) {
- return false;
- }
-
- if (targetId == null) {
- if (other.targetId != null) {
- return false;
- }
- } else if (!targetId.equals(other.targetId)) {
- return false;
- }
-
- return true;
- }
-
- @Override
public String toString() {
return "Request [CommonHeader=" + commonHeader + ", Action=" + action + ", TargetId=" + targetId + ", ObjectId="
+ objectId + ", Payload=" + payload + "]";
diff --git a/models-interactions/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java b/models-interactions/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java
index fb70151f6..368876f93 100644
--- a/models-interactions/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java
+++ b/models-interactions/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,11 +26,13 @@ import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
+import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
+@EqualsAndHashCode
public class Response implements Serializable {
private static final long serialVersionUID = 434953706339865151L;
@@ -71,47 +73,4 @@ public class Response implements Serializable {
public String toString() {
return "Response [CommonHeader=" + commonHeader + ", Status=" + status + ", Payload=" + payload + "]";
}
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode());
- result = prime * result + ((payload == null) ? 0 : payload.hashCode());
- result = prime * result + ((status == null) ? 0 : status.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;
- }
- Response other = (Response) obj;
- if (commonHeader == null) {
- if (other.commonHeader != null) {
- return false;
- }
- } else if (!commonHeader.equals(other.commonHeader)) {
- return false;
- }
- if (payload == null) {
- if (other.payload != null) {
- return false;
- }
- } else if (!payload.equals(other.payload)) {
- return false;
- }
- if (status == null) {
- return other.status == null;
- } else {
- return status.equals(other.status);
- }
- }
}
diff --git a/models-interactions/model-impl/cds/src/test/java/org/onap/policy/cds/client/CdsProcessorGrpcClientTest.java b/models-interactions/model-impl/cds/src/test/java/org/onap/policy/cds/client/CdsProcessorGrpcClientTest.java
index 17b4dc534..9d01ec851 100644
--- a/models-interactions/model-impl/cds/src/test/java/org/onap/policy/cds/client/CdsProcessorGrpcClientTest.java
+++ b/models-interactions/model-impl/cds/src/test/java/org/onap/policy/cds/client/CdsProcessorGrpcClientTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Bell Canada.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2020 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.
@@ -19,6 +19,7 @@
package org.onap.policy.cds.client;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
@@ -128,7 +129,7 @@ public class CdsProcessorGrpcClientTest {
@Test
public void testCdsProcessorGrpcClientConstructor() {
- new CdsProcessorGrpcClient(listener, props).close();
+ assertThatCode(() -> new CdsProcessorGrpcClient(listener, props).close()).doesNotThrowAnyException();
}
@Test(expected = IllegalStateException.class)
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java
index b79140a12..55c133306 100644
--- a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* controlloop
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,4 +27,8 @@ public class ControlLoopTargetType {
public static final String VFC = "VFC";
public static final String VNF = "VNF";
public static final String PNF = "PNF";
+
+ private ControlLoopTargetType() {
+ // do nothing
+ }
}
diff --git a/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java b/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java
deleted file mode 100644
index dcb5d1772..000000000
--- a/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * controlloop
- * ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.controlloop;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-public class ControlLoopTargetTypeTest {
-
- @Test
- public void test() {
- assertEquals(ControlLoopTargetType.VM, "VM");
- assertEquals(ControlLoopTargetType.VF, "VF");
- assertEquals(ControlLoopTargetType.VFC, "VFC");
- assertEquals(ControlLoopTargetType.VNF, "VNF");
- assertEquals(ControlLoopTargetType.PNF, "PNF");
- }
-}
diff --git a/models-interactions/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java b/models-interactions/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java
index dde3aa2e2..a452c142f 100644
--- a/models-interactions/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java
+++ b/models-interactions/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* rest
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,7 +21,7 @@
package org.onap.policy.rest;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Map.Entry;
import javax.xml.bind.DatatypeConverter;
@@ -262,6 +262,6 @@ public class RestManager {
}
String auth = username + ":" + (password == null ? "" : password);
- return "Basic " + DatatypeConverter.printBase64Binary(auth.getBytes(Charset.forName("ISO-8859-1")));
+ return "Basic " + DatatypeConverter.printBase64Binary(auth.getBytes(StandardCharsets.ISO_8859_1));
}
}
diff --git a/models-interactions/model-impl/sdc/src/main/java/org/onap/policy/sdc/Service.java b/models-interactions/model-impl/sdc/src/main/java/org/onap/policy/sdc/Service.java
index d372f1221..3327b78b0 100644
--- a/models-interactions/model-impl/sdc/src/main/java/org/onap/policy/sdc/Service.java
+++ b/models-interactions/model-impl/sdc/src/main/java/org/onap/policy/sdc/Service.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* sdc
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,6 +30,10 @@ public class Service implements Serializable {
private static final long serialVersionUID = -1249276698549996806L;
+ /*
+ * Note the field names ending in "UUID" may not be changed without breaking the
+ * interface, due to limitations in the YAML encoder/decoder.
+ */
private UUID serviceUUID;
private UUID serviceInvariantUUID;
private String serviceName;
diff --git a/models-interactions/model-impl/sdc/src/main/java/org/onap/policy/sdc/ServiceInstance.java b/models-interactions/model-impl/sdc/src/main/java/org/onap/policy/sdc/ServiceInstance.java
index b476de20f..6eac319fd 100644
--- a/models-interactions/model-impl/sdc/src/main/java/org/onap/policy/sdc/ServiceInstance.java
+++ b/models-interactions/model-impl/sdc/src/main/java/org/onap/policy/sdc/ServiceInstance.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* sdc
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,6 +30,10 @@ public class ServiceInstance implements Serializable {
private static final long serialVersionUID = 6285260780966679625L;
+ /*
+ * Note the field names ending in "UUID" may not be changed without breaking the
+ * interface, due to limitations in the YAML encoder/decoder.
+ */
private UUID personaModelUUID;
private UUID serviceUUID;
private UUID serviceInstanceUUID;
diff --git a/models-interactions/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/DemoTest.java b/models-interactions/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/DemoTest.java
index 41f07c3c7..7b5ad46c5 100644
--- a/models-interactions/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/DemoTest.java
+++ b/models-interactions/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/DemoTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Huawei. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2020 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,6 +20,8 @@
package org.onap.policy.sdnc;
+import static org.junit.Assert.assertNotNull;
+
import org.junit.Test;
import org.onap.policy.sdnc.util.Serialization;
import org.slf4j.Logger;
@@ -70,5 +72,6 @@ public class DemoTest {
body = Serialization.gsonPretty.toJson(response);
logger.info("{}", body);
+ assertNotNull(body);
}
}
diff --git a/models-interactions/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncManagerTest.java b/models-interactions/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncManagerTest.java
index c069f1c3b..b962ce8c7 100644
--- a/models-interactions/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncManagerTest.java
+++ b/models-interactions/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncManagerTest.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2018 Huawei. All rights reserved.
* ================================================================================
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved
+ * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,12 +24,13 @@
package org.onap.policy.sdnc;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyMap;
import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.endsWith;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.startsWith;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.UUID;
@@ -48,7 +49,6 @@ public class SdncManagerTest implements SdncCallback {
private RestManager mockedRestManager;
private Pair<Integer, String> httpResponsePutOk;
- private Pair<Integer, String> httpResponseGetOk;
private Pair<Integer, String> httpResponseBadResponse;
private Pair<Integer, String> httpResponseErr;
@@ -63,7 +63,6 @@ public class SdncManagerTest implements SdncCallback {
mockedRestManager = mock(RestManager.class);
httpResponsePutOk = mockedRestManager.new Pair<>(202, Serialization.gsonPretty.toJson(response));
- httpResponseGetOk = mockedRestManager.new Pair<>(200, Serialization.gsonPretty.toJson(response));
httpResponseBadResponse = mockedRestManager.new Pair<>(202, Serialization.gsonPretty.toJson(null));
httpResponseErr = mockedRestManager.new Pair<>(200, null);
}
@@ -120,14 +119,15 @@ public class SdncManagerTest implements SdncCallback {
SdncManager manager = new SdncManager(this, request, SOMEWHERE_OVER_THE_RAINBOW, DOROTHY, "Exception");
manager.setRestManager(mockedRestManager);
- Thread managerThread = new Thread(manager);
- managerThread.start();
-
when(mockedRestManager.post(startsWith(SOMEWHERE_OVER_THE_RAINBOW), eq(DOROTHY), eq("Exception"), anyMap(),
anyString(), anyString())).thenThrow(new RuntimeException("OzException"));
+ Thread managerThread = new Thread(manager);
+ managerThread.start();
+
+ managerThread.join(1000);
- managerThread.join(100);
+ verify(mockedRestManager).post(any(), any(), any(), any(), any(), any());
}
@Test
@@ -135,13 +135,12 @@ public class SdncManagerTest implements SdncCallback {
SdncManager manager = new SdncManager(this, request, SOMEWHERE_OVER_THE_RAINBOW, DOROTHY, "Null");
manager.setRestManager(mockedRestManager);
- Thread managerThread = new Thread(manager);
- managerThread.start();
-
when(mockedRestManager.post(startsWith(SOMEWHERE_OVER_THE_RAINBOW), eq(DOROTHY), eq("Null"), anyMap(),
anyString(), anyString())).thenReturn(null);
- managerThread.join(100);
+ manager.run();
+
+ verify(mockedRestManager).post(any(), any(), any(), any(), any(), any());
}
@@ -150,13 +149,12 @@ public class SdncManagerTest implements SdncCallback {
SdncManager manager = new SdncManager(this, request, SOMEWHERE_OVER_THE_RAINBOW, DOROTHY, "Error0");
manager.setRestManager(mockedRestManager);
- Thread managerThread = new Thread(manager);
- managerThread.start();
-
when(mockedRestManager.post(startsWith(SOMEWHERE_OVER_THE_RAINBOW), eq(DOROTHY), eq("Error0"), anyMap(),
anyString(), anyString())).thenReturn(httpResponseErr);
- managerThread.join(100);
+ manager.run();
+
+ verify(mockedRestManager).post(any(), any(), any(), any(), any(), any());
}
@Test
@@ -164,13 +162,12 @@ public class SdncManagerTest implements SdncCallback {
SdncManager manager = new SdncManager(this, request, SOMEWHERE_OVER_THE_RAINBOW, DOROTHY, "BadResponse");
manager.setRestManager(mockedRestManager);
- Thread managerThread = new Thread(manager);
- managerThread.start();
-
when(mockedRestManager.post(startsWith(SOMEWHERE_OVER_THE_RAINBOW), eq(DOROTHY), eq("OK"), anyMap(),
anyString(), anyString())).thenReturn(httpResponseBadResponse);
- managerThread.join(100);
+ manager.run();
+
+ verify(mockedRestManager).post(any(), any(), any(), any(), any(), any());
}
@Test
@@ -178,17 +175,12 @@ public class SdncManagerTest implements SdncCallback {
SdncManager manager = new SdncManager(this, request, SOMEWHERE_OVER_THE_RAINBOW, DOROTHY, "OOK");
manager.setRestManager(mockedRestManager);
- Thread managerThread = new Thread(manager);
- managerThread.start();
-
when(mockedRestManager.post(startsWith(SOMEWHERE_OVER_THE_RAINBOW), eq(DOROTHY), eq("OK"), anyMap(),
anyString(), anyString())).thenReturn(httpResponsePutOk);
- when(mockedRestManager.get(endsWith("1234"), eq(DOROTHY), eq("OK"), anyMap()))
- .thenReturn(httpResponseGetOk);
-
+ manager.run();
- managerThread.join(100);
+ verify(mockedRestManager).post(any(), any(), any(), any(), any(), any());
}
@Override
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 cdafa6858..0b3e98795 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 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2020 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.
@@ -29,11 +29,13 @@ import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
+import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
+@EqualsAndHashCode
public class PciCommonHeader implements Serializable {
private static final long serialVersionUID = 5435363539127062114L;
@@ -85,71 +87,4 @@ public class PciCommonHeader implements Serializable {
+ ", requestId=" + requestId + ", subRequestId=" + subRequestId + ", requestTrack=" + requestTrack
+ ", flags=" + flags + "]";
}
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((apiVer == null) ? 0 : apiVer.hashCode());
- result = prime * result + ((flags == null) ? 0 : flags.hashCode());
- result = prime * result + ((requestTrack == null) ? 0 : requestTrack.hashCode());
- result = prime * result + ((requestId == null) ? 0 : requestId.hashCode());
- result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode());
- result = prime * result + ((timeStamp == null) ? 0 : timeStamp.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;
- }
- PciCommonHeader other = (PciCommonHeader) obj;
- if (apiVer == null) {
- if (other.apiVer != null) {
- return false;
- }
- } else if (!apiVer.equals(other.apiVer)) {
- return false;
- }
- if (flags == null) {
- if (other.flags != null) {
- return false;
- }
- } else if (!flags.equals(other.flags)) {
- return false;
- }
- if (requestTrack == null) {
- if (other.requestTrack != null) {
- return false;
- }
- } else if (!requestTrack.equals(other.requestTrack)) {
- return false;
- }
- if (requestId == null) {
- if (other.requestId != null) {
- return false;
- }
- } else if (!requestId.equals(other.requestId)) {
- return false;
- }
- if (subRequestId == null) {
- if (other.subRequestId != null) {
- return false;
- }
- } else if (!subRequestId.equals(other.subRequestId)) {
- return false;
- }
- if (timeStamp == null) {
- return other.timeStamp == null;
- } else {
- return timeStamp.equals(other.timeStamp);
- }
- }
}
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 d1430a7dc..03fdfc1e4 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 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2020 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.
@@ -25,11 +25,13 @@ package org.onap.policy.sdnr;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
+import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
+@EqualsAndHashCode
public class PciRequest implements Serializable {
private static final long serialVersionUID = 323235565922846624L;
@@ -99,47 +101,4 @@ public class PciRequest implements Serializable {
public String toString() {
return "PciRequest[commonHeader=" + commonHeader + ", action=" + action + ", payload=" + payload + "]";
}
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode());
- result = prime * result + ((action == null) ? 0 : action.hashCode());
- result = prime * result + ((payload == null) ? 0 : payload.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;
- }
- PciRequest other = (PciRequest) obj;
- if (commonHeader == null) {
- if (other.commonHeader != null) {
- return false;
- }
- } else if (!commonHeader.equals(other.commonHeader)) {
- return false;
- }
- if (action == null) {
- if (other.action != null) {
- return false;
- }
- } else if (!action.equals(other.action)) {
- return false;
- }
- if (payload == null) {
- return other.payload == null;
- } else {
- return payload.equals(other.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 4de3a0d30..b4453ad93 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,6 +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.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,11 +23,13 @@
package org.onap.policy.sdnr;
import java.io.Serializable;
+import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
+@EqualsAndHashCode(callSuper = true)
public class PciRequestWrapper extends PciWrapper implements Serializable {
private static final long serialVersionUID = 879766924715980798L;
@@ -45,31 +48,4 @@ public class PciRequestWrapper extends PciWrapper implements Serializable {
public String toString() {
return "RequestWrapper [body=" + body + ", toString()=" + super.toString() + "]";
}
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((body == null) ? 0 : body.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- PciRequestWrapper other = (PciRequestWrapper) obj;
- if (body == null) {
- return other.body == null;
- } else {
- return body.equals(other.body);
- }
- }
}
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 0bc2eb4cf..5d7697eed 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,6 +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.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,11 +25,13 @@ package org.onap.policy.sdnr;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
+import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
+@EqualsAndHashCode
public class PciResponse implements Serializable {
private static final long serialVersionUID = 8375708697287669750L;
@@ -62,47 +65,4 @@ public class PciResponse implements Serializable {
return "PciResponse[CommonHeader=" + commonHeader + ", Status=" + status + ", Payload="
+ payload + "]";
}
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode());
- result = prime * result + ((payload == null) ? 0 : payload.hashCode());
- result = prime * result + ((status == null) ? 0 : status.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;
- }
- PciResponse other = (PciResponse) obj;
- if (commonHeader == null) {
- if (other.commonHeader != null) {
- return false;
- }
- } else if (!commonHeader.equals(other.commonHeader)) {
- return false;
- }
- if (payload == null) {
- if (other.payload != null) {
- return false;
- }
- } else if (!payload.equals(other.payload)) {
- return false;
- }
- if (status == null) {
- return other.status == null;
- } else {
- return status.equals(other.status);
- }
- }
}
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 e1613645d..a41ec90bc 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,6 +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.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,11 +23,13 @@
package org.onap.policy.sdnr;
import java.io.Serializable;
+import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
+@EqualsAndHashCode(callSuper = true)
public class PciResponseWrapper extends PciWrapper implements Serializable {
private static final long serialVersionUID = 109837814781086802L;
@@ -41,31 +44,4 @@ public class PciResponseWrapper extends PciWrapper implements Serializable {
public String toString() {
return "ResponseWrapper [body=" + body + ", toString()=" + super.toString() + "]";
}
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((body == null) ? 0 : body.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- PciResponseWrapper other = (PciResponseWrapper) obj;
- if (body == null) {
- return other.body == null;
- } else {
- return body.equals(other.body);
- }
- }
}
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 cf0a8a711..a3bffdadd 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,6 +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.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,11 +25,13 @@ package org.onap.policy.sdnr;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
+import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
+@EqualsAndHashCode
public class PciWrapper implements Serializable {
private static final long serialVersionUID = 375215806432396532L;
@@ -55,63 +58,4 @@ public class PciWrapper implements Serializable {
return "Wrapper [version=" + version + ", cambriaPartition=" + cambriaPartition + ", rpcName=" + rpcName
+ ", correlationId=" + correlationId + ", type=" + type + "]";
}
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((cambriaPartition == null) ? 0 : cambriaPartition.hashCode());
- result = prime * result + ((correlationId == null) ? 0 : correlationId.hashCode());
- result = prime * result + ((rpcName == null) ? 0 : rpcName.hashCode());
- result = prime * result + ((type == null) ? 0 : type.hashCode());
- result = prime * result + ((version == null) ? 0 : version.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;
- }
- PciWrapper other = (PciWrapper) obj;
- if (cambriaPartition == null) {
- if (other.cambriaPartition != null) {
- return false;
- }
- } else if (!cambriaPartition.equals(other.cambriaPartition)) {
- return false;
- }
- if (correlationId == null) {
- if (other.correlationId != null) {
- return false;
- }
- } else if (!correlationId.equals(other.correlationId)) {
- return false;
- }
- if (rpcName == null) {
- if (other.rpcName != null) {
- return false;
- }
- } else if (!rpcName.equals(other.rpcName)) {
- return false;
- }
- if (type == null) {
- if (other.type != null) {
- return false;
- }
- } else if (!type.equals(other.type)) {
- return false;
- }
- if (version == null) {
- return other.version == null;
- } else {
- return version.equals(other.version);
- }
- }
}
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 a8fe379e7..cdbe9dcb0 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,6 +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.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,11 +25,13 @@ package org.onap.policy.sdnr;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
+import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
+@EqualsAndHashCode
public class Status implements Serializable {
private static final long serialVersionUID = 877641506135467199L;
@@ -57,35 +60,4 @@ public class Status implements Serializable {
public String toString() {
return "Status [code = " + code + ", value = " + value + "]";
}
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + code;
- result = prime * result + ((value == null) ? 0 : value.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;
- }
- Status other = (Status) obj;
- if (code != other.code) {
- return false;
- }
- if (value == null) {
- return other.value == null;
- } else {
- return value.equals(other.value);
- }
- }
}
diff --git a/models-interactions/model-impl/so/src/main/java/org/onap/policy/so/SoRequestDetails.java b/models-interactions/model-impl/so/src/main/java/org/onap/policy/so/SoRequestDetails.java
index 3fa3332b3..9c3a4ec33 100644
--- a/models-interactions/model-impl/so/src/main/java/org/onap/policy/so/SoRequestDetails.java
+++ b/models-interactions/model-impl/so/src/main/java/org/onap/policy/so/SoRequestDetails.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2020 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.
@@ -25,11 +26,13 @@ import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
+@EqualsAndHashCode
public class SoRequestDetails implements Serializable {
private static final long serialVersionUID = -3283942659786236032L;
@@ -60,81 +63,6 @@ public class SoRequestDetails implements Serializable {
}
@Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- SoRequestDetails other = (SoRequestDetails) obj;
- if (cloudConfiguration == null) {
- if (other.cloudConfiguration != null) {
- return false;
- }
- } else if (!cloudConfiguration.equals(other.cloudConfiguration)) {
- return false;
- }
- if (configurationParameters == null) {
- if (other.configurationParameters != null) {
- return false;
- }
- } else if (!configurationParameters.equals(other.configurationParameters)) {
- return false;
- }
- if (modelInfo == null) {
- if (other.modelInfo != null) {
- return false;
- }
- } else if (!modelInfo.equals(other.modelInfo)) {
- return false;
- }
- if (relatedInstanceList == null) {
- if (other.relatedInstanceList != null) {
- return false;
- }
- } else if (!relatedInstanceList.equals(other.relatedInstanceList)) {
- return false;
- }
- if (requestInfo == null) {
- if (other.requestInfo != null) {
- return false;
- }
- } else if (!requestInfo.equals(other.requestInfo)) {
- return false;
- }
- if (requestParameters == null) {
- if (other.requestParameters != null) {
- return false;
- }
- } else if (!requestParameters.equals(other.requestParameters)) {
- return false;
- }
- if (subscriberInfo == null) {
- return other.subscriberInfo == null;
- } else {
- return subscriberInfo.equals(other.subscriberInfo);
- }
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((cloudConfiguration == null) ? 0 : cloudConfiguration.hashCode());
- result = prime * result + ((configurationParameters == null) ? 0 : configurationParameters.hashCode());
- result = prime * result + ((modelInfo == null) ? 0 : modelInfo.hashCode());
- result = prime * result + ((relatedInstanceList == null) ? 0 : relatedInstanceList.hashCode());
- result = prime * result + ((requestInfo == null) ? 0 : requestInfo.hashCode());
- result = prime * result + ((requestParameters == null) ? 0 : requestParameters.hashCode());
- result = prime * result + ((subscriberInfo == null) ? 0 : subscriberInfo.hashCode());
- return result;
- }
-
- @Override
public String toString() {
return "SORequestDetails [modelInfo=" + modelInfo + ", cloudConfiguration=" + cloudConfiguration
+ ", requestInfo=" + requestInfo + ", subscriberInfo=" + subscriberInfo
diff --git a/models-interactions/model-impl/so/src/test/resources/logback-test.xml b/models-interactions/model-impl/so/src/test/resources/logback-test.xml
new file mode 100644
index 000000000..855706304
--- /dev/null
+++ b/models-interactions/model-impl/so/src/test/resources/logback-test.xml
@@ -0,0 +1,38 @@
+<!--
+ ============LICENSE_START=======================================================
+ ONAP
+ ================================================================================
+ Copyright (C) 2020 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=========================================================
+-->
+
+<configuration scan="true" scanPeriod="60 seconds" debug="false">
+
+ <contextName>ModelImplSo</contextName>
+ <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
+ <property name="LOG_DIR" value="${java.io.tmpdir}/pf_logging/" />
+
+ <!-- USE FOR STD OUT ONLY -->
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
+ </encoder>
+ </appender>
+
+ <root level="warn">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration>
diff --git a/models-interactions/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java b/models-interactions/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java
index 7874d2514..8db3438cc 100644
--- a/models-interactions/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java
+++ b/models-interactions/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* vfc
* ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.. All rights reserved.
* Modifications Copyright (C) 2018-2019 AT&T Corporation. All rights reserved.
* ================================================================================
@@ -23,12 +23,13 @@
package org.onap.policy.vfc;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyMap;
import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.endsWith;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.startsWith;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
@@ -50,7 +51,6 @@ public class VfcManagerTest implements VfcCallback {
private RestManager mockedRestManager;
private Pair<Integer, String> httpResponsePutOk;
- private Pair<Integer, String> httpResponseGetOk;
private Pair<Integer, String> httpResponseBadResponse;
private Pair<Integer, String> httpResponseErr;
@@ -65,7 +65,6 @@ public class VfcManagerTest implements VfcCallback {
mockedRestManager = mock(RestManager.class);
httpResponsePutOk = mockedRestManager.new Pair<>(202, Serialization.gsonPretty.toJson(response));
- httpResponseGetOk = mockedRestManager.new Pair<>(200, Serialization.gsonPretty.toJson(response));
httpResponseBadResponse = mockedRestManager.new Pair<>(202, Serialization.gsonPretty.toJson(null));
httpResponseErr = mockedRestManager.new Pair<>(200, null);
}
@@ -131,9 +130,6 @@ public class VfcManagerTest implements VfcCallback {
VfcManager manager = new VfcManager(this, request, SOME_URL, DOROTHY, "Exception");
manager.setRestManager(mockedRestManager);
- Thread managerThread = new Thread(manager);
- managerThread.start();
-
when(mockedRestManager.post(
startsWith(SOME_URL),
eq(DOROTHY),
@@ -143,7 +139,9 @@ public class VfcManagerTest implements VfcCallback {
anyString()))
.thenThrow(new RuntimeException("OzException"));
- managerThread.join();
+ manager.run();
+
+ verify(mockedRestManager).post(any(), any(), any(), any(), any(), any());
}
@Test
@@ -151,14 +149,13 @@ public class VfcManagerTest implements VfcCallback {
VfcManager manager = new VfcManager(this, request, SOME_URL, DOROTHY, "Null");
manager.setRestManager(mockedRestManager);
- Thread managerThread = new Thread(manager);
- managerThread.start();
-
when(mockedRestManager.post(startsWith(SOME_URL),
eq(DOROTHY), eq("Null"), anyMap(), anyString(), anyString()))
.thenReturn(null);
- managerThread.join();
+ manager.run();
+
+ verify(mockedRestManager).post(any(), any(), any(), any(), any(), any());
}
@Test
@@ -166,14 +163,13 @@ public class VfcManagerTest implements VfcCallback {
VfcManager manager = new VfcManager(this, request, SOME_URL, DOROTHY, "Error0");
manager.setRestManager(mockedRestManager);
- Thread managerThread = new Thread(manager);
- managerThread.start();
-
when(mockedRestManager.post(startsWith(SOME_URL),
eq(DOROTHY), eq("Error0"), anyMap(), anyString(), anyString()))
.thenReturn(httpResponseErr);
- managerThread.join();
+ manager.run();
+
+ verify(mockedRestManager).post(any(), any(), any(), any(), any(), any());
}
@Test
@@ -181,14 +177,13 @@ public class VfcManagerTest implements VfcCallback {
VfcManager manager = new VfcManager(this, request, SOME_URL, DOROTHY, "BadResponse");
manager.setRestManager(mockedRestManager);
- Thread managerThread = new Thread(manager);
- managerThread.start();
-
when(mockedRestManager.post(startsWith(SOME_URL),
eq(DOROTHY), eq("OK"), anyMap(), anyString(), anyString()))
.thenReturn(httpResponseBadResponse);
- managerThread.join();
+ manager.run();
+
+ verify(mockedRestManager).post(any(), any(), any(), any(), any(), any());
}
@Test
@@ -196,17 +191,13 @@ public class VfcManagerTest implements VfcCallback {
VfcManager manager = new VfcManager(this, request, SOME_URL, DOROTHY, "Ok");
manager.setRestManager(mockedRestManager);
- Thread managerThread = new Thread(manager);
- managerThread.start();
-
when(mockedRestManager.post(startsWith(SOME_URL),
eq(DOROTHY), eq("OK"), anyMap(), anyString(), anyString()))
.thenReturn(httpResponsePutOk);
- when(mockedRestManager.get(endsWith("1234"), eq(DOROTHY), eq("OK"), anyMap()))
- .thenReturn(httpResponseGetOk);
+ manager.run();
- managerThread.join();
+ verify(mockedRestManager).post(any(), any(), any(), any(), any(), any());
}
@Override