Implement DMaaP message handling from policy 22/85222/3
authorkrishnaa96 <krishna.moorthy6@wipro.com>
Fri, 12 Apr 2019 14:26:25 +0000 (19:56 +0530)
committerkrishnaa96 <krishna.moorthy6@wipro.com>
Mon, 15 Apr 2019 10:19:27 +0000 (15:49 +0530)
Handling of dmaap response from policy implemented
Blueprint updated for config policy fetch
Fix sonar issues

Change-Id: I7a8a54b5d62e5db94ea2bc2d28805d8f5680d579
Issue-ID: DCAEGEN2-1427
Signed-off-by: krishnaa96 <krishna.moorthy6@wipro.com>
55 files changed:
README.md
dpo/blueprints/k8s-sonhms-inputs.yaml
dpo/blueprints/k8s-sonhms.yaml
dpo/data-formats/dmaap_son.json
dpo/data-formats/oofToSonAsyncResp-dataformat.json
dpo/data-formats/policyToSonDmaap-dataformat.json [new file with mode: 0644]
dpo/data-formats/sonToOofReq-dataformat.json
dpo/spec/sonhandler-componentspec.json
pom.xml
src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java
src/main/java/org/onap/dcaegen2/services/sonhms/Event.java
src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java
src/main/java/org/onap/dcaegen2/services/sonhms/FaultFields.java
src/main/java/org/onap/dcaegen2/services/sonhms/FaultNotificationComponent.java
src/main/java/org/onap/dcaegen2/services/sonhms/FaultNotificationtoClusterMapping.java
src/main/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponent.java
src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java
src/main/java/org/onap/dcaegen2/services/sonhms/NewPmNotification.java
src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java
src/main/java/org/onap/dcaegen2/services/sonhms/PmThread.java
src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java
src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java
src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java
src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java
src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java
src/main/java/org/onap/dcaegen2/services/sonhms/dao/HandOverMetricsRepository.java
src/main/java/org/onap/dcaegen2/services/sonhms/dao/PerformanceNotificationsRepository.java
src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java
src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/FmNotificationCallback.java [moved from src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/FMNotificationCallback.java with 63% similarity]
src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationCallback.java
src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PmNotificationCallback.java [moved from src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PMNotificationCallback.java with 63% similarity]
src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java
src/main/java/org/onap/dcaegen2/services/sonhms/entity/PerformanceNotifications.java
src/main/java/org/onap/dcaegen2/services/sonhms/model/AdditionalMeasurements.java
src/main/java/org/onap/dcaegen2/services/sonhms/model/AnrInput.java
src/main/java/org/onap/dcaegen2/services/sonhms/model/Configurations.java
src/main/java/org/onap/dcaegen2/services/sonhms/model/HoDetails.java
src/main/java/org/onap/dcaegen2/services/sonhms/model/LteNeighborListInUseLteCell.java
src/main/java/org/onap/dcaegen2/services/sonhms/model/MeasurementFields.java
src/main/java/org/onap/dcaegen2/services/sonhms/model/PmNotification.java [moved from src/main/java/org/onap/dcaegen2/services/sonhms/model/PMNotification.java with 92% similarity]
src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java
src/main/java/org/onap/dcaegen2/services/sonhms/model/Status.java [new file with mode: 0644]
src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AnrSolutions.java
src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java
src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PciSolutions.java
src/main/java/org/onap/dcaegen2/services/sonhms/restclient/Solutions.java
src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java
src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java
src/test/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponentTest.java
src/test/java/org/onap/dcaegen2/services/sonhms/PMNotificationHandlerTest.java
src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java
src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClientTest.java [new file with mode: 0644]
src/test/java/org/onap/dcaegen2/services/sonhms/model/NotificationTest.java
src/test/java/org/onap/dcaegen2/services/sonhms/model/PayloadTest.java
src/test/resources/policy_response.json [new file with mode: 0644]

index 65e28af..721274c 100644 (file)
--- a/README.md
+++ b/README.md
@@ -21,9 +21,8 @@ Variables coming from deployment system:
 - CBS_PROTOCOL - Config Binding Service protocol by default set to **http**, if it is need to change it then that can be set to different value
 - CONFIG_BINDING_SERVICE - used with conjunction with CBSPOLLTIMER, should be a name of CBS as it is registered in Consul
 - HOSTNAME - used with conjunction with CBSPOLLTIMER, should be a name of sonhms application as it is registered in CBS catalog
-
 ### Release images
-For R1 - image/version  pushed to nexus3 
+For R4 - image/version  pushed to nexus3 
 ```
 nexus3.onap.org:10001/snapshots/onap/org.onap.dcaegen2.services.son-handler   1.0.0
 ```
@@ -33,6 +32,10 @@ son handler can be manually deployed in dcae environment using cloudify blueprin
 
 login to bootstrap container in dcae deployment
 
+Copy the blueprints to the bootstrap container.
+
+The blueprint can be found under dpo/blueprints in the son-handler project.
+
 To install : 
        cfy install -b sonhms -d sonhms -i <inputs filepath> <blueprint filepath> 
 
index 052f0b9..e417c01 100644 (file)
@@ -36,9 +36,10 @@ buffer_time: 60
 cg: sonhms-cg
 cid: sonhms-cid
 config_db: http://sdnc.onap:8181
-oof: http://oof-osdf.onap:8080
+oof: http://oof-osdf.onap:8699
 pci_optimizer: pci
 log_path: /dockerdata-nfs/son-handler
+policy_id: com.Config_PCIMS_CONFIG_POLICY.1.xml
 topic00_location: onap
 topic00_client_role: son-subscriber
 topic00_client_id: sdnr-son-1
@@ -55,3 +56,7 @@ topic03_location: onap
 topic03_client_role: son-subscriber
 topic03_client_id: sdnr-son-1
 topic03_url: https://message-router.onap.svc.cluster.local:3905/events/DCAE_CL_OUTPUT
+topic04_location: onap
+topic04_client_role: son-subscriber
+topic04_client_id: sdnr-son-1
+topic04_url: https://message-router.onap.svc.cluster.local:3905/events/DCAE_CL_RSP
index 9d4e0db..d77f0fc 100644 (file)
@@ -21,6 +21,7 @@ imports:
   - "http://www.getcloudify.org/spec/cloudify/3.4/types.yaml"
   - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.5/k8splugin_types.yaml
   - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/type_files/pgaas/1.1.0/pgaas_types.yaml
+  - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml
 inputs:
   replicas:
     type: integer
@@ -77,7 +78,7 @@ inputs:
     description: threshold for poor neighbors
     default: 70
   namespace:
-    type: String
+    type: string
     description: namespace
     default: onap
   dmaap:
@@ -110,22 +111,30 @@ inputs:
     type: string
     description: log location in host
     default: /dockerdata-nfs/son-handler
+  policy_id:
+    type: string
+    description: policy id for config policy
   topic00_location:
   topic01_location:
   topic02_location:
   topic03_location:
+  topic04_location:
   topic00_client_role:
   topic01_client_role:
   topic02_client_role:
   topic03_client_role:
+  topic04_client_role:
   topic00_client_id:
   topic01_client_id:
   topic02_client_id:
   topic03_client_id:
+  topic04_client_id:
   topic00_url:
   topic01_url:
   topic02_url:
   topic03_url:
+  topic04_url:
+
   
 node_templates:
   pgaasvm:
@@ -191,6 +200,15 @@ node_templates:
               client_id: { get_input: topic02_client_id }
               topic_url: { get_input: topic02_url }
             type: message-router
+          dcae_cl_response_topic:
+            aaf_username: { get_input: aaf_username }
+            aaf_password: { get_input: aaf_password }
+            dmaap_info:
+              location: { get_input: topic04_location }
+              client_role: { get_input: topic04_client_role }
+              client_id: { get_input: topic04_client_id }
+              topic_url: { get_input: topic04_url }
+            type: message-router
         streams_publishes:
           CL_topic:
             aaf_username: { get_input: aaf_username }
@@ -234,7 +252,15 @@ node_templates:
     relationships:
       - type: cloudify.relationships.depends_on
         target: pgaasvm
-        
+      - type: cloudify.relationships.depends_on
+        target: son_policy
+
+  son_policy:
+    type: dcae.nodes.policy
+    properties:
+      policy_id:
+           get_input: policy_id
+       
       
       
         
index 7e4a950..af5fc83 100644 (file)
                        "location": "onap",
                        "topic_url": "https://HOSTNAME:3905/events/DCAE_CL_OUTPUT"
                }
-       }
+       },
+        "CL_RSP_topic": {
+                "type": "message_router",
+                "aaf_username": "",
+                "aaf_password": "",
+                "dmaap_info": {
+                        "client_role": "son-subscriber",
+                        "client_id": "policy-son-1",
+                        "location": "onap",
+                        "topic_url": "https://HOSTNAME:3905/events/DCAE_CL_RSP"
+                }
+        }
 }
index bf99528..4eb8f5a 100644 (file)
 {
-       "dataformatversion": "1.0.0",
-       "jsonschema": {
-               "$schema": "http://json-schema.org/draft-04/schema#",
-               "additionalproperties": true,
-               "description": "",
-               "properties": {
-                       "requestId": {
-                               "description": "",
-                               "type": "string"
-                       },
-                       "requestStatus": {
-                               "description": "",
-                               "type": "string"
-                       },
-                       "solutions": {
-                               "description": "",
-                               "items": {
-                                       "additionalproperties": true,
-                                       "description": "",
-                                       "properties": {
-                                               "finishTime": {
-                                                       "description": "",
-                                                       "type": "string"
-                                               },
-                                               "networkId": {
-                                                       "description": "",
-                                                       "type": "string"
-                                               },
-                                               "pciSolutions": {
-                                                       "description": "",
-                                                       "items": {
-                                                               "additionalproperties": true,
-                                                               "description": "",
-                                                               "properties": {
-                                                                       "cellId": {
-                                                                               "description": "",
-                                                                               "type": "string"
-                                                                       },
-                                                                       "pci": {
-                                                                               "description": "",
-                                                                               "type": "string"
-                                                                       }
-                                                               },
-                                                               "required": [
-                                                                       "cellId",
-                                                                       "pci"
-                                                               ],
-                                                               "type": "object"
-                                                       },
-                                                       "type": "array"
-                                               },
-                                               "startTime": {
-                                                       "description": "",
-                                                       "type": "string"
-                                               }
-                                       },
-                                       "required": [
-                                               "finishTime",
-                                               "networkId",
-                                               "pciSolutions",
-                                               "startTime"
-                                       ],
-                                       "type": "object"
-                               },
-                               "type": "array"
-                       },
-                       "statusMessage": {
-                               "description": "",
-                               "type": "string"
-                       },
-                       "transactionId": {
-                               "description": "",
-                               "type": "string"
-                       }
-               },
-               "required": [
-                       "requestId",
-                       "requestStatus",
-                       "solutions",
-                       "statusMessage",
-                       "transactionId"
-               ],
-               "type": "object"
-       },
-       "self": {
-               "description": "",
-               "name": "SON_OOF_ASYNC_RESP",
-               "version": "1.0.0"
-       }
+    "dataformatversion": "1.0.0", 
+    "jsonschema": {
+        "$schema": "http://json-schema.org/draft-04/schema#", 
+        "additionalproperties": true, 
+        "description": "", 
+        "properties": {
+            "requestId": {
+                "description": "", 
+                "type": "string"
+            }, 
+            "requestStatus": {
+                "description": "", 
+                "type": "string"
+            }, 
+            "solutions": {
+                "additionalproperties": true, 
+                "description": "", 
+                "properties": {
+                    "anrSolutions": {
+                        "description": "", 
+                        "items": {
+                            "additionalproperties": true, 
+                            "description": "", 
+                            "properties": {
+                                "cellId": {
+                                    "description": "", 
+                                    "type": "string"
+                                }, 
+                                "removeableNeighbors": {
+                                    "description": "", 
+                                    "items": {
+                                        "description": "", 
+                                        "type": "string"
+                                    }, 
+                                    "type": "array"
+                                }
+                            }, 
+                            "required": [
+                                "cellId", 
+                                "removeableNeighbors"
+                            ], 
+                            "type": "object"
+                        }, 
+                        "type": "array"
+                    }, 
+                    "networkId": {
+                        "description": "", 
+                        "type": "string"
+                    }, 
+                    "pciSolutions": {
+                        "description": "", 
+                        "items": {
+                            "additionalproperties": true, 
+                            "description": "", 
+                            "properties": {
+                                "cellId": {
+                                    "description": "", 
+                                    "type": "string"
+                                }, 
+                                "pci": {
+                                    "description": "", 
+                                    "type": "string"
+                                }
+                            }, 
+                            "required": [
+                                "cellId", 
+                                "pci"
+                            ], 
+                            "type": "object"
+                        }, 
+                        "type": "array"
+                    }
+                }, 
+                "required": [
+                    "anrSolutions", 
+                    "networkId", 
+                    "pciSolutions"
+                ], 
+                "type": "object"
+            }, 
+            "statusMessage": {
+                "description": "", 
+                "type": "string"
+            }, 
+            "transactionId": {
+                "description": "", 
+                "type": "string"
+            }
+        }, 
+        "required": [
+            "requestId", 
+            "requestStatus", 
+            "solutions", 
+            "statusMessage", 
+            "transactionId"
+        ], 
+        "type": "object"
+    }, 
+    "self": {
+        "description": "", 
+        "name": "SON_OOF_ASYNC_RESP", 
+        "version": "1.0.0"
+    }
 }
diff --git a/dpo/data-formats/policyToSonDmaap-dataformat.json b/dpo/data-formats/policyToSonDmaap-dataformat.json
new file mode 100644 (file)
index 0000000..28588a1
--- /dev/null
@@ -0,0 +1,58 @@
+{
+    "dataformatversion": "1.0.0", 
+    "jsonschema": {
+        "$schema": "http://json-schema.org/draft-04/schema#", 
+        "additionalproperties": true, 
+        "description": "", 
+        "properties": {
+            "closedLoopControlName": {
+                "description": "", 
+                "type": "string"
+            }, 
+            "from": {
+                "description": "", 
+                "type": "string"
+            }, 
+            "payload": {
+                "description": "", 
+                "type": "string"
+            }, 
+            "policyName": {
+                "description": "", 
+                "type": "string"
+            }, 
+            "policyVersion": {
+                "description": "", 
+                "type": "string"
+            }, 
+            "requestID": {
+                "description": "", 
+                "type": "string"
+            }, 
+            "target": {
+                "description": "", 
+                "type": "string"
+            }, 
+            "version": {
+                "description": "", 
+                "type": "string"
+            }
+        }, 
+        "required": [
+            "closedLoopControlName", 
+            "from", 
+            "payload", 
+            "policyName", 
+            "policyVersion", 
+            "requestID", 
+            "target", 
+            "version"
+        ], 
+        "type": "object"
+    }, 
+    "self": {
+        "description": "", 
+        "name": "POLICY_TO_SON_DMAAP", 
+        "version": "1.0.0"
+    }
+}
index e686dd1..d91edae 100644 (file)
 {
-       "dataformatversion": "1.0.0",
-       "jsonschema": {
-               "$schema": "http://json-schema.org/draft-04/schema#",
-               "additionalproperties": true,
-               "description": "",
-               "properties": {
-                       "cellInfo": {
-                               "additionalproperties": true,
-                               "description": "",
-                               "properties": {
-                                       "cellIdList": {
-                                               "description": "",
-                                               "items": {
-                                                       "description": "",
-                                                       "type": "string"
-                                               },
-                                               "type": "array"
-                                       },
-                                       "networkId": {
-                                               "description": "",
-                                               "type": "string"
-                                       }
-                               },
-                               "required": [
-                                       "cellIdList",
-                                       "networkId"
-                               ],
-                               "type": "object"
-                       },
-                       "requestInfo": {
-                               "additionalproperties": true,
-                               "description": "",
-                               "properties": {
-                                       "callbackUrl": {
-                                               "description": "",
-                                               "type": "string"
-                                       },
-                                       "numSolutions": {
-                                               "description": "",
-                                               "type": "integer"
-                                       },
-                                       "optimizers": {
-                                               "description": "",
-                                               "items": {
-                                                       "description": "",
-                                                       "type": "string"
-                                               },
-                                               "type": "array"
-                                       },
-                                       "requestId": {
-                                               "description": "",
-                                               "type": "string"
-                                       },
-                                       "requestType": {
-                                               "description": "",
-                                               "type": "string"
-                                       },
-                                       "sourceId": {
-                                               "description": "",
-                                               "type": "string"
-                                       },
-                                       "timeout": {
-                                               "description": "",
-                                               "type": "integer"
-                                       },
-                                       "transactionId": {
-                                               "description": "",
-                                               "type": "string"
-                                       }
-                               },
-                               "required": [
-                                       "callbackUrl",
-                                       "numSolutions",
-                                       "optimizers",
-                                       "requestId",
-                                       "requestType",
-                                       "sourceId",
-                                       "timeout",
-                                       "transactionId"
-                               ],
-                               "type": "object"
-                       }
-               },
-               "required": [
-                       "cellInfo",
-                       "requestInfo"
-               ],
-               "type": "object"
-       },
-       "self": {
-               "description": "",
-               "name": "SON_TO_OOF_REST_REQ",
-               "version": "1.0.0"
-       }
+    "dataformatversion": "1.0.0", 
+    "jsonschema": {
+        "$schema": "http://json-schema.org/draft-04/schema#", 
+        "additionalproperties": true, 
+        "description": "", 
+        "properties": {
+            "cellInfo": {
+                "additionalproperties": true, 
+                "description": "", 
+                "properties": {
+                    "anrInputList": {
+                        "description": "", 
+                        "items": {
+                            "additionalproperties": true, 
+                            "description": "", 
+                            "properties": {
+                                "cellId": {
+                                    "description": "", 
+                                    "type": "string"
+                                }, 
+                                "removeableNeighbors": {
+                                    "description": "", 
+                                    "items": {
+                                        "description": "", 
+                                        "type": "string"
+                                    }, 
+                                    "type": "array"
+                                }
+                            }, 
+                            "required": [
+                                "cellId", 
+                                "removeableNeighbors"
+                            ], 
+                            "type": "object"
+                        }, 
+                        "type": "array"
+                    }, 
+                    "cellIdList": {
+                        "description": "", 
+                        "items": {
+                            "description": "", 
+                            "type": "string"
+                        }, 
+                        "type": "array"
+                    }, 
+                    "networkId": {
+                        "description": "", 
+                        "type": "integer"
+                    }, 
+                    "trigger": {
+                        "description": "", 
+                        "type": "string"
+                    }
+                }, 
+                "required": [
+                    "anrInputList", 
+                    "cellIdList", 
+                    "networkId", 
+                    "trigger"
+                ], 
+                "type": "object"
+            }, 
+            "requestInfo": {
+                "additionalproperties": true, 
+                "description": "", 
+                "properties": {
+                    "callbackHeader": {
+                        "additionalproperties": true, 
+                        "description": "", 
+                        "properties": {
+                            "blob": {
+                                "description": "", 
+                                "type": "string"
+                            }
+                        }, 
+                        "required": [
+                            "blob"
+                        ], 
+                        "type": "object"
+                    }, 
+                    "callbackUrl": {
+                        "description": "", 
+                        "type": "string"
+                    }, 
+                    "numSolutions": {
+                        "description": "", 
+                        "type": "integer"
+                    }, 
+                    "optimizers": {
+                        "description": "", 
+                        "items": {
+                            "description": "", 
+                            "type": "string"
+                        }, 
+                        "type": "array"
+                    }, 
+                    "requestId": {
+                        "description": "", 
+                        "type": "string"
+                    }, 
+                    "requestType": {
+                        "description": "", 
+                        "type": "string"
+                    }, 
+                    "sourceId": {
+                        "description": "", 
+                        "type": "string"
+                    }, 
+                    "timeout": {
+                        "description": "", 
+                        "type": "integer"
+                    }, 
+                    "transactionId": {
+                        "description": "", 
+                        "type": "string"
+                    }
+                }, 
+                "required": [
+                    "callbackHeader", 
+                    "callbackUrl", 
+                    "numSolutions", 
+                    "optimizers", 
+                    "requestId", 
+                    "requestType", 
+                    "sourceId", 
+                    "timeout", 
+                    "transactionId"
+                ], 
+                "type": "object"
+            }
+        }, 
+        "required": [
+            "cellInfo", 
+            "requestInfo"
+        ], 
+        "type": "object"
+    }, 
+    "self": {
+        "description": "", 
+        "name": "SON_TO_OOF_REST_REQ", 
+        "version": "1.0.0"
+    }
 }
-
index 6fc51be..2d23fb8 100644 (file)
                                "version": "1.0.0",
                                "route": "/callbackUrl",
                                "type": "http"
-                       }
+                       },
+                        {
+                                "format": "POLICY_TO_SON_DMAAP",
+                                "version": "1.0.0",
+                                "config_key": "CL_RSP_topic",
+                                "type": "message router"
+                        }
                ],
                "publishes": [
                        {
                        "designer_editable": false
                },
                {
-                       "name": "sonhandler.callbackUrl",
-                       "value": "http://sonhms.onap:8080/callbackUrl",
-                       "description": "sonhms callback url",
+                       "name": "sonhandler.namespace",
+                       "value": "onap",
+                       "description": "namespace where MS will be deployed",
                        "sourced_at_deployment": false,
                        "policy_editable": false,
                        "designer_editable": false
diff --git a/pom.xml b/pom.xml
index f87e777..e12462e 100644 (file)
--- a/pom.xml
+++ b/pom.xml
                        <version>1.4.0.RELEASE</version>
                </dependency>
 
-
-
-               <!-- https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-mapper-asl -->
-               <dependency>
-                       <groupId>org.codehaus.jackson</groupId>
-                       <artifactId>jackson-mapper-asl</artifactId>
-                       <version>1.9.13</version>
-               </dependency>
                <dependency>
                        <groupId>org.hibernate.javax.persistence</groupId>
                        <artifactId>hibernate-jpa-2.0-api</artifactId>
index 39cfbd1..a5d8ba7 100644 (file)
@@ -29,7 +29,7 @@ import java.io.IOException;
 import org.onap.dcaegen2.services.sonhms.dao.DmaapNotificationsRepository;
 import org.onap.dcaegen2.services.sonhms.dao.PerformanceNotificationsRepository;
 import org.onap.dcaegen2.services.sonhms.model.Notification;
-import org.onap.dcaegen2.services.sonhms.model.PMNotification;
+import org.onap.dcaegen2.services.sonhms.model.PmNotification;
 import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -39,7 +39,7 @@ public class DmaapNotificationsComponent {
     private static Logger log = LoggerFactory.getLogger(DmaapNotificationsComponent.class);
     
     /**
-     * Get sdnr notifications
+     * Get sdnr notifications.
      */
     public Either<Notification, Integer> getSdnrNotifications() {
         DmaapNotificationsRepository dmaapNotificationsRepository = BeanUtil
@@ -61,21 +61,22 @@ public class DmaapNotificationsComponent {
     }
     
     /**
-     * Get pm notifications
+     * Get pm notifications.
      */
-    public Either<PMNotification,Integer> getPmNotifications(){
-        PerformanceNotificationsRepository pmNotificationRepository = BeanUtil.getBean(PerformanceNotificationsRepository.class);
+    public Either<PmNotification,Integer> getPmNotifications() {
+        PerformanceNotificationsRepository pmNotificationRepository =
+                BeanUtil.getBean(PerformanceNotificationsRepository.class);
         String pmNotificationString = pmNotificationRepository.getPerformanceNotificationFromQueue();
         if (pmNotificationString == null) {
             return Either.right(404);
         }
         ObjectMapper mapper = new ObjectMapper();        
-        PMNotification pmNotification = new PMNotification();
+        PmNotification pmNotification = new PmNotification();
         
         try {
-            pmNotification = mapper.readValue(pmNotificationString, PMNotification.class);
+            pmNotification = mapper.readValue(pmNotificationString, PmNotification.class);
             return Either.left(pmNotification);
-        } catch(IOException e) {
+        } catch (IOException e)  {
             log.error("Exception in parsing pm notification ",pmNotificationString,e);
             return Either.right(400);
         }
index 84b8eee..3a71f2b 100644 (file)
  *     ============LICENSE_END=========================================================
  *  
  *******************************************************************************/
+
 package org.onap.dcaegen2.services.sonhms;
 
 public class Event {
-       private CommonEventHeader commonEventHeader;
-       private FaultFields faultFields;
-       public CommonEventHeader getCommonEventHeader() {
-               return commonEventHeader;
-       }
-       public void setCommonEventHeader(CommonEventHeader commonEventHeader) {
-               this.commonEventHeader = commonEventHeader;
-       }
-       public FaultFields getFaultFields() {
-               return faultFields;
-       }
-       public void setFaultFields(FaultFields faultFields) {
-               this.faultFields = faultFields;
-       }
+    private CommonEventHeader commonEventHeader;
+    private FaultFields faultFields;
+
+    public CommonEventHeader getCommonEventHeader() {
+        return commonEventHeader;
+    }
+
+    public void setCommonEventHeader(CommonEventHeader commonEventHeader) {
+        this.commonEventHeader = commonEventHeader;
+    }
+
+    public FaultFields getFaultFields() {
+        return faultFields;
+    }
+
+    public void setFaultFields(FaultFields faultFields) {
+        this.faultFields = faultFields;
+    }
+
     @Override
     public String toString() {
         return "Event [commonEventHeader=" + commonEventHeader + ", faultFields=" + faultFields + "]";
     }
-       
-       
+
 }
index bcd9e92..c96cbc8 100644 (file)
@@ -106,7 +106,8 @@ public class EventHandler {
 
         faultNotificationtoClusterMapping.setCollisionConfusionMap(collisionConfusionMap);
         // matching cells
-        if (faultNotificationtoClusterMapping.getCellsinCluster() != null && !faultNotificationtoClusterMapping.getCellsinCluster().isEmpty()) {
+        if (faultNotificationtoClusterMapping.getCellsinCluster() != null 
+                && !faultNotificationtoClusterMapping.getCellsinCluster().isEmpty()) {
             try {
                 handleMatchedFmCells(faultNotificationtoClusterMapping, clusterDetails);
             } catch (ConfigDbNotFoundException e) {
@@ -115,7 +116,8 @@ public class EventHandler {
 
         }
         // unmatched new cells
-        if (faultNotificationtoClusterMapping.getNewCells() != null && !faultNotificationtoClusterMapping.getNewCells().isEmpty()) {
+        if (faultNotificationtoClusterMapping.getNewCells() != null 
+                && !faultNotificationtoClusterMapping.getNewCells().isEmpty()) {
             handleUnmatchedFmCells(faultNotificationtoClusterMapping, networkId);
 
         }
@@ -161,8 +163,6 @@ public class EventHandler {
     /**
      * handle unmatched fm cells.
      * 
-     * @param networkId2
-     * @param faultNotificationtoClusterMapping
      */
     private void handleUnmatchedFmCells(FaultNotificationtoClusterMapping faultNotificationtoClusterMapping,
             String networkId) {
@@ -175,7 +175,7 @@ public class EventHandler {
                     .get(cellId);
             log.info("Handle Unmatching cells for FM notificatins,collisionConfusionCount{}", collisionConfusionCount);
 
-            Either<Graph, Integer> existingCluster = clusterUtils.getClusterForFMCell(cellId, newClusters);
+            Either<Graph, Integer> existingCluster = clusterUtils.getClusterForFmCell(cellId, newClusters);
             if (existingCluster.isRight()) {
                 try {
                     Map<CellPciPair, ArrayList<CellPciPair>> clusterMap = clusterUtils.findClusterMap(cellId);
index c1649b2..a2c877d 100644 (file)
@@ -23,7 +23,7 @@ package org.onap.dcaegen2.services.sonhms;
 
 public class FaultFields {
 
-       @Override
+    @Override
     public String toString() {
         return "FaultFields [faultFieldsVersion=" + faultFieldsVersion + ", alarmCondition=" + alarmCondition
                 + ", eventSourceType=" + eventSourceType + ", specificProblem=" + specificProblem + ", eventSeverity="
@@ -32,13 +32,12 @@ public class FaultFields {
     }
 
     private double faultFieldsVersion;
-       private String alarmCondition;
-       private String eventSourceType;
-       private String specificProblem;
-       private String eventSeverity;
-       private String vfStatus;
-       private AlarmAdditionalInformation alarmAdditionalInformation;
-       
+    private String alarmCondition;
+    private String eventSourceType;
+    private String specificProblem;
+    private String eventSeverity;
+    private String vfStatus;
+    private AlarmAdditionalInformation alarmAdditionalInformation;
 
     public AlarmAdditionalInformation getAlarmAdditionalInformation() {
         return alarmAdditionalInformation;
@@ -49,51 +48,51 @@ public class FaultFields {
     }
 
     public double getFaultFieldsVersion() {
-               return faultFieldsVersion;
-       }
+        return faultFieldsVersion;
+    }
 
-       public void setFaultFieldsVersion(double faultFieldsVersion) {
-               this.faultFieldsVersion = faultFieldsVersion;
-       }
+    public void setFaultFieldsVersion(double faultFieldsVersion) {
+        this.faultFieldsVersion = faultFieldsVersion;
+    }
 
-       public String getAlarmCondition() {
-               return alarmCondition;
-       }
+    public String getAlarmCondition() {
+        return alarmCondition;
+    }
 
-       public void setAlarmCondition(String alarmCondition) {
-               this.alarmCondition = alarmCondition;
-       }
+    public void setAlarmCondition(String alarmCondition) {
+        this.alarmCondition = alarmCondition;
+    }
 
-       public String getEventSourceType() {
-               return eventSourceType;
-       }
+    public String getEventSourceType() {
+        return eventSourceType;
+    }
 
-       public void setEventSourceType(String eventSourceType) {
-               this.eventSourceType = eventSourceType;
-       }
+    public void setEventSourceType(String eventSourceType) {
+        this.eventSourceType = eventSourceType;
+    }
 
-       public String getSpecificProblem() {
-               return specificProblem;
-       }
+    public String getSpecificProblem() {
+        return specificProblem;
+    }
 
-       public void setSpecificProblem(String specificProblem) {
-               this.specificProblem = specificProblem;
-       }
+    public void setSpecificProblem(String specificProblem) {
+        this.specificProblem = specificProblem;
+    }
 
-       public String getEventSeverity() {
-               return eventSeverity;
-       }
+    public String getEventSeverity() {
+        return eventSeverity;
+    }
 
-       public void setEventSeverity(String eventSeverity) {
-               this.eventSeverity = eventSeverity;
-       }
+    public void setEventSeverity(String eventSeverity) {
+        this.eventSeverity = eventSeverity;
+    }
 
-       public String getVfStatus() {
-               return vfStatus;
-       }
+    public String getVfStatus() {
+        return vfStatus;
+    }
 
-       public void setVfStatus(String vfStatus) {
-               this.vfStatus = vfStatus;
-       }
+    public void setVfStatus(String vfStatus) {
+        this.vfStatus = vfStatus;
+    }
 
 }
index 99695ab..d1bf351 100644 (file)
@@ -36,35 +36,35 @@ import org.slf4j.LoggerFactory;
 
 public class FaultNotificationComponent {
 
-       private static Logger log = LoggerFactory.getLogger(FaultNotificationComponent.class);
+    private static Logger log = LoggerFactory.getLogger(FaultNotificationComponent.class);
 
-       /**
-        * Get fault notifications.
-        */
-       public Either<List<FaultEvent>,Integer> getFaultNotifications() {
-               FaultNotificationsRepository faultNotificationsRepository = BeanUtil
-                               .getBean(FaultNotificationsRepository.class);
-               String notificationString = faultNotificationsRepository.getFaultNotificationFromQueue();
-               log.info("get fault notifications method");
-               if (notificationString == null) {
-                   return Either.right(404);
-               }
-               ObjectMapper mapper = new ObjectMapper();
-               FaultEvent faultEvent = new FaultEvent();
-               List<FaultEvent> faultEvents = new ArrayList<>();
-               try {
-            faultEvent = mapper.readValue(notificationString,FaultEvent.class);
+    /**
+     * Get fault notifications.
+     */
+    public Either<List<FaultEvent>, Integer> getFaultNotifications() {
+        FaultNotificationsRepository faultNotificationsRepository = BeanUtil
+                .getBean(FaultNotificationsRepository.class);
+        String notificationString = faultNotificationsRepository.getFaultNotificationFromQueue();
+        log.info("get fault notifications method");
+        if (notificationString == null) {
+            return Either.right(404);
+        }
+        ObjectMapper mapper = new ObjectMapper();
+        FaultEvent faultEvent = new FaultEvent();
+        List<FaultEvent> faultEvents = new ArrayList<>();
+        try {
+            faultEvent = mapper.readValue(notificationString, FaultEvent.class);
             log.info("Parsing FM notification");
-            
+
         } catch (IOException e) {
             log.error("Exception in parsing Notification {}", e);
             return Either.right(400);
         }
-               
-               faultEvents.add(faultEvent);
-               
-               return Either.left(faultEvents);
 
-       }
+        faultEvents.add(faultEvent);
+
+        return Either.left(faultEvents);
+
+    }
 
 }
index 5e59467..1ac6715 100644 (file)
@@ -27,26 +27,26 @@ import java.util.Map;
 
 public class FaultNotificationtoClusterMapping {
     public Map<String, String> getCellsinCluster() {
-               return cellsinCluster;
-       }
+        return cellsinCluster;
+    }
+
+    public void setCellsinCluster(Map<String, String> cellsinCluster) {
+        this.cellsinCluster = cellsinCluster;
+    }
 
-       public void setCellsinCluster(Map<String, String> cellsinCluster) {
-               this.cellsinCluster = cellsinCluster;
-       }
+    public List<String> getNewCells() {
+        return newCells;
+    }
 
-       public List<String> getNewCells() {
-               return newCells;
-       }
+    public void setNewCells(List<String> newCells) {
+        this.newCells = newCells;
+    }
 
-       public void setNewCells(List<String> newCells) {
-               this.newCells = newCells;
-       }
-       
-       private Map<String, ArrayList<Integer>> collisionConfusionMap;
+    private Map<String, ArrayList<Integer>> collisionConfusionMap;
 
-       //map that returns cellid and its matching cluster id
+    // map that returns cellid and its matching cluster id
 
-       public Map<String, ArrayList<Integer>> getCollisionConfusionMap() {
+    public Map<String, ArrayList<Integer>> getCollisionConfusionMap() {
         return collisionConfusionMap;
     }
 
@@ -55,7 +55,7 @@ public class FaultNotificationtoClusterMapping {
     }
 
     private Map<String, String> cellsinCluster;
-    
-       //cells that dont match
+
+    // cells that dont match
     private List<String> newCells;
 }
index d27227f..cf1cf45 100644 (file)
@@ -57,7 +57,8 @@ public class HoMetricsComponent {
                 log.error("Exception in parsing HO metrics", hoDetailsString, e);
                 return Either.right(400);
             }
-        } else
+        } else {
             return Either.right(404);
+        }
     }
 }
index 6cbb711..43c8e3d 100644 (file)
@@ -55,7 +55,7 @@ public class MainThread implements Runnable {
 
     private EventHandler eventHandler;
 
-    private Map<String, FaultEvent> bufferedFMNotificationCells;
+    private Map<String, FaultEvent> bufferedFmNotificationCells;
 
     private List<String> sdnrNotificationCells;
 
@@ -77,7 +77,7 @@ public class MainThread implements Runnable {
         faultNotificationComponent = new FaultNotificationComponent();
         sdnrNotificationCells = new ArrayList<>();
         fmNotificationToBuffer = new ArrayList<>();
-        bufferedFMNotificationCells = new HashMap<>();
+        bufferedFmNotificationCells = new HashMap<>();
         eventHandler = new EventHandler(childStatusQueue,
                 Executors.newFixedThreadPool(Configuration.getInstance().getMaximumClusters()), new HashMap<>(),
                 new ClusterUtils(), new ThreadUtils());
@@ -101,15 +101,14 @@ public class MainThread implements Runnable {
                 if (difference > 5000) {
                     log.info("FM handling difference > 5000");
 
-                    for (String sdnrCell: sdnrNotificationCells) {
-                        bufferedFMNotificationCells.remove(sdnrCell);
+                    for (String sdnrCell : sdnrNotificationCells) {
+                        bufferedFmNotificationCells.remove(sdnrCell);
                     }
-                    
-                    log.info("FM bufferedFMNotificationCells {}", bufferedFMNotificationCells.values());
-                    List<FaultEvent> fmNotificationsToHandle = new ArrayList<>(
-                            bufferedFMNotificationCells.values());
+
+                    log.info("FM bufferedFMNotificationCells {}", bufferedFmNotificationCells.values());
+                    List<FaultEvent> fmNotificationsToHandle = new ArrayList<>(bufferedFmNotificationCells.values());
                     Boolean result = eventHandler.handleFaultNotification(fmNotificationsToHandle);
-                    bufferedFMNotificationCells = new HashMap<>();
+                    bufferedFmNotificationCells = new HashMap<>();
                     isTimer = false;
                     log.info("FM notification handling {}", result);
                 }
@@ -160,21 +159,21 @@ public class MainThread implements Runnable {
                     } else {
                         for (FaultEvent fmNotification : fmNotifications.left().value()) {
                             faultCellId = fmNotification.getEvent().getCommonEventHeader().getSourceName();
-                            bufferedFMNotificationCells.put(faultCellId, fmNotification);
+                            bufferedFmNotificationCells.put(faultCellId, fmNotification);
                             log.info("Buffered FM cell {}", faultCellId);
                             log.info("fmNotification{}", fmNotification);
 
                         }
                         log.info("bufferedFMNotificationCells before staring timer {}",
-                                bufferedFMNotificationCells.keySet());
+                                bufferedFmNotificationCells.keySet());
 
-                        for (String sdnrCell: sdnrNotificationCells) {
-                                bufferedFMNotificationCells.remove(sdnrCell);
+                        for (String sdnrCell : sdnrNotificationCells) {
+                            bufferedFmNotificationCells.remove(sdnrCell);
                         }
-                        
+
                         startTimer = new Timestamp(System.currentTimeMillis());
                         isTimer = true;
-                        log.info("Buffered FM cell {}", bufferedFMNotificationCells.keySet());
+                        log.info("Buffered FM cell {}", bufferedFmNotificationCells.keySet());
                     }
 
                 }
index ce583dd..374e615 100644 (file)
@@ -27,29 +27,29 @@ import org.springframework.stereotype.Component;
 
 @Component
 public class NewPmNotification {
-       
+
     private Boolean newNotif;
-        
+
     @PostConstruct
     public void init() {
-        newNotif=false;
+        newNotif = false;
     }
 
     public Boolean getNewNotif() {
-            return newNotif;
-        }
+        return newNotif;
+    }
 
     public void setNewNotif(Boolean newNotif) {
-            this.newNotif = newNotif;
+        this.newNotif = newNotif;
     }
 
-       public NewPmNotification(Boolean newNotif) {
+    public NewPmNotification(Boolean newNotif) {
         super();
         this.newNotif = newNotif;
     }
-           
+
     public NewPmNotification() {
-               
+
     }
 
 }
index 0df0bdb..e2223d7 100644 (file)
@@ -43,16 +43,17 @@ import org.onap.dcaegen2.services.sonhms.model.HoDetails;
 import org.onap.dcaegen2.services.sonhms.model.Lte;
 import org.onap.dcaegen2.services.sonhms.model.LteCell;
 import org.onap.dcaegen2.services.sonhms.model.NeighborListInUse;
-import org.onap.dcaegen2.services.sonhms.model.PMNotification;
 import org.onap.dcaegen2.services.sonhms.model.Payload;
+import org.onap.dcaegen2.services.sonhms.model.PmNotification;
 import org.onap.dcaegen2.services.sonhms.model.Ran;
 import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
+import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class PmNotificationHandler {
 
-    private static Logger log = LoggerFactory.getLogger(DmaapNotificationsComponent.class);
+    private static Logger log = LoggerFactory.getLogger(PmNotificationHandler.class);
     PolicyDmaapClient policyDmaapClient;
 
     public PmNotificationHandler() {
@@ -66,7 +67,7 @@ public class PmNotificationHandler {
     /**
      * handle PM notifications.
      */
-    public Boolean handlePmNotifications(PMNotification pmNotification, int badThreshold) {
+    public Boolean handlePmNotifications(PmNotification pmNotification, int badThreshold) {
         HandOverMetricsRepository handOverMetricsRepository = BeanUtil.getBean(HandOverMetricsRepository.class);
         Boolean result;
         try {
@@ -75,10 +76,8 @@ public class PmNotificationHandler {
             String srcCellId = pmNotification.getEvent().getCommonEventHeader().getSourceName();
             for (AdditionalMeasurements additionalMeasurements : pmNotification.getEvent().getMeasurementFields()
                     .getAdditionalMeasurements()) {
-                int attemptsCount = Integer
-                        .parseInt(additionalMeasurements.getHashMap().get("InterEnbOutAtt_X2HO"));
-                int successCount = Integer
-                        .parseInt(additionalMeasurements.getHashMap().get("InterEnbOutSucc_X2HO"));
+                int attemptsCount = Integer.parseInt(additionalMeasurements.getHashMap().get("InterEnbOutAtt_X2HO"));
+                int successCount = Integer.parseInt(additionalMeasurements.getHashMap().get("InterEnbOutSucc_X2HO"));
                 float successRate = ((float) successCount / attemptsCount) * 100;
                 if (successRate >= badThreshold) {
                     HoDetails hoDetails = new HoDetails();
@@ -101,7 +100,7 @@ public class PmNotificationHandler {
             if (!lteCellList.isEmpty()) {
                 log.info("triggering policy to remove bad neighbors");
                 Flag policyTriggerFlag = BeanUtil.getBean(Flag.class);
-                
+
                 while (policyTriggerFlag.getHolder().equals("CHILD")) {
                     Thread.sleep(100);
                 }
@@ -138,27 +137,34 @@ public class PmNotificationHandler {
 
     }
 
-    private Boolean sendAnrUpdateToPolicy(PMNotification pmNotification, List<LteCell> lteCellList) {
+    private Boolean sendAnrUpdateToPolicy(PmNotification pmNotification, List<LteCell> lteCellList) {
         ObjectMapper mapper = new ObjectMapper();
         try {
             mapper.setSerializationInclusion(Include.NON_NULL);
             ArrayList<Configurations> configurations = new ArrayList<>();
             String cellId = pmNotification.getEvent().getCommonEventHeader().getSourceName();
             Configurations configuration = new Configurations(
-                    new Data(new FapService(cellId, null, new CellConfig(new Lte(new Ran(new Common(cellId),
-                            new NeighborListInUse(null, lteCellList, String.valueOf(lteCellList.size()))))))));
+                    new Data(new FapService(cellId, null,
+                            new CellConfig(new Lte(new Ran(new Common(cellId),
+                                    new NeighborListInUse(null, lteCellList, String.valueOf(lteCellList.size()))))))),
+                    null);
             configurations.add(configuration);
             Payload payload = new Payload(configurations);
             log.info("payload : {}", payload);
             String anrUpdateString = mapper.writeValueAsString(payload);
             ChildThreadUtils childUtils = new ChildThreadUtils(ConfigPolicy.getInstance(), new PnfUtils(),
-                    new PolicyDmaapClient());
-            String notification = childUtils.getNotificationString(pmNotification.getEvent().getCommonEventHeader().getReportingEntityName(), UUID.randomUUID().toString(), anrUpdateString,
-                    System.currentTimeMillis(), "ModifyConfigANR");
+                    new PolicyDmaapClient(new DmaapUtils(), Configuration.getInstance()));
+            String requestId = UUID.randomUUID().toString();
+            String notification = childUtils.getNotificationString(
+                    pmNotification.getEvent().getCommonEventHeader().getReportingEntityName(), requestId,
+                    anrUpdateString, System.currentTimeMillis(), "ModifyConfigANR");
             log.info("Policy Notification: {}", notification);
             Boolean result = policyDmaapClient.sendNotificationToPolicy(notification);
             log.info("send notification to policy result {} ", result);
-            
+            // getting policy response
+            policyDmaapClient.handlePolicyResponse(requestId);
+            log.info("handled policy response");
+
         } catch (Exception e) {
             log.error("Exception in sending Anr update to policy ", e);
             return false;
index d2d509f..49f0c56 100644 (file)
@@ -24,7 +24,8 @@ package org.onap.dcaegen2.services.sonhms;
 import fj.data.Either;
 
 import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient;
-import org.onap.dcaegen2.services.sonhms.model.PMNotification;
+import org.onap.dcaegen2.services.sonhms.model.PmNotification;
+import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -46,7 +47,8 @@ public class PmThread implements Runnable {
         super();
         this.newPmNotification = newPmNotification;
         dmaapNotificationsComponent = new DmaapNotificationsComponent();
-        pmNotificationHandler = new PmNotificationHandler(new PolicyDmaapClient());
+        pmNotificationHandler = new PmNotificationHandler(new PolicyDmaapClient(new DmaapUtils(), 
+                Configuration.getInstance()));
     }
 
     @Override
@@ -59,7 +61,7 @@ public class PmThread implements Runnable {
                 Thread.sleep(1000);
                 if (newPmNotification.getNewNotif()) {
                     log.info("New PM notification from Dmaap");
-                    Either<PMNotification, Integer> pmNotification = dmaapNotificationsComponent.getPmNotifications();
+                    Either<PmNotification, Integer> pmNotification = dmaapNotificationsComponent.getPmNotifications();
                     if (pmNotification.isRight()) {
                         if (pmNotification.right().value() == 400) {
                             log.error("error parsing pm notifications");
index 15a2881..b053467 100644 (file)
@@ -55,6 +55,7 @@ import org.onap.dcaegen2.services.sonhms.model.ThreadId;
 import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody;
 import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
 import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils;
+import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils;
 import org.slf4j.Logger;
 import org.slf4j.MDC;
 
@@ -149,7 +150,7 @@ public class ChildThread implements Runnable {
         ClusterUtils clusterUtils = new ClusterUtils();
         Detection detect = new Detection();
         ChildThreadUtils childUtils = new ChildThreadUtils(ConfigPolicy.getInstance(), new PnfUtils(),
-                new PolicyDmaapClient());
+                new PolicyDmaapClient(new DmaapUtils(), Configuration.getInstance()));
 
         try {
             String networkId = cluster.getNetworkId();
@@ -167,9 +168,9 @@ public class ChildThread implements Runnable {
 
                 Boolean trigger = childUtils.triggerOrWait(collisionConfusionResult);
                 ConfigPolicy configPolicy = ConfigPolicy.getInstance();
-                int timer = 60;
+                double timer = 60;
                 try {
-                    timer = (int) configPolicy.getConfig().get("PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS");
+                    timer = (double) configPolicy.getConfig().get("PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS");
                 } catch (NullPointerException e) {
                     log.info("Policy config not available. Using default timeout - 60 seconds");
                 }
index 1acfde6..183de84 100644 (file)
@@ -111,9 +111,9 @@ public class ChildThreadUtils {
      * get policy notification string from oof result.
      *
      */
-    public String getNotificationString(String pnfName, String requestId, String payloadString,
-            Long alarmStartTime, String action) {
-        
+    public String getNotificationString(String pnfName, String requestId, String payloadString, Long alarmStartTime,
+            String action) {
+
         String closedLoopControlName = "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459";
         try {
             closedLoopControlName = (String) configPolicy.getConfig().get("PCI_MODCONFIG_POLICY_NAME");
@@ -127,6 +127,7 @@ public class ChildThreadUtils {
         policyNotification.setClosedLoopControlName(closedLoopControlName);
         policyNotification.setPayload(payloadString);
         ObjectMapper mapper = new ObjectMapper();
+        mapper.setSerializationInclusion(Include.NON_NULL);
 
         String notification = "";
         try {
@@ -161,7 +162,8 @@ public class ChildThreadUtils {
                     String cellId = cellPciPair.getCellId();
                     int pci = cellPciPair.getPhysicalCellId();
                     Configurations configuration = new Configurations(new Data(new FapService(cellId,
-                            new X0005b9Lte(pci, pnfName), new CellConfig(new Lte(new Ran(new Common(cellId), null))))));
+                            new X0005b9Lte(pci, pnfName), new CellConfig(new Lte(new Ran(new Common(cellId), null))))),
+                            null);
                     configurations.add(configuration);
                 }
 
@@ -175,7 +177,9 @@ public class ChildThreadUtils {
                     log.debug("JSON processing exception: {}", e);
                 }
 
-                String notification = getNotificationString(pnfName, UUID.randomUUID().toString(), payloadString,
+                String requestId = UUID.randomUUID().toString();
+
+                String notification = getNotificationString(pnfName, requestId, payloadString,
                         System.currentTimeMillis(), "ModifyConfig");
                 log.info("Policy Notification: {}", notification);
                 boolean status = policyDmaapClient.sendNotificationToPolicy(notification);
@@ -185,34 +189,37 @@ public class ChildThreadUtils {
                 } else {
                     log.debug("Sending notification to policy failed");
                 }
+                policyDmaapClient.handlePolicyResponse(requestId);
+                log.info("handled policy response in ModifyConfig");
 
             }
         }
         if (!solutions.getAnrSolutions().isEmpty()) {
-            Map<String, List<Map<String,List<String>>>> anrPnfs;
+            Map<String, List<Map<String, List<String>>>> anrPnfs;
             List<Configurations> configurations = new ArrayList<>();
             anrPnfs = pnfUtils.getPnfsForAnrSolutions(solutions.getAnrSolutions());
-            for(Map.Entry<String, List<Map<String,List<String>>>> entry : anrPnfs.entrySet()) {
+            for (Map.Entry<String, List<Map<String, List<String>>>> entry : anrPnfs.entrySet()) {
                 String pnfName = entry.getKey();
-                for(Map<String,List<String>> cellRemNeighborsPair : anrPnfs.get(pnfName)) {
-                  for(Map.Entry<String, List<String>> entry1 : cellRemNeighborsPair.entrySet()) {
-                      String cellId = entry1.getKey();
-                      List<LteCell> lteCellList = new ArrayList<>();
-                      for(String removeableNeighbor : entry1.getValue()) {
-                          LteCell lteCell = new LteCell();
-                          lteCell.setBlacklisted("true");
-                          lteCell.setPlmnId(solutions.getNetworkId());
-                          lteCell.setCid(removeableNeighbor);
-                          int pci = SdnrRestClient.getPci(cellId);
-                          lteCell.setPhyCellId(pci);
-                          lteCell.setPnfName(pnfName);
-                          lteCellList.add(lteCell);
-                      }
-                      Configurations configuration = new Configurations(
-                              new Data(new FapService(cellId, null, new CellConfig(new Lte(new Ran(new Common(cellId),
-                                      new NeighborListInUse(null, lteCellList, String.valueOf(lteCellList.size()))))))));
-                      configurations.add(configuration); 
-                  }
+                for (Map<String, List<String>> cellRemNeighborsPair : anrPnfs.get(pnfName)) {
+                    for (Map.Entry<String, List<String>> entry1 : cellRemNeighborsPair.entrySet()) {
+                        String cellId = entry1.getKey();
+                        List<LteCell> lteCellList = new ArrayList<>();
+                        for (String removeableNeighbor : entry1.getValue()) {
+                            LteCell lteCell = new LteCell();
+                            lteCell.setBlacklisted("true");
+                            lteCell.setPlmnId(solutions.getNetworkId());
+                            lteCell.setCid(removeableNeighbor);
+                            int pci = SdnrRestClient.getPci(cellId);
+                            lteCell.setPhyCellId(pci);
+                            lteCell.setPnfName(pnfName);
+                            lteCellList.add(lteCell);
+                        }
+                        Configurations configuration = new Configurations(new Data(new FapService(cellId, null,
+                                new CellConfig(new Lte(new Ran(new Common(cellId), new NeighborListInUse(null,
+                                        lteCellList, String.valueOf(lteCellList.size()))))))),
+                                null);
+                        configurations.add(configuration);
+                    }
                 }
                 Payload payload = new Payload(configurations);
                 ObjectMapper mapper = new ObjectMapper();
@@ -223,13 +230,17 @@ public class ChildThreadUtils {
                 } catch (JsonProcessingException e) {
                     log.error("Exception in writing anrupdate string", e);
                 }
-                String notification = getNotificationString(pnfName, UUID.randomUUID().toString(), payloadString,
+                String requestId = UUID.randomUUID().toString();
+                String notification = getNotificationString(pnfName, requestId, payloadString,
                         System.currentTimeMillis(), "ModifyConfigANR");
                 log.info("Policy Notification: {}", notification);
                 Boolean result = policyDmaapClient.sendNotificationToPolicy(notification);
                 log.info("send notification to policy result {} ", result);
+                policyDmaapClient.handlePolicyResponse(requestId);
+                log.info("handled policy response in ModifyConfigANR");
+
             }
-            
+
         }
         return true;
     }
index 43c6c53..66f8221 100644 (file)
@@ -38,8 +38,6 @@ import org.onap.dcaegen2.services.sonhms.restclient.Solutions;
 import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
 import org.slf4j.Logger;
 
-
-
 public class PnfUtils {
 
     private static final Logger log = org.slf4j.LoggerFactory.getLogger(ChildThreadUtils.class);
@@ -50,58 +48,59 @@ public class PnfUtils {
      */
     public Map<String, List<CellPciPair>> getPnfs(Solutions solutions) throws ConfigDbNotFoundException {
 
-        Map<String, List<CellPciPair>> pnfs = new HashMap<>(); 
+        Map<String, List<CellPciPair>> pnfs = new HashMap<>();
         List<PciSolutions> pciSolutions = solutions.getPciSolutions();
         for (PciSolutions pciSolution : pciSolutions) {
-                String cellId = pciSolution.getCellId();
-                int pci = pciSolution.getPci();
+            String cellId = pciSolution.getCellId();
+            int pci = pciSolution.getPci();
 
-                String pnfName = "";
-                CellInfoRepository cellInfoRepository = BeanUtil.getBean(CellInfoRepository.class);
-                Optional<CellInfo> cellInfo = cellInfoRepository.findById(cellId);
-                if (cellInfo.isPresent()) {
-                    pnfName = cellInfo.get().getPnfName();
-                } else {
-                    pnfName = SdnrRestClient.getPnfName(cellId);
-                    cellInfoRepository.save(new CellInfo(cellId, pnfName));
-                }
-                if (pnfs.containsKey(pnfName)) {
-                    pnfs.get(pnfName).add(new CellPciPair(cellId, pci));
-                } else {
-                    List<CellPciPair> cellPciPairs = new ArrayList<>();
-                    cellPciPairs.add(new CellPciPair(cellId, pci));
-                    pnfs.put(pnfName, cellPciPairs);
-                }
+            String pnfName = "";
+            CellInfoRepository cellInfoRepository = BeanUtil.getBean(CellInfoRepository.class);
+            Optional<CellInfo> cellInfo = cellInfoRepository.findById(cellId);
+            if (cellInfo.isPresent()) {
+                pnfName = cellInfo.get().getPnfName();
+            } else {
+                pnfName = SdnrRestClient.getPnfName(cellId);
+                cellInfoRepository.save(new CellInfo(cellId, pnfName));
+            }
+            if (pnfs.containsKey(pnfName)) {
+                pnfs.get(pnfName).add(new CellPciPair(cellId, pci));
+            } else {
+                List<CellPciPair> cellPciPairs = new ArrayList<>();
+                cellPciPairs.add(new CellPciPair(cellId, pci));
+                pnfs.put(pnfName, cellPciPairs);
+            }
 
         }
         return pnfs;
     }
-    
+
     /**
-     * get pnfs for ANR solutions
+     * get pnfs for ANR solutions.
      * 
      */
-    public Map<String, List<Map<String,List<String>>>> getPnfsForAnrSolutions(List<AnrSolutions> anrSolutions) throws ConfigDbNotFoundException {
-        
-        Map<String, List<Map<String,List<String>>>> anrPnfs = new HashMap<>();
-        
+    public Map<String, List<Map<String, List<String>>>> getPnfsForAnrSolutions(List<AnrSolutions> anrSolutions)
+            throws ConfigDbNotFoundException {
+
+        Map<String, List<Map<String, List<String>>>> anrPnfs = new HashMap<>();
+
         List<String> removeableNeighbors;
-        for(AnrSolutions anrSolution : anrSolutions) {
+        for (AnrSolutions anrSolution : anrSolutions) {
             String cellId = anrSolution.getCellId();
             String pnfName = SdnrRestClient.getPnfName(cellId);
             removeableNeighbors = anrSolution.getRemoveableNeighbors();
-            Map<String,List<String>> cellRemNeighborsPair = new HashMap<>();
+            Map<String, List<String>> cellRemNeighborsPair = new HashMap<>();
             cellRemNeighborsPair.put(cellId, removeableNeighbors);
-            if(anrPnfs.containsKey(pnfName)) {
+            if (anrPnfs.containsKey(pnfName)) {
                 anrPnfs.get(pnfName).add(cellRemNeighborsPair);
-            }else {
-                List<Map<String,List<String>>> anrCells = new ArrayList<>();
+            } else {
+                List<Map<String, List<String>>> anrCells = new ArrayList<>();
                 anrCells.add(cellRemNeighborsPair);
                 anrPnfs.put(pnfName, anrCells);
             }
         }
-        log.info("anr Pnfs {}",anrPnfs.toString());
+        log.info("anr Pnfs {}", anrPnfs);
         return anrPnfs;
-        
+
     }
 }
index a92617c..acfa1a4 100644 (file)
@@ -35,6 +35,7 @@ import org.slf4j.Logger;
 public class StateOof {
     private static final Logger log = org.slf4j.LoggerFactory.getLogger(StateOof.class);
     private BlockingQueue<List<String>> childStatusUpdate;
+
     public StateOof() {
 
     }
@@ -50,13 +51,15 @@ public class StateOof {
 
     /**
      * Triggers OOF for pci.
-     * @throws OofNotFoundException  when trigger oof fails
+     * 
+     * @throws OofNotFoundException
+     *             when trigger oof fails
      */
-    public UUID triggerOof(List<String> cellidList, 
-            String networkId, List<AnrInput> anrInputList) throws OofNotFoundException, InterruptedException {
-        
+    public UUID triggerOof(List<String> cellidList, String networkId, List<AnrInput> anrInputList)
+            throws OofNotFoundException, InterruptedException {
+
         log.info("Triggering oof");
-        
+
         log.debug("the cells triggering the oof are {}", cellidList);
 
         UUID transactionId = UUID.randomUUID();
@@ -79,9 +82,8 @@ public class StateOof {
             Thread.currentThread().interrupt();
 
         }
-        
+
         return transactionId;
     }
-    
 
 }
index 767dae2..548cb4d 100644 (file)
@@ -40,7 +40,6 @@ import org.onap.dcaegen2.services.sonhms.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
 public class ConfigFetchFromCbs {
 
     private static Logger log = LoggerFactory.getLogger(ConfigFetchFromCbs.class);
@@ -56,40 +55,42 @@ public class ConfigFetchFromCbs {
         RequestDiagnosticContext diagnosticContext = RequestDiagnosticContext.create();
         // Read necessary properties from the environment
         final EnvProperties env = EnvProperties.fromEnvironment();
-        log.debug("environments {}",env);
+        log.debug("environments {}", env);
         ConfigPolicy configPolicy = ConfigPolicy.getInstance();
-        
+
         // Create the client and use it to get the configuration
         final CbsRequest request = CbsRequests.getAll(diagnosticContext);
-        CbsClientFactory.createCbsClient(env).flatMap(cbsClient -> cbsClient.get(request))
-                .subscribe(jsonObject -> {
-                    log.debug("configuration from CBS {}", jsonObject);
-                    JsonObject config = jsonObject.getAsJsonObject("config");
-                    
-                    updateConfigurationFromJsonObject(config);
-                    
-                    Type mapType = new TypeToken<Map<String, Object>>() {}.getType();
-                    JsonObject policyJson = jsonObject.getAsJsonObject("policy");
-                    Map<String,Object> policy = new Gson().fromJson(policyJson, mapType);
-                    configPolicy.setConfig(policy);
-                }, throwable -> log.warn("Ooops", throwable)) ;
+        CbsClientFactory.createCbsClient(env).flatMap(cbsClient -> cbsClient.get(request)).subscribe(jsonObject -> {
+            log.info("configuration and policy from CBS {}", jsonObject);
+            JsonObject config = jsonObject.getAsJsonObject("config");
+
+            updateConfigurationFromJsonObject(config);
+
+            Type mapType = new TypeToken<Map<String, Object>>() {
+            }.getType();
+            JsonObject policyJson = jsonObject.getAsJsonObject("policies").getAsJsonArray("items").get(0)
+                    .getAsJsonObject().getAsJsonObject("config");
+            Map<String, Object> policy = new Gson().fromJson(policyJson, mapType);
+            configPolicy.setConfig(policy);
+            log.info("Config policy {}", configPolicy);
+        }, throwable -> log.warn("Ooops", throwable));
 
     }
 
     private void updateConfigurationFromJsonObject(JsonObject jsonObject) {
-        
+
         log.info("Updating configuration from CBS");
         Configuration configuration = Configuration.getInstance();
-        log.info("configuration from CBS {}", jsonObject);
-        
-        Type mapType = new TypeToken<Map<String, Object>>() {}.getType();
-        
+
+        Type mapType = new TypeToken<Map<String, Object>>() {
+        }.getType();
+
         JsonObject subscribes = jsonObject.getAsJsonObject("streams_subscribes");
         Map<String, Object> streamsSubscribes = new Gson().fromJson(subscribes, mapType);
-        
+
         JsonObject publishes = jsonObject.getAsJsonObject("streams_publishes");
         Map<String, Object> streamsPublishes = new Gson().fromJson(publishes, mapType);
-        
+
         int pgPort = jsonObject.get("postgres.port").getAsInt();
         int pollingInterval = jsonObject.get("sonhandler.pollingInterval").getAsInt();
         String pgPassword = jsonObject.get("postgres.password").getAsString();
@@ -102,19 +103,20 @@ public class ConfigFetchFromCbs {
         String pgHost = jsonObject.get("postgres.host").getAsString();
 
         JsonArray servers = jsonObject.getAsJsonArray("sonhandler.dmaap.server");
-        Type listType = new TypeToken<List<String>>() {}.getType();
+        Type listType = new TypeToken<List<String>>() {
+        }.getType();
         List<String> dmaapServers = new Gson().fromJson(servers, listType);
-        
+
         String cg = jsonObject.get("sonhandler.cg").getAsString();
         int bufferTime = jsonObject.get("sonhandler.bufferTime").getAsInt();
         String cid = jsonObject.get("sonhandler.cid").getAsString();
         String configDbService = jsonObject.get("sonhandler.configDb.service").getAsString();
         String namespace = jsonObject.get("sonhandler.namespace").getAsString();
         String callbackUrl = "http://" + System.getenv("HOSTNAME") + "." + namespace + ":8080/callbackUrl";
-        
+
         JsonArray optimizersJson = jsonObject.getAsJsonArray("sonhandler.optimizers");
-        List<String> optimizers = new Gson().fromJson(optimizersJson, listType);                   
-        
+        List<String> optimizers = new Gson().fromJson(optimizersJson, listType);
+
         String oofService = jsonObject.get("sonhandler.oof.service").getAsString();
         int pollingTimeout = jsonObject.get("sonhandler.pollingTimeout").getAsInt();
 
index efc1e19..40ba19a 100644 (file)
 package org.onap.dcaegen2.services.sonhms.dao;
 
 import org.onap.dcaegen2.services.sonhms.entity.HandOverMetrics;
+import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.CrudRepository;
 import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
 
 @Repository
+@Transactional
 public interface HandOverMetricsRepository extends CrudRepository<HandOverMetrics, String> {
 
-    @Query(nativeQuery=true, 
-            value="SELECT ho_details FROM handover_metrics WHERE src_cell_id=?1")
+    @Query(nativeQuery = true, value = "SELECT ho_details FROM handover_metrics WHERE src_cell_id=?1")
     public String getHandOverMetrics(String srcCellId);
 
-    @Query(nativeQuery=true,
-            value="UPDATE handover_metrics SET ho_details=?1 where src_cell_id=?2")
+    @Modifying
+    @Query(nativeQuery = true, value = "UPDATE handover_metrics SET ho_details=?1 where src_cell_id=?2")
     public void updateHoMetrics(String hoDetails, String srcCellId);
 }
index c83956f..d45d7de 100644 (file)
@@ -28,11 +28,10 @@ import org.springframework.stereotype.Repository;
 
 @Repository
 public interface PerformanceNotificationsRepository extends CrudRepository<PerformanceNotifications, String> {
-       
-       @Query(nativeQuery = true,
-            value = "DELETE FROM performance_notifications "
-                    + "WHERE notification = ( SELECT notification FROM performance_notifications ORDER BY "
-                    + "created_at FOR UPDATE SKIP LOCKED LIMIT 1 ) RETURNING notification;")
+
+    @Query(nativeQuery = true, value = "DELETE FROM performance_notifications "
+            + "WHERE notification = ( SELECT notification FROM performance_notifications ORDER BY "
+            + "created_at FOR UPDATE SKIP LOCKED LIMIT 1 ) RETURNING notification;")
 
     public String getPerformanceNotificationFromQueue();
 
index d3ca349..664dbf8 100644 (file)
@@ -100,7 +100,7 @@ public class DmaapClient {
 
         // create notification consumers for FM
         NotificationConsumer fmNotificationConsumer = new NotificationConsumer(fmNotifCambriaConsumer,
-                new FMNotificationCallback());
+                new FmNotificationCallback());
         // start fm notification consumer threads
         executorPool = Executors.newScheduledThreadPool(10);
         executorPool.scheduleAtFixedRate(fmNotificationConsumer, 0, configuration.getPollingInterval(),
@@ -108,7 +108,7 @@ public class DmaapClient {
 
         // create notification consumers for PM
         NotificationConsumer pmNotificationConsumer = new NotificationConsumer(pmNotifCambriaConsumer,
-                new PMNotificationCallback());
+                new PmNotificationCallback());
         // start pm notification consumer threads
         executorPool = Executors.newScheduledThreadPool(10);
         executorPool.scheduleAtFixedRate(pmNotificationConsumer, 0, configuration.getPollingInterval(),
@@ -28,28 +28,29 @@ import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class FMNotificationCallback extends NotificationCallback{
-       
-       private static Logger log = LoggerFactory.getLogger(FMNotificationCallback.class);
-       
-       @Override
-       public void activateCallBack(String msg){
-               handleNotification(msg);
-       }
-    
-       private void handleNotification(String msg) {
-               
-               FaultNotificationsRepository faultNotificationsRepository=BeanUtil
-                   .getBean(FaultNotificationsRepository.class);
-               
-               NewFmNotification newNotification=BeanUtil.getBean(NewFmNotification.class);
-               FaultNotifications faultNotification = new FaultNotifications();
-               faultNotification.setNotification(msg);
-               if (log.isDebugEnabled()) {
-                       log.debug(faultNotification.toString());
-               }
-               faultNotificationsRepository.save(faultNotification);
-               newNotification.setNewNotif(true);
-       }
+public class FmNotificationCallback extends NotificationCallback {
+
+    private static Logger log = LoggerFactory.getLogger(FmNotificationCallback.class);
+
+    @Override
+    public void activateCallBack(String msg) {
+        handleNotification(msg);
+    }
+
+    private void handleNotification(String msg) {
+
+        FaultNotificationsRepository faultNotificationsRepository = BeanUtil
+                .getBean(FaultNotificationsRepository.class);
+
+        
+        FaultNotifications faultNotification = new FaultNotifications();
+        faultNotification.setNotification(msg);
+        if (log.isDebugEnabled()) {
+            log.debug(faultNotification.toString());
+        }
+        NewFmNotification newNotification = BeanUtil.getBean(NewFmNotification.class);
+        faultNotificationsRepository.save(faultNotification);
+        newNotification.setNewNotif(true);
+    }
 
 }
index f488f03..860789a 100644 (file)
@@ -23,6 +23,6 @@ package org.onap.dcaegen2.services.sonhms.dmaap;
 
 public abstract class NotificationCallback {
 
-       public abstract void activateCallBack(String msg);
-       
+    public abstract void activateCallBack(String msg);
+
 }
@@ -28,25 +28,25 @@ import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class PMNotificationCallback extends NotificationCallback {
-       
-       private static Logger log = LoggerFactory.getLogger(PMNotificationCallback.class);
-       
-       @Override
-       public void activateCallBack(String msg){
-               handleNotification(msg);
-       }
-    
-       private void handleNotification(String msg) {
-               
-               PerformanceNotificationsRepository performanceNotificationsRepository=BeanUtil.getBean(PerformanceNotificationsRepository.class);
-               NewPmNotification newNotification=BeanUtil.getBean(NewPmNotification.class);
-               PerformanceNotifications performanceNotification = new PerformanceNotifications();
-               performanceNotification.setNotification(msg);
-               log.info("Performance notification {}", performanceNotification);
-               performanceNotificationsRepository.save(performanceNotification);
-               newNotification.setNewNotif(true);
-       }
+public class PmNotificationCallback extends NotificationCallback {
 
+    private static Logger log = LoggerFactory.getLogger(PmNotificationCallback.class);
+
+    @Override
+    public void activateCallBack(String msg) {
+        handleNotification(msg);
+    }
+
+    private void handleNotification(String msg) {
+
+        PerformanceNotificationsRepository performanceNotificationsRepository = BeanUtil
+                .getBean(PerformanceNotificationsRepository.class);
+        PerformanceNotifications performanceNotification = new PerformanceNotifications();
+        performanceNotification.setNotification(msg);
+        log.info("Performance notification {}", performanceNotification);
+        NewPmNotification newNotification = BeanUtil.getBean(NewPmNotification.class);
+        performanceNotificationsRepository.save(performanceNotification);
+        newNotification.setNewNotif(true);
+    }
 
 }
index dbd9b58..d5371eb 100644 (file)
 package org.onap.dcaegen2.services.sonhms.dmaap;
 
 import com.att.nsa.cambria.client.CambriaBatchingPublisher;
+import com.att.nsa.cambria.client.CambriaConsumer;
+import com.fasterxml.jackson.databind.ObjectMapper;
 
 import java.io.IOException;
+import java.sql.Timestamp;
 import java.util.Map;
 
 import org.onap.dcaegen2.services.sonhms.Configuration;
+import org.onap.dcaegen2.services.sonhms.model.Payload;
+import org.onap.dcaegen2.services.sonhms.model.PolicyNotification;
 import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils;
+import org.slf4j.Logger;
 
 public class PolicyDmaapClient {
 
+    private static final Logger log = org.slf4j.LoggerFactory.getLogger(PolicyDmaapClient.class);
+    
     private DmaapUtils dmaapUtils;
+    
+    private Configuration configuration;
+    
+    
+    public PolicyDmaapClient(DmaapUtils dmaapUtils, Configuration configuration) {
+        this.dmaapUtils = dmaapUtils;
+        this.configuration = configuration;
+    } 
 
     /**
      * Method stub for sending notification to policy.
      */
     @SuppressWarnings("unchecked")
     public boolean sendNotificationToPolicy(String msg) {
-        dmaapUtils = new DmaapUtils();
-        Map<String, Object> streamsPublishes = Configuration.getInstance().getStreamsPublishes();
+        Map<String, Object> streamsPublishes = configuration.getStreamsPublishes();
         String policyTopicUrl = ((Map<String, String>) ((Map<String, Object>) streamsPublishes.get("CL_topic"))
                 .get("dmaap_info")).get("topic_url");
         String[] policyTopicSplit = policyTopicUrl.split("\\/");
         String policyTopic = policyTopicSplit[policyTopicSplit.length - 1];
-        Configuration configuration = Configuration.getInstance();
         CambriaBatchingPublisher cambriaBatchingPublisher;
         try {
 
@@ -57,4 +71,51 @@ public class PolicyDmaapClient {
         }
         return true;
     }
+    
+    /**
+     * Handles policy response.
+     */
+    @SuppressWarnings("unchecked")
+    public Boolean handlePolicyResponse(String requestId) {
+
+        Map<String, Object> streamSubscribes = configuration.getStreamsSubscribes();
+        String policyResponseTopicUrl = ((Map<String, String>) ((Map<String, Object>) streamSubscribes
+                .get("dcae_cl_response_topic")).get("dmaap_info")).get("topic_url");
+        String[] policyResponseTopicUrlSplit = policyResponseTopicUrl.split("\\/");
+        String policyResponseTopic = policyResponseTopicUrlSplit[policyResponseTopicUrlSplit.length - 1];
+        log.debug("policyResponse Topic : {}", policyResponseTopic);
+        CambriaConsumer policyResponseCambriaConsumer = null;
+        policyResponseCambriaConsumer = dmaapUtils.buildConsumer(configuration, policyResponseTopic);
+        Timestamp startTimer = new Timestamp(System.currentTimeMillis());
+
+        Timestamp currentTime = new Timestamp(System.currentTimeMillis());
+        Long difference = currentTime.getTime() - startTimer.getTime();
+
+        while (difference < 10000) {
+            Iterable<String> policyResponseMessages;
+            try {
+                policyResponseMessages = policyResponseCambriaConsumer.fetch();
+                for (String msg : policyResponseMessages) {
+                    ObjectMapper mapper = new ObjectMapper();
+                    PolicyNotification policyResponse = mapper.readValue(msg, PolicyNotification.class);
+                    if (requestId.equals(policyResponse.getRequestId())) {
+                        String payload = policyResponse.getPayload();
+                        Payload payloadObject = mapper.readValue(payload, Payload.class);
+                        int status = payloadObject.getConfiguration().get(0).getStatus().getCode();
+                        String statusToString = Integer.toString(status);
+                        log.info("response from policy, status code {}", statusToString);
+
+                    }
+                    return true;
+                }
+            } catch (IOException e) {
+                log.info("caught io exception while fetching policy response");
+            }
+            currentTime = new Timestamp(System.currentTimeMillis());
+            difference = currentTime.getTime() - startTimer.getTime();
+        }
+        log.info("no response from policy, timer expired");
+        return true;
+
+    }
 }
index 30a6c0e..67981d7 100644 (file)
@@ -33,8 +33,8 @@ import org.hibernate.annotations.CreationTimestamp;
 @Entity
 @Table(name = "PERFORMANCE_NOTIFICATIONS")
 public class PerformanceNotifications {
-       
-       @Id
+
+    @Id
     @Column(name = "notification", columnDefinition = "text")
     private String notification;
 
@@ -67,5 +67,4 @@ public class PerformanceNotifications {
         this.createdAt = createdAt;
     }
 
-
 }
index 15a93e9..c55c6d6 100644 (file)
@@ -24,30 +24,33 @@ package org.onap.dcaegen2.services.sonhms.model;
 import java.util.Map;
 
 public class AdditionalMeasurements {
-    
+
     String name;
-    Map<String,String> hashMap ;  
-    
+    Map<String, String> hashMap;
+
     public AdditionalMeasurements() {
-        
+
     }
+
     public String getName() {
         return name;
     }
+
     public void setName(String name) {
         this.name = name;
     }
+
     public Map<String, String> getHashMap() {
         return hashMap;
     }
+
     public void setHashMap(Map<String, String> hashMap) {
         this.hashMap = hashMap;
     }
+
     @Override
     public String toString() {
         return "AdditionalMeasurements [name=" + name + ", hashMap=" + hashMap + "]";
     }
-  
-  
-    
+
 }
index faff91e..07a2923 100644 (file)
@@ -27,10 +27,11 @@ public class AnrInput {
 
     String cellId;
     List<String> removeableNeighbors;
-    
+
     public AnrInput() {
-        
+
     }
+
     /**
      * Parameterized Constructor.
      */
@@ -40,18 +41,21 @@ public class AnrInput {
         this.cellId = cellId;
         this.removeableNeighbors = removeableNeighbors;
     }
+
     public String getCellId() {
         return cellId;
     }
+
     public void setCellId(String cellId) {
         this.cellId = cellId;
     }
+
     public List<String> getRemoveableNeighbors() {
         return removeableNeighbors;
     }
+
     public void setRemoveableNeighbors(List<String> removeableNeighbors) {
         this.removeableNeighbors = removeableNeighbors;
     }
-    
-    
+
 }
index 415b7d9..686666c 100644 (file)
@@ -27,6 +27,9 @@ public class Configurations {
     @JsonProperty("data")
     private Data data;
 
+    @JsonProperty("Status")
+    private Status status;
+
     /**
      * constructor.
      *
@@ -34,22 +37,31 @@ public class Configurations {
     public Configurations() {
 
     }
+
     /**
      * Parameterized constructor.
      *
      */
-    public Configurations(Data data) {
+    public Configurations(Data data, Status status) {
         super();
         this.data = data;
+        this.status = status;
     }
+
     public Data getData() {
         return data;
     }
+
     public void setData(Data data) {
         this.data = data;
     }
 
-   
-   
+    public Status getStatus() {
+        return status;
+    }
+
+    public void setStatus(Status status) {
+        this.status = status;
+    }
 
 }
index ecc2048..1d43f09 100644 (file)
 package org.onap.dcaegen2.services.sonhms.model;
 
 public class HoDetails {
-    
+
     private String dstCellId;
     private int attemptsCount;
     private int successCount;
     private float successRate;
-    
+
     /**
-     * default constructor
+     * default constructor.
      */
     public HoDetails() {
-        
+
     }
-    
+
     public String getDstCellId() {
         return dstCellId;
     }
+
     public void setDstCellId(String dstCellId) {
         this.dstCellId = dstCellId;
     }
+
     public int getAttemptsCount() {
         return attemptsCount;
     }
+
     public void setAttemptsCount(int attemptsCount) {
         this.attemptsCount = attemptsCount;
     }
+
     public int getSuccessCount() {
         return successCount;
     }
+
     public void setSuccessCount(int successCount) {
         this.successCount = successCount;
     }
+
     public float getSuccessRate() {
         return successRate;
     }
+
     public void setSuccessRate(float successRate) {
         this.successRate = successRate;
     }
-    
 
 }
index f1cae93..ce9099b 100644 (file)
@@ -24,6 +24,7 @@ package org.onap.dcaegen2.services.sonhms.model;
 import com.fasterxml.jackson.annotation.JsonProperty;
 
 public class LteNeighborListInUseLteCell {
+    
     @JsonProperty("pnfName")
     private String pnfName;
 
@@ -52,6 +53,9 @@ public class LteNeighborListInUseLteCell {
 
     }
 
+    /**
+     * constructor.
+     */
     public LteNeighborListInUseLteCell(String pnfName, String enable, String alias, String mustInclude, String plmnId,
             String cid, int phyCellId, String blacklisted) {
         super();
index bdd8641..477a2d3 100644 (file)
@@ -27,15 +27,16 @@ public class MeasurementFields {
 
     String measurementInterval;
     String measurementFieldsVersion;
-   
+
     List<AdditionalMeasurements> additionalMeasurements;
-    
+
     /**
-     * default constructor
+     * default constructor.
      */
     public MeasurementFields() {
-        
+
     }
+
     public String getMeasurementInterval() {
         return measurementInterval;
     }
@@ -51,13 +52,13 @@ public class MeasurementFields {
     public void setAdditionalMeasurements(List<AdditionalMeasurements> additionalMeasurements) {
         this.additionalMeasurements = additionalMeasurements;
     }
-    
+
     public String getMeasurementFieldsVersion() {
         return measurementFieldsVersion;
     }
+
     public void setMeasurementFieldsVersion(String measurementFieldsVersion) {
         this.measurementFieldsVersion = measurementFieldsVersion;
     }
 
-    
 }
 
 package org.onap.dcaegen2.services.sonhms.model;
 
-public class PMNotification {
+public class PmNotification {
 
     Event event;
-    
+
     /**
-     * default constructor
+     * default constructor.
      */
-    public PMNotification() {
-        
+    public PmNotification() {
+
     }
-    
+
     public Event getEvent() {
         return event;
     }
+
     public void setEvent(Event event) {
         this.event = event;
     }
-    
-   
-    
+
 }
index e432b0c..16f7518 100644 (file)
@@ -32,7 +32,7 @@ public class PolicyNotification {
     private long closedLoopAlarmStart;
     private String closedLoopEventClient;
     private String closedLoopEventStatus;
-
+    
     @JsonProperty("target_type")
     private String targetType;
 
@@ -46,6 +46,9 @@ public class PolicyNotification {
 
     private String from;
     private String version;
+    
+    private String policyName;
+    private String policyVersion;
 
     @JsonProperty("Action")
     private String action;
@@ -60,9 +63,9 @@ public class PolicyNotification {
 
     /**
      * Constructor.
-     *
      */
-    public PolicyNotification(String closedLoopControlName, String requestId, Long alarmStartTime, String pnfName, String action) {
+    public PolicyNotification(String closedLoopControlName, String requestId, Long alarmStartTime, String pnfName,
+            String action) {
         this.closedLoopControlName = closedLoopControlName;
         this.requestId = requestId;
         this.closedLoopEventClient = "microservice.PCI";
@@ -210,6 +213,22 @@ public class PolicyNotification {
         }
         return (this.hashCode() == obj.hashCode());
     }
+
+    public String getPolicyName() {
+        return policyName;
+    }
+
+    public void setPolicyName(String policyName) {
+        this.policyName = policyName;
+    }
+
+    public String getPolicyVersion() {
+        return policyVersion;
+    }
+
+    public void setPolicyVersion(String policyVersion) {
+        this.policyVersion = policyVersion;
+    }
     
     
 
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Status.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Status.java
new file mode 100644 (file)
index 0000000..8f35b50
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  son-handler
+ *  ================================================================================
+ *   Copyright (C) 2019 Wipro Limited.
+ *   ==============================================================================
+ *     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.dcaegen2.services.sonhms.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+
+public class Status {
+    @JsonProperty("Code")
+    private int code;
+    
+    @JsonProperty("Value")
+    private String value;
+
+    public int getCode() {
+        return code;
+    }
+
+    public void setCode(int code) {
+        this.code = code;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+}
index 117f202..042603a 100644 (file)
@@ -25,14 +25,17 @@ import java.util.ArrayList;
 import java.util.List;
 
 public class AnrSolutions {
-    
+
     String cellId;
     List<String> removeableNeighbors = new ArrayList<>();
-    
+
     public AnrSolutions() {
-        
+
     }
-    
+
+    /**
+     * constructor.
+     */
     public AnrSolutions(String cellId, List<String> removeableNeighbors) {
         super();
         this.cellId = cellId;
@@ -42,19 +45,22 @@ public class AnrSolutions {
     public String getCellId() {
         return cellId;
     }
+
     public void setCellId(String cellId) {
         this.cellId = cellId;
     }
+
     public List<String> getRemoveableNeighbors() {
         return removeableNeighbors;
     }
+
     public void setRemoveableNeighbors(List<String> removeableNeighbors) {
         this.removeableNeighbors = removeableNeighbors;
     }
+
     @Override
     public String toString() {
         return "AnrSolutions [cellId=" + cellId + ", removeableNeighbors=" + removeableNeighbors + "]";
     }
-    
 
 }
index 0f6dd98..97668ed 100644 (file)
@@ -29,7 +29,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
-import org.onap.dcaegen2.services.sonhms.ConfigPolicy;
 import org.onap.dcaegen2.services.sonhms.Configuration;
 import org.onap.dcaegen2.services.sonhms.exceptions.OofNotFoundException;
 import org.onap.dcaegen2.services.sonhms.model.AnrInput;
@@ -73,13 +72,7 @@ public class OofRestClient {
         Map<String, String> callbackHeader = new HashMap<>();
         callbackHeader.put("Content-Type", "application/json");
         requestInfo.setCallbackHeader(callbackHeader);
-        ConfigPolicy config = ConfigPolicy.getInstance();
         int timeout = 60;
-        try {
-            timeout = (int) config.getConfig().get("PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS");
-        } catch (NullPointerException e) {
-            log.debug("No config policy available. Using default timeout 60 sec");
-        }
         requestInfo.setTimeout(timeout);
 
         CellInfo cellInfo = new CellInfo();
index eec3fd8..039285c 100644 (file)
@@ -27,8 +27,9 @@ public class PciSolutions {
     int pci;
 
     public PciSolutions() {
-        
+
     }
+
     public String getCellId() {
         return cellId;
     }
index 8e694a3..c39a20d 100644 (file)
@@ -25,14 +25,15 @@ import java.util.ArrayList;
 import java.util.List;
 
 public class Solutions {
-    
+
     String networkId = null;
     List<PciSolutions> pciSolutions = new ArrayList<>();
     List<AnrSolutions> anrSolutions = new ArrayList<>();
-    
+
     public Solutions() {
-        
+
     }
+
     public String getNetworkId() {
         return networkId;
     }
@@ -53,6 +54,7 @@ public class Solutions {
         this.pciSolutions = pciSolutions;
 
     }
+
     public List<AnrSolutions> getAnrSolutions() {
         return anrSolutions;
     }
@@ -67,7 +69,4 @@ public class Solutions {
                 + "]";
     }
 
-   
-
-   
 }
index a25fd54..7228f78 100644 (file)
@@ -177,7 +177,7 @@ public class ClusterUtils {
     /**
      * Get clusters for FM Cell.
      */
-    public Either<Graph, Integer> getClusterForFMCell(String cellId, List<Graph> newClusters) {
+    public Either<Graph, Integer> getClusterForFmCell(String cellId, List<Graph> newClusters) {
         if (newClusters.isEmpty()) {
             log.info("getClusterForFMCell 404");
             return Either.right(404);
@@ -222,8 +222,10 @@ public class ClusterUtils {
 
         return clusterCells;
     }
-    // generic create cluster for both fm and sdnr
-
+    
+    /**
+     * Create cluster.
+     */
     public Graph createCluster(Map<CellPciPair, ArrayList<CellPciPair>> clusterMap) throws ConfigDbNotFoundException {
 
         Graph cluster = new Graph();
index 6fb72c3..68b94fb 100644 (file)
@@ -28,7 +28,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.hibernate.sql.ConditionFragment;
 import org.junit.Test;
 
 
index 5bf76b3..4b36b32 100644 (file)
@@ -40,7 +40,7 @@ import org.mockito.Mock;
 import org.onap.dcaegen2.services.sonhms.dao.DmaapNotificationsRepository;
 import org.onap.dcaegen2.services.sonhms.dao.PerformanceNotificationsRepository;
 import org.onap.dcaegen2.services.sonhms.model.Notification;
-import org.onap.dcaegen2.services.sonhms.model.PMNotification;
+import org.onap.dcaegen2.services.sonhms.model.PmNotification;
 import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
 import org.powermock.api.mockito.PowerMockito;
 import org.powermock.core.classloader.annotations.PrepareForTest;
@@ -104,7 +104,7 @@ public class DmaapNotificationsComponentTest {
                 .thenReturn(performanceNotificationsRepositoryMock);
         when(performanceNotificationsRepositoryMock.getPerformanceNotificationFromQueue()).thenReturn(pmNotificationString);
         
-        Either<PMNotification,Integer> result = component.getPmNotifications();
+        Either<PmNotification,Integer> result = component.getPmNotifications();
         assertTrue(result.isLeft());
         assertNotNull(result.left().value());
         
index 9cae5b6..cbd0265 100644 (file)
@@ -40,7 +40,7 @@ import org.onap.dcaegen2.services.sonhms.dao.HandOverMetricsRepository;
 import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient;
 import org.onap.dcaegen2.services.sonhms.entity.HandOverMetrics;
 import org.onap.dcaegen2.services.sonhms.model.Flag;
-import org.onap.dcaegen2.services.sonhms.model.PMNotification;
+import org.onap.dcaegen2.services.sonhms.model.PmNotification;
 import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
 import org.powermock.api.mockito.PowerMockito;
 import org.powermock.core.classloader.annotations.PrepareForTest;
@@ -69,20 +69,20 @@ public class PMNotificationHandlerTest {
     
     private static String pmNotificationsString ;
     private static String pmNotificationsString1 ;
-    private static PMNotification pmNotification;
-    private static PMNotification pmNotification1;
+    private static PmNotification pmNotification;
+    private static PmNotification pmNotification1;
 
     @BeforeClass
     public static void setup() {
         pmNotificationsString=readFromFile("/pmNotification.json");
         pmNotificationsString1=readFromFile("/pmNotification1.json");
         ObjectMapper mapper = new ObjectMapper();        
-        pmNotification = new PMNotification();
-        pmNotification1 = new PMNotification();
+        pmNotification = new PmNotification();
+        pmNotification1 = new PmNotification();
         
         try {
-            pmNotification = mapper.readValue(pmNotificationsString, PMNotification.class);
-            pmNotification1 = mapper.readValue(pmNotificationsString1, PMNotification.class);
+            pmNotification = mapper.readValue(pmNotificationsString, PmNotification.class);
+            pmNotification1 = mapper.readValue(pmNotificationsString1, PmNotification.class);
         } catch(Exception e) {
             e.printStackTrace();      
             }
@@ -98,6 +98,7 @@ public class PMNotificationHandlerTest {
         when(handOverMetricsRepositoryMock.save(new HandOverMetrics())).thenReturn(null);
         when(flagMock.getHolder()).thenReturn("NONE");
         when(policyDmaapClient.sendNotificationToPolicy(Mockito.anyString())).thenReturn(true);
+        when(policyDmaapClient.handlePolicyResponse(Mockito.anyString())).thenReturn(true);
         assertTrue(pmNotificationHandler.handlePmNotifications(pmNotification, 50));
         assertFalse(pmNotificationHandler.handlePmNotifications(null, 0));
         assertTrue(pmNotificationHandler.handlePmNotifications(pmNotification1, 50));
index 536f327..28940b3 100644 (file)
@@ -187,6 +187,7 @@ public class TestChildThreadUtils {
         pciPairList.add(cell2);
         pciPairList.add(cell3);
         pnfsMap.put("pnf1", pciPairList);
+        when(policyDmaapClient.handlePolicyResponse(Mockito.anyString())).thenReturn(true);
         when(pnfUtils.getPnfs(async.getSolutions())).thenReturn(pnfsMap);
         List<String> remNeighbors = new ArrayList<>();
         remNeighbors.add("EXP006");
diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClientTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClientTest.java
new file mode 100644 (file)
index 0000000..16f205f
--- /dev/null
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  son-handler
+ *  ================================================================================
+ *   Copyright (C) 2019 Wipro Limited.
+ *   ==============================================================================
+ *     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.dcaegen2.services.sonhms.dmaap;
+
+import static org.junit.Assert.*;
+
+import com.att.nsa.cambria.client.CambriaBatchingPublisher;
+import com.att.nsa.cambria.client.CambriaConsumer;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.dcaegen2.services.sonhms.Configuration;
+import org.onap.dcaegen2.services.sonhms.utils.ClusterUtilsTest;
+import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@RunWith(MockitoJUnitRunner.class)
+@SpringBootTest(classes = PolicyDmaapClient.class)
+public class PolicyDmaapClientTest {
+    
+    @Mock
+    Configuration configurationMock;
+    
+    @Mock
+    DmaapUtils dmaapUtilsMock;
+    
+    @InjectMocks
+    PolicyDmaapClient policyDmaapClient;
+    
+    @Mock
+    CambriaConsumer policyResponseCambriaConsumerMock;
+    
+    @Mock
+    CambriaBatchingPublisher cambriaBatchingPublisherMock;
+    
+    @Mock
+    NotificationProducer notificationProducerMock;
+    
+    @Before
+    public void setup() {
+        policyDmaapClient = new PolicyDmaapClient(dmaapUtilsMock, configurationMock);
+    }
+    
+    @Test
+    public void handlePolicyResponseTest() {
+        
+        Map<String, Object> streamsSubscribes = new HashMap<>();
+        Map<String, String> topics = new HashMap<>();
+        Map<String, Object> dmaapInfo = new HashMap<>();
+        topics.put("topic_url", "https://message-router.onap.svc.cluster.local:3905/events/DCAE_CL_RSP");
+        dmaapInfo.put("dmaap_info", topics);
+        streamsSubscribes.put("dcae_cl_response_topic", dmaapInfo);
+        System.out.println(streamsSubscribes);
+        String policyResponseString = readFromFile("/policy_response.json");
+        List<String> responseMsgs = new ArrayList<>();
+        responseMsgs.add(policyResponseString);
+        Iterable<String> msgs = () -> new Iterator<String>() {
+            private int index = 0;
+
+            @Override
+            public boolean hasNext() {
+                return responseMsgs.size() > index;
+            }
+
+            @Override
+            public String next() {
+                return responseMsgs.get(index++);
+            }
+        };
+        Mockito.when(configurationMock.getStreamsSubscribes()).thenReturn(streamsSubscribes);
+        Mockito.when(dmaapUtilsMock.buildConsumer(configurationMock, "DCAE_CL_RSP")).thenReturn(policyResponseCambriaConsumerMock);
+        try {
+            Mockito.when(policyResponseCambriaConsumerMock.fetch()).thenReturn(msgs);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        assertTrue(policyDmaapClient.handlePolicyResponse("9d2d790e-a5f0-11e8-98d0-529269fb1459"));
+    }
+    
+    @Test
+    public void sendNotificationToPolicyTest() {
+        Map<String, Object> streamsPublishes = new HashMap<>();
+        Map<String, String> topics = new HashMap<>();
+        Map<String, Object> dmaapInfo = new HashMap<>();
+        topics.put("topic_url", "https://message-router.onap.svc.cluster.local:3905/events/DCAE_CL_OUTPUT");
+        dmaapInfo.put("dmaap_info", topics);
+        streamsPublishes.put("CL_topic", dmaapInfo);
+        Mockito.when(configurationMock.getStreamsPublishes()).thenReturn(streamsPublishes);
+        Mockito.when(dmaapUtilsMock.buildPublisher(configurationMock, "DCAE_CL_OUTPUT")).thenReturn(cambriaBatchingPublisherMock);
+        try {
+            Mockito.when(cambriaBatchingPublisherMock.send("", "hello")).thenReturn(0);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        assertTrue(policyDmaapClient.sendNotificationToPolicy("hello"));
+        
+    }
+    
+    private static String readFromFile(String file) {
+        String content = new String();
+        try {
+
+            InputStream is = ClusterUtilsTest.class.getResourceAsStream(file);
+            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is));
+            content = bufferedReader.readLine();
+            String temp;
+            while ((temp = bufferedReader.readLine()) != null) {
+                content = content.concat(temp);
+            }
+            content = content.trim();
+            bufferedReader.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+            content = null;
+        }
+        return content;
+    }
+}
index 12c4912..d4c7828 100644 (file)
@@ -108,8 +108,10 @@ public class NotificationTest {
         } catch (IOException e) {
             e.printStackTrace();
         }
-
-        assertNotEquals(notif, notif1);
+        
+        Notification notif2 = new Notification("9d2d790e-a5f0-11e8-98d0-529269fb1459", "{}", "SDNR", "1.0.2", "NeighborListModified", payload) ;
+        assertEquals(notif2.getPayload(), notif.getPayload());
+        assertNotEquals(notif, notif1); 
         assertEquals(notif.getAction(), notif1.getAction());
         assertEquals(notif.getAai().toString(), notif1.getAai().toString());
 
index e89c8c3..537630c 100644 (file)
@@ -47,7 +47,7 @@ public class PayloadTest {
 
         Data data = new Data(fapService);
 
-        Configurations config = new Configurations(data);
+        Configurations config = new Configurations(data, null);
         ArrayList<Configurations> al = new ArrayList<>();
         al.add(config);
 
diff --git a/src/test/resources/policy_response.json b/src/test/resources/policy_response.json
new file mode 100644 (file)
index 0000000..37d263a
--- /dev/null
@@ -0,0 +1,10 @@
+{
+  "closedLoopControlName": "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459",
+ "requestID": "9d2d790e-a5f0-11e8-98d0-529269fb1459",
+ "target": "SONHandler",
+  "from": "SDNR",
+  "version": "1.0.2",
+  "policyName": "PCI",
+  "policyVersion": "1.0.2",
+  "payload": " { \"Configurations\":[ { \"Status\": { \"Code\": 200, \"Value\": \"SUCCESS\" }, \"data\":{\"FAPService\":{\"alias\":\"Chn0330\",\"X0005b9Lte\":{\"phyCellIdInUse\":6,\"pnfName\":\"ncserver23\"},\"CellConfig\":{\"LTE\":{\"RAN\":{\"Common\":{\"CellIdentity\":\"Chn0330\"}}}}}} } ] }"
+}