From 3cd4023832810e8b65f85a9db807c8bafec38d82 Mon Sep 17 00:00:00 2001 From: ramya Date: Mon, 11 Mar 2019 17:34:41 +0530 Subject: code coverage for M3 Change-Id: Ib421ce2ac9357a3210d99293497f9e304f8cd2f5 Issue-ID: DCAEGEN2-1259 Signed-off-by: Ramya Ravichandran --- .gitignore | 1 + LICENSE.txt | 2 +- pom.xml | 92 +++--- src/main/docker/postgres_scripts/init_db.sh | 20 ++ src/main/docker/son-handler/entrypoint.sh | 20 ++ .../java/com/wipro/www/sonhms/Application.java | 128 -------- .../www/sonhms/BufferNotificationComponent.java | 62 ---- .../wipro/www/sonhms/BufferNotificationState.java | 38 --- .../sonhms/BufferedNotificationHandlingState.java | 34 -- .../wipro/www/sonhms/ChildStatusUpdateState.java | 88 ------ .../com/wipro/www/sonhms/ChildTriggeringState.java | 40 --- .../wipro/www/sonhms/ClusterDetailsComponent.java | 58 ---- .../java/com/wipro/www/sonhms/ConfigPolicy.java | 57 ---- .../java/com/wipro/www/sonhms/Configuration.java | 281 ----------------- src/main/java/com/wipro/www/sonhms/MainThread.java | 49 --- .../com/wipro/www/sonhms/MainThreadComponent.java | 55 ---- .../java/com/wipro/www/sonhms/NewNotification.java | 40 --- .../com/wipro/www/sonhms/ResourceCleanupState.java | 34 -- .../www/sonhms/SdnrNotificationHandlingState.java | 259 ---------------- src/main/java/com/wipro/www/sonhms/SonContext.java | 122 -------- .../java/com/wipro/www/sonhms/SonController.java | 59 ---- .../com/wipro/www/sonhms/SonRequestsComponent.java | 40 --- src/main/java/com/wipro/www/sonhms/SonState.java | 26 -- src/main/java/com/wipro/www/sonhms/Topic.java | 72 ----- src/main/java/com/wipro/www/sonhms/WaitState.java | 90 ------ .../com/wipro/www/sonhms/child/ChildThread.java | 245 --------------- .../wipro/www/sonhms/child/ClusterFormation.java | 144 --------- .../www/sonhms/child/ClusterModification.java | 147 --------- .../java/com/wipro/www/sonhms/child/Detection.java | 87 ------ .../java/com/wipro/www/sonhms/child/Graph.java | 202 ------------ .../java/com/wipro/www/sonhms/child/StateOof.java | 271 ---------------- .../dao/BufferedNotificationsRepository.java | 43 --- .../wipro/www/sonhms/dao/CellInfoRepository.java | 34 -- .../www/sonhms/dao/ClusterDetailsRepository.java | 59 ---- .../sonhms/dao/DmaapNotificationsRepository.java | 40 --- .../www/sonhms/dao/SonRequestsRepository.java | 43 --- .../com/wipro/www/sonhms/dmaap/DmaapClient.java | 215 ------------- .../www/sonhms/dmaap/NotificationConsumer.java | 59 ---- .../www/sonhms/dmaap/NotificationProducer.java | 57 ---- .../wipro/www/sonhms/dmaap/PolicyDmaapClient.java | 53 ---- .../www/sonhms/entity/BufferedNotifications.java | 84 ----- .../java/com/wipro/www/sonhms/entity/CellInfo.java | 69 ----- .../wipro/www/sonhms/entity/ClusterDetails.java | 80 ----- .../www/sonhms/entity/DmaapNotifications.java | 69 ----- .../com/wipro/www/sonhms/entity/PciRequests.java | 68 ---- .../exceptions/ConfigDbNotFoundException.java | 33 -- .../sonhms/exceptions/OofNotFoundException.java | 33 -- .../com/wipro/www/sonhms/model/CellConfig.java | 47 --- .../wipro/www/sonhms/model/CellNeighbourList.java | 69 ----- .../com/wipro/www/sonhms/model/CellPciPair.java | 98 ------ .../java/com/wipro/www/sonhms/model/Common.java | 47 --- .../com/wipro/www/sonhms/model/Configurations.java | 54 ---- src/main/java/com/wipro/www/sonhms/model/Data.java | 47 --- .../com/wipro/www/sonhms/model/FapService.java | 74 ----- .../com/wipro/www/sonhms/model/FapServiceList.java | 80 ----- src/main/java/com/wipro/www/sonhms/model/Lte.java | 47 --- .../sonhms/model/LteNeighborListInUseLteCell.java | 135 -------- .../wipro/www/sonhms/model/NeighborListInUse.java | 64 ---- .../com/wipro/www/sonhms/model/Notification.java | 112 ------- .../www/sonhms/model/NotificationCellConfig.java | 51 --- .../wipro/www/sonhms/model/NotificationLte.java | 51 --- .../www/sonhms/model/NotificationPayload.java | 51 --- .../wipro/www/sonhms/model/NotificationRan.java | 63 ---- .../java/com/wipro/www/sonhms/model/Payload.java | 54 ---- .../wipro/www/sonhms/model/PolicyNotification.java | 179 ----------- .../com/wipro/www/sonhms/model/RadioAccess.java | 64 ---- src/main/java/com/wipro/www/sonhms/model/Ran.java | 50 --- .../java/com/wipro/www/sonhms/model/Response.java | 48 --- .../com/wipro/www/sonhms/model/SdnrResponse.java | 37 --- .../java/com/wipro/www/sonhms/model/ThreadId.java | 35 --- .../com/wipro/www/sonhms/model/X0005b9Lte.java | 63 ---- .../www/sonhms/restclient/AsyncResponseBody.java | 79 ----- .../com/wipro/www/sonhms/restclient/CellInfo.java | 48 --- .../www/sonhms/restclient/OofRequestBody.java | 44 --- .../wipro/www/sonhms/restclient/OofRestClient.java | 101 ------ .../www/sonhms/restclient/PolicyRequestBody.java | 53 ---- .../www/sonhms/restclient/PolicyRestClient.java | 74 ----- .../wipro/www/sonhms/restclient/RequestInfo.java | 100 ------ .../www/sonhms/restclient/SdnrRestClient.java | 137 -------- .../com/wipro/www/sonhms/restclient/Solution.java | 74 ----- .../wipro/www/sonhms/restclient/SonSolution.java | 44 --- .../java/com/wipro/www/sonhms/utils/BeanUtil.java | 40 --- .../java/com/wipro/www/sonhms/utils/FileIo.java | 50 --- .../com/wipro/www/sonhms/utils/HttpRequester.java | 284 ----------------- .../onap/dcaegen2/services/sonhms/Application.java | 129 ++++++++ .../sonhms/BufferNotificationComponent.java | 63 ++++ .../services/sonhms/ClusterDetailsComponent.java | 59 ++++ .../dcaegen2/services/sonhms/ConfigPolicy.java | 58 ++++ .../dcaegen2/services/sonhms/Configuration.java | 309 ++++++++++++++++++ .../services/sonhms/ConfigurationFetcher.java | 72 +++++ .../sonhms/DmaapNotificationsComponent.java | 58 ++++ .../dcaegen2/services/sonhms/EventHandler.java | 252 +++++++++++++++ .../onap/dcaegen2/services/sonhms/MainThread.java | 98 ++++++ .../services/sonhms/MainThreadComponent.java | 43 +++ .../dcaegen2/services/sonhms/NewNotification.java | 41 +++ .../sonhms/NotificationToClusterMapping.java | 93 ++++++ .../dcaegen2/services/sonhms/SonController.java | 59 ++++ .../services/sonhms/SonRequestsComponent.java | 41 +++ .../org/onap/dcaegen2/services/sonhms/Topic.java | 73 +++++ .../services/sonhms/child/ChildThread.java | 245 +++++++++++++++ .../services/sonhms/child/ChildThreadUtils.java | 94 ++++++ .../services/sonhms/child/ClusterFormation.java | 146 +++++++++ .../dcaegen2/services/sonhms/child/Detection.java | 88 ++++++ .../onap/dcaegen2/services/sonhms/child/Graph.java | 242 +++++++++++++++ .../dcaegen2/services/sonhms/child/PnfUtils.java | 78 +++++ .../dcaegen2/services/sonhms/child/StateOof.java | 193 ++++++++++++ .../services/sonhms/controller/HealthCheck.java | 36 +++ .../dao/BufferedNotificationsRepository.java | 44 +++ .../services/sonhms/dao/CellInfoRepository.java | 35 +++ .../sonhms/dao/ClusterDetailsRepository.java | 60 ++++ .../sonhms/dao/DmaapNotificationsRepository.java | 41 +++ .../services/sonhms/dao/SonRequestsRepository.java | 44 +++ .../services/sonhms/dmaap/DmaapClient.java | 215 +++++++++++++ .../sonhms/dmaap/NotificationConsumer.java | 60 ++++ .../sonhms/dmaap/NotificationProducer.java | 52 ++++ .../services/sonhms/dmaap/PolicyDmaapClient.java | 52 ++++ .../sonhms/entity/BufferedNotifications.java | 85 +++++ .../dcaegen2/services/sonhms/entity/CellInfo.java | 70 +++++ .../services/sonhms/entity/ClusterDetails.java | 87 ++++++ .../services/sonhms/entity/DmaapNotifications.java | 70 +++++ .../services/sonhms/entity/PciRequests.java | 69 +++++ .../exceptions/ConfigDbNotFoundException.java | 34 ++ .../sonhms/exceptions/OofNotFoundException.java | 34 ++ .../dcaegen2/services/sonhms/model/CellConfig.java | 48 +++ .../services/sonhms/model/CellNeighbourList.java | 70 +++++ .../services/sonhms/model/CellPciPair.java | 99 ++++++ .../dcaegen2/services/sonhms/model/Common.java | 48 +++ .../services/sonhms/model/Configurations.java | 55 ++++ .../onap/dcaegen2/services/sonhms/model/Data.java | 48 +++ .../dcaegen2/services/sonhms/model/FapService.java | 75 +++++ .../services/sonhms/model/FapServiceList.java | 81 +++++ .../onap/dcaegen2/services/sonhms/model/Lte.java | 48 +++ .../sonhms/model/LteNeighborListInUseLteCell.java | 136 ++++++++ .../services/sonhms/model/NeighborListInUse.java | 65 ++++ .../services/sonhms/model/Notification.java | 120 +++++++ .../sonhms/model/NotificationCellConfig.java | 52 ++++ .../services/sonhms/model/NotificationLte.java | 52 ++++ .../services/sonhms/model/NotificationPayload.java | 52 ++++ .../services/sonhms/model/NotificationRan.java | 64 ++++ .../dcaegen2/services/sonhms/model/Payload.java | 55 ++++ .../services/sonhms/model/PolicyNotification.java | 206 ++++++++++++ .../services/sonhms/model/RadioAccess.java | 65 ++++ .../onap/dcaegen2/services/sonhms/model/Ran.java | 51 +++ .../dcaegen2/services/sonhms/model/Response.java | 49 +++ .../services/sonhms/model/SdnrResponse.java | 38 +++ .../dcaegen2/services/sonhms/model/ThreadId.java | 36 +++ .../dcaegen2/services/sonhms/model/X0005b9Lte.java | 64 ++++ .../sonhms/restclient/AsyncResponseBody.java | 80 +++++ .../services/sonhms/restclient/CellInfo.java | 49 +++ .../services/sonhms/restclient/OofRequestBody.java | 45 +++ .../services/sonhms/restclient/OofRestClient.java | 104 +++++++ .../sonhms/restclient/PolicyRequestBody.java | 54 ++++ .../sonhms/restclient/PolicyRestClient.java | 77 +++++ .../services/sonhms/restclient/RequestInfo.java | 101 ++++++ .../services/sonhms/restclient/SdnrRestClient.java | 141 +++++++++ .../services/sonhms/restclient/Solution.java | 75 +++++ .../services/sonhms/restclient/SonSolution.java | 45 +++ .../dcaegen2/services/sonhms/utils/AppConfig.java | 68 ++++ .../dcaegen2/services/sonhms/utils/BeanUtil.java | 41 +++ .../services/sonhms/utils/ClusterUtils.java | 344 +++++++++++++++++++++ .../dcaegen2/services/sonhms/utils/FileIo.java | 51 +++ .../sonhms/utils/SonHandlerRestTemplate.java | 162 ++++++++++ .../services/sonhms/utils/ThreadUtils.java | 84 +++++ src/main/resources/application.properties | 38 +-- src/main/resources/logback.xml | 37 +-- .../java/com/wipro/www/sonhms/ApplicationTest.java | 24 -- .../sonhms/BufferNotificationComponentTest.java | 115 ------- .../www/sonhms/ChildStatusUpdateStateTest.java | 25 -- .../www/sonhms/ClusterDetailsComponentTest.java | 118 ------- .../com/wipro/www/sonhms/ConfigPolicyTest.java | 43 --- .../com/wipro/www/sonhms/ConfigurationTest.java | 88 ------ .../sonhms/SdnrNotificationHandlingStateTest.java | 31 -- .../java/com/wipro/www/sonhms/SonContextTest.java | 59 ---- .../java/com/wipro/www/sonhms/WaitStateTest.java | 24 -- .../java/com/wipro/www/sonhms/child/GraphTest.java | 63 ---- .../www/sonhms/child/TestClusterModification.java | 188 ----------- .../com/wipro/www/sonhms/child/TestDetection.java | 117 ------- .../com/wipro/www/sonhms/model/CellConfigTest.java | 44 --- .../www/sonhms/model/CellNeighbourListTest.java | 41 --- .../www/sonhms/model/NotificationPayloadTest.java | 32 -- .../wipro/www/sonhms/model/NotificationTest.java | 127 -------- .../com/wipro/www/sonhms/model/PayloadTest.java | 71 ----- .../com/wipro/www/sonhms/model/ResponseTest.java | 38 --- .../sonhms/restclient/AsyncResponseBodyTest.java | 57 ---- .../wipro/www/sonhms/restclient/CellInfoTest.java | 45 --- .../www/sonhms/restclient/OofRequestBodyTest.java | 62 ---- .../www/sonhms/restclient/OofRestClientTest.java | 25 -- .../www/sonhms/restclient/PciSolutionsTest.java | 40 --- .../sonhms/restclient/PolicyRequestBodyTest.java | 43 --- .../www/sonhms/restclient/RequestInfoTest.java | 57 ---- .../wipro/www/sonhms/restclient/SolutionsTest.java | 55 ---- .../dcaegen2/services/sonhms/ApplicationTest.java | 25 ++ .../sonhms/BufferNotificationComponentTest.java | 105 +++++++ .../sonhms/ClusterDetailsComponentTest.java | 108 +++++++ .../dcaegen2/services/sonhms/ConfigPolicyTest.java | 43 +++ .../services/sonhms/ConfigurationTest.java | 89 ++++++ .../sonhms/DmaapNotificationsComponentTest.java | 108 +++++++ .../dcaegen2/services/sonhms/EventHandlerTest.java | 150 +++++++++ .../dcaegen2/services/sonhms/MainThreadTest.java | 26 ++ .../onap/dcaegen2/services/sonhms/TopicTest.java | 41 +++ .../dcaegen2/services/sonhms/child/GraphTest.java | 64 ++++ .../sonhms/child/TestChildThreadUtils.java | 111 +++++++ .../services/sonhms/child/TestDetection.java | 117 +++++++ .../services/sonhms/child/TestPnfUtils.java | 157 ++++++++++ .../services/sonhms/dmaap/DmaapClientTest.java | 112 +++++++ .../sonhms/dmaap/NotificationProducerTest.java | 71 +++++ .../sonhms/entity/BufferedNotificationsTest.java | 44 +++ .../services/sonhms/entity/CellInfoTest.java | 38 +++ .../sonhms/entity/DmaapNotificationsTest.java | 43 +++ .../services/sonhms/entity/PciRequestsTest.java | 38 +++ .../services/sonhms/model/CellConfigTest.java | 45 +++ .../sonhms/model/CellNeighbourListTest.java | 42 +++ .../sonhms/model/NotificationPayloadTest.java | 33 ++ .../services/sonhms/model/NotificationTest.java | 128 ++++++++ .../services/sonhms/model/PayloadTest.java | 71 +++++ .../sonhms/model/PolicyNotificationTest.java | 121 ++++++++ .../services/sonhms/model/ResponseTest.java | 39 +++ .../services/sonhms/model/SdnrResponseTest.java | 44 +++ .../services/sonhms/model/ThreadIdTest.java | 38 +++ .../sonhms/restclient/AsyncResponseBodyTest.java | 57 ++++ .../services/sonhms/restclient/CellInfoTest.java | 45 +++ .../sonhms/restclient/OofRequestBodyTest.java | 62 ++++ .../sonhms/restclient/OofRestClientTest.java | 131 ++++++++ .../sonhms/restclient/PciSolutionsTest.java | 40 +++ .../sonhms/restclient/PolicyRequestBodyTest.java | 43 +++ .../sonhms/restclient/PolicyRestClientTest.java | 117 +++++++ .../sonhms/restclient/RequestInfoTest.java | 57 ++++ .../sonhms/restclient/SdnrRestClientTest.java | 158 ++++++++++ .../services/sonhms/restclient/SolutionsTest.java | 56 ++++ .../services/sonhms/utils/ClusterUtilsTest.java | 270 ++++++++++++++++ src/test/resources/ClusterDetailsTest.json | 10 + src/test/resources/clusterInfo1.json | 1 + src/test/resources/clusterInfo2.json | 1 + src/test/resources/clusterInfo3.json | 1 + src/test/resources/clusterInfo4.json | 1 + src/test/resources/clusterInfo5.json | 1 + src/test/resources/clusterInfo6.json | 1 + src/test/resources/clusterInfo7.json | 1 + src/test/resources/notification1.json | 45 +++ src/test/resources/notification2.json | 55 ++++ src/test/resources/notification3.json | 45 +++ src/test/resources/policy_notification.json | 20 ++ src/test/resources/solutions.json | 1 + 243 files changed, 10211 insertions(+), 8236 deletions(-) delete mode 100644 src/main/java/com/wipro/www/sonhms/Application.java delete mode 100644 src/main/java/com/wipro/www/sonhms/BufferNotificationComponent.java delete mode 100644 src/main/java/com/wipro/www/sonhms/BufferNotificationState.java delete mode 100644 src/main/java/com/wipro/www/sonhms/BufferedNotificationHandlingState.java delete mode 100644 src/main/java/com/wipro/www/sonhms/ChildStatusUpdateState.java delete mode 100644 src/main/java/com/wipro/www/sonhms/ChildTriggeringState.java delete mode 100644 src/main/java/com/wipro/www/sonhms/ClusterDetailsComponent.java delete mode 100644 src/main/java/com/wipro/www/sonhms/ConfigPolicy.java delete mode 100644 src/main/java/com/wipro/www/sonhms/Configuration.java delete mode 100644 src/main/java/com/wipro/www/sonhms/MainThread.java delete mode 100644 src/main/java/com/wipro/www/sonhms/MainThreadComponent.java delete mode 100644 src/main/java/com/wipro/www/sonhms/NewNotification.java delete mode 100644 src/main/java/com/wipro/www/sonhms/ResourceCleanupState.java delete mode 100644 src/main/java/com/wipro/www/sonhms/SdnrNotificationHandlingState.java delete mode 100644 src/main/java/com/wipro/www/sonhms/SonContext.java delete mode 100644 src/main/java/com/wipro/www/sonhms/SonController.java delete mode 100644 src/main/java/com/wipro/www/sonhms/SonRequestsComponent.java delete mode 100644 src/main/java/com/wipro/www/sonhms/SonState.java delete mode 100644 src/main/java/com/wipro/www/sonhms/Topic.java delete mode 100644 src/main/java/com/wipro/www/sonhms/WaitState.java delete mode 100644 src/main/java/com/wipro/www/sonhms/child/ChildThread.java delete mode 100644 src/main/java/com/wipro/www/sonhms/child/ClusterFormation.java delete mode 100644 src/main/java/com/wipro/www/sonhms/child/ClusterModification.java delete mode 100644 src/main/java/com/wipro/www/sonhms/child/Detection.java delete mode 100644 src/main/java/com/wipro/www/sonhms/child/Graph.java delete mode 100644 src/main/java/com/wipro/www/sonhms/child/StateOof.java delete mode 100644 src/main/java/com/wipro/www/sonhms/dao/BufferedNotificationsRepository.java delete mode 100644 src/main/java/com/wipro/www/sonhms/dao/CellInfoRepository.java delete mode 100644 src/main/java/com/wipro/www/sonhms/dao/ClusterDetailsRepository.java delete mode 100644 src/main/java/com/wipro/www/sonhms/dao/DmaapNotificationsRepository.java delete mode 100644 src/main/java/com/wipro/www/sonhms/dao/SonRequestsRepository.java delete mode 100644 src/main/java/com/wipro/www/sonhms/dmaap/DmaapClient.java delete mode 100644 src/main/java/com/wipro/www/sonhms/dmaap/NotificationConsumer.java delete mode 100644 src/main/java/com/wipro/www/sonhms/dmaap/NotificationProducer.java delete mode 100644 src/main/java/com/wipro/www/sonhms/dmaap/PolicyDmaapClient.java delete mode 100644 src/main/java/com/wipro/www/sonhms/entity/BufferedNotifications.java delete mode 100644 src/main/java/com/wipro/www/sonhms/entity/CellInfo.java delete mode 100644 src/main/java/com/wipro/www/sonhms/entity/ClusterDetails.java delete mode 100644 src/main/java/com/wipro/www/sonhms/entity/DmaapNotifications.java delete mode 100644 src/main/java/com/wipro/www/sonhms/entity/PciRequests.java delete mode 100644 src/main/java/com/wipro/www/sonhms/exceptions/ConfigDbNotFoundException.java delete mode 100644 src/main/java/com/wipro/www/sonhms/exceptions/OofNotFoundException.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/CellConfig.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/CellNeighbourList.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/CellPciPair.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/Common.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/Configurations.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/Data.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/FapService.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/FapServiceList.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/Lte.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/LteNeighborListInUseLteCell.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/NeighborListInUse.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/Notification.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/NotificationCellConfig.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/NotificationLte.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/NotificationPayload.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/NotificationRan.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/Payload.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/PolicyNotification.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/RadioAccess.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/Ran.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/Response.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/SdnrResponse.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/ThreadId.java delete mode 100644 src/main/java/com/wipro/www/sonhms/model/X0005b9Lte.java delete mode 100644 src/main/java/com/wipro/www/sonhms/restclient/AsyncResponseBody.java delete mode 100644 src/main/java/com/wipro/www/sonhms/restclient/CellInfo.java delete mode 100644 src/main/java/com/wipro/www/sonhms/restclient/OofRequestBody.java delete mode 100644 src/main/java/com/wipro/www/sonhms/restclient/OofRestClient.java delete mode 100644 src/main/java/com/wipro/www/sonhms/restclient/PolicyRequestBody.java delete mode 100644 src/main/java/com/wipro/www/sonhms/restclient/PolicyRestClient.java delete mode 100644 src/main/java/com/wipro/www/sonhms/restclient/RequestInfo.java delete mode 100644 src/main/java/com/wipro/www/sonhms/restclient/SdnrRestClient.java delete mode 100644 src/main/java/com/wipro/www/sonhms/restclient/Solution.java delete mode 100644 src/main/java/com/wipro/www/sonhms/restclient/SonSolution.java delete mode 100644 src/main/java/com/wipro/www/sonhms/utils/BeanUtil.java delete mode 100644 src/main/java/com/wipro/www/sonhms/utils/FileIo.java delete mode 100644 src/main/java/com/wipro/www/sonhms/utils/HttpRequester.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/Application.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponent.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponent.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/ConfigPolicy.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/ConfigurationFetcher.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/NewNotification.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/NotificationToClusterMapping.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/SonController.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/SonRequestsComponent.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/Topic.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/child/ClusterFormation.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/child/Detection.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/child/Graph.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/controller/HealthCheck.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/dao/BufferedNotificationsRepository.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/dao/CellInfoRepository.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/dao/ClusterDetailsRepository.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/dao/DmaapNotificationsRepository.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/dao/SonRequestsRepository.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationConsumer.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationProducer.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/entity/BufferedNotifications.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/entity/CellInfo.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/entity/ClusterDetails.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/entity/DmaapNotifications.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/entity/PciRequests.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/exceptions/ConfigDbNotFoundException.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/exceptions/OofNotFoundException.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/CellConfig.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/CellNeighbourList.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/CellPciPair.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/Common.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/Configurations.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/Data.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/FapService.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/FapServiceList.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/Lte.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/LteNeighborListInUseLteCell.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/NeighborListInUse.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/Notification.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationCellConfig.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationLte.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationPayload.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationRan.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/Payload.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/RadioAccess.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/Ran.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/Response.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/SdnrResponse.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/ThreadId.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/X0005b9Lte.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBody.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfo.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRequestBody.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRequestBody.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRestClient.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/restclient/RequestInfo.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClient.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/restclient/Solution.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SonSolution.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/utils/AppConfig.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/utils/BeanUtil.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/utils/FileIo.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java delete mode 100644 src/test/java/com/wipro/www/sonhms/ApplicationTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/BufferNotificationComponentTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/ChildStatusUpdateStateTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/ClusterDetailsComponentTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/ConfigPolicyTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/ConfigurationTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/SdnrNotificationHandlingStateTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/SonContextTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/WaitStateTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/child/GraphTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/child/TestClusterModification.java delete mode 100644 src/test/java/com/wipro/www/sonhms/child/TestDetection.java delete mode 100644 src/test/java/com/wipro/www/sonhms/model/CellConfigTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/model/CellNeighbourListTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/model/NotificationPayloadTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/model/NotificationTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/model/PayloadTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/model/ResponseTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/restclient/AsyncResponseBodyTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/restclient/CellInfoTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/restclient/OofRequestBodyTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/restclient/OofRestClientTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/restclient/PciSolutionsTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/restclient/PolicyRequestBodyTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/restclient/RequestInfoTest.java delete mode 100644 src/test/java/com/wipro/www/sonhms/restclient/SolutionsTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/ApplicationTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponentTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponentTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/ConfigPolicyTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponentTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/EventHandlerTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/MainThreadTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/TopicTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/child/GraphTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/child/TestDetection.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/child/TestPnfUtils.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClientTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationProducerTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/entity/BufferedNotificationsTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/entity/CellInfoTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/entity/DmaapNotificationsTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/entity/PciRequestsTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/model/CellConfigTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/model/CellNeighbourListTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/model/NotificationPayloadTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/model/NotificationTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/model/PayloadTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotificationTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/model/ResponseTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/model/SdnrResponseTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/model/ThreadIdTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBodyTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfoTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/restclient/OofRequestBodyTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClientTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/restclient/PciSolutionsTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRequestBodyTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRestClientTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/restclient/RequestInfoTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClientTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/restclient/SolutionsTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtilsTest.java create mode 100644 src/test/resources/ClusterDetailsTest.json create mode 100644 src/test/resources/clusterInfo1.json create mode 100644 src/test/resources/clusterInfo2.json create mode 100644 src/test/resources/clusterInfo3.json create mode 100644 src/test/resources/clusterInfo4.json create mode 100644 src/test/resources/clusterInfo5.json create mode 100644 src/test/resources/clusterInfo6.json create mode 100644 src/test/resources/clusterInfo7.json create mode 100644 src/test/resources/notification1.json create mode 100644 src/test/resources/notification2.json create mode 100644 src/test/resources/notification3.json create mode 100644 src/test/resources/policy_notification.json create mode 100644 src/test/resources/solutions.json diff --git a/.gitignore b/.gitignore index 8e4c769..26bb426 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ target/ .settings/ .classpath *.jar +/bin/ diff --git a/LICENSE.txt b/LICENSE.txt index 22e7ef8..e4915f2 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,7 +1,7 @@ /* * ============LICENSE_START========================================== * =================================================================== -* Copyright (c) 2018 NOKIA Intellectual Property. All rights reserved. +* Copyright (c) 2019 WIPRO Intellectual Property. All rights reserved. * =================================================================== * * Unless otherwise specified, all software contained herein is licensed diff --git a/pom.xml b/pom.xml index 648f1e6..cbb2c72 100644 --- a/pom.xml +++ b/pom.xml @@ -1,23 +1,24 @@ + ============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========================================================= + + --> 4.0.0 @@ -65,7 +66,16 @@ junit test - + + com.fasterxml.jackson.core + jackson-core + 2.9.8 + + + com.fasterxml.jackson.core + jackson-databind + 2.9.8 + javax.json @@ -76,21 +86,7 @@ org.springframework.boot spring-boot-starter-web - 2.0.4.RELEASE - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - - - org.springframework - spring-web - - + 2.0.4.RELEASE org.postgresql @@ -100,30 +96,22 @@ org.springframework.boot spring-boot-starter-data-jpa - 2.0.4.RELEASE - - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - 2.9.8 - - - com.fasterxml.jackson.core - jackson-databind - 2.9.8 - - - org.springframework - spring-web - 5.0.11.RELEASE + 2.0.4.RELEASE org.springframework.data spring-data-commons-core - 1.4.1.RELEASE + 1.4.0.RELEASE + + + + org.codehaus.jackson + jackson-mapper-asl + 1.9.13 + org.hibernate.javax.persistence hibernate-jpa-2.0-api @@ -133,7 +121,7 @@ org.springframework spring-beans - 5.0.11.RELEASE + 5.0.10.RELEASE diff --git a/src/main/docker/postgres_scripts/init_db.sh b/src/main/docker/postgres_scripts/init_db.sh index cbc27a6..f01eea6 100644 --- a/src/main/docker/postgres_scripts/init_db.sh +++ b/src/main/docker/postgres_scripts/init_db.sh @@ -1,3 +1,23 @@ #!/bin/bash +#******************************************************************************* +# ============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========================================================= +# +#******************************************************************************* psql -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'pci_ms'" | grep -q 1 || psql -U postgres -c "CREATE DATABASE pci_ms" diff --git a/src/main/docker/son-handler/entrypoint.sh b/src/main/docker/son-handler/entrypoint.sh index bf69065..36e3178 100644 --- a/src/main/docker/son-handler/entrypoint.sh +++ b/src/main/docker/son-handler/entrypoint.sh @@ -1,4 +1,24 @@ #!/bin/bash +#******************************************************************************* +# ============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========================================================= +# +#******************************************************************************* sed -i s/DMAAP_SERVER/$DMAAPSERVER/ /etc/config.json sed -i s/SDNR_SERVICE/$SDNRSERVICE/ /etc/config.json diff --git a/src/main/java/com/wipro/www/sonhms/Application.java b/src/main/java/com/wipro/www/sonhms/Application.java deleted file mode 100644 index 4c831b4..0000000 --- a/src/main/java/com/wipro/www/sonhms/Application.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.wipro.www.sonhms.dmaap.DmaapClient; -import com.wipro.www.sonhms.restclient.PolicyRestClient; -import com.wipro.www.sonhms.utils.FileIo; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.annotation.PostConstruct; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class Application { - - @Autowired - DmaapClient dmaapClient; - - @Autowired - MainThreadComponent mainThreadComponent; - - private static Logger log = LoggerFactory.getLogger(Application.class); - - /** - * Main method where the pci context is initially set. - */ - public static void main(String[] args) { - SpringApplication.run(Application.class); - - } - - /** - * initialization. - */ - @PostConstruct - void init() { - getConfig(); - fetchIntialConfigFromPolicy(); - NewNotification newNotification = new NewNotification(false); - dmaapClient.initClient(newNotification); - mainThreadComponent.init(newNotification); - } - - /** - * Gets configuration from policy. - */ - @SuppressWarnings("unchecked") - private void fetchIntialConfigFromPolicy() { - log.debug("fetch initial config from policy"); - String configPolicyResponseJson = PolicyRestClient.fetchConfigFromPolicy(); - if (configPolicyResponseJson.equals("Post failed")) { - log.debug("cannot fetch config from policy"); - return; - } - ObjectMapper mapper = new ObjectMapper(); - List> configPolicyResponse = new ArrayList<>(); - try { - configPolicyResponse = mapper.readValue(configPolicyResponseJson, List.class); - } catch (IOException e) { - log.debug("exception during parsing response from policy", e); - } - String configPolicyJson = null; - if (configPolicyResponse != null) { - configPolicyJson = (String) configPolicyResponse.get(0).get("config"); - } else { - return; - } - Map configPolicyMap = new HashMap<>(); - try { - configPolicyMap = mapper.readValue(configPolicyJson, HashMap.class); - } catch (IOException e) { - log.debug("exception during parsing config body from policy", e); - } - ConfigPolicy configPolicy = ConfigPolicy.getInstance(); - configPolicy.setConfig(configPolicyMap); - if (log.isDebugEnabled()) { - log.debug(configPolicy.toString()); - } - } - - /** - * Gets config from config.json. - * - */ - private void getConfig() { - log.debug("getting initial config"); - String configJson = FileIo.readFromFile("/etc/config.json"); - ObjectMapper mapper = new ObjectMapper(); - Configuration configuration = Configuration.getInstance(); - try { - mapper.readerForUpdating(configuration).readValue(configJson); - if (log.isDebugEnabled()) { - log.debug(configuration.toString()); - } - } catch (IOException e) { - log.debug("exception during parsing configuration", e); - } - } -} diff --git a/src/main/java/com/wipro/www/sonhms/BufferNotificationComponent.java b/src/main/java/com/wipro/www/sonhms/BufferNotificationComponent.java deleted file mode 100644 index 6074a31..0000000 --- a/src/main/java/com/wipro/www/sonhms/BufferNotificationComponent.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import com.wipro.www.sonhms.dao.BufferedNotificationsRepository; -import com.wipro.www.sonhms.entity.BufferedNotifications; -import com.wipro.www.sonhms.utils.BeanUtil; -import java.util.List; - -public class BufferNotificationComponent { - - /** - * Buffers notification along with cluster id in the database. - */ - public void bufferNotification(String notification, String clusterId) { - BufferedNotifications bufferedNotifications = new BufferedNotifications(); - bufferedNotifications.setNotification(notification); - bufferedNotifications.setClusterId(clusterId); - BufferedNotificationsRepository bufferedNotificationsRepository = BeanUtil - .getBean(BufferedNotificationsRepository.class); - bufferedNotificationsRepository.save(bufferedNotifications); - - } - - /** - * Retrieves buffered notification from the database. - */ - public List getBufferedNotification(String clusterId) { - BufferedNotificationsRepository bufferedNotificationsRepository = BeanUtil - .getBean(BufferedNotificationsRepository.class); - return bufferedNotificationsRepository.getNotificationsFromQueue(clusterId); - - } - - /** - * Retrieves clusterid from the database. - */ - public String getClusterId(String notification) { - BufferedNotificationsRepository bufferedNotificationsRepository = BeanUtil - .getBean(BufferedNotificationsRepository.class); - return bufferedNotificationsRepository.getClusterIdForNotification(notification); - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/BufferNotificationState.java b/src/main/java/com/wipro/www/sonhms/BufferNotificationState.java deleted file mode 100644 index 62d485f..0000000 --- a/src/main/java/com/wipro/www/sonhms/BufferNotificationState.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class BufferNotificationState implements SonState { - private static Logger log = LoggerFactory.getLogger(BufferNotificationState.class); - - @Override - public void stateChange(SonContext sonContext) { - log.debug("inside buffer notification state"); - WaitState waitState = WaitState.getInstance(); - sonContext.setPciState(waitState); - sonContext.stateChange(sonContext); - - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/BufferedNotificationHandlingState.java b/src/main/java/com/wipro/www/sonhms/BufferedNotificationHandlingState.java deleted file mode 100644 index ef76bdb..0000000 --- a/src/main/java/com/wipro/www/sonhms/BufferedNotificationHandlingState.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -public class BufferedNotificationHandlingState implements SonState { - - @Override - public void stateChange(SonContext sonContext) { - // any other pci context change to be done - WaitState waitState = WaitState.getInstance(); - sonContext.setPciState(waitState); - sonContext.stateChange(sonContext); - - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/ChildStatusUpdateState.java b/src/main/java/com/wipro/www/sonhms/ChildStatusUpdateState.java deleted file mode 100644 index b8d0cf4..0000000 --- a/src/main/java/com/wipro/www/sonhms/ChildStatusUpdateState.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.wipro.www.sonhms.model.FapServiceList; - -import java.io.IOException; -import java.util.List; -import java.util.Set; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ChildStatusUpdateState implements SonState { - private static Logger log = LoggerFactory.getLogger(ChildStatusUpdateState.class); - - @Override - public void stateChange(SonContext sonContext) { - if (sonContext.getChildStatus(sonContext.getChildThreadId()).equals("triggeredOof")) { - WaitState waitState = WaitState.getInstance(); - sonContext.setPciState(waitState); - sonContext.stateChange(sonContext); - } else if (sonContext.getChildStatus(sonContext.getChildThreadId()).equals("success")) { - BufferNotificationComponent bufferNotificationComponent = new BufferNotificationComponent(); - ClusterDetailsComponent clusterDetailsComponent = new ClusterDetailsComponent(); - String clusterId = clusterDetailsComponent.getClusterId(sonContext.getChildThreadId()); - List bufferedNotifications = bufferNotificationComponent.getBufferedNotification(clusterId); - if ((bufferedNotifications == null) || bufferedNotifications.isEmpty()) { - // resource clean up - // kill the child thread cleanup resources for the cluster - log.debug("no buffered notification to be handled"); - - Set setOfThread = Thread.getAllStackTraces().keySet(); - for (Thread thread : setOfThread) { - if (thread.getId() == sonContext.getChildThreadId()) { - sonContext.deleteChildStatus(); - thread.interrupt(); - } - } - - sonContext.setPciState(new ResourceCleanupState()); - sonContext.stateChange(sonContext); - - } else { - // forward to child thread - ObjectMapper mapper = new ObjectMapper(); - log.debug("handling buffer notification"); - long childThreadId = sonContext.getChildThreadId(); - for (String notification : bufferedNotifications) { - FapServiceList fapServiceList; - try { - fapServiceList = mapper.readValue(notification, FapServiceList.class); - log.debug("fapServiceList{}", fapServiceList); - - SdnrNotificationHandlingState.getChildThreadMap().get(childThreadId) - .putInQueueWithNotify(fapServiceList); - sonContext.setPciState(new BufferedNotificationHandlingState()); - sonContext.stateChange(sonContext); - - } catch (IOException e) { - log.error("caught in child status update {}", e); - } - - } - } - } - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/ChildTriggeringState.java b/src/main/java/com/wipro/www/sonhms/ChildTriggeringState.java deleted file mode 100644 index 6683085..0000000 --- a/src/main/java/com/wipro/www/sonhms/ChildTriggeringState.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ChildTriggeringState implements SonState { - private static Logger log = LoggerFactory.getLogger(ChildTriggeringState.class); - - @Override - public void stateChange(SonContext sonContext) { - // any other pci context change to be done - - log.debug("inside child trigger state"); - WaitState waitState = WaitState.getInstance(); - sonContext.setPciState(waitState); - sonContext.stateChange(sonContext); - - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/ClusterDetailsComponent.java b/src/main/java/com/wipro/www/sonhms/ClusterDetailsComponent.java deleted file mode 100644 index 939f9e1..0000000 --- a/src/main/java/com/wipro/www/sonhms/ClusterDetailsComponent.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import com.wipro.www.sonhms.dao.ClusterDetailsRepository; -import com.wipro.www.sonhms.entity.ClusterDetails; -import com.wipro.www.sonhms.utils.BeanUtil; - -import java.util.List; - - -public class ClusterDetailsComponent { - - /** - * get cluster details. - */ - public List getClusterDetails() { - ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class); - return clusterDetailsRepository.getAllClusterDetails(); - } - - /** - * get child thread. - */ - public long getChildThread(String clusterId) { - ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class); - return clusterDetailsRepository.getChildThreadForCluster(clusterId); - - } - - /** - * get cluster id. - */ - public String getClusterId(long childThreadId) { - ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class); - return clusterDetailsRepository.getClusterIdForChildThread(childThreadId); - - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/ConfigPolicy.java b/src/main/java/com/wipro/www/sonhms/ConfigPolicy.java deleted file mode 100644 index 6d2994f..0000000 --- a/src/main/java/com/wipro/www/sonhms/ConfigPolicy.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import java.util.Map; - -public class ConfigPolicy { - - private static ConfigPolicy instance = null; - private Map config; - - protected ConfigPolicy() { - - } - - /** - * Get instance of class. - */ - public static ConfigPolicy getInstance() { - if (instance == null) { - instance = new ConfigPolicy(); - } - return instance; - } - - public Map getConfig() { - return config; - } - - public void setConfig(Map config) { - this.config = config; - } - - @Override - public String toString() { - return "ConfigPolicy [config=" + config + "]"; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/Configuration.java b/src/main/java/com/wipro/www/sonhms/Configuration.java deleted file mode 100644 index fb53f9b..0000000 --- a/src/main/java/com/wipro/www/sonhms/Configuration.java +++ /dev/null @@ -1,281 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import java.util.List; - -public class Configuration { - - private static Configuration instance = null; - private List topics; - private String sdnrTopic; - private String policyTopic; - private List servers; - private String managerApiKey; - private String managerSecretKey; - private String pcimsApiKey; - private String pcimsSecretKey; - private String cg; - private String cid; - private int pollingInterval; - private int pollingTimeout; - private int minCollision; - private int minConfusion; - private String sdnrService; - private String policyService; - private String oofService; - private String sourceId; - private String policyName; - private String configName; - private String callbackUrl; - private List optimizers; - private int numSolutions; - private int bufferTime; - private int maximumClusters; - - public int getMaximumClusters() { - return maximumClusters; - } - - public void setMaximumClusters(int maximumClusters) { - this.maximumClusters = maximumClusters; - } - - protected Configuration() { - - } - - /** - * Get instance of class. - */ - public static Configuration getInstance() { - if (instance == null) { - instance = new Configuration(); - } - return instance; - } - - public List getServers() { - return servers; - } - - public void setServers(List servers) { - this.servers = servers; - } - - public String getManagerApiKey() { - return managerApiKey; - } - - public void setManagerApiKey(String managerApiKey) { - this.managerApiKey = managerApiKey; - } - - public String getManagerSecretKey() { - return managerSecretKey; - } - - public void setManagerSecretKey(String managerSecretKey) { - this.managerSecretKey = managerSecretKey; - } - - public String getPcimsApiKey() { - return pcimsApiKey; - } - - public void setPcimsApiKey(String pcimsApiKey) { - this.pcimsApiKey = pcimsApiKey; - } - - public String getPcimsSecretKey() { - return pcimsSecretKey; - } - - public void setPcimsSecretKey(String pcimsSecretKey) { - this.pcimsSecretKey = pcimsSecretKey; - } - - public String getCg() { - return cg; - } - - public void setCg(String cg) { - this.cg = cg; - } - - public String getCid() { - return cid; - } - - public void setCid(String cid) { - this.cid = cid; - } - - public int getPollingInterval() { - return pollingInterval; - } - - public void setPollingInterval(int pollingInterval) { - this.pollingInterval = pollingInterval; - } - - public int getPollingTimeout() { - return pollingTimeout; - } - - public void setPollingTimeout(int pollingTimeout) { - this.pollingTimeout = pollingTimeout; - } - - public int getMinCollision() { - return minCollision; - } - - public void setMinCollision(int minCollision) { - this.minCollision = minCollision; - } - - public int getMinConfusion() { - return minConfusion; - } - - public void setMinConfusion(int minConfusion) { - this.minConfusion = minConfusion; - } - - public String getSdnrService() { - return sdnrService; - } - - public void setSdnrService(String sdnrService) { - this.sdnrService = sdnrService; - } - - public String getPolicyService() { - return policyService; - } - - public void setPolicyService(String policyService) { - this.policyService = policyService; - } - - public String getOofService() { - return oofService; - } - - public void setOofService(String oofService) { - this.oofService = oofService; - } - - public String getSourceId() { - return sourceId; - } - - public void setSourceId(String sourceId) { - this.sourceId = sourceId; - } - - public String getPolicyName() { - return policyName; - } - - public void setPolicyName(String policyName) { - this.policyName = policyName; - } - - public String getConfigName() { - return configName; - } - - public void setConfigName(String configName) { - this.configName = configName; - } - - public String getCallbackUrl() { - return callbackUrl; - } - - public void setCallbackUrl(String callbackUrl) { - this.callbackUrl = callbackUrl; - } - - public List getOptimizers() { - return optimizers; - } - - public void setOptimizers(List optimizers) { - this.optimizers = optimizers; - } - - public int getNumSolutions() { - return numSolutions; - } - - public void setNumSolutions(int numSolutions) { - this.numSolutions = numSolutions; - } - - public int getBufferTime() { - return bufferTime; - } - - public void setBufferTime(int bufferTime) { - this.bufferTime = bufferTime; - } - - public List getTopics() { - return topics; - } - - public void setTopics(List topics) { - this.topics = topics; - } - - public String getSdnrTopic() { - return sdnrTopic; - } - - public void setSdnrTopic(String sdnrTopic) { - this.sdnrTopic = sdnrTopic; - } - - public String getPolicyTopic() { - return policyTopic; - } - - public void setPolicyTopic(String policyTopic) { - this.policyTopic = policyTopic; - } - - @Override - public String toString() { - return "Configuration [topics=" + topics + ", sdnrTopic=" + sdnrTopic + ", policyTopic=" + policyTopic - + ", servers=" + servers + ", managerApiKey=" + managerApiKey + ", managerSecretKey=" + managerSecretKey - + ", pcimsApiKey=" + pcimsApiKey + ", pcimsSecretKey=" + pcimsSecretKey + ", cg=" + cg + ", cid=" + cid - + ", pollingInterval=" + pollingInterval + ", pollingTimeout=" + pollingTimeout + ", minCollision=" - + minCollision + ", minConfusion=" + minConfusion + ", sdnrService=" + sdnrService + ", policyService=" - + policyService + ", oofService=" + oofService + ", sourceId=" + sourceId + ", policyName=" + policyName - + ", configName=" + configName + ", callbackUrl=" + callbackUrl + ", optimizers=" + optimizers - + ", numSolutions=" + numSolutions + ", bufferTime=" + bufferTime + ", maximumClusters=" - + maximumClusters + "]"; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/MainThread.java b/src/main/java/com/wipro/www/sonhms/MainThread.java deleted file mode 100644 index 2b6c843..0000000 --- a/src/main/java/com/wipro/www/sonhms/MainThread.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import java.util.List; -import java.util.concurrent.LinkedBlockingQueue; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class MainThread implements Runnable { - private static Logger log = LoggerFactory.getLogger(MainThread.class); - - private NewNotification newNotification; - - @Override - public void run() { - log.debug("Starting pci context"); - SonContext sonContext = new SonContext(new LinkedBlockingQueue>(), newNotification); - log.debug("initializing pci state to wait state"); - WaitState waitState = WaitState.getInstance(); - sonContext.setPciState(waitState); - sonContext.stateChange(sonContext); - } - - public MainThread(NewNotification newNotification) { - super(); - this.newNotification = newNotification; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/MainThreadComponent.java b/src/main/java/com/wipro/www/sonhms/MainThreadComponent.java deleted file mode 100644 index 2b8516d..0000000 --- a/src/main/java/com/wipro/www/sonhms/MainThreadComponent.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component -public class MainThreadComponent { - - private static Logger log = LoggerFactory.getLogger(MainThreadComponent.class); - - private ExecutorService pool; - - public ExecutorService getPool() { - return pool; - } - - /** - * main thread initialization. - */ - public void init(NewNotification newNotification) { - log.debug("initializing main thread"); - log.debug("initializing executors"); - Configuration configuration = Configuration.getInstance(); - int maximumClusters = configuration.getMaximumClusters(); - log.debug("pool creating"); - pool = Executors.newFixedThreadPool(maximumClusters); - log.debug("pool created"); - Thread thread = new Thread(new MainThread(newNotification)); - thread.start(); - } -} diff --git a/src/main/java/com/wipro/www/sonhms/NewNotification.java b/src/main/java/com/wipro/www/sonhms/NewNotification.java deleted file mode 100644 index 5d4f704..0000000 --- a/src/main/java/com/wipro/www/sonhms/NewNotification.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -public class NewNotification { - - private Boolean newNotif; - - public Boolean getNewNotif() { - return newNotif; - } - - public void setNewNotif(Boolean newNotif) { - this.newNotif = newNotif; - } - - public NewNotification(Boolean newNotif) { - super(); - this.newNotif = newNotif; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/ResourceCleanupState.java b/src/main/java/com/wipro/www/sonhms/ResourceCleanupState.java deleted file mode 100644 index 1487b5e..0000000 --- a/src/main/java/com/wipro/www/sonhms/ResourceCleanupState.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -public class ResourceCleanupState implements SonState { - - @Override - public void stateChange(SonContext sonContext) { - // any other pci context change to be done - WaitState waitState = WaitState.getInstance(); - sonContext.setPciState(waitState); - sonContext.stateChange(sonContext); - - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/SdnrNotificationHandlingState.java b/src/main/java/com/wipro/www/sonhms/SdnrNotificationHandlingState.java deleted file mode 100644 index 2637790..0000000 --- a/src/main/java/com/wipro/www/sonhms/SdnrNotificationHandlingState.java +++ /dev/null @@ -1,259 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.wipro.www.sonhms.child.ChildThread; -import com.wipro.www.sonhms.child.Graph; -import com.wipro.www.sonhms.dao.CellInfoRepository; -import com.wipro.www.sonhms.dao.ClusterDetailsRepository; -import com.wipro.www.sonhms.entity.CellInfo; -import com.wipro.www.sonhms.entity.ClusterDetails; -import com.wipro.www.sonhms.exceptions.ConfigDbNotFoundException; -import com.wipro.www.sonhms.model.CellPciPair; -import com.wipro.www.sonhms.model.FapServiceList; -import com.wipro.www.sonhms.model.LteNeighborListInUseLteCell; -import com.wipro.www.sonhms.model.Notification; -import com.wipro.www.sonhms.model.ThreadId; -import com.wipro.www.sonhms.restclient.SdnrRestClient; -import com.wipro.www.sonhms.utils.BeanUtil; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; - -import org.slf4j.Logger; - -public class SdnrNotificationHandlingState implements SonState { - private static Map childThreadMap = new HashMap<>(); - private static final Logger log = org.slf4j.LoggerFactory.getLogger(SdnrNotificationHandlingState.class); - - @Override - public void stateChange(SonContext sonContext) { - // logic to determine if notif to be processed - log.debug("inside statechange of sdnr notif state"); - String notification = sonContext.getSdnrNotification(); - Notification notificationObject; - try { - - ObjectMapper mapper = new ObjectMapper(); - notificationObject = mapper.readValue(notification, Notification.class); - log.debug("notificationObject{}", notificationObject); - - List serviceList = notificationObject.getPayload().getRadioAccess().getFapServiceList(); - for (FapServiceList fapService : serviceList) { - String cellId = fapService.getCellConfig().getLte().getRan().getCellIdentity(); - log.debug("cellId:{}", cellId); - log.debug("inside for loop"); - - List clusterDetails = getAllClusters(); - - ClusterDetails clusterDetail = getClusterForNotification(fapService, clusterDetails); - - if (clusterDetail == null) { - // form the cluster - Graph cluster = createCluster(fapService); - // save to db - UUID clusterId = UUID.randomUUID(); - cluster.setGraphId(clusterId); - // create the child thread - log.debug("creating new child"); - BlockingQueue queue = new LinkedBlockingQueue<>(); - ThreadId threadId = new ThreadId(); - threadId.setChildThreadId(0); - ChildThread child = new ChildThread(sonContext.getChildStatusUpdate(), cluster, queue, threadId); - queue.put(fapService); - MainThreadComponent mainThreadComponent = BeanUtil.getBean(MainThreadComponent.class); - mainThreadComponent.getPool().execute(child); - - waitForThreadId(threadId); - - saveCluster(cluster, clusterId, threadId.getChildThreadId()); - addChildThreadMap(threadId.getChildThreadId(), child); - sonContext.addChildStatus(threadId.getChildThreadId(), "processingNotifications"); - - } - - else { - if (isOofTriggeredForCluster(sonContext, clusterDetail)) { - sonContext.setNotifToBeProcessed(false); - bufferNotification(fapService, clusterDetail.getClusterId()); - } else { - sonContext.setNotifToBeProcessed(true); - log.debug("childThreadId:{}", clusterDetail.getChildThreadId()); - childThreadMap.get(clusterDetail.getChildThreadId()).putInQueue(fapService); - } - } - } - } catch (Exception e) { - log.error("caught in sdnr notif handling state{}", e); - } - - WaitState waitState = WaitState.getInstance(); - sonContext.setPciState(waitState); - sonContext.stateChange(sonContext); - } - - private void waitForThreadId(ThreadId threadId) { - try { - synchronized (threadId) { - while (threadId.getChildThreadId() == 0) { - threadId.wait(); - } - } - } catch (InterruptedException e) { - - log.error("ChildThread queue error {}", e); - Thread.currentThread().interrupt(); - } - } - - private String saveCluster(Graph cluster, UUID clusterId, Long threadId) { - - String cellPciNeighbourString = cluster.getPciNeighbourJson(); - - log.debug("cluster hahsmap to string : {}", cellPciNeighbourString); - cluster.setGraphId(clusterId); - - ClusterDetails details = new ClusterDetails(); - details.setClusterId(clusterId.toString()); - details.setClusterInfo(cellPciNeighbourString); - details.setChildThreadId(threadId); - - ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class); - clusterDetailsRepository.save(details); - - return clusterId.toString(); - } - - private Graph createCluster(FapServiceList fapService) throws ConfigDbNotFoundException { - - Graph cluster = new Graph(); - log.debug("cluster formation started"); - int phycellId = fapService.getX0005b9Lte().getPhyCellIdInUse(); - String cellId = fapService.getCellConfig().getLte().getRan().getCellIdentity(); - - CellInfoRepository cellInfoRepository = BeanUtil.getBean(CellInfoRepository.class); - cellInfoRepository.save(new CellInfo(cellId, fapService.getX0005b9Lte().getPnfName())); - - CellPciPair val = new CellPciPair(); - val.setCellId(cellId); - val.setPhysicalCellId(phycellId); - List neighbourlist; - neighbourlist = fapService.getCellConfig().getLte().getRan().getNeighborListInUse() - .getLteNeighborListInUseLteCell(); - log.debug("Neighbor list size: {}", neighbourlist.size()); - - for (int i = 0; i < neighbourlist.size(); i++) { - String cell = neighbourlist.get(i).getAlias(); - int phy = neighbourlist.get(i).getPhyCellId(); - - cellInfoRepository.save(new CellInfo(cell, neighbourlist.get(i).getPnfName())); - - log.debug("cellID: {}", cell); - log.debug("PCI: {}", phy); - CellPciPair val1 = new CellPciPair(); - val1.setCellId(cell); - val1.setPhysicalCellId(phy); - cluster.addEdge(val, val1); - log.debug("cluster: {}", cluster); - - List nbrList = SdnrRestClient.getNbrList(neighbourlist.get(i).getAlias()); - - for (CellPciPair nbr : nbrList) { - String cid = nbr.getCellId(); - int pci = nbr.getPhysicalCellId(); - CellPciPair val3 = new CellPciPair(); - val3.setCellId(cid); - val3.setPhysicalCellId(pci); - - cluster.addEdge(val1, val3); - } - } - - log.debug("final cluster: {}", cluster); - return cluster; - } - - private void bufferNotification(FapServiceList fapService, String clusterId) { - - ObjectMapper mapper = new ObjectMapper(); - BufferNotificationComponent bufferNotifComponent = new BufferNotificationComponent(); - String serviceListString = ""; - try { - serviceListString = mapper.writeValueAsString(fapService); - } catch (JsonProcessingException e) { - log.debug("JSON processing exception: {}", e); - } - bufferNotifComponent.bufferNotification(serviceListString, clusterId); - - } - - private boolean isOofTriggeredForCluster(SonContext pciContext, ClusterDetails clusterDetail) { - Long childThreadId = clusterDetail.getChildThreadId(); - String childStatus = pciContext.getChildStatus(childThreadId); - return childStatus.equals("triggeredOof"); - - } - - private ClusterDetails getClusterForNotification(FapServiceList fapService, List clusterDetails) { - - String cellId = fapService.getCellConfig().getLte().getRan().getCellIdentity(); - Map> cellPciNeighbourMap; - - for (ClusterDetails clusterDetail : clusterDetails) { - Graph cluster = new Graph(clusterDetail.getClusterInfo()); - cellPciNeighbourMap = cluster.getCellPciNeighbourMap(); - Set keys = cellPciNeighbourMap.keySet(); - Iterator traverse = keys.iterator(); - while (traverse.hasNext()) { - CellPciPair key = traverse.next(); - String currentCellId = key.getCellId(); - if (cellId.equals(currentCellId)) { - return clusterDetail; - } - } - } - - return null; - } - - private List getAllClusters() { - ClusterDetailsComponent clusterDetailsComponent = new ClusterDetailsComponent(); - return clusterDetailsComponent.getClusterDetails(); - } - - public static void addChildThreadMap(Long childThreadId, ChildThread child) { - childThreadMap.put(childThreadId, child); - } - - public static Map getChildThreadMap() { - return childThreadMap; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/SonContext.java b/src/main/java/com/wipro/www/sonhms/SonContext.java deleted file mode 100644 index 491dccc..0000000 --- a/src/main/java/com/wipro/www/sonhms/SonContext.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.BlockingQueue; - -public class SonContext implements SonState { - private SonState pciState; - boolean notifToBeProcessed; - private String sdnrNotification; - private long childThreadId; - private Map childStatus; - private BlockingQueue> childStatusUpdate; - private NewNotification newNotification; - - public String getSdnrNotification() { - return sdnrNotification; - } - - public void setSdnrNotification(String sdnrNotification) { - this.sdnrNotification = sdnrNotification; - } - - SonContext(SonState pciState) { - this.pciState = pciState; - this.childStatus = new HashMap<>(); - } - - public SonContext() { - - } - - /** - * Parameterized constructor. - */ - public SonContext(BlockingQueue> childStatusUpdate, NewNotification newNotification) { - this.setChildStatusUpdate(childStatusUpdate); - this.setNewNotification(newNotification); - this.childStatus = new HashMap<>(); - } - - public SonState getPciState() { - return pciState; - } - - public long getChildThreadId() { - return childThreadId; - } - - public void setChildThreadId(long childThreadId) { - this.childThreadId = childThreadId; - } - - public void setPciState(SonState pciState) { - this.pciState = pciState; - } - - public boolean isNotifToBeProcessed() { - return notifToBeProcessed; - } - - public void setNotifToBeProcessed(boolean notifToBeProcessed) { - this.notifToBeProcessed = notifToBeProcessed; - } - - @Override - public void stateChange(SonContext pciContext) { - this.pciState.stateChange(pciContext); - } - - public BlockingQueue> getChildStatusUpdate() { - return childStatusUpdate; - } - - public void setChildStatusUpdate(BlockingQueue> childStatusUpdate) { - this.childStatusUpdate = childStatusUpdate; - } - - public void addChildStatus(Long threadId, String status) { - this.childStatus.put(threadId, status); - } - - public String getChildStatus(Long threadId) { - return childStatus.get(threadId); - - } - - public NewNotification getNewNotification() { - return newNotification; - } - - public void setNewNotification(NewNotification newNotification) { - this.newNotification = newNotification; - } - - public void deleteChildStatus() { - this.childStatus.remove(childThreadId); - - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/SonController.java b/src/main/java/com/wipro/www/sonhms/SonController.java deleted file mode 100644 index 8923614..0000000 --- a/src/main/java/com/wipro/www/sonhms/SonController.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - - -import com.wipro.www.sonhms.child.ChildThread; -import com.wipro.www.sonhms.restclient.AsyncResponseBody; - -import org.slf4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - - -@RestController -public class SonController { - private static final Logger log = org.slf4j.LoggerFactory.getLogger(SonController.class); - - @Autowired - SonRequestsComponent pciRequestsComponent; - - @RequestMapping(value = "/callbackUrl", method = RequestMethod.POST) - String callBackUrl(@RequestBody AsyncResponseBody callback) { - log.debug("received request to callback url"); - String async = callback.toString(); - log.debug("AsyncResponseBody{}", async); - - String transactionId = callback.getTransactionId(); - log.debug("transaction id {}", transactionId); - - long childThreadId = pciRequestsComponent.getChildThread(transactionId); - log.debug("childThreadId {}", childThreadId); - - ChildThread.putResponse(childThreadId, callback); - return "Forwarded to child thread"; - - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/SonRequestsComponent.java b/src/main/java/com/wipro/www/sonhms/SonRequestsComponent.java deleted file mode 100644 index 5b57850..0000000 --- a/src/main/java/com/wipro/www/sonhms/SonRequestsComponent.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import com.wipro.www.sonhms.dao.SonRequestsRepository; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - - -@Component -public class SonRequestsComponent { - - @Autowired - private SonRequestsRepository sonRequestsRepository; - - public long getChildThread(String transactionId) { - return sonRequestsRepository.getChildThreadMapping(transactionId); - } - -} - diff --git a/src/main/java/com/wipro/www/sonhms/SonState.java b/src/main/java/com/wipro/www/sonhms/SonState.java deleted file mode 100644 index c287c6b..0000000 --- a/src/main/java/com/wipro/www/sonhms/SonState.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -public interface SonState { - - public void stateChange(SonContext pciContext); -} diff --git a/src/main/java/com/wipro/www/sonhms/Topic.java b/src/main/java/com/wipro/www/sonhms/Topic.java deleted file mode 100644 index 3be2087..0000000 --- a/src/main/java/com/wipro/www/sonhms/Topic.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -public class Topic { - - private String name; - private String producer; - private String consumer; - - public Topic() { - - } - - /** - * Parameterized constructor. - */ - public Topic(String name, String producer, String consumer) { - super(); - this.name = name; - this.producer = producer; - this.consumer = consumer; - } - - @Override - public String toString() { - return "topic [name=" + name + ", producer=" + producer + ", consumer=" + consumer + "]"; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getProducer() { - return producer; - } - - public void setProducer(String producer) { - this.producer = producer; - } - - public String getConsumer() { - return consumer; - } - - public void setConsumer(String consumer) { - this.consumer = consumer; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/WaitState.java b/src/main/java/com/wipro/www/sonhms/WaitState.java deleted file mode 100644 index a74f795..0000000 --- a/src/main/java/com/wipro/www/sonhms/WaitState.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import com.wipro.www.sonhms.dao.DmaapNotificationsRepository; -import com.wipro.www.sonhms.utils.BeanUtil; -import java.util.ArrayList; -import java.util.List; -import org.slf4j.Logger; - - - -public class WaitState implements SonState { - - private static WaitState instance; - private List sdnrNotification = new ArrayList<>(); - private static final Logger log = org.slf4j.LoggerFactory.getLogger(WaitState.class); - - protected WaitState() { - - } - - /** - * singleton. - */ - public static WaitState getInstance() { - if (instance == null) { - return new WaitState(); - } - return instance; - } - - public void putSdnrNotification(String notification) { - sdnrNotification.add(notification); - log.debug("sdnrNotification size: {}", sdnrNotification.size()); - } - - @Override - public void stateChange(SonContext pciContext) { - log.debug("inside state change of wait state"); - - while (pciContext.getChildStatusUpdate().isEmpty() && !pciContext.getNewNotification().getNewNotif()) { - } - - List childStatus = pciContext.getChildStatusUpdate().poll(); - if (childStatus != null) { - Long threadId = Long.parseLong(childStatus.get(0)); - log.debug("threadId: {}", threadId); - log.debug("childStatus: {}", childStatus.get(1)); - pciContext.setChildThreadId(threadId); - pciContext.addChildStatus(threadId, childStatus.get(1)); - pciContext.setPciState(new ChildStatusUpdateState()); - pciContext.stateChange(pciContext); - } - - DmaapNotificationsRepository dmaapNotificationsRepository = BeanUtil - .getBean(DmaapNotificationsRepository.class); - String notification = dmaapNotificationsRepository.getNotificationFromQueue(); - if (notification != null) { - log.debug("notification from sdnr:{}", notification); - pciContext.setSdnrNotification(notification); - pciContext.setPciState(new SdnrNotificationHandlingState()); - pciContext.stateChange(pciContext); - } else { - pciContext.getNewNotification().setNewNotif(false); - log.debug("setting new notification to false"); - pciContext.setPciState(this); - pciContext.stateChange(pciContext); - } - - } -} diff --git a/src/main/java/com/wipro/www/sonhms/child/ChildThread.java b/src/main/java/com/wipro/www/sonhms/child/ChildThread.java deleted file mode 100644 index 718cc46..0000000 --- a/src/main/java/com/wipro/www/sonhms/child/ChildThread.java +++ /dev/null @@ -1,245 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.child; - - -import com.wipro.www.sonhms.Configuration; -import com.wipro.www.sonhms.dao.ClusterDetailsRepository; -import com.wipro.www.sonhms.model.FapServiceList; -import com.wipro.www.sonhms.model.ThreadId; -import com.wipro.www.sonhms.restclient.AsyncResponseBody; -import com.wipro.www.sonhms.utils.BeanUtil; - -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import org.slf4j.Logger; -import org.slf4j.MDC; - - -public class ChildThread implements Runnable { - - private BlockingQueue> childStatusUpdate; - private BlockingQueue queue = new LinkedBlockingQueue<>(); - // static BlockingQueue asynchronousResponse = new - // LinkedBlockingQueue<>(); - private static Map responseMap = new HashMap<>(); - private Graph cluster; - private ThreadId threadId; - FapServiceList fapServiceList = new FapServiceList(); - private static final Logger log = org.slf4j.LoggerFactory.getLogger(ChildThread.class); - - /** - * Constructor with parameters. - */ - public ChildThread(BlockingQueue> childStatusUpdate, Graph cluster, - BlockingQueue queue, ThreadId threadId) { - super(); - this.childStatusUpdate = childStatusUpdate; - this.queue = queue; - this.threadId = threadId; - this.cluster = cluster; - } - - /** - * Puts notification in queue. - */ - public void putInQueue(FapServiceList fapserviceList) { - try { - queue.put(fapserviceList); - } catch (InterruptedException e) { - log.error(" The Thread is Interrupted", e); - Thread.currentThread().interrupt(); - } - } - - /** - * Puts notification in queue with notify. - */ - public void putInQueueWithNotify(FapServiceList fapserviceList) { - synchronized (queue) { - try { - queue.put(fapserviceList); - queue.notifyAll(); - } catch (InterruptedException e) { - log.error(" The Thread is Interrupted", e); - Thread.currentThread().interrupt(); - } - - } - - } - - /** - * Puts response in queue. - */ - public static void putResponse(Long threadId, AsyncResponseBody obj) { - synchronized (responseMap) { - responseMap.put(threadId, obj); - } - - } - - public static Map getResponseMap() { - return responseMap; - } - - @Override - public void run() { - - threadId.setChildThreadId(Thread.currentThread().getId()); - synchronized (threadId) { - threadId.notifyAll(); - } - - MDC.put("logFileName", Thread.currentThread().getName()); - log.debug("Starting child thread"); - - try { - fapServiceList = queue.take(); - if (log.isDebugEnabled()) { - log.debug("fapServicelist: {}", fapServiceList); - } - } catch (InterruptedException e1) { - log.error("InterruptedException is {}", e1); - Thread.currentThread().interrupt(); - } - - ClusterFormation clusterFormation = new ClusterFormation(queue); - StateOof oof = new StateOof(childStatusUpdate); - ClusterModification clusterModification = new ClusterModification(); - Detection detect = new Detection(); - - try { - String networkId = fapServiceList.getCellConfig().getLte().getRan().getNeighborListInUse() - .getLteNeighborListInUseLteCell().get(0).getPlmnid(); - - Boolean done = false; - - while (!done) { - - Map> collisionConfusionResult = detect.detectCollisionConfusion(cluster); - Boolean trigger = clusterFormation.triggerOrWait(collisionConfusionResult); - - if (!trigger) { - collisionConfusionResult = clusterFormation.waitForNotification(collisionConfusionResult, cluster); - } - oof.triggerOof(collisionConfusionResult, networkId); - - if (isNotificationsBuffered()) { - List fapServiceLists = bufferNotification(); - for (FapServiceList fapService : fapServiceLists) { - cluster = clusterModification.clustermod(cluster, fapService); - } - String cellPciNeighbourString = cluster.getPciNeighbourJson(); - UUID clusterId = cluster.getGraphId(); - ClusterDetailsRepository clusterDetailsRepository = BeanUtil - .getBean(ClusterDetailsRepository.class); - clusterDetailsRepository.updateCluster(cellPciNeighbourString, clusterId.toString()); - - } else { - done = true; - } - - } - - } catch (Exception e) { - log.error("{}", e); - } - - cleanup(); - } - - private boolean isNotificationsBuffered() { - synchronized (queue) { - - try { - while (queue.isEmpty()) { - queue.wait(); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - return false; - } - } - return true; - } - - /** - * cleanup resources. - */ - private void cleanup() { - log.debug("cleaning up database and killing child thread"); - ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class); - clusterDetailsRepository.deleteByChildThreadId(threadId.getChildThreadId()); - log.debug("Child thread :{} {}", Thread.currentThread().getId(), "completed"); - MDC.remove("logFileName"); - - } - - /** - * Buffer Notification. - */ - public List bufferNotification() { - - // Processing Buffered notifications - - List fapServiceLists = new ArrayList<>(); - - Configuration config = Configuration.getInstance(); - - int bufferTime = config.getBufferTime(); - - Timestamp currentTime = new Timestamp(System.currentTimeMillis()); - log.debug("Current time {}", currentTime); - - Timestamp laterTime = new Timestamp(System.currentTimeMillis()); - log.debug("Later time {}", laterTime); - - long difference = laterTime.getTime() - currentTime.getTime(); - while (difference < bufferTime) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - log.error("InterruptedException {}", e); - Thread.currentThread().interrupt(); - - } - laterTime = new Timestamp(System.currentTimeMillis()); - difference = laterTime.getTime() - currentTime.getTime(); - - log.debug("Timer has run for seconds {}", difference); - - if (!queue.isEmpty()) { - FapServiceList fapService; - fapService = queue.poll(); - fapServiceLists.add(fapService); - } - } - return fapServiceLists; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/child/ClusterFormation.java b/src/main/java/com/wipro/www/sonhms/child/ClusterFormation.java deleted file mode 100644 index 7b3d5bf..0000000 --- a/src/main/java/com/wipro/www/sonhms/child/ClusterFormation.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.child; - -import com.wipro.www.sonhms.ConfigPolicy; -import com.wipro.www.sonhms.Configuration; -import com.wipro.www.sonhms.dao.ClusterDetailsRepository; -import com.wipro.www.sonhms.entity.ClusterDetails; -import com.wipro.www.sonhms.model.FapServiceList; -import com.wipro.www.sonhms.utils.BeanUtil; - -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Map; -import java.util.Properties; -import java.util.UUID; -import java.util.concurrent.BlockingQueue; - -import org.slf4j.Logger; - - -public class ClusterFormation { - - private static final Logger log = org.slf4j.LoggerFactory.getLogger(ClusterFormation.class); - private BlockingQueue queue; - private ClusterModification clusterModification; - private Detection detect; - Properties confProp; - ClusterDetails details = new ClusterDetails(); - - public ClusterFormation() { - this.detect = new Detection(); - } - - /** - * parameterized constructor. - * - */ - public ClusterFormation(BlockingQueue queue) { - super(); - this.queue = queue; - this.detect = new Detection(); - this.clusterModification = new ClusterModification(); - } - - /** - * Determines whether to trigger Oof or wait for notifications. - */ - public Boolean triggerOrWait(Map> collisionConfusionResult) { - // determine collision or confusion - - Configuration configuration = Configuration.getInstance(); - int collisionSum = 0; - int confusionSum = 0; - - for (Map.Entry> entry : collisionConfusionResult.entrySet()) { - - ArrayList arr; - arr = entry.getValue(); - // check for 0 collision and confusion - if (!arr.isEmpty()) { - collisionSum = collisionSum + arr.get(0); - confusionSum = confusionSum + arr.get(1); - } - } - return ((collisionSum >= configuration.getMinCollision()) && (confusionSum >= configuration.getMinConfusion())); - - } - - /** - * Waits for notifications. - */ - public Map> waitForNotification(Map> collisionConfusionResult, - Graph cluster) { - - FapServiceList newNotification; - ConfigPolicy config = ConfigPolicy.getInstance(); - int timer = 60; - try { - timer = (int) config.getConfig().get("PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS"); - } catch (NullPointerException e) { - log.debug("Policy config not available. Using default timeout - 60 seconds"); - } - - Timestamp currentTime = new Timestamp(System.currentTimeMillis()); - log.debug("Current Time {}", currentTime); - - Timestamp laterTime = new Timestamp(System.currentTimeMillis()); - log.debug("LaterTime {}", laterTime); - - long difference = laterTime.getTime() - currentTime.getTime(); - - int flag = 0; - - while (difference < (timer * 1000)) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - log.error("Interrupted Exception is {}", e); - Thread.currentThread().interrupt(); - } - - laterTime = new Timestamp(System.currentTimeMillis()); - difference = laterTime.getTime() - currentTime.getTime(); - - if ((difference < (timer * 1000)) && (!queue.isEmpty())) { - newNotification = queue.poll(); - cluster = clusterModification.clustermod(cluster, newNotification); - - // update cluster in DB - String cellPciNeighbourString = cluster.getPciNeighbourJson(); - UUID clusterId = cluster.getGraphId(); - ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class); - clusterDetailsRepository.updateCluster(cellPciNeighbourString, clusterId.toString()); - flag++; - - } - } - if (flag != 0) { - return detect.detectCollisionConfusion(cluster); - - } - return collisionConfusionResult; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/child/ClusterModification.java b/src/main/java/com/wipro/www/sonhms/child/ClusterModification.java deleted file mode 100644 index 9926cf4..0000000 --- a/src/main/java/com/wipro/www/sonhms/child/ClusterModification.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.child; - -import com.wipro.www.sonhms.model.CellPciPair; -import com.wipro.www.sonhms.model.FapServiceList; -import com.wipro.www.sonhms.model.LteNeighborListInUseLteCell; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.slf4j.Logger; - - - -public class ClusterModification { - private static final Logger log = org.slf4j.LoggerFactory.getLogger(ClusterModification.class); - - /** - * Forms a modified cluster for the existing cluster. - */ - - public Graph clustermod(Graph cluster, FapServiceList fapser) { - - int phycellId = fapser.getX0005b9Lte().getPhyCellIdInUse(); - String cellId = fapser.getCellConfig().getLte().getRan().getCellIdentity(); - CellPciPair mainCellPciPair = new CellPciPair(); - mainCellPciPair.setCellId(cellId); - mainCellPciPair.setPhysicalCellId(phycellId); - List newNeighbourList; - newNeighbourList = fapser.getCellConfig().getLte().getRan().getNeighborListInUse() - .getLteNeighborListInUseLteCell(); - - Map> clusterMap; - clusterMap = cluster.getCellPciNeighbourMap(); - - // coe - - List tempCellPair = new ArrayList<>(); - for (Map.Entry> entry : clusterMap.entrySet()) { - CellPciPair oldClusterKeys = entry.getKey(); - tempCellPair.add(oldClusterKeys); - } - - for (CellPciPair entry : tempCellPair) { - String cell = entry.getCellId(); - int physicalCell = entry.getPhysicalCellId(); - CellPciPair mapVal = new CellPciPair(); - mapVal.setCellId(cell); - mapVal.setPhysicalCellId(physicalCell); - - if (cellId.equals(cell)) { - - // removes the old neighbours and adds new neighbours for that cell - cluster.updateVertex(mapVal, mainCellPciPair); - - } - - } - - /////// update cluster with new pci values for the same cell - - if (clusterMap.containsKey(mainCellPciPair)) { - ArrayList oldClusterArray; - oldClusterArray = clusterMap.get(mainCellPciPair); - oldClusterArray.clear(); - - for (int i = 0; i < newNeighbourList.size(); i++) { - String cid = newNeighbourList.get(i).getAlias(); - int phy = newNeighbourList.get(i).getPhyCellId(); - CellPciPair val2 = new CellPciPair(); - val2.setCellId(cid); - val2.setPhysicalCellId(phy); - cluster.addEdge(mainCellPciPair, val2); - } - - } - - for (CellPciPair entry : tempCellPair) { - String cell = entry.getCellId(); - int physicalCell = entry.getPhysicalCellId(); - CellPciPair mapVal = new CellPciPair(); - mapVal.setCellId(cell); - mapVal.setPhysicalCellId(physicalCell); - for (int j = 0; j < newNeighbourList.size(); j++) { - String cid1 = newNeighbourList.get(j).getAlias(); - int phy1 = newNeighbourList.get(j).getPhyCellId(); - CellPciPair val3 = new CellPciPair(); - val3.setCellId(cid1); - val3.setPhysicalCellId(phy1); - - if (cid1.equals(cell)) { - - // removes the old neighbours and adds new neighbours for that cell - cluster.updateVertex(mapVal, val3); - - } - - } - } - - for (int j = 0; j < newNeighbourList.size(); j++) { - String cid1 = newNeighbourList.get(j).getAlias(); - int phy1 = newNeighbourList.get(j).getPhyCellId(); - CellPciPair val3 = new CellPciPair(); - val3.setCellId(cid1); - val3.setPhysicalCellId(phy1); - if (clusterMap.containsKey(val3)) { - cluster.addEdge(mainCellPciPair, val3); - } - - } - - for (int k = 0; k < newNeighbourList.size(); k++) { - String cid2 = newNeighbourList.get(k).getAlias(); - int phy2 = newNeighbourList.get(k).getPhyCellId(); - CellPciPair val5 = new CellPciPair(); - val5.setCellId(cid2); - val5.setPhysicalCellId(phy2); - cluster.addEdge(mainCellPciPair, val5); - } - - log.debug("Modified Cluster {}", cluster); - - return cluster; - } - -} \ No newline at end of file diff --git a/src/main/java/com/wipro/www/sonhms/child/Detection.java b/src/main/java/com/wipro/www/sonhms/child/Detection.java deleted file mode 100644 index fc2e941..0000000 --- a/src/main/java/com/wipro/www/sonhms/child/Detection.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.child; - -import com.wipro.www.sonhms.model.CellPciPair; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import org.slf4j.Logger; - - -public class Detection { - - private static final Logger log = org.slf4j.LoggerFactory.getLogger(Detection.class); - - /** - * Returns a map with key as cellid and its value is a list of its collision and - * confusion. - */ - - public Map> detectCollisionConfusion(Graph cluster) { - - Map> clusterMap = cluster.getCellPciNeighbourMap(); - HashMap> hash = new HashMap<>(); - - for (Map.Entry> entry : clusterMap.entrySet()) { - int collisionCount = 0; - int confusionCount = 0; - CellPciPair val = entry.getKey(); - String cellId = val.getCellId(); - int pci = val.getPhysicalCellId(); - ArrayList arr; - // getting colision and confusion count - ArrayList counts = new ArrayList<>(); - // gets the value for the key - arr = entry.getValue(); - if (!arr.isEmpty()) { - for (int i = 0; i < arr.size(); i++) { - if (pci == arr.get(i).getPhysicalCellId()) { - collisionCount++; - } - - } - counts.add(collisionCount); - - for (int j = 0; j < arr.size(); j++) { - for (int k = j + 1; k < arr.size(); k++) { - if (arr.get(j).getPhysicalCellId() == arr.get(k).getPhysicalCellId()) { - confusionCount++; - - } - } - - } - counts.add(confusionCount); - log.debug("count {}", counts); - - } - hash.put(cellId, counts); - - } - log.debug("collison and confusion map {}", hash); - - return hash; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/child/Graph.java b/src/main/java/com/wipro/www/sonhms/child/Graph.java deleted file mode 100644 index 5e48dfc..0000000 --- a/src/main/java/com/wipro/www/sonhms/child/Graph.java +++ /dev/null @@ -1,202 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.child; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.wipro.www.sonhms.model.CellNeighbourList; -import com.wipro.www.sonhms.model.CellPciPair; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.UUID; - -import java.util.concurrent.ConcurrentHashMap; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.slf4j.Logger; - -public class Graph { - private static final Logger log = org.slf4j.LoggerFactory.getLogger(Graph.class); - - // symbol table: key = string vertex, value = set of neighboring vertices - private Map> cellPciNeighbourMap; - private UUID graphId; - - /** - * Parameterized constructor. - */ - @SuppressWarnings("unchecked") - public Graph(String clusterInfo) { - JSONArray cells = new JSONArray(clusterInfo); - - Map> cellMap = new HashMap<>(); - for (int i = 0; i < cells.length(); i++) { - JSONObject cell = (JSONObject) cells.get(i); - CellPciPair cellPciPair = new CellPciPair(cell.getString("cellId"), cell.getInt("physicalCellId")); - ObjectMapper mapper = new ObjectMapper(); - ArrayList neighbours = new ArrayList<>(); - try { - neighbours = mapper.readValue(cell.getString("neighbours"), ArrayList.class); - } catch (JSONException | IOException e) { - log.debug("Error parsing json: {}", e); - } - cellMap.put(cellPciPair, neighbours); - - } - - this.cellPciNeighbourMap = cellMap; - } - - public UUID getGraphId() { - return graphId; - } - - public void setGraphId(UUID graphId) { - this.graphId = graphId; - } - - public Map> getCellPciNeighbourMap() { - return cellPciNeighbourMap; - } - - public void setCellPciNeighbourMap(Map> cellPciNeighbourMap) { - this.cellPciNeighbourMap = cellPciNeighbourMap; - } - - /** - * Initializes an empty graph with no vertices or edges. - */ - public Graph() { - this.cellPciNeighbourMap = new ConcurrentHashMap<>(); - } - - // throw an exception if v is not a vertex - private void validateVertex(CellPciPair start) { - if (!hasVertex(start)) { - throw new IllegalArgumentException(start + " is not a vertex"); - } - } - - /** - * Adds the edge v-w to this graph (if it is not already an edge). - */ - public void addEdge(CellPciPair start, CellPciPair end) { - if (!hasVertex(start)) { - addVertex(start); - } - if (!hasVertex(end)) { - addVertex(end); - } - if (!hasEdge(start, end)) { - this.cellPciNeighbourMap.get(start).add(end); - } - } - - /** - * Adds vertex v to this graph (if it is not already a vertex). - */ - public void addVertex(CellPciPair start) { - if (!hasVertex(start)) { - this.cellPciNeighbourMap.put(start, new ArrayList()); - } - } - - /** - * Returns true if v is a vertex in this graph. - */ - public boolean hasVertex(CellPciPair start) { - return this.cellPciNeighbourMap.containsKey(start); - } - - /** - * Returns true if v-w is an edge in this graph. - */ - public boolean hasEdge(CellPciPair start, CellPciPair end) { - validateVertex(start); - validateVertex(end); - return this.cellPciNeighbourMap.get(start).contains(end); - } - - /** - * Updates Vertex. - */ - public void updateVertex(CellPciPair oldPair, CellPciPair newPair) { - int oldPci = oldPair.getPhysicalCellId(); - int newPci = newPair.getPhysicalCellId(); - - if (oldPci != newPci) { - - this.cellPciNeighbourMap.put(newPair, this.cellPciNeighbourMap.get(oldPair)); - this.cellPciNeighbourMap.remove(oldPair); - - } - for (Map.Entry> entry : this.cellPciNeighbourMap.entrySet()) { - - ArrayList al = entry.getValue(); - for (int i = 0; i < al.size(); i++) { - int pci = al.get(i).getPhysicalCellId(); - if ((pci != newPci) && al.contains(oldPair)) { - al.remove(oldPair); - al.add(newPair); - } - } - } - log.debug("Final Map {}", cellPciNeighbourMap); - - } - - @Override - public String toString() { - return "Graph [cellPciNeighbourMap=" + cellPciNeighbourMap + ", graphId=" + graphId + "]"; - } - - /** - * Convert Graph into a json. - */ - public String getPciNeighbourJson() { - - List cells = new ArrayList<>(); - - for (Entry> entry : cellPciNeighbourMap.entrySet()) { - CellPciPair key = entry.getKey(); - JSONArray neighbours = new JSONArray(cellPciNeighbourMap.get(key)); - CellNeighbourList cell = new CellNeighbourList(key.getCellId(), key.getPhysicalCellId(), - neighbours.toString()); - cells.add(cell); - } - ObjectMapper mapper = new ObjectMapper(); - String pciNeighbourJson = ""; - try { - pciNeighbourJson = mapper.writeValueAsString(cells); - } catch (JsonProcessingException e) { - log.debug("Error while processing json: {}", e); - } - return pciNeighbourJson; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/child/StateOof.java b/src/main/java/com/wipro/www/sonhms/child/StateOof.java deleted file mode 100644 index 3215c46..0000000 --- a/src/main/java/com/wipro/www/sonhms/child/StateOof.java +++ /dev/null @@ -1,271 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.child; - -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.wipro.www.sonhms.ConfigPolicy; -import com.wipro.www.sonhms.Configuration; -import com.wipro.www.sonhms.dao.CellInfoRepository; -import com.wipro.www.sonhms.dao.SonRequestsRepository; -import com.wipro.www.sonhms.dmaap.PolicyDmaapClient; -import com.wipro.www.sonhms.entity.CellInfo; -import com.wipro.www.sonhms.entity.PciRequests; -import com.wipro.www.sonhms.exceptions.ConfigDbNotFoundException; -import com.wipro.www.sonhms.exceptions.OofNotFoundException; -import com.wipro.www.sonhms.model.CellConfig; -import com.wipro.www.sonhms.model.CellPciPair; -import com.wipro.www.sonhms.model.Common; -import com.wipro.www.sonhms.model.Configurations; -import com.wipro.www.sonhms.model.Data; -import com.wipro.www.sonhms.model.FapService; -import com.wipro.www.sonhms.model.Lte; -import com.wipro.www.sonhms.model.Payload; -import com.wipro.www.sonhms.model.PolicyNotification; -import com.wipro.www.sonhms.model.Ran; -import com.wipro.www.sonhms.model.X0005b9Lte; -import com.wipro.www.sonhms.restclient.AsyncResponseBody; -import com.wipro.www.sonhms.restclient.OofRestClient; -import com.wipro.www.sonhms.restclient.SdnrRestClient; -import com.wipro.www.sonhms.restclient.Solution; -import com.wipro.www.sonhms.restclient.SonSolution; -import com.wipro.www.sonhms.utils.BeanUtil; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.BlockingQueue; - -import org.slf4j.Logger; - -public class StateOof { - private static final Logger log = org.slf4j.LoggerFactory.getLogger(StateOof.class); - private BlockingQueue> childStatusUpdate; - - public StateOof() { - - } - - /** - * Parameterized Constructor. - * - */ - public StateOof(BlockingQueue> childStatusUpdate) { - super(); - this.childStatusUpdate = childStatusUpdate; - } - - /** - * Triggers OOF. - * @throws OofNotFoundException when trigger oof fails - */ - public void triggerOof(Map> result, String networkId) throws OofNotFoundException { - // check for 0 collision and 0 confusion - ArrayList cellidList = new ArrayList<>(); - ArrayList cellIds = new ArrayList<>(); - - for (Map.Entry> entry : result.entrySet()) { - String key = entry.getKey(); - ArrayList arr; - arr = entry.getValue(); - if (!arr.isEmpty()) { - Set set = new HashSet<>(arr); - if (((set.size() == 1) && !set.contains(0)) || (set.size() != 1)) { - cellIds.add(key); - - } - } - - } - - for (String cell : cellIds) { - log.debug("cellidList entries: {}", cell); - cellidList.add(cell); - } - log.debug("the cells triggering the oof are {}", cellidList); - - UUID transactionId = UUID.randomUUID(); - - Configuration config = Configuration.getInstance(); - int numSolutions = config.getNumSolutions(); - List optimizers = config.getOptimizers(); - - String oofResponse = OofRestClient.queryOof(numSolutions, transactionId.toString(), "create", cellidList, - networkId, optimizers); - log.debug("Synchronous Response {}", oofResponse); - - List childStatus = new ArrayList<>(); - childStatus.add(Long.toString(Thread.currentThread().getId())); - childStatus.add("triggeredOof"); - try { - childStatusUpdate.put(childStatus); - } catch (InterruptedException e1) { - log.debug("Interrupted execption {}", e1); - Thread.currentThread().interrupt(); - - } - - // Store Request details in Database - - PciRequests pciRequest = new PciRequests(); - - long childThreadId = Thread.currentThread().getId(); - pciRequest.setTransactionId(transactionId.toString()); - pciRequest.setChildThreadId(childThreadId); - SonRequestsRepository pciRequestsRepository = BeanUtil.getBean(SonRequestsRepository.class); - pciRequestsRepository.save(pciRequest); - - while (!ChildThread.getResponseMap().containsKey(childThreadId)) { - - } - - AsyncResponseBody asynResponseBody = ChildThread.getResponseMap().get(childThreadId); - - try { - sendToPolicy(asynResponseBody, networkId); - } catch (ConfigDbNotFoundException e1) { - log.debug("Config DB is unreachable: {}", e1); - } - - pciRequestsRepository = BeanUtil.getBean(SonRequestsRepository.class); - pciRequestsRepository.deleteByChildThreadId(childThreadId); - - childStatus = new ArrayList<>(); - childStatus.add(Long.toString(Thread.currentThread().getId())); - childStatus.add("success"); - try { - childStatusUpdate.put(childStatus); - } catch (InterruptedException e) { - log.debug("InterruptedException {}", e); - Thread.currentThread().interrupt(); - - } - - } - - /** - * Sends Dmaap notification to Policy. - * - * @throws ConfigDbNotFoundException - * when config db is unreachable - */ - private void sendToPolicy(AsyncResponseBody async, String networkId) throws ConfigDbNotFoundException { - - if (log.isDebugEnabled()) { - log.debug(async.toString()); - } - - List solutions; - solutions = async.getSolutions(); - - Map> pnfs = getPnfs(solutions); - - for (Map.Entry> entry : pnfs.entrySet()) { - String pnfName = entry.getKey(); - List cellPciPairs = entry.getValue(); - - String notification = getNotificationString(pnfName, cellPciPairs, networkId); - log.debug("Policy Notification: {}", notification); - PolicyDmaapClient policy = new PolicyDmaapClient(); - boolean status = policy.sendNotificationToPolicy(notification); - log.debug("sent Message: {}", status); - if (status) { - log.debug("Message sent to policy"); - } else { - log.debug("Sending notification to policy failed"); - } - - } - } - - private String getNotificationString(String pnfName, List cellPciPairs, String networkId) { - ArrayList configurations = new ArrayList<>(); - for (CellPciPair cellPciPair : cellPciPairs) { - 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))))))); - configurations.add(configuration); - } - - Payload payload = new Payload(configurations); - ObjectMapper mapper = new ObjectMapper(); - String payloadString = ""; - try { - payloadString = mapper.writeValueAsString(payload); - } catch (JsonProcessingException e) { - log.debug("JSON processing exception: {}", e); - } - PolicyNotification policyNotification = new PolicyNotification(); - ConfigPolicy configPolicy = ConfigPolicy.getInstance(); - String closedLoopControlName = (String) configPolicy.getConfig().get("PCI_MODCONFIG_POLICY_NAME"); - policyNotification.setClosedLoopControlName(closedLoopControlName); - policyNotification.setPayload(payloadString); - - mapper.setSerializationInclusion(Include.NON_NULL); - String notification = ""; - try { - notification = mapper.writeValueAsString(policyNotification); - } catch (JsonProcessingException e1) { - log.debug("JSON processing exception: {}", e1); - } - return notification; - } - - private Map> getPnfs(List solutions) throws ConfigDbNotFoundException { - - Map> pnfs = new HashMap<>(); - - for (Solution solution : solutions) { - List pciSolutions = solution.getPciSolutions(); - for (SonSolution pciSolution : pciSolutions) { - String cellId = pciSolution.getCellId(); - int pci = pciSolution.getPci(); - - String pnfName = ""; - CellInfoRepository cellInfoRepository = BeanUtil.getBean(CellInfoRepository.class); - Optional 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 cellPciPairs = new ArrayList<>(); - cellPciPairs.add(new CellPciPair(cellId, pci)); - pnfs.put(pnfName, cellPciPairs); - } - } - - } - return pnfs; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/dao/BufferedNotificationsRepository.java b/src/main/java/com/wipro/www/sonhms/dao/BufferedNotificationsRepository.java deleted file mode 100644 index bdbdb6e..0000000 --- a/src/main/java/com/wipro/www/sonhms/dao/BufferedNotificationsRepository.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.dao; - -import com.wipro.www.sonhms.entity.BufferedNotifications; - -import java.util.List; - -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - - -@Repository -public interface BufferedNotificationsRepository extends CrudRepository { - - @Query(nativeQuery = true, value = "SELECT cluster_id FROM buffered_notifications WHERE notification=?1") - public String getClusterIdForNotification(String notification); - - @Query(nativeQuery = true, - value = "DELETE FROM buffered_notifications " + "WHERE notification = ( SELECT notification " - + "FROM buffered_notifications WHERE cluster_id=?1) RETURNING notification;") - public List getNotificationsFromQueue(String clusterId); - -} diff --git a/src/main/java/com/wipro/www/sonhms/dao/CellInfoRepository.java b/src/main/java/com/wipro/www/sonhms/dao/CellInfoRepository.java deleted file mode 100644 index c4e1f8b..0000000 --- a/src/main/java/com/wipro/www/sonhms/dao/CellInfoRepository.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.dao; - -import com.wipro.www.sonhms.entity.CellInfo; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - - -@Repository -public interface CellInfoRepository extends CrudRepository { - - // public void - -} diff --git a/src/main/java/com/wipro/www/sonhms/dao/ClusterDetailsRepository.java b/src/main/java/com/wipro/www/sonhms/dao/ClusterDetailsRepository.java deleted file mode 100644 index a833fbf..0000000 --- a/src/main/java/com/wipro/www/sonhms/dao/ClusterDetailsRepository.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.dao; - -import com.wipro.www.sonhms.entity.ClusterDetails; - -import java.util.List; - -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 ClusterDetailsRepository extends CrudRepository { - - @Modifying - @Query(nativeQuery = true, value = "UPDATE CLUSTER_DETAILS SET cluster_info=?1 WHERE cluster_id = ?2") - public void updateCluster(String clusterInfo, String clusterId); - - @Query(nativeQuery = true, value = "SELECT * FROM cluster_details") - public List getAllClusterDetails(); - - @Query(nativeQuery = true, value = "SELECT child_thread_id FROM cluster_details WHERE cluster_id = ?1") - public long getChildThreadForCluster(String clusterId); - - @Query(nativeQuery = true, value = "SELECT cluster_id FROM cluster_details WHERE child_thread_id = ?1") - public String getClusterIdForChildThread(long childThreadId); - - @Modifying - @Query(nativeQuery = true, value = "DELETE FROM cluster_details WHERE child_thread_id = ?1") - public void deleteByChildThreadId(Long threadId); - - @Modifying - @Query(nativeQuery = true, value = "UPDATE cluster_details SET child_thread_id = ?2 WHERE cluster_id = ?1") - public void updateThreadId(String clusterId, Long threadId); - -} diff --git a/src/main/java/com/wipro/www/sonhms/dao/DmaapNotificationsRepository.java b/src/main/java/com/wipro/www/sonhms/dao/DmaapNotificationsRepository.java deleted file mode 100644 index 1ac2ff4..0000000 --- a/src/main/java/com/wipro/www/sonhms/dao/DmaapNotificationsRepository.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.dao; - -import com.wipro.www.sonhms.entity.DmaapNotifications; - -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - - -@Repository -public interface DmaapNotificationsRepository extends CrudRepository { - - @Query(nativeQuery = true, - value = "DELETE FROM dmaap_notifications " - + "WHERE notification = ( SELECT notification FROM dmaap_notifications ORDER BY " - + "created_at FOR UPDATE SKIP LOCKED LIMIT 1 ) RETURNING notification;") - - public String getNotificationFromQueue(); - -} diff --git a/src/main/java/com/wipro/www/sonhms/dao/SonRequestsRepository.java b/src/main/java/com/wipro/www/sonhms/dao/SonRequestsRepository.java deleted file mode 100644 index 6b0458d..0000000 --- a/src/main/java/com/wipro/www/sonhms/dao/SonRequestsRepository.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.dao; - -import com.wipro.www.sonhms.entity.PciRequests; - -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 SonRequestsRepository extends CrudRepository { - - @Query(nativeQuery = true, value = "SELECT child_thread_id FROM pci_requests WHERE transaction_id = ?1") - public long getChildThreadMapping(String transactionId); - - @Modifying - @Query(nativeQuery = true, value = "DELETE FROM pci_requests WHERE child_thread_id = ?1") - public void deleteByChildThreadId(Long threadId); - -} diff --git a/src/main/java/com/wipro/www/sonhms/dmaap/DmaapClient.java b/src/main/java/com/wipro/www/sonhms/dmaap/DmaapClient.java deleted file mode 100644 index 051b00e..0000000 --- a/src/main/java/com/wipro/www/sonhms/dmaap/DmaapClient.java +++ /dev/null @@ -1,215 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.dmaap; - -import com.att.nsa.apiClient.http.HttpException; -import com.att.nsa.cambria.client.CambriaClient; -import com.att.nsa.cambria.client.CambriaClientBuilders; -import com.att.nsa.cambria.client.CambriaClientBuilders.ConsumerBuilder; -import com.att.nsa.cambria.client.CambriaClientBuilders.TopicManagerBuilder; -import com.att.nsa.cambria.client.CambriaConsumer; -import com.att.nsa.cambria.client.CambriaTopicManager; -import com.wipro.www.sonhms.Configuration; -import com.wipro.www.sonhms.NewNotification; -import com.wipro.www.sonhms.Topic; -import com.wipro.www.sonhms.dao.DmaapNotificationsRepository; -import com.wipro.www.sonhms.entity.DmaapNotifications; - - -import java.io.IOException; -import java.net.MalformedURLException; -import java.security.GeneralSecurityException; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class DmaapClient { - - @Autowired - private DmaapNotificationsRepository dmaapNotificationsRepository; - private Configuration configuration; - private static Logger log = LoggerFactory.getLogger(DmaapClient.class); - private static final String CONSUMER = "CONSUMER"; - private static final String PRODUCER = "PRODUCER"; - private static final String DESCRIPTION = "api keys for OOF PCI use case"; - private static final int PARTITION_COUNT = 1; - private static final int REPLICATION_COUNT = 1; - private NewNotification newNotification; - private CambriaTopicManager topicManager; - - public class NotificationCallback { - DmaapClient dmaapClient; - - public NotificationCallback(DmaapClient dmaapClient) { - this.dmaapClient = dmaapClient; - } - - public void activateCallBack(String msg) { - handleNotification(msg); - } - - private void handleNotification(String msg) { - DmaapNotifications dmaapNotification = new DmaapNotifications(); - dmaapNotification.setNotification(msg); - if (log.isDebugEnabled()) { - log.debug(dmaapNotification.toString()); - } - dmaapNotificationsRepository.save(dmaapNotification); - newNotification.setNewNotif(true); - } - } - - /** - * init dmaap client. - */ - public void initClient(NewNotification newNotification) { - log.debug("initializing client"); - configuration = Configuration.getInstance(); - if (log.isDebugEnabled()) { - log.debug(configuration.toString()); - } - this.newNotification = newNotification; - - createAndConfigureTopics(); - startClient(); - } - - /** - * create and configures topics. - */ - private void createAndConfigureTopics() { - - try { - topicManager = buildCambriaClient(new TopicManagerBuilder().usingHosts(configuration.getServers()) - .authenticatedBy(configuration.getManagerApiKey(), configuration.getManagerSecretKey())); - } catch (GeneralSecurityException | IOException e) { - log.debug("exception during creating topic", e); - } - List topics = configuration.getTopics(); - - for (Topic topic : topics) { - Set topicsInDmaap = getAllTopicsFromDmaap(); - - createTopic(topic, topicsInDmaap); - subscribeToTopic(topic.getName(), topic.getProducer(), PRODUCER); - subscribeToTopic(topic.getName(), topic.getConsumer(), CONSUMER); - - } - - topicManager.close(); - - } - - /** - * create topic. - */ - private void createTopic(Topic topic, Set topicsInDmaap) { - if (topicsInDmaap.contains(topic.getName())) { - log.debug("topic exists in dmaap"); - } else { - try { - topicManager.createTopic(topic.getName(), DESCRIPTION, PARTITION_COUNT, REPLICATION_COUNT); - } catch (HttpException | IOException e) { - log.debug("error while creating topic: {}", e); - } - } - } - - /** - * get all topics from dmaap. - */ - private Set getAllTopicsFromDmaap() { - Set topics = new HashSet<>(); - try { - topics = topicManager.getTopics(); - } catch (IOException e) { - log.debug("IOException while fetching topics"); - } - return topics; - - } - - /** - * start dmaap client. - */ - private synchronized void startClient() { - - ScheduledExecutorService executorPool; - CambriaConsumer cambriaConsumer = null; - - try { - cambriaConsumer = new ConsumerBuilder() - .authenticatedBy(configuration.getPcimsApiKey(), configuration.getPcimsSecretKey()) - .knownAs(configuration.getCg(), configuration.getCid()).onTopic(configuration.getSdnrTopic()) - .usingHosts(configuration.getServers()).withSocketTimeout(configuration.getPollingTimeout() * 1000) - .build(); - - // create notification consumers for SNDR and policy - NotificationConsumer notificationConsumer = new NotificationConsumer(cambriaConsumer, - new NotificationCallback(this)); - - // start notification consumer threads - executorPool = Executors.newScheduledThreadPool(10); - executorPool.scheduleAtFixedRate(notificationConsumer, 0, configuration.getPollingInterval(), - TimeUnit.SECONDS); - } catch (MalformedURLException | GeneralSecurityException e) { - log.debug("exception during starting client", e); - } - - } - - /** - * subscribe to topic. - */ - private void subscribeToTopic(String topicName, String subscriberApiKey, String subscriberType) { - if (subscriberType.equals(PRODUCER)) { - try { - topicManager.allowProducer(topicName, subscriberApiKey); - } catch (HttpException | IOException e) { - log.debug("error while subscribing to a topic: {}", e); - } - } else if (subscriberType.equals(CONSUMER)) { - try { - topicManager.allowConsumer(topicName, subscriberApiKey); - } catch (HttpException | IOException e) { - log.debug("error while subscribing to a topic: {}", e); - } - } - - } - - @SuppressWarnings("unchecked") - private static T buildCambriaClient( - CambriaClientBuilders.AbstractAuthenticatedManagerBuilder client) - throws MalformedURLException, GeneralSecurityException { - return (T) client.build(); - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/dmaap/NotificationConsumer.java b/src/main/java/com/wipro/www/sonhms/dmaap/NotificationConsumer.java deleted file mode 100644 index 1bdbac2..0000000 --- a/src/main/java/com/wipro/www/sonhms/dmaap/NotificationConsumer.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.dmaap; - -import com.att.nsa.cambria.client.CambriaConsumer; -import com.wipro.www.sonhms.dmaap.DmaapClient.NotificationCallback; - -import java.io.IOException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class NotificationConsumer implements Runnable { - - private static Logger log = LoggerFactory.getLogger(NotificationConsumer.class); - private CambriaConsumer cambriaConsumer; - private NotificationCallback notificationCallback; - - /** - * Parameterized Constructor. - */ - public NotificationConsumer(CambriaConsumer cambriaConsumer, NotificationCallback notificationCallback) { - super(); - this.cambriaConsumer = cambriaConsumer; - this.notificationCallback = notificationCallback; - } - - @Override - public void run() { - try { - Iterable msgs = cambriaConsumer.fetch(); - for (String msg : msgs) { - log.debug(msg); - notificationCallback.activateCallBack(msg); - } - } catch (IOException e) { - log.debug("exception when fetching msgs from dmaap", e); - } - - } -} diff --git a/src/main/java/com/wipro/www/sonhms/dmaap/NotificationProducer.java b/src/main/java/com/wipro/www/sonhms/dmaap/NotificationProducer.java deleted file mode 100644 index 7dd505f..0000000 --- a/src/main/java/com/wipro/www/sonhms/dmaap/NotificationProducer.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.dmaap; - -import com.att.nsa.cambria.client.CambriaBatchingPublisher; -import com.att.nsa.cambria.client.CambriaClientBuilders.PublisherBuilder; - -import java.io.IOException; -import java.security.GeneralSecurityException; -import java.util.List; - -public class NotificationProducer { - - private List servers; - private String apiKey; - private String secret; - - /** - * Parameterised constructor. - */ - public NotificationProducer(List servers, String apiKey, String secret) { - super(); - this.servers = servers; - this.apiKey = apiKey; - this.secret = secret; - } - - /** - * sends notification to dmaap. - */ - public int sendNotification(String topic, String msg) throws GeneralSecurityException, IOException { - CambriaBatchingPublisher cambriaBatchingPublisher = null; - cambriaBatchingPublisher = new PublisherBuilder().usingHosts(servers).onTopic(topic) - .authenticatedBy(apiKey, secret).build(); - return cambriaBatchingPublisher.send("", msg); - - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/dmaap/PolicyDmaapClient.java b/src/main/java/com/wipro/www/sonhms/dmaap/PolicyDmaapClient.java deleted file mode 100644 index f1491b4..0000000 --- a/src/main/java/com/wipro/www/sonhms/dmaap/PolicyDmaapClient.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.dmaap; - -import com.wipro.www.sonhms.Configuration; - -import java.io.IOException; -import java.security.GeneralSecurityException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class PolicyDmaapClient { - - private static Logger log = LoggerFactory.getLogger(PolicyDmaapClient.class); - - /** - * Method stub for sending notification to policy. - */ - public boolean sendNotificationToPolicy(String msg) { - - Configuration configuration = Configuration.getInstance(); - NotificationProducer notificationProducer = new NotificationProducer(configuration.getServers(), - configuration.getPcimsApiKey(), configuration.getPcimsSecretKey()); - try { - int result = notificationProducer.sendNotification(configuration.getPolicyTopic(), msg); - log.debug("result: {}", result); - } catch (GeneralSecurityException | IOException e) { - log.debug("exception when sending notification to policy", e); - return false; - } - return true; - } -} diff --git a/src/main/java/com/wipro/www/sonhms/entity/BufferedNotifications.java b/src/main/java/com/wipro/www/sonhms/entity/BufferedNotifications.java deleted file mode 100644 index 9ac10aa..0000000 --- a/src/main/java/com/wipro/www/sonhms/entity/BufferedNotifications.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.entity; - -import java.sql.Timestamp; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -import org.hibernate.annotations.CreationTimestamp; - -@Entity -@Table(name = "BUFFERED_NOTIFICATIONS") -public class BufferedNotifications { - - @Id - @Column(name = "notification", columnDefinition = "text") - private String notification; - - @Column(name = "cluster_id", columnDefinition = "text") - private String clusterId; - - @CreationTimestamp - @Column(name = "created_at", columnDefinition = "timestamp") - private Timestamp createdAt; - - public BufferedNotifications() { - - } - - /** - * Parameterised constructor. - */ - public BufferedNotifications(String notification, Timestamp createdAt, String clusterId) { - this.notification = notification; - this.createdAt = createdAt; - this.clusterId = clusterId; - } - - public String getNotification() { - return notification; - } - - public void setNotification(String notification) { - this.notification = notification; - } - - public String getClusterId() { - return clusterId; - } - - public void setClusterId(String clusterId) { - this.clusterId = clusterId; - } - - public Timestamp getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Timestamp createdAt) { - this.createdAt = createdAt; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/entity/CellInfo.java b/src/main/java/com/wipro/www/sonhms/entity/CellInfo.java deleted file mode 100644 index e2bb326..0000000 --- a/src/main/java/com/wipro/www/sonhms/entity/CellInfo.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.entity; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -@Entity -@Table(name = "CELL_INFO") -public class CellInfo { - - @Id - @Column(name = "CELL_ID") - private String cellId; - - @Column(name = "PNF_NAME") - private String pnfName; - - public CellInfo() { - - } - - /** - * CellIdPnf Constructor. - */ - - public CellInfo(String cellId, String pnfName) { - super(); - this.cellId = cellId; - this.pnfName = pnfName; - } - - public String getCellId() { - return cellId; - } - - public void setCellId(String cellId) { - this.cellId = cellId; - } - - public String getPnfName() { - return pnfName; - } - - public void setPnfName(String pnfName) { - this.pnfName = pnfName; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/entity/ClusterDetails.java b/src/main/java/com/wipro/www/sonhms/entity/ClusterDetails.java deleted file mode 100644 index 59868eb..0000000 --- a/src/main/java/com/wipro/www/sonhms/entity/ClusterDetails.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.entity; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -@Entity -@Table(name = "CLUSTER_DETAILS") -public class ClusterDetails { - - @Id - @Column(name = "CLUSTER_ID") - private String clusterId; - - @Column(name = "CLUSTER_INFO") - private String clusterInfo; - - @Column(name = "CHILD_THREAD_ID") - private long childThreadId; - - public ClusterDetails() { - - } - - /** - * Parameterised constructor. - */ - public ClusterDetails(String clusterId, String clusterInfo, long childThreadId) { - super(); - this.clusterId = clusterId; - this.clusterInfo = clusterInfo; - this.childThreadId = childThreadId; - } - - public long getChildThreadId() { - return childThreadId; - } - - public void setChildThreadId(long childThreadId) { - this.childThreadId = childThreadId; - } - - public String getClusterId() { - return clusterId; - } - - public void setClusterId(String clusterId) { - this.clusterId = clusterId; - } - - public String getClusterInfo() { - return clusterInfo; - } - - public void setClusterInfo(String clusterInfo) { - this.clusterInfo = clusterInfo; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/entity/DmaapNotifications.java b/src/main/java/com/wipro/www/sonhms/entity/DmaapNotifications.java deleted file mode 100644 index 925a9e6..0000000 --- a/src/main/java/com/wipro/www/sonhms/entity/DmaapNotifications.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.entity; - -import java.sql.Timestamp; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -import org.hibernate.annotations.CreationTimestamp; - -@Entity -@Table(name = "DMAAP_NOTIFICATIONS") -public class DmaapNotifications { - - @Id - @Column(name = "notification", columnDefinition = "text") - private String notification; - - @CreationTimestamp - @Column(name = "created_at", columnDefinition = "timestamp") - private Timestamp createdAt; - - public DmaapNotifications() { - - } - - public DmaapNotifications(String notification, Timestamp createdAt) { - this.notification = notification; - this.createdAt = createdAt; - } - - public String getNotification() { - return notification; - } - - public void setNotification(String notification) { - this.notification = notification; - } - - public Timestamp getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Timestamp createdAt) { - this.createdAt = createdAt; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/entity/PciRequests.java b/src/main/java/com/wipro/www/sonhms/entity/PciRequests.java deleted file mode 100644 index cce914d..0000000 --- a/src/main/java/com/wipro/www/sonhms/entity/PciRequests.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.entity; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -@Entity -@Table(name = "PCI_REQUESTS") -public class PciRequests { - - @Id - @Column(name = "TRANSACTION_ID") - private String transactionId; - - @Column(name = "CHILD_THREAD_ID") - private long childThreadId; - - public PciRequests() { - - } - - /** - * Parameterised constructor. - */ - public PciRequests(String transactionId, long childThreadId) { - super(); - this.transactionId = transactionId; - this.childThreadId = childThreadId; - } - - public String getTransactionId() { - return transactionId; - } - - public void setTransactionId(String transactionId) { - this.transactionId = transactionId; - } - - public long getChildThreadId() { - return childThreadId; - } - - public void setChildThreadId(long childThreadId) { - this.childThreadId = childThreadId; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/exceptions/ConfigDbNotFoundException.java b/src/main/java/com/wipro/www/sonhms/exceptions/ConfigDbNotFoundException.java deleted file mode 100644 index 70127b5..0000000 --- a/src/main/java/com/wipro/www/sonhms/exceptions/ConfigDbNotFoundException.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.exceptions; - -public class ConfigDbNotFoundException extends Exception { - - /** - * serial version. - */ - private static final long serialVersionUID = 1L; - - public ConfigDbNotFoundException(String message) { - super(message); - } -} diff --git a/src/main/java/com/wipro/www/sonhms/exceptions/OofNotFoundException.java b/src/main/java/com/wipro/www/sonhms/exceptions/OofNotFoundException.java deleted file mode 100644 index fb95a0f..0000000 --- a/src/main/java/com/wipro/www/sonhms/exceptions/OofNotFoundException.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.exceptions; - -public class OofNotFoundException extends Exception { - /** - * serial version. - */ - private static final long serialVersionUID = 1L; - - public OofNotFoundException(String message) { - super(message); - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/CellConfig.java b/src/main/java/com/wipro/www/sonhms/model/CellConfig.java deleted file mode 100644 index 1fab733..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/CellConfig.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class CellConfig { - - @JsonProperty(value = "LTE") - private Lte lte; - - public CellConfig() { - - } - - public CellConfig(Lte lte) { - super(); - this.lte = lte; - } - - public Lte getLte() { - return lte; - } - - public void setLte(Lte lte) { - this.lte = lte; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/CellNeighbourList.java b/src/main/java/com/wipro/www/sonhms/model/CellNeighbourList.java deleted file mode 100644 index 5bbff6d..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/CellNeighbourList.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -public class CellNeighbourList { - - private String cellId; - private int physicalCellId; - private String neighbours; - - public String getCellId() { - return cellId; - } - - public void setCellId(String cellId) { - this.cellId = cellId; - } - - public int getPhysicalCellId() { - return physicalCellId; - } - - public void setPhysicalCellId(int physicalCellId) { - this.physicalCellId = physicalCellId; - } - - public String getNeighbours() { - return neighbours; - } - - public void setNeighbours(String neighbours) { - this.neighbours = neighbours; - } - - /** - * constructor. - */ - public CellNeighbourList() { - - } - - /** - * Parameterized constructor. - */ - public CellNeighbourList(String cellId, int physicalCellId, String neighbours) { - super(); - this.cellId = cellId; - this.physicalCellId = physicalCellId; - this.neighbours = neighbours; - } -} diff --git a/src/main/java/com/wipro/www/sonhms/model/CellPciPair.java b/src/main/java/com/wipro/www/sonhms/model/CellPciPair.java deleted file mode 100644 index fb4c91a..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/CellPciPair.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class CellPciPair { - @JsonProperty("cellId") - private String cellId; - - @JsonProperty("physicalCellId") - private int physicalCellId; - - @Override - public String toString() { - return "CellPciPair [cellId=" + cellId + ", physicalCellId=" + physicalCellId + "]"; - } - - public CellPciPair() { - - } - - /** - * Parameterized constructor. - */ - public CellPciPair(String cellId, int physicalCellId) { - super(); - this.cellId = cellId; - this.physicalCellId = physicalCellId; - } - - public String getCellId() { - return cellId; - } - - public void setCellId(String cellId) { - this.cellId = cellId; - } - - public int getPhysicalCellId() { - return physicalCellId; - } - - public void setPhysicalCellId(int physicalCellId) { - this.physicalCellId = physicalCellId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = (prime * result) + ((cellId == null) ? 0 : cellId.hashCode()); - result = (prime * result) + physicalCellId; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - CellPciPair other = (CellPciPair) obj; - if (cellId == null) { - if (other.cellId != null) { - return false; - } - } else if (!cellId.equals(other.cellId)) { - return false; - } - return (physicalCellId == other.physicalCellId); - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/Common.java b/src/main/java/com/wipro/www/sonhms/model/Common.java deleted file mode 100644 index f317467..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/Common.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class Common { - - @JsonProperty(value = "CellIdentity") - private String cellIdentity; - - public Common() { - - } - - public Common(String cellIdentity) { - super(); - this.cellIdentity = cellIdentity; - } - - public String getCellIdentity() { - return cellIdentity; - } - - public void setCellIdentity(String cellIdentity) { - this.cellIdentity = cellIdentity; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/Configurations.java b/src/main/java/com/wipro/www/sonhms/model/Configurations.java deleted file mode 100644 index f5dcd7e..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/Configurations.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class Configurations { - @JsonProperty("data") - private Data data; - - /** - * constructor. - * - */ - public Configurations() { - - } - - /** - * Parameterized constructor. - * - */ - public Configurations(Data data) { - super(); - this.data = data; - } - - public Data getData() { - return data; - } - - public void setData(Data data) { - this.data = data; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/Data.java b/src/main/java/com/wipro/www/sonhms/model/Data.java deleted file mode 100644 index 6bff144..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/Data.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class Data { - - @JsonProperty("FAPService") - private FapService fapservice; - - public Data() { - - } - - public Data(FapService fapservice) { - super(); - this.fapservice = fapservice; - } - - public FapService getFapservice() { - return fapservice; - } - - public void setFapservice(FapService fapservice) { - this.fapservice = fapservice; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/FapService.java b/src/main/java/com/wipro/www/sonhms/model/FapService.java deleted file mode 100644 index c949922..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/FapService.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class FapService { - - @JsonProperty("alias") - private String alias; - - @JsonProperty("X0005b9Lte") - private X0005b9Lte x0005b9Lte; - - @JsonProperty("CellConfig") - private CellConfig cellConfig; - - public FapService() { - - } - - /** - * Parameterized constructor. - */ - public FapService(String alias, X0005b9Lte x0005b9Lte, CellConfig cellConfig) { - super(); - this.alias = alias; - this.x0005b9Lte = x0005b9Lte; - this.cellConfig = cellConfig; - } - - public String getAlias() { - return alias; - } - - public void setAlias(String alias) { - this.alias = alias; - } - - public CellConfig getCellConfig() { - return cellConfig; - } - - public void setCellConfig(CellConfig cellConfig) { - this.cellConfig = cellConfig; - } - - public X0005b9Lte getX0005b9Lte() { - return x0005b9Lte; - } - - public void setX0005b9Lte(X0005b9Lte x0005b9Lte) { - this.x0005b9Lte = x0005b9Lte; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/FapServiceList.java b/src/main/java/com/wipro/www/sonhms/model/FapServiceList.java deleted file mode 100644 index 96cde4c..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/FapServiceList.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class FapServiceList { - - @Override - public String toString() { - return "FapServiceList [alias=" + alias + ", x0005b9Lte=" + x0005b9Lte + ", cellConfig=" + cellConfig + "]"; - } - - @JsonProperty("alias") - private String alias; - - @JsonProperty("X0005b9Lte") - private X0005b9Lte x0005b9Lte; - - @JsonProperty("CellConfig") - private NotificationCellConfig cellConfig; - - public FapServiceList() { - - } - - /** - * Parameterized Constructor. - */ - - public FapServiceList(String alias, X0005b9Lte x0005b9Lte, NotificationCellConfig cellConfig) { - super(); - this.alias = alias; - this.x0005b9Lte = x0005b9Lte; - this.cellConfig = cellConfig; - } - - public String getAlias() { - return alias; - } - - public void setAlias(String alias) { - this.alias = alias; - } - - public X0005b9Lte getX0005b9Lte() { - return x0005b9Lte; - } - - public void setX0005b9Lte(X0005b9Lte x0005b9Lte) { - this.x0005b9Lte = x0005b9Lte; - } - - public NotificationCellConfig getCellConfig() { - return cellConfig; - } - - public void setCellConfig(NotificationCellConfig cellConfig) { - this.cellConfig = cellConfig; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/Lte.java b/src/main/java/com/wipro/www/sonhms/model/Lte.java deleted file mode 100644 index 871f100..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/Lte.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class Lte { - - @JsonProperty(value = "RAN") - private Ran ran; - - public Lte() { - - } - - public Lte(Ran ran) { - super(); - this.ran = ran; - } - - public Ran getRan() { - return ran; - } - - public void setRan(Ran ran) { - this.ran = ran; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/LteNeighborListInUseLteCell.java b/src/main/java/com/wipro/www/sonhms/model/LteNeighborListInUseLteCell.java deleted file mode 100644 index fe85d47..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/LteNeighborListInUseLteCell.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class LteNeighborListInUseLteCell { - @JsonProperty("pnfName") - private String pnfName; - - @JsonProperty("enable") - private String enable; - - @JsonProperty("alias") - private String alias; - - @JsonProperty("mustInclude") - private String mustInclude; - - @JsonProperty("plmnid") - private String plmnId; - - @JsonProperty("cid") - private String cid; - - @JsonProperty("phyCellId") - private int phyCellId; - - @JsonProperty("blacklisted") - private String blacklisted; - - public LteNeighborListInUseLteCell() { - - } - - /** - * Parameterized Constructor. - */ - - public LteNeighborListInUseLteCell(String pnfName, String enable, String alias, String mustInclude, String plmnId, - String cid, int phyCellId, String blacklisted) { - super(); - this.pnfName = pnfName; - this.enable = enable; - this.alias = alias; - this.mustInclude = mustInclude; - this.plmnId = plmnId; - this.cid = cid; - this.phyCellId = phyCellId; - this.blacklisted = blacklisted; - } - - public String getMustInclude() { - return mustInclude; - } - - public void setMustInclude(String mustInclude) { - this.mustInclude = mustInclude; - } - - public int getPhyCellId() { - return phyCellId; - } - - public void setPhyCellId(int phyCellId) { - this.phyCellId = phyCellId; - } - - public String getAlias() { - return alias; - } - - public void setAlias(String alias) { - this.alias = alias; - } - - public String getEnable() { - return enable; - } - - public void setEnable(String enable) { - this.enable = enable; - } - - public String getBlacklisted() { - return blacklisted; - } - - public void setBlacklisted(String blacklisted) { - this.blacklisted = blacklisted; - } - - public String getCid() { - return cid; - } - - public void setCid(String cid) { - this.cid = cid; - } - - public String getPnfName() { - return pnfName; - } - - public void setPnfName(String pnfName) { - this.pnfName = pnfName; - } - - public String getPlmnid() { - return plmnId; - } - - public void setPlmnid(String plmnId) { - this.plmnId = plmnId; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/NeighborListInUse.java b/src/main/java/com/wipro/www/sonhms/model/NeighborListInUse.java deleted file mode 100644 index d240a88..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/NeighborListInUse.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -public class NeighborListInUse { - @JsonProperty("LTENeighborListInUseLTECell") - private List lteNeighborListInUseLteCell; - - @JsonProperty("LTECellNumberOfEntries") - private String lteCellNumberOfEntries; - - public NeighborListInUse() { - - } - - /** - * Parameterized Constructor. - */ - - public NeighborListInUse(List lteNeighborListInUseLteCell, - String lteCellNumberOfEntries) { - super(); - this.lteNeighborListInUseLteCell = lteNeighborListInUseLteCell; - this.lteCellNumberOfEntries = lteCellNumberOfEntries; - } - - public List getLteNeighborListInUseLteCell() { - return lteNeighborListInUseLteCell; - } - - public void setLteNeighborListInUseLteCell(List lteNeighborListInUseLteCell) { - this.lteNeighborListInUseLteCell = lteNeighborListInUseLteCell; - } - - public String getLteCellNumberOfEntries() { - return lteCellNumberOfEntries; - } - - public void setLteCellNumberOfEntries(String lteCellNumberOfEntries) { - this.lteCellNumberOfEntries = lteCellNumberOfEntries; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/Notification.java b/src/main/java/com/wipro/www/sonhms/model/Notification.java deleted file mode 100644 index 417e443..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/Notification.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class Notification { - - @JsonProperty("requestID") - private String requestId; - - @JsonProperty("AAI") - private Object aai; - - @JsonProperty("from") - private String from; - - @JsonProperty("version") - private String version; - - @JsonProperty("Action") - private String action; - - @JsonProperty("Payload") - private NotificationPayload payload; - - public Notification() { - - } - - /** - * Parameterized Constructor. - */ - - public Notification(String requestId, Object aai, String from, String version, String action, - NotificationPayload payload) { - super(); - this.requestId = requestId; - this.aai = aai; - this.from = from; - this.version = version; - this.action = action; - this.payload = payload; - } - - public NotificationPayload getPayload() { - return payload; - } - - public void setPayload(NotificationPayload payload) { - this.payload = payload; - } - - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getFrom() { - return from; - } - - public void setFrom(String from) { - this.from = from; - } - - public Object getAai() { - return aai; - } - - public void setAai(Object aai) { - this.aai = aai; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/NotificationCellConfig.java b/src/main/java/com/wipro/www/sonhms/model/NotificationCellConfig.java deleted file mode 100644 index a3acaf0..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/NotificationCellConfig.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class NotificationCellConfig { - - @JsonProperty("LTE") - private NotificationLte lte; - - public NotificationCellConfig() { - - } - - /** - * Parameterized Constructor. - */ - - public NotificationCellConfig(NotificationLte lte) { - super(); - this.lte = lte; - } - - public NotificationLte getLte() { - return lte; - } - - public void setLte(NotificationLte lte) { - this.lte = lte; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/NotificationLte.java b/src/main/java/com/wipro/www/sonhms/model/NotificationLte.java deleted file mode 100644 index f1e26e7..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/NotificationLte.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class NotificationLte { - - @JsonProperty("RAN") - private NotificationRan ran; - - public NotificationLte() { - - } - - /** - * Parameterized Constructor. - */ - - public NotificationLte(NotificationRan ran) { - super(); - this.ran = ran; - } - - public NotificationRan getRan() { - return ran; - } - - public void setRan(NotificationRan ran) { - this.ran = ran; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/NotificationPayload.java b/src/main/java/com/wipro/www/sonhms/model/NotificationPayload.java deleted file mode 100644 index fea882b..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/NotificationPayload.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class NotificationPayload { - - @JsonProperty("RadioAccess") - private RadioAccess radioAccess; - - public NotificationPayload() { - - } - - /** - * Parameterized Constructor. - */ - - public NotificationPayload(RadioAccess radioAccess) { - super(); - this.radioAccess = radioAccess; - } - - public RadioAccess getRadioAccess() { - return radioAccess; - } - - public void setRadioAccess(RadioAccess radioAccess) { - this.radioAccess = radioAccess; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/NotificationRan.java b/src/main/java/com/wipro/www/sonhms/model/NotificationRan.java deleted file mode 100644 index cc0e085..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/NotificationRan.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class NotificationRan { - - @JsonProperty("NeighborListInUse") - private NeighborListInUse neighborListInUse; - - @JsonProperty("CellIdentity") - private String cellIdentity; - - public NotificationRan() { - - } - - /** - * Parameterized Constructor. - */ - - public NotificationRan(NeighborListInUse neighborListInUse, String cellIdentity) { - super(); - this.neighborListInUse = neighborListInUse; - this.cellIdentity = cellIdentity; - } - - public NeighborListInUse getNeighborListInUse() { - return neighborListInUse; - } - - public void setNeighborListInUse(NeighborListInUse neighborListInUse) { - this.neighborListInUse = neighborListInUse; - } - - public String getCellIdentity() { - return cellIdentity; - } - - public void setCellIdentity(String cellIdentity) { - this.cellIdentity = cellIdentity; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/Payload.java b/src/main/java/com/wipro/www/sonhms/model/Payload.java deleted file mode 100644 index 9f10acb..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/Payload.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -public class Payload { - - @JsonProperty("Configurations") - private List configuration; - - public Payload() { - - } - - public Payload(List configuration) { - super(); - this.configuration = configuration; - } - - public List getConfiguration() { - return configuration; - } - - public void setConfiguration(List configuration) { - this.configuration = configuration; - } - - @Override - public String toString() { - return "Payload [configuration=" + configuration + "]"; - - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/PolicyNotification.java b/src/main/java/com/wipro/www/sonhms/model/PolicyNotification.java deleted file mode 100644 index e367b0b..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/PolicyNotification.java +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -public class PolicyNotification { - - private String closedLoopControlName; - private long closedLoopAlarmStart; - private String closedLoopEventClient; - private String closedLoopEventStatus; - - @JsonProperty("target_type") - private String targetType; - - private String target; - - @JsonProperty("requestID") - private String requestId; - - @JsonProperty("AAI") - private Map aai; - - private String from; - private String version; - - @JsonProperty("Action") - private String action; - private String payload; - - /** - * constructor. - */ - public PolicyNotification() { - this.requestId = UUID.randomUUID().toString(); - this.closedLoopEventClient = "microservice.PCI"; - this.closedLoopEventStatus = "ONSET"; - this.closedLoopAlarmStart = System.currentTimeMillis(); - this.from = "PCIMS"; - this.version = "1.0.2"; - this.action = "ModifyConfig"; - this.target = "generic-vnf.vnf-id"; - this.targetType = "VNF"; - this.aai = new HashMap<>(); - aai.put("generic-vnf.is-closed-loop-disabled", "false"); - aai.put("generic-vnf.prov-status", "ACTIVE"); - aai.put("generic-vnf.vnf-id", "notused"); - - } - - public long getClosedLoopAlarmStart() { - return closedLoopAlarmStart; - } - - public void setClosedLoopAlarmStart(long closedLoopAlarmStart) { - this.closedLoopAlarmStart = closedLoopAlarmStart; - } - - public String getClosedLoopEventClient() { - return closedLoopEventClient; - } - - public void setClosedLoopEventClient(String closedLoopEventClient) { - this.closedLoopEventClient = closedLoopEventClient; - } - - public String getClosedLoopEventStatus() { - return closedLoopEventStatus; - } - - public void setClosedLoopEventStatus(String closedLoopEventStatus) { - this.closedLoopEventStatus = closedLoopEventStatus; - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getFrom() { - return from; - } - - public void setFrom(String from) { - this.from = from; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - public String getClosedLoopControlName() { - return closedLoopControlName; - } - - public void setClosedLoopControlName(String closedLoopControlName) { - this.closedLoopControlName = closedLoopControlName; - } - - public String getPayload() { - return payload; - } - - public void setPayload(String payload) { - this.payload = payload; - } - - public String getTargetType() { - return targetType; - } - - public void setTargetType(String targetType) { - this.targetType = targetType; - } - - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - public Map getAai() { - return aai; - } - - public void setAai(Map aai) { - this.aai = aai; - } - - @Override - public String toString() { - return "PolicyNotification [closedLoopControlName=" + closedLoopControlName + ", closedLoopAlarmStart=" - + closedLoopAlarmStart + ", closedLoopEventClient=" + closedLoopEventClient + ", closedLoopEventStatus=" - + closedLoopEventStatus + ", targetType=" + targetType + ", target=" + target + ", requestId=" - + requestId + ", aai=" + aai + ", from=" + from + ", version=" + version + ", action=" + action - + ", payload=" + payload + "]"; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/RadioAccess.java b/src/main/java/com/wipro/www/sonhms/model/RadioAccess.java deleted file mode 100644 index cc1ee4a..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/RadioAccess.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -public class RadioAccess { - - @JsonProperty("FAPServiceNumberOfEntries") - private String fapServiceNumberOfEntries; - - @JsonProperty("FAPServiceList") - private List fapServiceList; - - public RadioAccess() { - - } - - /** - * Parameterized Constructor. - */ - - public RadioAccess(String fapServiceNumberOfEntries, List fapServiceList) { - super(); - this.fapServiceNumberOfEntries = fapServiceNumberOfEntries; - this.fapServiceList = fapServiceList; - } - - public String getFapServiceNumberOfEntries() { - return fapServiceNumberOfEntries; - } - - public void setFapServiceNumberOfEntries(String fapServiceNumberOfEntries) { - this.fapServiceNumberOfEntries = fapServiceNumberOfEntries; - } - - public List getFapServiceList() { - return fapServiceList; - } - - public void setFapServiceList(List fapServiceList) { - this.fapServiceList = fapServiceList; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/Ran.java b/src/main/java/com/wipro/www/sonhms/model/Ran.java deleted file mode 100644 index d4dda3a..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/Ran.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class Ran { - - @JsonProperty(value = "Common") - private Common common; - - public Ran() { - - } - - /** - * Parameterized constructor. - */ - public Ran(Common common) { - super(); - this.common = common; - } - - public Common getCommon() { - return common; - } - - public void setCommon(Common common) { - this.common = common; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/Response.java b/src/main/java/com/wipro/www/sonhms/model/Response.java deleted file mode 100644 index e34c10f..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/Response.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class Response { - - @JsonProperty(value = "cellId") - private String cellId; - - private int pci; - - public String getCellId() { - return cellId; - } - - public void setCellId(String cellId) { - this.cellId = cellId; - } - - public int getPci() { - return pci; - } - - public void setPci(int pci) { - this.pci = pci; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/SdnrResponse.java b/src/main/java/com/wipro/www/sonhms/model/SdnrResponse.java deleted file mode 100644 index b57b20e..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/SdnrResponse.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import java.util.List; - -public class SdnrResponse { - - private List response; - - public List getResponse() { - return response; - } - - public void setResponse(List response) { - this.response = response; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/ThreadId.java b/src/main/java/com/wipro/www/sonhms/model/ThreadId.java deleted file mode 100644 index d0139f2..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/ThreadId.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -public class ThreadId { - - private long childThreadId; - - public long getChildThreadId() { - return childThreadId; - } - - public void setChildThreadId(long childThreadId) { - this.childThreadId = childThreadId; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/model/X0005b9Lte.java b/src/main/java/com/wipro/www/sonhms/model/X0005b9Lte.java deleted file mode 100644 index cb52715..0000000 --- a/src/main/java/com/wipro/www/sonhms/model/X0005b9Lte.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class X0005b9Lte { - - @JsonProperty("phyCellIdInUse") - private int phyCellIdInUse; - - @JsonProperty("pnfName") - private String pnfName; - - public X0005b9Lte() { - - } - - /** - * Parameterized Constructor. - */ - - public X0005b9Lte(int phyCellIdInUse, String pnfName) { - super(); - this.phyCellIdInUse = phyCellIdInUse; - this.pnfName = pnfName; - } - - public int getPhyCellIdInUse() { - return phyCellIdInUse; - } - - public void setPhyCellIdInUse(int phyCellIdInUse) { - this.phyCellIdInUse = phyCellIdInUse; - } - - public String getPnfName() { - return pnfName; - } - - public void setPnfName(String pnfName) { - this.pnfName = pnfName; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/restclient/AsyncResponseBody.java b/src/main/java/com/wipro/www/sonhms/restclient/AsyncResponseBody.java deleted file mode 100644 index 94e6919..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/AsyncResponseBody.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; - -import java.util.List; - -public class AsyncResponseBody { - - String transactionId = null; - String requestId = null; - String requestStatus = null; - String statusMessage = null; - List solutions; - - public String getTransactionId() { - return transactionId; - } - - public void setTransactionId(String transactionId) { - this.transactionId = transactionId; - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getRequestStatus() { - return requestStatus; - } - - @Override - public String toString() { - return "AsyncResponseBody [transactionId=" + transactionId + ", requestId=" + requestId + ", requestStatus=" - + requestStatus + ", statusMessage=" + statusMessage + ", solutions=" + solutions + "]"; - } - - public void setRequestStatus(String requestStatus) { - this.requestStatus = requestStatus; - } - - public String getStatusMessage() { - return statusMessage; - } - - public void setStatusMessage(String statusMessage) { - this.statusMessage = statusMessage; - } - - public List getSolutions() { - return solutions; - } - - public void setSolutions(List solutions) { - this.solutions = solutions; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/restclient/CellInfo.java b/src/main/java/com/wipro/www/sonhms/restclient/CellInfo.java deleted file mode 100644 index 77d4003..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/CellInfo.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; - -import java.util.ArrayList; -import java.util.List; - -public class CellInfo { - String networkId = null; - List cellIdList = new ArrayList<>(); - - public String getNetworkId() { - return networkId; - } - - public void setNetworkId(String networkId) { - this.networkId = networkId; - } - - public List getCellIdList() { - return cellIdList; - } - - public void setCellIdList(List cellIdList) { - this.cellIdList = cellIdList; - } - - - -} diff --git a/src/main/java/com/wipro/www/sonhms/restclient/OofRequestBody.java b/src/main/java/com/wipro/www/sonhms/restclient/OofRequestBody.java deleted file mode 100644 index edee572..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/OofRequestBody.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; - -public class OofRequestBody { - - protected RequestInfo requestInfo = new RequestInfo(); - protected CellInfo cellInfo = new CellInfo(); - - public RequestInfo getRequestInfo() { - return requestInfo; - } - - public void setRequestInfo(RequestInfo requestInfo) { - this.requestInfo = requestInfo; - } - - public CellInfo getCellInfo() { - return cellInfo; - } - - public void setCellInfo(CellInfo cellInfo) { - this.cellInfo = cellInfo; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/restclient/OofRestClient.java b/src/main/java/com/wipro/www/sonhms/restclient/OofRestClient.java deleted file mode 100644 index 7b95d90..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/OofRestClient.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.wipro.www.sonhms.ConfigPolicy; -import com.wipro.www.sonhms.Configuration; -import com.wipro.www.sonhms.exceptions.OofNotFoundException; -import com.wipro.www.sonhms.utils.HttpRequester; - -import java.util.List; -import java.util.UUID; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class OofRestClient { - private static Logger log = LoggerFactory.getLogger(OofRestClient.class); - - private OofRestClient() { - - } - - /** - * rest client that pci uses to query the OOF for pci solutions. - * @throws OofNotFoundException when request to oof fails - */ - - public static String queryOof(int numSolutions, String transactionId, String requestType, - List cellIdList, String networkId, List optimizers) throws OofNotFoundException { - log.debug("inside queryoof"); - - String response = ""; - Configuration configuration = Configuration.getInstance(); - try { - UUID requestUuid = UUID.randomUUID(); - String requestId = requestUuid.toString(); - String callbackUrl = configuration.getCallbackUrl(); - RequestInfo requestInfo = new RequestInfo(); - requestInfo.setTransactionId(transactionId); - requestInfo.setRequestId(requestId); - requestInfo.setCallbackUrl(callbackUrl); - String sourceId = configuration.getSourceId(); - requestInfo.setSourceId(sourceId); - requestInfo.setRequestType(requestType); - requestInfo.setNumSolutions(numSolutions); - requestInfo.setOptimizers(optimizers); - 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(); - cellInfo.setCellIdList(cellIdList); - cellInfo.setNetworkId(networkId); - OofRequestBody oofRequestBody = new OofRequestBody(); - oofRequestBody.setRequestInfo(requestInfo); - oofRequestBody.setCellInfo(cellInfo); - - ObjectMapper mapper = new ObjectMapper(); - String requestBody = mapper.writeValueAsString(oofRequestBody); - log.debug("requestBody{}", requestBody); - - String requestUrl = configuration.getOofService() + "/api/oof/v1/pci"; - log.debug("requestUrl {}", requestUrl); - - response = HttpRequester.sendPostRequestToOof(requestUrl, requestBody); - if (response == null) { - throw new OofNotFoundException("Request to oof failed"); - } - log.debug("response {}", response); - - return response; - } catch (JsonProcessingException e) { - log.debug("exception{}", e); - - } - return response; - } -} diff --git a/src/main/java/com/wipro/www/sonhms/restclient/PolicyRequestBody.java b/src/main/java/com/wipro/www/sonhms/restclient/PolicyRequestBody.java deleted file mode 100644 index e9e7b0d..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/PolicyRequestBody.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; - -public class PolicyRequestBody { - - String configName = null; - String policyName = null; - String requestId = null; - - public String getConfigName() { - return configName; - } - - public void setConfigName(String configName) { - this.configName = configName; - } - - public String getPolicyName() { - return policyName; - } - - public void setPolicyName(String policyName) { - this.policyName = policyName; - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/restclient/PolicyRestClient.java b/src/main/java/com/wipro/www/sonhms/restclient/PolicyRestClient.java deleted file mode 100644 index 7c286af..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/PolicyRestClient.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.wipro.www.sonhms.Configuration; -import com.wipro.www.sonhms.utils.HttpRequester; - -import java.util.UUID; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class PolicyRestClient { - private static Logger log = LoggerFactory.getLogger(PolicyRestClient.class); - - private PolicyRestClient() { - - } - - /** - * Fetches configuration from policy. - */ - public static String fetchConfigFromPolicy() { - log.debug("inside fetconfig from policy"); - - Configuration configuration = Configuration.getInstance(); - String response = ""; - String configName = configuration.getConfigName(); - String policyName = configuration.getPolicyName(); - - try { - PolicyRequestBody policyRequestBody = new PolicyRequestBody(); - policyRequestBody.setConfigName(configName); - policyRequestBody.setPolicyName(policyName); - UUID requestUuid = UUID.randomUUID(); - String requestId = requestUuid.toString(); - policyRequestBody.setRequestId(requestId); - ObjectMapper mapper = new ObjectMapper(); - String requestBody; - requestBody = mapper.writeValueAsString(policyRequestBody); - - log.debug("policyRequestBody{}", requestBody); - String requestUrl = configuration.getPolicyService() + "/pdp/api/getConfig"; - response = HttpRequester.sendPostToPolicy(requestUrl, requestBody); - log.debug("policy response{}", response); - - return response; - } catch (JsonProcessingException e) { - log.debug("exception", e); - } - return response; - - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/restclient/RequestInfo.java b/src/main/java/com/wipro/www/sonhms/restclient/RequestInfo.java deleted file mode 100644 index 6dcbf63..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/RequestInfo.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; - -import java.util.List; - -public class RequestInfo { - String transactionId = null; - String requestId = null; - String callbackUrl = null; - String sourceId = null; - String requestType = null; - int numSolutions; - List optimizers = null; - - public void setOptimizers(List optimizers) { - this.optimizers = optimizers; - } - - public List getOptimizers() { - return optimizers; - } - - int timeout; - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getCallbackUrl() { - return callbackUrl; - } - - public void setCallbackUrl(String callbackUrl) { - this.callbackUrl = callbackUrl; - } - - public String getSourceId() { - return sourceId; - } - - public void setSourceId(String sourceId) { - this.sourceId = sourceId; - } - - public String getRequestType() { - return requestType; - } - - public void setRequestType(String requestType) { - this.requestType = requestType; - } - - public int getNumSolutions() { - return numSolutions; - } - - public void setNumSolutions(int numSolutions) { - this.numSolutions = numSolutions; - } - - public int getTimeout() { - return timeout; - } - - public void setTimeout(int timeout) { - this.timeout = timeout; - } - - public String getTransactionId() { - return transactionId; - } - - public void setTransactionId(String transactionId) { - this.transactionId = transactionId; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/restclient/SdnrRestClient.java b/src/main/java/com/wipro/www/sonhms/restclient/SdnrRestClient.java deleted file mode 100644 index c37791f..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/SdnrRestClient.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; - -import com.wipro.www.sonhms.Configuration; -import com.wipro.www.sonhms.exceptions.ConfigDbNotFoundException; -import com.wipro.www.sonhms.model.CellPciPair; -import com.wipro.www.sonhms.utils.HttpRequester; - -import java.sql.Time; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; - -import org.json.JSONArray; -import org.json.JSONObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - - -public class SdnrRestClient { - - private static final String DATETIMEFORMAT = "yyyy-MM-dd HH:mm:ss"; - private static Logger log = LoggerFactory.getLogger(SdnrRestClient.class); - - private SdnrRestClient() { - - } - - /** - * Method to get cell list from SDNR. - * - * @throws ConfigDbNotFoundException - * when request to configDB fails - */ - public static String getCellList(String networkId) throws ConfigDbNotFoundException { - Configuration configuration = Configuration.getInstance(); - String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis())); - String requestUrl = configuration.getSdnrService() + "/SDNCConfigDBAPI/getCellList" + "/" + networkId + "/" - + encode(ts); - return sendRequest(requestUrl); - } - - /** - * Method to get neibhbour list from SDNR. - * - * @throws ConfigDbNotFoundException - * when request to configDB fails - */ - public static List getNbrList(String cellId) throws ConfigDbNotFoundException { - Configuration configuration = Configuration.getInstance(); - String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis())); - String requestUrl = configuration.getSdnrService() + "/SDNCConfigDBAPI/getNbrList" + "/" + cellId + "/" - + encode(ts); - log.debug("request url: {}", requestUrl); - String response = sendRequest(requestUrl); - List nbrList = new ArrayList<>(); - JSONArray nbrListObj = new JSONArray(response); - for (int i = 0; i < nbrListObj.length(); i++) { - JSONObject cellObj = nbrListObj.getJSONObject(i); - CellPciPair cell = new CellPciPair(cellObj.getString("cellId"), cellObj.getInt("pciValue")); - nbrList.add(cell); - } - - return nbrList; - } - - /** - * Method to get PCI from SDNR. - * - * @throws ConfigDbNotFoundException - * when request to configDB fails - */ - public static int getPci(String cellId) throws ConfigDbNotFoundException { - Configuration configuration = Configuration.getInstance(); - String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis())); - String requestUrl = configuration.getSdnrService() + "/SDNCConfigDBAPI/getPCI" + "/" + cellId + "/" - + encode(ts); - String response = sendRequest(requestUrl); - JSONObject respObj = new JSONObject(response); - return respObj.getInt("value"); - } - - /** - * Method to get PNF name from SDNR. - * - * @throws ConfigDbNotFoundException - * when request to configDB fails - */ - public static String getPnfName(String cellId) throws ConfigDbNotFoundException { - Configuration configuration = Configuration.getInstance(); - String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis())); - String requestUrl = configuration.getSdnrService() + "/SDNCConfigDBAPI/getPnfName" + "/" + cellId + "/" - + encode(ts); - String response = sendRequest(requestUrl); - JSONObject responseObject = new JSONObject(response); - return responseObject.getString("value"); - } - - /** - * Method to encode url. - */ - private static String encode(String url) { - return url.replace(" ", "%20"); - } - - /** - * Method to send request. - */ - private static String sendRequest(String url) throws ConfigDbNotFoundException { - String response = HttpRequester.sendGetRequest(url); - if (response.equals("")) { - throw new ConfigDbNotFoundException("Cannot reach Config DB"); - } - return response; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/restclient/Solution.java b/src/main/java/com/wipro/www/sonhms/restclient/Solution.java deleted file mode 100644 index 765501a..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/Solution.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; - -import java.util.ArrayList; -import java.util.List; - -public class Solution { - String startTime = null; - String finishTime = null; - String networkId = null; - List pciSolutions = new ArrayList<>(); - - public String getStartTime() { - return startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getFinishTime() { - return finishTime; - } - - public void setFinishTime(String finishTime) { - this.finishTime = finishTime; - } - - public String getNetworkId() { - return networkId; - } - - public void setNetworkId(String networkId) { - this.networkId = networkId; - } - - public List getPciSolutions() { - return pciSolutions; - } - - /** - * Sets PciSolutions. - */ - public void setPciSolutions(List pciSolutions) { - - this.pciSolutions = pciSolutions; - - } - - @Override - public String toString() { - return "Solutions [startTime=" + startTime + ", finishTime=" + finishTime + ", networkId=" + networkId - + ", pciSolutions=" + pciSolutions + "]"; - } -} diff --git a/src/main/java/com/wipro/www/sonhms/restclient/SonSolution.java b/src/main/java/com/wipro/www/sonhms/restclient/SonSolution.java deleted file mode 100644 index 4872fc7..0000000 --- a/src/main/java/com/wipro/www/sonhms/restclient/SonSolution.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; - -public class SonSolution { - - String cellId = null; - int pci; - - public String getCellId() { - return cellId; - } - - public void setCellId(String cellId) { - this.cellId = cellId; - } - - public int getPci() { - return pci; - } - - public void setPci(int pci) { - this.pci = pci; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/utils/BeanUtil.java b/src/main/java/com/wipro/www/sonhms/utils/BeanUtil.java deleted file mode 100644 index 9d7cdb3..0000000 --- a/src/main/java/com/wipro/www/sonhms/utils/BeanUtil.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.utils; - -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.stereotype.Service; - -@Service -public class BeanUtil implements ApplicationContextAware { - private static ApplicationContext context; - - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - context = applicationContext; - } - - public static T getBean(Class beanClass) { - return context.getBean(beanClass); - } -} diff --git a/src/main/java/com/wipro/www/sonhms/utils/FileIo.java b/src/main/java/com/wipro/www/sonhms/utils/FileIo.java deleted file mode 100644 index 929ae95..0000000 --- a/src/main/java/com/wipro/www/sonhms/utils/FileIo.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.utils; - -import java.io.BufferedReader; -import java.io.FileReader; - -public class FileIo { - - private FileIo() { - - } - - /** - * Reads from File. - */ - public static String readFromFile(String file) { - String content = ""; - try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) { - content = bufferedReader.readLine(); - String temp; - while ((temp = bufferedReader.readLine()) != null) { - content = content.concat(temp); - } - content = content.trim(); - } catch (Exception e) { - content = null; - } - return content; - } - -} diff --git a/src/main/java/com/wipro/www/sonhms/utils/HttpRequester.java b/src/main/java/com/wipro/www/sonhms/utils/HttpRequester.java deleted file mode 100644 index 4e4e411..0000000 --- a/src/main/java/com/wipro/www/sonhms/utils/HttpRequester.java +++ /dev/null @@ -1,284 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.utils; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.net.HttpURLConnection; -import java.net.URL; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLSession; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class HttpRequester { - - private static final String ACCEPT = "Accept"; - private static final String JSON = "application/json"; - private static final String CONTENT = "Content-Type"; - private static final String UTF = "UTF-8"; - private static final String FAILMSG = "Post failed"; - private static final String AUTH = "Authorization"; - private static Logger log = LoggerFactory.getLogger(HttpRequester.class); - - public static class MyHostnameVerifier implements HostnameVerifier { - - @Override - public boolean verify(String hostname, SSLSession session) { - // verification of hostname is switched off - log.debug("Hostname: {}", hostname); - return true; - } - } - - /** - * Send Post Request. - */ - public static String sendPostRequest(String requestUrl, String requestBody) { - String response = ""; - - try { - URL url = new URL(requestUrl); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setDoOutput(true); - connection.setDoInput(true); - connection.setRequestMethod("POST"); - connection.setRequestProperty(ACCEPT, JSON); - connection.setRequestProperty(CONTENT, JSON); - OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream(), UTF); - writer.write(requestBody); - writer.close(); - BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream())); - String temp; - int responseCode = connection.getResponseCode(); - log.debug("response code: {}", responseCode); - response = br.readLine(); - while ((temp = br.readLine()) != null) { - response = response.concat(temp); - } - br.close(); - connection.disconnect(); - - if (response == null) { - response = String.valueOf(responseCode); - } - - } catch (Exception e) { - response = FAILMSG; - } - - return response; - } - - /** - * Send Post Request to policy. - */ - public static String sendPostToPolicy(String requestUrl, String requestBody) { - String response = ""; - log.debug("inside post to policy"); - - try { - URL url = new URL(requestUrl); - - HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); - connection.setHostnameVerifier(new MyHostnameVerifier()); - connection.setDoOutput(true); - connection.setDoInput(true); - connection.setRequestMethod("POST"); - connection.setRequestProperty(ACCEPT, JSON); - connection.setRequestProperty(CONTENT, JSON); - connection.setRequestProperty("ClientAuth", "cHl0aG9uOnRlc3Q="); - connection.setRequestProperty("Environment", "TEST"); - connection.setRequestProperty(AUTH, "Basic dGVzdHBkcDphbHBoYTEyMw=="); - OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream(), UTF); - writer.write(requestBody); - writer.close(); - BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream())); - String temp; - int responseCode = connection.getResponseCode(); - log.debug("response code: {}", responseCode); - response = br.readLine(); - while ((temp = br.readLine()) != null) { - response = response.concat(temp); - } - br.close(); - connection.disconnect(); - - } catch (Exception e) { - log.debug("Exception during post to policy: {}", e); - response = FAILMSG; - } - - return response; - } - - /** - * Send Get Request. - */ - public static String sendGetRequest(String requestUrl) { - String response = ""; - int returnCode = 0; - - try { - URL url = new URL(requestUrl); - HttpURLConnection connection = null; - connection = (HttpURLConnection) url.openConnection(); - connection.setDoInput(true); - connection.setRequestMethod("GET"); - connection.setRequestProperty(ACCEPT, JSON); - returnCode = connection.getResponseCode(); - InputStream connectionIn = null; - if (returnCode == 200) { - connectionIn = connection.getInputStream(); - BufferedReader buffer = new BufferedReader(new InputStreamReader(connectionIn)); - String inputLine; - while ((inputLine = buffer.readLine()) != null) { - response = response.concat(inputLine); - } - buffer.close(); - } - - else { - response = ""; - log.debug("return code: {}", returnCode); - } - } catch (Exception e) { - log.debug("Get failed,Exception : {}", e); - response = ""; - } - return response; - - } - - /** - * Send Get Request to SDNR. - */ - public String sendGetRequest(String requestUrl, String requestBody) { - String response; - try { - URL url = new URL(requestUrl); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setDoOutput(true); - connection.setDoInput(true); - connection.setRequestMethod("POST"); - connection.setRequestProperty(ACCEPT, "text/plain"); - connection.setRequestProperty(CONTENT, JSON); - connection.setRequestProperty(AUTH, "Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA=="); - OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream(), UTF); - writer.write(requestBody); - writer.close(); - BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream())); - String temp; - response = br.readLine(); - while ((temp = br.readLine()) != null) { - response = response.concat(temp); - } - br.close(); - connection.disconnect(); - - } catch (Exception e) { - response = FAILMSG; - } - - return response; - } - - /** - * Send Post Request. - */ - public String sendPostRequest1(String requestUrl, String requestBody) { - String response; - try { - URL url = new URL(requestUrl); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setDoOutput(true); - connection.setDoInput(true); - connection.setRequestMethod("POST"); - connection.setRequestProperty(ACCEPT, JSON); - connection.setRequestProperty(CONTENT, JSON); - connection.setRequestProperty(AUTH, "Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA=="); - connection.setRequestProperty("Content-Length", "" + requestBody.length()); - OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream(), UTF); - writer.write(requestBody); - writer.close(); - BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream())); - String temp; - response = br.readLine(); - while ((temp = br.readLine()) != null) { - response = response.concat(temp); - } - br.close(); - connection.disconnect(); - - } catch (Exception e) { - response = FAILMSG; - } - - return response; - } - - /** - * Send Post Request to oof. - */ - public static String sendPostRequestToOof(String requestUrl, String requestBody) { - String response = ""; - - try { - URL url = new URL(requestUrl); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setDoOutput(true); - connection.setDoInput(true); - connection.setRequestMethod("POST"); - connection.setRequestProperty(ACCEPT, JSON); - connection.setRequestProperty(CONTENT, JSON); - connection.setRequestProperty(AUTH, "Basic cGNpX3Rlc3Q6cGNpX3Rlc3Rwd2Q="); - OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream(), UTF); - writer.write(requestBody); - writer.close(); - BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream())); - String temp; - int responseCode = connection.getResponseCode(); - log.debug("response code: {}", responseCode); - response = br.readLine(); - while ((temp = br.readLine()) != null) { - response = response.concat(temp); - } - br.close(); - connection.disconnect(); - - if (response == null) { - log.debug("Response code: {}", responseCode); - } - - } catch (Exception e) { - log.debug("exception occured when posting: {}", e); - return null; - } - - return response; - } - -} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java new file mode 100644 index 0000000..7eb9e62 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Application.java @@ -0,0 +1,129 @@ +/******************************************************************************* + * ============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; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.dcaegen2.services.sonhms.dmaap.DmaapClient; +import org.onap.dcaegen2.services.sonhms.restclient.PolicyRestClient; +import org.onap.dcaegen2.services.sonhms.utils.FileIo; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.annotation.PostConstruct; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + @Autowired + DmaapClient dmaapClient; + + @Autowired + MainThreadComponent mainThreadComponent; + + private static Logger log = LoggerFactory.getLogger(Application.class); + + /** + * Main method where the pci context is initially set. + */ + public static void main(String[] args) { + SpringApplication.run(Application.class); + + } + + /** + * initialization. + */ + @PostConstruct + void init() { + getConfig(); + fetchIntialConfigFromPolicy(); + NewNotification newNotification = new NewNotification(false); + dmaapClient.initClient(newNotification); + mainThreadComponent.init(newNotification); + } + + /** + * Gets configuration from policy. + */ + @SuppressWarnings("unchecked") + private void fetchIntialConfigFromPolicy() { + log.debug("fetch initial config from policy"); + String configPolicyResponseJson = PolicyRestClient.fetchConfigFromPolicy(); + if (configPolicyResponseJson.equals("Post failed")) { + log.debug("cannot fetch config from policy"); + return; + } + ObjectMapper mapper = new ObjectMapper(); + List> configPolicyResponse = new ArrayList<>(); + try { + configPolicyResponse = mapper.readValue(configPolicyResponseJson, List.class); + } catch (IOException e) { + log.debug("exception during parsing response from policy", e); + } + String configPolicyJson = null; + if (configPolicyResponse != null) { + configPolicyJson = (String) configPolicyResponse.get(0).get("config"); + } else { + return; + } + Map configPolicyMap = new HashMap<>(); + try { + configPolicyMap = mapper.readValue(configPolicyJson, HashMap.class); + } catch (IOException e) { + log.debug("exception during parsing config body from policy", e); + } + ConfigPolicy configPolicy = ConfigPolicy.getInstance(); + configPolicy.setConfig(configPolicyMap); + if (log.isDebugEnabled()) { + log.debug(configPolicy.toString()); + } + } + + /** + * Gets config from config.json. + * + */ + private void getConfig() { + log.debug("getting initial config"); + String configJson = FileIo.readFromFile("/etc/config.json"); + ObjectMapper mapper = new ObjectMapper(); + Configuration configuration = Configuration.getInstance(); + try { + mapper.readerForUpdating(configuration).readValue(configJson); + if (log.isDebugEnabled()) { + log.debug(configuration.toString()); + } + } catch (IOException e) { + log.debug("exception during parsing configuration", e); + } + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponent.java new file mode 100644 index 0000000..50dec11 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponent.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * ============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; + +import org.onap.dcaegen2.services.sonhms.dao.BufferedNotificationsRepository; +import org.onap.dcaegen2.services.sonhms.entity.BufferedNotifications; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; +import java.util.List; + +public class BufferNotificationComponent { + + /** + * Buffers notification along with cluster id in the database. + */ + public void bufferNotification(String notification, String clusterId) { + BufferedNotifications bufferedNotifications = new BufferedNotifications(); + bufferedNotifications.setNotification(notification); + bufferedNotifications.setClusterId(clusterId); + BufferedNotificationsRepository bufferedNotificationsRepository = BeanUtil + .getBean(BufferedNotificationsRepository.class); + bufferedNotificationsRepository.save(bufferedNotifications); + + } + + /** + * Retrieves buffered notification from the database. + */ + public List getBufferedNotification(String clusterId) { + BufferedNotificationsRepository bufferedNotificationsRepository = BeanUtil + .getBean(BufferedNotificationsRepository.class); + return bufferedNotificationsRepository.getNotificationsFromQueue(clusterId); + + } + + /** + * Retrieves clusterid from the database. + */ + public String getClusterId(String notification) { + BufferedNotificationsRepository bufferedNotificationsRepository = BeanUtil + .getBean(BufferedNotificationsRepository.class); + return bufferedNotificationsRepository.getClusterIdForNotification(notification); + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponent.java new file mode 100644 index 0000000..8e4b357 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponent.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * ============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; + +import org.onap.dcaegen2.services.sonhms.dao.ClusterDetailsRepository; +import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; + +import java.util.List; + + +public class ClusterDetailsComponent { + + /** + * get cluster details. + */ + public List getClusterDetails() { + ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class); + return clusterDetailsRepository.getAllClusterDetails(); + } + + /** + * get child thread. + */ + public long getChildThread(String clusterId) { + ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class); + return clusterDetailsRepository.getChildThreadForCluster(clusterId); + + } + + /** + * get cluster id. + */ + public String getClusterId(long childThreadId) { + ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class); + return clusterDetailsRepository.getClusterIdForChildThread(childThreadId); + + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/ConfigPolicy.java b/src/main/java/org/onap/dcaegen2/services/sonhms/ConfigPolicy.java new file mode 100644 index 0000000..7c065ac --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/ConfigPolicy.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * ============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; + +import java.util.Map; + +public class ConfigPolicy { + + private static ConfigPolicy instance = null; + private Map config; + + protected ConfigPolicy() { + + } + + /** + * Get instance of class. + */ + public static ConfigPolicy getInstance() { + if (instance == null) { + instance = new ConfigPolicy(); + } + return instance; + } + + public Map getConfig() { + return config; + } + + public void setConfig(Map config) { + this.config = config; + } + + @Override + public String toString() { + return "ConfigPolicy [config=" + config + "]"; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java new file mode 100644 index 0000000..a90a0b9 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java @@ -0,0 +1,309 @@ +/******************************************************************************* + * ============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; + +import java.util.List; + +public class Configuration { + + private static Configuration instance = null; + private List topics; + private String sdnrTopic; + private String policyTopic; + private List servers; + private String managerApiKey; + private String managerSecretKey; + private String pcimsApiKey; + private String pcimsSecretKey; + private String cg; + private String cid; + private int pollingInterval; + private int pollingTimeout; + private int minCollision; + private int minConfusion; + private String sdnrService; + private String policyService; + private String oofService; + private String sourceId; + private String policyName; + private String configName; + private String callbackUrl; + private List optimizers; + private int numSolutions; + private int bufferTime; + private int maximumClusters; + private String consulHost; + private String hostName; + private String configBindingService; + + public String getConsulHost() { + return consulHost; + } + + public void setConsulHost(String consulHost) { + this.consulHost = consulHost; + } + + public String getHostName() { + return hostName; + } + + public void setHostName(String hostName) { + this.hostName = hostName; + } + + public String getConfigBindingService() { + return configBindingService; + } + + public void setConfigBindingService(String configBindingService) { + this.configBindingService = configBindingService; + } + + public int getMaximumClusters() { + return maximumClusters; + } + + public void setMaximumClusters(int maximumClusters) { + this.maximumClusters = maximumClusters; + } + + protected Configuration() { + + } + + /** + * Get instance of class. + */ + public static Configuration getInstance() { + if (instance == null) { + instance = new Configuration(); + } + return instance; + } + + public List getServers() { + return servers; + } + + public void setServers(List servers) { + this.servers = servers; + } + + public String getManagerApiKey() { + return managerApiKey; + } + + public void setManagerApiKey(String managerApiKey) { + this.managerApiKey = managerApiKey; + } + + public String getManagerSecretKey() { + return managerSecretKey; + } + + public void setManagerSecretKey(String managerSecretKey) { + this.managerSecretKey = managerSecretKey; + } + + public String getPcimsApiKey() { + return pcimsApiKey; + } + + public void setPcimsApiKey(String pcimsApiKey) { + this.pcimsApiKey = pcimsApiKey; + } + + public String getPcimsSecretKey() { + return pcimsSecretKey; + } + + public void setPcimsSecretKey(String pcimsSecretKey) { + this.pcimsSecretKey = pcimsSecretKey; + } + + public String getCg() { + return cg; + } + + public void setCg(String cg) { + this.cg = cg; + } + + public String getCid() { + return cid; + } + + public void setCid(String cid) { + this.cid = cid; + } + + public int getPollingInterval() { + return pollingInterval; + } + + public void setPollingInterval(int pollingInterval) { + this.pollingInterval = pollingInterval; + } + + public int getPollingTimeout() { + return pollingTimeout; + } + + public void setPollingTimeout(int pollingTimeout) { + this.pollingTimeout = pollingTimeout; + } + + public int getMinCollision() { + return minCollision; + } + + public void setMinCollision(int minCollision) { + this.minCollision = minCollision; + } + + public int getMinConfusion() { + return minConfusion; + } + + public void setMinConfusion(int minConfusion) { + this.minConfusion = minConfusion; + } + + public String getSdnrService() { + return sdnrService; + } + + public void setSdnrService(String sdnrService) { + this.sdnrService = sdnrService; + } + + public String getPolicyService() { + return policyService; + } + + public void setPolicyService(String policyService) { + this.policyService = policyService; + } + + public String getOofService() { + return oofService; + } + + public void setOofService(String oofService) { + this.oofService = oofService; + } + + public String getSourceId() { + return sourceId; + } + + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + public String getPolicyName() { + return policyName; + } + + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + public String getConfigName() { + return configName; + } + + public void setConfigName(String configName) { + this.configName = configName; + } + + public String getCallbackUrl() { + return callbackUrl; + } + + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public List getOptimizers() { + return optimizers; + } + + public void setOptimizers(List optimizers) { + this.optimizers = optimizers; + } + + public int getNumSolutions() { + return numSolutions; + } + + public void setNumSolutions(int numSolutions) { + this.numSolutions = numSolutions; + } + + public int getBufferTime() { + return bufferTime; + } + + public void setBufferTime(int bufferTime) { + this.bufferTime = bufferTime; + } + + public List getTopics() { + return topics; + } + + public void setTopics(List topics) { + this.topics = topics; + } + + public String getSdnrTopic() { + return sdnrTopic; + } + + public void setSdnrTopic(String sdnrTopic) { + this.sdnrTopic = sdnrTopic; + } + + public String getPolicyTopic() { + return policyTopic; + } + + public void setPolicyTopic(String policyTopic) { + this.policyTopic = policyTopic; + } + + @Override + public String toString() { + return "Configuration [topics=" + topics + ", sdnrTopic=" + sdnrTopic + ", policyTopic=" + policyTopic + + ", servers=" + servers + ", managerApiKey=" + managerApiKey + ", managerSecretKey=" + managerSecretKey + + ", pcimsApiKey=" + pcimsApiKey + ", pcimsSecretKey=" + pcimsSecretKey + ", cg=" + cg + ", cid=" + cid + + ", pollingInterval=" + pollingInterval + ", pollingTimeout=" + pollingTimeout + ", minCollision=" + + minCollision + ", minConfusion=" + minConfusion + ", sdnrService=" + sdnrService + ", policyService=" + + policyService + ", oofService=" + oofService + ", sourceId=" + sourceId + ", policyName=" + policyName + + ", configName=" + configName + ", callbackUrl=" + callbackUrl + ", optimizers=" + optimizers + + ", numSolutions=" + numSolutions + ", bufferTime=" + bufferTime + ", maximumClusters=" + + maximumClusters + "]"; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/ConfigurationFetcher.java b/src/main/java/org/onap/dcaegen2/services/sonhms/ConfigurationFetcher.java new file mode 100644 index 0000000..4a55393 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/ConfigurationFetcher.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * ============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; + +import org.onap.dcaegen2.services.sonhms.utils.SonHandlerRestTemplate; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.json.JSONTokener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.ResponseEntity; + + +public class ConfigurationFetcher { + private static Logger log = LoggerFactory.getLogger(ConfigurationFetcher.class); + + /** + * method that fetches config from config binding service. + */ + public void fetchFromCbs() { + + Configuration configuration = Configuration.getInstance(); + String consulHost = configuration.getConsulHost(); + String configBindingService = configuration.getConfigBindingService(); + ResponseEntity response = null; + String requestUrl = ""; + if ((consulHost != null) && (configBindingService != null)) { + requestUrl = consulHost + ":8500/v1/catalog/service/" + configBindingService; + response = SonHandlerRestTemplate.sendPostRequest(requestUrl, "", + new ParameterizedTypeReference() {}); + } + JSONTokener jsonTokener = new JSONTokener(response.getBody()); + JSONObject cbsjobj = (JSONObject) new JSONArray(jsonTokener).get(0); + String cbsUrl = ""; + String configurationRequestUrl = ""; + ResponseEntity configurationResponse = null; + if (cbsjobj.has("ServiceAddress") && cbsjobj.has("ServicePort")) { + cbsUrl = cbsjobj.getString("ServiceAddress") + ":" + cbsjobj.getInt("ServicePort"); + + } + + configurationRequestUrl = cbsUrl + "/service_component/" + configuration.getHostName(); + configurationResponse = SonHandlerRestTemplate.sendPostRequest1(configurationRequestUrl, "", + new ParameterizedTypeReference() {}); + JSONObject config = new JSONObject(new JSONTokener(configurationResponse.getBody())); + String configString = config.toString(); + log.debug("config:{}",configString); + } + + +} \ No newline at end of file diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java new file mode 100644 index 0000000..f28de63 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * ============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; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.dcaegen2.services.sonhms.dao.DmaapNotificationsRepository; +import org.onap.dcaegen2.services.sonhms.model.Notification; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; +import fj.data.Either; + +import java.io.IOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DmaapNotificationsComponent { + + private static Logger log = LoggerFactory.getLogger(DmaapNotificationsComponent.class); + + /** + * Get dmaap notifications. + */ + public Either getDmaapNotifications() { + DmaapNotificationsRepository dmaapNotificationsRepository = BeanUtil + .getBean(DmaapNotificationsRepository.class); + String notificationString = dmaapNotificationsRepository.getNotificationFromQueue(); + ObjectMapper mapper = new ObjectMapper(); + + Notification notification = new Notification(); + try { + notification = mapper.readValue(notificationString, Notification.class); + return Either.left(notification); + } catch (IOException e) { + log.error("Exception in parsing notification", notificationString, e); + return Either.right(400); + } + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java b/src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java new file mode 100644 index 0000000..312ca60 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java @@ -0,0 +1,252 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.dcaegen2.services.sonhms.child.ChildThread; +import org.onap.dcaegen2.services.sonhms.child.Graph; +import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails; +import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException; +import org.onap.dcaegen2.services.sonhms.model.FapServiceList; +import org.onap.dcaegen2.services.sonhms.model.Notification; +import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils; +import org.onap.dcaegen2.services.sonhms.utils.ThreadUtils; + +import fj.data.Either; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.ExecutorService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class EventHandler { + + private static Logger log = LoggerFactory.getLogger(EventHandler.class); + + private static Map childThreadMap = new HashMap<>(); + + private BlockingQueue> childStatusQueue; + + private Map childStatus; + + private ExecutorService pool; + + private ClusterUtils clusterUtils; + + private ThreadUtils threadUtils; + + /** + * Constructor. + */ + public EventHandler(BlockingQueue> childStatusQueue, ExecutorService pool, + Map childStatus, ClusterUtils clusterUtils, ThreadUtils threadUtils) { + + this.childStatusQueue = childStatusQueue; + this.childStatus = childStatus; + this.pool = pool; + this.clusterUtils = clusterUtils; + this.threadUtils = threadUtils; + } + + /** + * handle sdnr notification. + */ + public Boolean handleSdnrNotification(Notification notification) { + // Check if notification matches with a cluster + + try { + List clusterDetails = clusterUtils.getAllClusters(); + + NotificationToClusterMapping mapping = new NotificationToClusterMapping(); + mapping = clusterUtils.getClustersForNotification(notification, clusterDetails); + + // Matching cells + System.out.println(mapping); + if (mapping.getCellsinCluster() != null) { + handleMatchingCells(mapping.getCellsinCluster(), clusterDetails); + } + + // unmatched cells + if (mapping.getNewCells() != null) { + handleUnMatchingCells(mapping.getNewCells()); + } + } catch (Exception e) { + log.error("Exception in sdnr notification handling {}", e); + return false; + } + + return true; + + } + + private void handleUnMatchingCells(List newCells) { + List newClusters = new ArrayList<>(); + + for (FapServiceList fapService : newCells) { + + Either existingCluster = clusterUtils.getClusterForCell(fapService, newClusters); + if (existingCluster.isRight()) { + try { + Graph cluster = clusterUtils.createCluster(fapService); + newClusters.add(cluster); + } catch (ConfigDbNotFoundException e) { + log.error("Error connecting with configDB {}", e); + } + } + + else { + Graph cluster = existingCluster.left().value(); + + Graph modifiedCluster = clusterUtils.modifyCluster(cluster, fapService); + newClusters.remove(cluster); + newClusters.add(modifiedCluster); + } + + } + + // create new child thread + + threadUtils.createNewThread(newClusters, childStatusQueue, pool, this); + + } + + private void handleMatchingCells(Map cellsInCluster, List clusterDetails) { + for (Entry entry : cellsInCluster.entrySet()) { + + FapServiceList fapService = entry.getKey(); + String clusterId = entry.getValue(); + Either clusterDetail = clusterUtils.getClusterDetailsFromClusterId(clusterId, + clusterDetails); + + if (clusterDetail.isRight()) { + log.error("Cannot find the cluster for Cluster ID"); + return; + } else { + long threadId = clusterDetail.left().value().getChildThreadId(); + + if (childStatus.get(threadId).equals("triggeredOof")) { + log.info("OOF triggered for the cluster, buffering notification"); + bufferNotification(fapService, clusterId); + } else { + childThreadMap.get(threadId).putInQueue(fapService); + } + } + } + } + + private void bufferNotification(FapServiceList fapService, String clusterId) { + ObjectMapper mapper = new ObjectMapper(); + BufferNotificationComponent bufferNotifComponent = new BufferNotificationComponent(); + String serviceListString = ""; + try { + serviceListString = mapper.writeValueAsString(fapService); + } catch (JsonProcessingException e) { + log.debug("JSON processing exception: {}", e); + } + bufferNotifComponent.bufferNotification(serviceListString, clusterId); + + } + + /** + * handle child status update. + */ + public void handleChildStatusUpdate(List childStatus) { + + // update Child status in data structure + Long childThreadId = Long.parseLong(childStatus.get(0)); + addChildStatus(childThreadId, childStatus.get(1)); + + // if child status is OOF result success, handle buffered notifications + if (childStatus.get(1).equals("success")) { + BufferNotificationComponent bufferNotificationComponent = new BufferNotificationComponent(); + ClusterDetailsComponent clusterDetailsComponent = new ClusterDetailsComponent(); + String clusterId = clusterDetailsComponent.getClusterId(childThreadId); + List bufferedNotifications = bufferNotificationComponent.getBufferedNotification(clusterId); + + if (bufferedNotifications == null || bufferedNotifications.isEmpty()) { + log.info("No buffered notification for this thread"); + + Set setOfThread = Thread.getAllStackTraces().keySet(); + for (Thread thread : setOfThread) { + if (thread.getId() == childThreadId) { + deleteChildStatus(childThreadId); + thread.interrupt(); + } + } + } else { + handleBufferedNotifications(childThreadId, bufferedNotifications); + } + } + // else kill the child thread + + } + + private void handleBufferedNotifications(Long childThreadId, List bufferedNotifications) { + + ObjectMapper mapper = new ObjectMapper(); + for (String notification : bufferedNotifications) { + FapServiceList fapServiceList; + try { + fapServiceList = mapper.readValue(notification, FapServiceList.class); + log.debug("fapServiceList{}", fapServiceList); + + childThreadMap.get(childThreadId).putInQueueWithNotify(fapServiceList); + + } catch (IOException e) { + log.error("Error parsing the buffered notification, skipping {}", e); + } + } + } + + public static void addChildThreadMap(Long childThreadId, ChildThread child) { + childThreadMap.put(childThreadId, child); + } + + public static Map getChildThreadMap() { + return childThreadMap; + } + + public void addChildStatus(Long threadId, String status) { + this.childStatus.put(threadId, status); + } + + public String getChildStatus(Long threadId) { + return childStatus.get(threadId); + + } + + public void deleteChildStatus(Long childThreadId) { + this.childStatus.remove(childThreadId); + + } + + public ExecutorService getPool() { + return pool; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java new file mode 100644 index 0000000..2026500 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * ============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; + +import org.onap.dcaegen2.services.sonhms.model.Notification; +import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils; +import org.onap.dcaegen2.services.sonhms.utils.ThreadUtils; + +import fj.data.Either; + +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.Executors; +import java.util.concurrent.LinkedBlockingQueue; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class MainThread implements Runnable { + private static Logger log = LoggerFactory.getLogger(MainThread.class); + + private NewNotification newNotification; + + private BlockingQueue> childStatusQueue; + + private DmaapNotificationsComponent dmaapNotificationsComponent; + + private EventHandler eventHandler; + + /** + * parameterized constructor. + */ + public MainThread(NewNotification newNotification) { + super(); + this.newNotification = newNotification; + childStatusQueue = new LinkedBlockingQueue<>(); + dmaapNotificationsComponent = new DmaapNotificationsComponent(); + eventHandler = new EventHandler(childStatusQueue, + Executors.newFixedThreadPool(Configuration.getInstance().getMaximumClusters()), + new HashMap<>(), new ClusterUtils(), new ThreadUtils()); + } + + @Override + public void run() { + log.info("Starting Main Thread"); + + // Check for Notifications from Dmaap and Child thread + Boolean done = false; + + while (!done) { + try { + if (!childStatusQueue.isEmpty()) { + List childState = childStatusQueue.poll(); + if (childState != null) { + eventHandler.handleChildStatusUpdate(childState); + } + } + + if (newNotification.getNewNotif()) { + Either notification = dmaapNotificationsComponent.getDmaapNotifications(); + if (notification.isRight()) { + log.error("Error parsing the notification from SDNR"); + } else if (notification.isLeft()) { + Boolean result = eventHandler.handleSdnrNotification(notification.left().value()); + log.debug("SDNR notification handling {}", result); + } + + } + + } catch (Exception e) { + log.error("Exception in main Thread", e); + done = true; + } + + } + + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java new file mode 100644 index 0000000..f83541a --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThreadComponent.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * ============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; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +@Component +public class MainThreadComponent { + + private static Logger log = LoggerFactory.getLogger(MainThreadComponent.class); + + + + /** + * main thread initialization. + */ + public void init(NewNotification newNotification) { + log.debug("initializing main thread"); + Thread thread = new Thread(new MainThread(newNotification)); + thread.start(); + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/NewNotification.java b/src/main/java/org/onap/dcaegen2/services/sonhms/NewNotification.java new file mode 100644 index 0000000..9f6e57f --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/NewNotification.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * ============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; + +public class NewNotification { + + private Boolean newNotif; + + public Boolean getNewNotif() { + return newNotif; + } + + public void setNewNotif(Boolean newNotif) { + this.newNotif = newNotif; + } + + public NewNotification(Boolean newNotif) { + super(); + this.newNotif = newNotif; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/NotificationToClusterMapping.java b/src/main/java/org/onap/dcaegen2/services/sonhms/NotificationToClusterMapping.java new file mode 100644 index 0000000..14961e5 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/NotificationToClusterMapping.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * ============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; + +import org.onap.dcaegen2.services.sonhms.model.FapServiceList; + +import java.util.List; +import java.util.Map; + + +public class NotificationToClusterMapping { + + private Map cellsinCluster; + + private List newCells; + + public Map getCellsinCluster() { + return cellsinCluster; + } + + public void setCellsinCluster(Map cellsinCluster) { + this.cellsinCluster = cellsinCluster; + } + + public List getNewCells() { + return newCells; + } + + public void setNewCells(List newCells) { + this.newCells = newCells; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((cellsinCluster == null) ? 0 : cellsinCluster.hashCode()); + result = prime * result + ((newCells == null) ? 0 : newCells.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + NotificationToClusterMapping other = (NotificationToClusterMapping) obj; + if (cellsinCluster == null) { + if (other.cellsinCluster != null) { + return false; + } + } else if (!cellsinCluster.equals(other.cellsinCluster)) { + return false; + } + if (newCells == null) { + if (other.newCells != null) { + return false; + } + } else if (!newCells.equals(other.newCells)) { + return false; + } + return true; + } + + + + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/SonController.java b/src/main/java/org/onap/dcaegen2/services/sonhms/SonController.java new file mode 100644 index 0000000..15aa907 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/SonController.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * ============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; + +import org.onap.dcaegen2.services.sonhms.child.ChildThread; +import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody; + +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +public class SonController { + private static final Logger log = org.slf4j.LoggerFactory.getLogger(SonController.class); + + @Autowired + SonRequestsComponent pciRequestsComponent; + + @RequestMapping(value = "/callbackUrl", method = RequestMethod.POST) + String callBackUrl(@RequestBody AsyncResponseBody callback) { + log.debug("received request to callback url"); + String async = callback.toString(); + log.debug("AsyncResponseBody{}", async); + + String transactionId = callback.getTransactionId(); + log.debug("transaction id {}", transactionId); + + long childThreadId = pciRequestsComponent.getChildThread(transactionId); + log.debug("childThreadId {}", childThreadId); + + ChildThread.putResponse(childThreadId, callback); + return "Forwarded to child thread"; + + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/SonRequestsComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/SonRequestsComponent.java new file mode 100644 index 0000000..51607fa --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/SonRequestsComponent.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * ============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; + +import org.onap.dcaegen2.services.sonhms.dao.SonRequestsRepository; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +@Component +public class SonRequestsComponent { + + @Autowired + private SonRequestsRepository sonRequestsRepository; + + public long getChildThread(String transactionId) { + return sonRequestsRepository.getChildThreadMapping(transactionId); + } + +} + diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Topic.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Topic.java new file mode 100644 index 0000000..616d389 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Topic.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * ============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; + +public class Topic { + + private String name; + private String producer; + private String consumer; + + public Topic() { + + } + + /** + * Parameterized constructor. + */ + public Topic(String name, String producer, String consumer) { + super(); + this.name = name; + this.producer = producer; + this.consumer = consumer; + } + + @Override + public String toString() { + return "topic [name=" + name + ", producer=" + producer + ", consumer=" + consumer + "]"; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getProducer() { + return producer; + } + + public void setProducer(String producer) { + this.producer = producer; + } + + public String getConsumer() { + return consumer; + } + + public void setConsumer(String consumer) { + this.consumer = consumer; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java new file mode 100644 index 0000000..eff7a84 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java @@ -0,0 +1,245 @@ +/******************************************************************************* + * ============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.child; + +import org.onap.dcaegen2.services.sonhms.Configuration; +import org.onap.dcaegen2.services.sonhms.dao.ClusterDetailsRepository; +import org.onap.dcaegen2.services.sonhms.model.FapServiceList; +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 java.sql.Timestamp; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; +import org.slf4j.Logger; +import org.slf4j.MDC; + + +public class ChildThread implements Runnable { + + private BlockingQueue> childStatusUpdate; + private BlockingQueue queue = new LinkedBlockingQueue<>(); + + private static Map responseMap = new HashMap<>(); + private Graph cluster; + private ThreadId threadId; + FapServiceList fapServiceList = new FapServiceList(); + private static final Logger log = org.slf4j.LoggerFactory.getLogger(ChildThread.class); + + /** + * Constructor with parameters. + */ + public ChildThread(BlockingQueue> childStatusUpdate, Graph cluster, + BlockingQueue queue, ThreadId threadId) { + super(); + this.childStatusUpdate = childStatusUpdate; + this.queue = queue; + this.threadId = threadId; + this.cluster = cluster; + } + + /** + * Puts notification in queue. + */ + public void putInQueue(FapServiceList fapserviceList) { + try { + queue.put(fapserviceList); + } catch (InterruptedException e) { + log.error(" The Thread is Interrupted", e); + Thread.currentThread().interrupt(); + } + } + + /** + * Puts notification in queue with notify. + */ + public void putInQueueWithNotify(FapServiceList fapserviceList) { + synchronized (queue) { + try { + queue.put(fapserviceList); + queue.notifyAll(); + } catch (InterruptedException e) { + log.error(" The Thread is Interrupted", e); + Thread.currentThread().interrupt(); + } + + } + + } + + /** + * Puts response in queue. + */ + public static void putResponse(Long threadId, AsyncResponseBody obj) { + synchronized (responseMap) { + responseMap.put(threadId, obj); + } + + } + + public static Map getResponseMap() { + return responseMap; + } + + @Override + public void run() { + + threadId.setChildThreadId(Thread.currentThread().getId()); + synchronized (threadId) { + threadId.notifyAll(); + } + + MDC.put("logFileName", Thread.currentThread().getName()); + log.debug("Starting child thread"); + + try { + fapServiceList = queue.take(); + if (log.isDebugEnabled()) { + log.debug("fapServicelist: {}", fapServiceList); + } + } catch (InterruptedException e1) { + log.error("InterruptedException is {}", e1); + Thread.currentThread().interrupt(); + } + + ClusterFormation clusterFormation = new ClusterFormation(queue); + StateOof oof = new StateOof(childStatusUpdate); + ClusterUtils clusterUtils = new ClusterUtils(); + Detection detect = new Detection(); + + try { + String networkId = fapServiceList.getCellConfig().getLte().getRan().getNeighborListInUse() + .getLteNeighborListInUseLteCell().get(0).getPlmnid(); + + Boolean done = false; + + while (!done) { + + Map> collisionConfusionResult = detect.detectCollisionConfusion(cluster); + Boolean trigger = clusterFormation.triggerOrWait(collisionConfusionResult); + + if (!trigger) { + collisionConfusionResult = clusterFormation.waitForNotification(collisionConfusionResult, cluster); + } + oof.triggerOof(collisionConfusionResult, networkId); + + if (isNotificationsBuffered()) { + List fapServiceLists = bufferNotification(); + for (FapServiceList fapService : fapServiceLists) { + cluster = clusterUtils.modifyCluster(cluster, fapService); + } + String cellPciNeighbourString = cluster.getPciNeighbourJson(); + UUID clusterId = cluster.getGraphId(); + ClusterDetailsRepository clusterDetailsRepository = BeanUtil + .getBean(ClusterDetailsRepository.class); + clusterDetailsRepository.updateCluster(cellPciNeighbourString, clusterId.toString()); + + } else { + done = true; + } + + } + + } catch (Exception e) { + log.error("{}", e); + } + + cleanup(); + } + + private boolean isNotificationsBuffered() { + synchronized (queue) { + + try { + while (queue.isEmpty()) { + queue.wait(); + } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + return false; + } + } + return true; + } + + /** + * cleanup resources. + */ + private void cleanup() { + log.debug("cleaning up database and killing child thread"); + ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class); + clusterDetailsRepository.deleteByChildThreadId(threadId.getChildThreadId()); + log.debug("Child thread :{} {}", Thread.currentThread().getId(), "completed"); + MDC.remove("logFileName"); + + } + + /** + * Buffer Notification. + */ + public List bufferNotification() { + + // Processing Buffered notifications + + List fapServiceLists = new ArrayList<>(); + + Configuration config = Configuration.getInstance(); + + int bufferTime = config.getBufferTime(); + + Timestamp currentTime = new Timestamp(System.currentTimeMillis()); + log.debug("Current time {}", currentTime); + + Timestamp laterTime = new Timestamp(System.currentTimeMillis()); + log.debug("Later time {}", laterTime); + + long difference = laterTime.getTime() - currentTime.getTime(); + while (difference < bufferTime) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + log.error("InterruptedException {}", e); + Thread.currentThread().interrupt(); + + } + laterTime = new Timestamp(System.currentTimeMillis()); + difference = laterTime.getTime() - currentTime.getTime(); + + log.debug("Timer has run for seconds {}", difference); + + if (!queue.isEmpty()) { + FapServiceList fapService; + fapService = queue.poll(); + fapServiceLists.add(fapService); + } + } + return fapServiceLists; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java new file mode 100644 index 0000000..d7ff57a --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * ============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.child; + +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.dcaegen2.services.sonhms.ConfigPolicy; +import org.onap.dcaegen2.services.sonhms.model.CellConfig; +import org.onap.dcaegen2.services.sonhms.model.CellPciPair; +import org.onap.dcaegen2.services.sonhms.model.Common; +import org.onap.dcaegen2.services.sonhms.model.Configurations; +import org.onap.dcaegen2.services.sonhms.model.Data; +import org.onap.dcaegen2.services.sonhms.model.FapService; +import org.onap.dcaegen2.services.sonhms.model.Lte; +import org.onap.dcaegen2.services.sonhms.model.Payload; +import org.onap.dcaegen2.services.sonhms.model.PolicyNotification; +import org.onap.dcaegen2.services.sonhms.model.Ran; +import org.onap.dcaegen2.services.sonhms.model.X0005b9Lte; +import java.util.ArrayList; +import java.util.List; +import org.slf4j.Logger; + +public class ChildThreadUtils { + + private static final Logger log = org.slf4j.LoggerFactory.getLogger(ChildThreadUtils.class); + ConfigPolicy configPolicy; + + public ChildThreadUtils(ConfigPolicy configPolicy) { + this.configPolicy = configPolicy; + } + + + /** + * get policy notification string from oof result. + * + */ + public String getNotificationString(String pnfName, List cellPciPairs, String requestId, + Long alarmStartTime) { + ArrayList configurations = new ArrayList<>(); + for (CellPciPair cellPciPair : cellPciPairs) { + 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))))))); + configurations.add(configuration); + } + + Payload payload = new Payload(configurations); + ObjectMapper mapper = new ObjectMapper(); + String payloadString = ""; + try { + payloadString = mapper.writeValueAsString(payload); + } catch (JsonProcessingException e) { + log.debug("JSON processing exception: {}", e); + } + + String closedLoopControlName = (String) configPolicy.getConfig().get("PCI_MODCONFIG_POLICY_NAME"); + PolicyNotification policyNotification = new PolicyNotification(closedLoopControlName, + requestId, alarmStartTime, pnfName); + + policyNotification.setClosedLoopControlName(closedLoopControlName); + policyNotification.setPayload(payloadString); + + mapper.setSerializationInclusion(Include.NON_NULL); + String notification = ""; + try { + notification = mapper.writeValueAsString(policyNotification); + } catch (JsonProcessingException e1) { + log.debug("JSON processing exception: {}", e1); + } + return notification; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ClusterFormation.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ClusterFormation.java new file mode 100644 index 0000000..9a594a1 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ClusterFormation.java @@ -0,0 +1,146 @@ +/******************************************************************************* + * ============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.child; + +import org.onap.dcaegen2.services.sonhms.ConfigPolicy; +import org.onap.dcaegen2.services.sonhms.Configuration; +import org.onap.dcaegen2.services.sonhms.dao.ClusterDetailsRepository; +import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails; +import org.onap.dcaegen2.services.sonhms.model.FapServiceList; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; +import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils; + +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; +import java.util.concurrent.BlockingQueue; + +import org.slf4j.Logger; + + +public class ClusterFormation { + + private static final Logger log = org.slf4j.LoggerFactory.getLogger(ClusterFormation.class); + private BlockingQueue queue; + private ClusterUtils clusterUtils; + private Detection detect; + Properties confProp; + ClusterDetails details = new ClusterDetails(); + + public ClusterFormation() { + this.detect = new Detection(); + } + + /** + * parameterized constructor. + * + */ + public ClusterFormation(BlockingQueue queue) { + super(); + this.queue = queue; + this.detect = new Detection(); + this.clusterUtils = new ClusterUtils(); + } + + /** + * Determines whether to trigger Oof or wait for notifications. + */ + public Boolean triggerOrWait(Map> collisionConfusionResult) { + // determine collision or confusion + + Configuration configuration = Configuration.getInstance(); + int collisionSum = 0; + int confusionSum = 0; + + for (Map.Entry> entry : collisionConfusionResult.entrySet()) { + + ArrayList arr; + arr = entry.getValue(); + // check for 0 collision and confusion + if (!arr.isEmpty()) { + collisionSum = collisionSum + arr.get(0); + confusionSum = confusionSum + arr.get(1); + } + } + return ((collisionSum >= configuration.getMinCollision()) && (confusionSum >= configuration.getMinConfusion())); + + } + + /** + * Waits for notifications. + */ + public Map> waitForNotification(Map> collisionConfusionResult, + Graph cluster) { + + FapServiceList newNotification; + ConfigPolicy config = ConfigPolicy.getInstance(); + int timer = 60; + try { + timer = (int) config.getConfig().get("PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS"); + } catch (NullPointerException e) { + log.debug("Policy config not available. Using default timeout - 60 seconds"); + } + + Timestamp currentTime = new Timestamp(System.currentTimeMillis()); + log.debug("Current Time {}", currentTime); + + Timestamp laterTime = new Timestamp(System.currentTimeMillis()); + log.debug("LaterTime {}", laterTime); + + long difference = laterTime.getTime() - currentTime.getTime(); + + int flag = 0; + + while (difference < (timer * 1000)) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + log.error("Interrupted Exception is {}", e); + Thread.currentThread().interrupt(); + } + + laterTime = new Timestamp(System.currentTimeMillis()); + difference = laterTime.getTime() - currentTime.getTime(); + + if ((difference < (timer * 1000)) && (!queue.isEmpty())) { + newNotification = queue.poll(); + cluster = clusterUtils.modifyCluster(cluster, newNotification); + + // update cluster in DB + String cellPciNeighbourString = cluster.getPciNeighbourJson(); + UUID clusterId = cluster.getGraphId(); + ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class); + clusterDetailsRepository.updateCluster(cellPciNeighbourString, clusterId.toString()); + flag++; + + } + } + if (flag != 0) { + return detect.detectCollisionConfusion(cluster); + + } + return collisionConfusionResult; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/Detection.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/Detection.java new file mode 100644 index 0000000..847e2d5 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/Detection.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * ============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.child; + +import org.onap.dcaegen2.services.sonhms.model.CellPciPair; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import org.slf4j.Logger; + + +public class Detection { + + private static final Logger log = org.slf4j.LoggerFactory.getLogger(Detection.class); + + /** + * Returns a map with key as cellid and its value is a list of its collision and + * confusion. + */ + + public Map> detectCollisionConfusion(Graph cluster) { + + Map> clusterMap = cluster.getCellPciNeighbourMap(); + HashMap> hash = new HashMap<>(); + + for (Map.Entry> entry : clusterMap.entrySet()) { + int collisionCount = 0; + int confusionCount = 0; + CellPciPair val = entry.getKey(); + String cellId = val.getCellId(); + int pci = val.getPhysicalCellId(); + ArrayList arr; + // getting colision and confusion count + ArrayList counts = new ArrayList<>(); + // gets the value for the key + arr = entry.getValue(); + if (!arr.isEmpty()) { + for (int i = 0; i < arr.size(); i++) { + if (pci == arr.get(i).getPhysicalCellId()) { + collisionCount++; + } + + } + counts.add(collisionCount); + + for (int j = 0; j < arr.size(); j++) { + for (int k = j + 1; k < arr.size(); k++) { + if (arr.get(j).getPhysicalCellId() == arr.get(k).getPhysicalCellId()) { + confusionCount++; + + } + } + + } + counts.add(confusionCount); + log.debug("count {}", counts); + + } + hash.put(cellId, counts); + + } + log.debug("collison and confusion map {}", hash); + + return hash; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/Graph.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/Graph.java new file mode 100644 index 0000000..eedbd94 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/Graph.java @@ -0,0 +1,242 @@ +/******************************************************************************* + * ============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.child; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.dcaegen2.services.sonhms.model.CellNeighbourList; +import org.onap.dcaegen2.services.sonhms.model.CellPciPair; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.UUID; + +import java.util.concurrent.ConcurrentHashMap; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.slf4j.Logger; + +public class Graph { + private static final Logger log = org.slf4j.LoggerFactory.getLogger(Graph.class); + + // symbol table: key = string vertex, value = set of neighboring vertices + private Map> cellPciNeighbourMap; + private UUID graphId; + + /** + * Parameterized constructor. + */ + public Graph(String clusterInfo) { + JSONArray cells = new JSONArray(clusterInfo); + + Map> cellMap = new HashMap<>(); + for (int i = 0; i < cells.length(); i++) { + JSONObject cell = (JSONObject) cells.get(i); + CellPciPair cellPciPair = new CellPciPair(cell.getString("cellId"), cell.getInt("physicalCellId")); + ObjectMapper mapper = new ObjectMapper(); + ArrayList neighbours = new ArrayList<>(); + try { + neighbours = mapper.readValue(cell.getString("neighbours"), + new TypeReference>() { }); + } catch (JSONException | IOException e) { + log.debug("Error parsing json: {}", e); + } + cellMap.put(cellPciPair, neighbours); + + } + + this.cellPciNeighbourMap = cellMap; + } + + public UUID getGraphId() { + return graphId; + } + + public void setGraphId(UUID graphId) { + this.graphId = graphId; + } + + public Map> getCellPciNeighbourMap() { + return cellPciNeighbourMap; + } + + public void setCellPciNeighbourMap(Map> cellPciNeighbourMap) { + this.cellPciNeighbourMap = cellPciNeighbourMap; + } + + /** + * Initializes an empty graph with no vertices or edges. + */ + public Graph() { + this.cellPciNeighbourMap = new ConcurrentHashMap<>(); + } + + // throw an exception if v is not a vertex + private void validateVertex(CellPciPair start) { + if (!hasVertex(start)) { + throw new IllegalArgumentException(start + " is not a vertex"); + } + } + + /** + * Adds the edge v-w to this graph (if it is not already an edge). + */ + public void addEdge(CellPciPair start, CellPciPair end) { + if (!hasVertex(start)) { + addVertex(start); + } + if (!hasVertex(end)) { + addVertex(end); + } + if (!hasEdge(start, end)) { + this.cellPciNeighbourMap.get(start).add(end); + } + } + + /** + * Adds vertex v to this graph (if it is not already a vertex). + */ + public void addVertex(CellPciPair start) { + if (!hasVertex(start)) { + this.cellPciNeighbourMap.put(start, new ArrayList()); + } + } + + /** + * Returns true if v is a vertex in this graph. + */ + public boolean hasVertex(CellPciPair start) { + return this.cellPciNeighbourMap.containsKey(start); + } + + /** + * Returns true if v-w is an edge in this graph. + */ + public boolean hasEdge(CellPciPair start, CellPciPair end) { + validateVertex(start); + validateVertex(end); + return this.cellPciNeighbourMap.get(start).contains(end); + } + + /** + * Updates Vertex. + */ + public void updateVertex(CellPciPair oldPair, CellPciPair newPair) { + int oldPci = oldPair.getPhysicalCellId(); + int newPci = newPair.getPhysicalCellId(); + + if (oldPci != newPci) { + + this.cellPciNeighbourMap.put(newPair, this.cellPciNeighbourMap.get(oldPair)); + this.cellPciNeighbourMap.remove(oldPair); + + } + for (Map.Entry> entry : this.cellPciNeighbourMap.entrySet()) { + + ArrayList al = entry.getValue(); + for (int i = 0; i < al.size(); i++) { + int pci = al.get(i).getPhysicalCellId(); + if ((pci != newPci) && al.contains(oldPair)) { + al.remove(oldPair); + al.add(newPair); + } + } + } + log.debug("Final Map {}", cellPciNeighbourMap); + + } + + @Override + public String toString() { + return "Graph [cellPciNeighbourMap=" + cellPciNeighbourMap + ", graphId=" + graphId + "]"; + } + + /** + * Convert Graph into a json. + */ + public String getPciNeighbourJson() { + + List cells = new ArrayList<>(); + + for (Entry> entry : cellPciNeighbourMap.entrySet()) { + CellPciPair key = entry.getKey(); + JSONArray neighbours = new JSONArray(cellPciNeighbourMap.get(key)); + CellNeighbourList cell = new CellNeighbourList(key.getCellId(), key.getPhysicalCellId(), + neighbours.toString()); + cells.add(cell); + } + ObjectMapper mapper = new ObjectMapper(); + String pciNeighbourJson = ""; + try { + pciNeighbourJson = mapper.writeValueAsString(cells); + } catch (JsonProcessingException e) { + log.debug("Error while processing json: {}", e); + } + return pciNeighbourJson; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((cellPciNeighbourMap == null) ? 0 : cellPciNeighbourMap.hashCode()); + result = prime * result + ((graphId == null) ? 0 : graphId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Graph other = (Graph) obj; + if (cellPciNeighbourMap == null) { + if (other.cellPciNeighbourMap != null) { + return false; + } + } else if (!cellPciNeighbourMap.equals(other.cellPciNeighbourMap)) { + return false; + } + if (graphId == null) { + if (other.graphId != null) { + return false; + } + } else if (!graphId.equals(other.graphId)) { + return false; + } + return true; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java new file mode 100644 index 0000000..560fd52 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * ============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.child; + +import org.onap.dcaegen2.services.sonhms.dao.CellInfoRepository; +import org.onap.dcaegen2.services.sonhms.entity.CellInfo; +import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException; +import org.onap.dcaegen2.services.sonhms.model.CellPciPair; +import org.onap.dcaegen2.services.sonhms.restclient.SdnrRestClient; +import org.onap.dcaegen2.services.sonhms.restclient.Solution; +import org.onap.dcaegen2.services.sonhms.restclient.SonSolution; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + + + +public class PnfUtils { + + /** + * get pnfs. + * + */ + public Map> getPnfs(List solutions) throws ConfigDbNotFoundException { + + Map> pnfs = new HashMap<>(); + + for (Solution solution : solutions) { + List pciSolutions = solution.getPciSolutions(); + for (SonSolution pciSolution : pciSolutions) { + String cellId = pciSolution.getCellId(); + int pci = pciSolution.getPci(); + + String pnfName = ""; + CellInfoRepository cellInfoRepository = BeanUtil.getBean(CellInfoRepository.class); + Optional 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 cellPciPairs = new ArrayList<>(); + cellPciPairs.add(new CellPciPair(cellId, pci)); + pnfs.put(pnfName, cellPciPairs); + } + } + + } + return pnfs; + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java new file mode 100644 index 0000000..d731725 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java @@ -0,0 +1,193 @@ +/******************************************************************************* + * ============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.child; + +import org.onap.dcaegen2.services.sonhms.ConfigPolicy; +import org.onap.dcaegen2.services.sonhms.Configuration; +import org.onap.dcaegen2.services.sonhms.dao.SonRequestsRepository; +import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient; +import org.onap.dcaegen2.services.sonhms.entity.PciRequests; +import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException; +import org.onap.dcaegen2.services.sonhms.exceptions.OofNotFoundException; +import org.onap.dcaegen2.services.sonhms.model.CellPciPair; +import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody; +import org.onap.dcaegen2.services.sonhms.restclient.OofRestClient; +import org.onap.dcaegen2.services.sonhms.restclient.Solution; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.BlockingQueue; + +import org.slf4j.Logger; + +public class StateOof { + private static final Logger log = org.slf4j.LoggerFactory.getLogger(StateOof.class); + private BlockingQueue> childStatusUpdate; + + public StateOof() { + + } + + /** + * Parameterized Constructor. + * + */ + public StateOof(BlockingQueue> childStatusUpdate) { + super(); + this.childStatusUpdate = childStatusUpdate; + } + + /** + * Triggers OOF. + * @throws OofNotFoundException when trigger oof fails + */ + public void triggerOof(Map> result, + String networkId) throws OofNotFoundException, InterruptedException { + // check for 0 collision and 0 confusion + ArrayList cellidList = new ArrayList<>(); + ArrayList cellIds = new ArrayList<>(); + + for (Map.Entry> entry : result.entrySet()) { + String key = entry.getKey(); + ArrayList arr; + arr = entry.getValue(); + if (!arr.isEmpty()) { + Set set = new HashSet<>(arr); + if (((set.size() == 1) && !set.contains(0)) || (set.size() != 1)) { + cellIds.add(key); + + } + } + + } + + for (String cell : cellIds) { + log.debug("cellidList entries: {}", cell); + cellidList.add(cell); + } + log.debug("the cells triggering the oof are {}", cellidList); + + UUID transactionId = UUID.randomUUID(); + + Configuration config = Configuration.getInstance(); + int numSolutions = config.getNumSolutions(); + List optimizers = config.getOptimizers(); + + String oofResponse = OofRestClient.queryOof(numSolutions, transactionId.toString(), "create", cellidList, + networkId, optimizers); + log.debug("Synchronous Response {}", oofResponse); + + List childStatus = new ArrayList<>(); + childStatus.add(Long.toString(Thread.currentThread().getId())); + childStatus.add("triggeredOof"); + try { + childStatusUpdate.put(childStatus); + } catch (InterruptedException e1) { + log.debug("Interrupted execption {}", e1); + Thread.currentThread().interrupt(); + + } + + // Store Request details in Database + + PciRequests pciRequest = new PciRequests(); + + long childThreadId = Thread.currentThread().getId(); + pciRequest.setTransactionId(transactionId.toString()); + pciRequest.setChildThreadId(childThreadId); + SonRequestsRepository pciRequestsRepository = BeanUtil.getBean(SonRequestsRepository.class); + pciRequestsRepository.save(pciRequest); + + while (!ChildThread.getResponseMap().containsKey(childThreadId)) { + Thread.sleep(100); + } + + AsyncResponseBody asynResponseBody = ChildThread.getResponseMap().get(childThreadId); + + try { + sendToPolicy(asynResponseBody); + } catch (ConfigDbNotFoundException e1) { + log.debug("Config DB is unreachable: {}", e1); + } + + pciRequestsRepository = BeanUtil.getBean(SonRequestsRepository.class); + pciRequestsRepository.deleteByChildThreadId(childThreadId); + + childStatus = new ArrayList<>(); + childStatus.add(Long.toString(Thread.currentThread().getId())); + childStatus.add("success"); + try { + childStatusUpdate.put(childStatus); + } catch (InterruptedException e) { + log.debug("InterruptedException {}", e); + Thread.currentThread().interrupt(); + + } + + } + + /** + * Sends Dmaap notification to Policy. + * + * @throws ConfigDbNotFoundException + * when config db is unreachable + */ + private void sendToPolicy(AsyncResponseBody async) throws ConfigDbNotFoundException { + + if (log.isDebugEnabled()) { + log.debug(async.toString()); + } + + List solutions; + solutions = async.getSolutions(); + + PnfUtils pnfUtils = new PnfUtils(); + Map> pnfs = pnfUtils.getPnfs(solutions); + + for (Map.Entry> entry : pnfs.entrySet()) { + String pnfName = entry.getKey(); + List cellPciPairs = entry.getValue(); + + ChildThreadUtils childThreadUtils = new ChildThreadUtils(ConfigPolicy.getInstance()); + String notification = childThreadUtils.getNotificationString(pnfName, cellPciPairs, + UUID.randomUUID().toString(), System.currentTimeMillis()); + log.debug("Policy Notification: {}", notification); + PolicyDmaapClient policy = new PolicyDmaapClient(); + boolean status = policy.sendNotificationToPolicy(notification); + log.debug("sent Message: {}", status); + if (status) { + log.debug("Message sent to policy"); + } else { + log.debug("Sending notification to policy failed"); + } + + } + } + + + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/controller/HealthCheck.java b/src/main/java/org/onap/dcaegen2/services/sonhms/controller/HealthCheck.java new file mode 100644 index 0000000..d0d9321 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/controller/HealthCheck.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * ============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.controller; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HealthCheck { + @RequestMapping(value = "/healthcheck", method = RequestMethod.GET) + ResponseEntity healthCheck() { + return new ResponseEntity(HttpStatus.OK); + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/BufferedNotificationsRepository.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/BufferedNotificationsRepository.java new file mode 100644 index 0000000..43bb1f3 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/BufferedNotificationsRepository.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * ============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.dao; + +import org.onap.dcaegen2.services.sonhms.entity.BufferedNotifications; + +import java.util.List; + +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + + +@Repository +public interface BufferedNotificationsRepository extends CrudRepository { + + @Query(nativeQuery = true, value = "SELECT cluster_id FROM buffered_notifications WHERE notification=?1") + public String getClusterIdForNotification(String notification); + + @Query(nativeQuery = true, + value = "DELETE FROM buffered_notifications " + "WHERE notification = ( SELECT notification " + + "FROM buffered_notifications WHERE cluster_id=?1) RETURNING notification;") + public List getNotificationsFromQueue(String clusterId); + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/CellInfoRepository.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/CellInfoRepository.java new file mode 100644 index 0000000..80066ad --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/CellInfoRepository.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * ============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.dao; + +import org.onap.dcaegen2.services.sonhms.entity.CellInfo; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + + +@Repository +public interface CellInfoRepository extends CrudRepository { + + // public void + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/ClusterDetailsRepository.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/ClusterDetailsRepository.java new file mode 100644 index 0000000..babef00 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/ClusterDetailsRepository.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * ============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.dao; + +import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails; + +import java.util.List; + +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 ClusterDetailsRepository extends CrudRepository { + + @Modifying + @Query(nativeQuery = true, value = "UPDATE CLUSTER_DETAILS SET cluster_info=?1 WHERE cluster_id = ?2") + public void updateCluster(String clusterInfo, String clusterId); + + @Query(nativeQuery = true, value = "SELECT * FROM cluster_details") + public List getAllClusterDetails(); + + @Query(nativeQuery = true, value = "SELECT child_thread_id FROM cluster_details WHERE cluster_id = ?1") + public long getChildThreadForCluster(String clusterId); + + @Query(nativeQuery = true, value = "SELECT cluster_id FROM cluster_details WHERE child_thread_id = ?1") + public String getClusterIdForChildThread(long childThreadId); + + @Modifying + @Query(nativeQuery = true, value = "DELETE FROM cluster_details WHERE child_thread_id = ?1") + public void deleteByChildThreadId(Long threadId); + + @Modifying + @Query(nativeQuery = true, value = "UPDATE cluster_details SET child_thread_id = ?2 WHERE cluster_id = ?1") + public void updateThreadId(String clusterId, Long threadId); + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/DmaapNotificationsRepository.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/DmaapNotificationsRepository.java new file mode 100644 index 0000000..356dca6 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/DmaapNotificationsRepository.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * ============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.dao; + +import org.onap.dcaegen2.services.sonhms.entity.DmaapNotifications; + +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + + +@Repository +public interface DmaapNotificationsRepository extends CrudRepository { + + @Query(nativeQuery = true, + value = "DELETE FROM dmaap_notifications " + + "WHERE notification = ( SELECT notification FROM dmaap_notifications ORDER BY " + + "created_at FOR UPDATE SKIP LOCKED LIMIT 1 ) RETURNING notification;") + + public String getNotificationFromQueue(); + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/SonRequestsRepository.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/SonRequestsRepository.java new file mode 100644 index 0000000..b54661b --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/SonRequestsRepository.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * ============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.dao; + +import org.onap.dcaegen2.services.sonhms.entity.PciRequests; + +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 SonRequestsRepository extends CrudRepository { + + @Query(nativeQuery = true, value = "SELECT child_thread_id FROM pci_requests WHERE transaction_id = ?1") + public long getChildThreadMapping(String transactionId); + + @Modifying + @Query(nativeQuery = true, value = "DELETE FROM pci_requests WHERE child_thread_id = ?1") + public void deleteByChildThreadId(Long threadId); + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java new file mode 100644 index 0000000..002f835 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java @@ -0,0 +1,215 @@ +/******************************************************************************* + * ============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 com.att.nsa.apiClient.http.HttpException; +import com.att.nsa.cambria.client.CambriaClient; +import com.att.nsa.cambria.client.CambriaClientBuilders; +import com.att.nsa.cambria.client.CambriaClientBuilders.ConsumerBuilder; +import com.att.nsa.cambria.client.CambriaClientBuilders.TopicManagerBuilder; +import com.att.nsa.cambria.client.CambriaConsumer; +import com.att.nsa.cambria.client.CambriaTopicManager; +import org.onap.dcaegen2.services.sonhms.Configuration; +import org.onap.dcaegen2.services.sonhms.NewNotification; +import org.onap.dcaegen2.services.sonhms.Topic; +import org.onap.dcaegen2.services.sonhms.dao.DmaapNotificationsRepository; +import org.onap.dcaegen2.services.sonhms.entity.DmaapNotifications; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.security.GeneralSecurityException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class DmaapClient { + + @Autowired + private DmaapNotificationsRepository dmaapNotificationsRepository; + private Configuration configuration; + private static Logger log = LoggerFactory.getLogger(DmaapClient.class); + private static final String CONSUMER = "CONSUMER"; + private static final String PRODUCER = "PRODUCER"; + private static final String DESCRIPTION = "api keys for OOF PCI use case"; + private static final int PARTITION_COUNT = 1; + private static final int REPLICATION_COUNT = 1; + private NewNotification newNotification; + private CambriaTopicManager topicManager; + + public class NotificationCallback { + DmaapClient dmaapClient; + + public NotificationCallback(DmaapClient dmaapClient) { + this.dmaapClient = dmaapClient; + } + + public void activateCallBack(String msg) { + handleNotification(msg); + } + + private void handleNotification(String msg) { + DmaapNotifications dmaapNotification = new DmaapNotifications(); + dmaapNotification.setNotification(msg); + if (log.isDebugEnabled()) { + log.debug(dmaapNotification.toString()); + } + dmaapNotificationsRepository.save(dmaapNotification); + newNotification.setNewNotif(true); + } + } + + /** + * init dmaap client. + */ + public void initClient(NewNotification newNotification) { + log.debug("initializing client"); + configuration = Configuration.getInstance(); + if (log.isDebugEnabled()) { + log.debug(configuration.toString()); + } + this.newNotification = newNotification; + + createAndConfigureTopics(); + startClient(); + } + + /** + * create and configures topics. + */ + private void createAndConfigureTopics() { + + try { + topicManager = buildCambriaClient(new TopicManagerBuilder().usingHosts(configuration.getServers()) + .authenticatedBy(configuration.getManagerApiKey(), configuration.getManagerSecretKey())); + } catch (GeneralSecurityException | IOException e) { + log.debug("exception during creating topic", e); + } + List topics = configuration.getTopics(); + + for (Topic topic : topics) { + Set topicsInDmaap = getAllTopicsFromDmaap(); + + createTopic(topic, topicsInDmaap); + subscribeToTopic(topic.getName(), topic.getProducer(), PRODUCER); + subscribeToTopic(topic.getName(), topic.getConsumer(), CONSUMER); + + } + + topicManager.close(); + + } + + /** + * create topic. + */ + private void createTopic(Topic topic, Set topicsInDmaap) { + if (topicsInDmaap.contains(topic.getName())) { + log.debug("topic exists in dmaap"); + } else { + try { + topicManager.createTopic(topic.getName(), DESCRIPTION, PARTITION_COUNT, REPLICATION_COUNT); + } catch (HttpException | IOException e) { + log.debug("error while creating topic: {}", e); + } + } + } + + /** + * get all topics from dmaap. + */ + private Set getAllTopicsFromDmaap() { + Set topics = new HashSet<>(); + try { + topics = topicManager.getTopics(); + } catch (IOException e) { + log.debug("IOException while fetching topics"); + } + return topics; + + } + + /** + * start dmaap client. + */ + private synchronized void startClient() { + + ScheduledExecutorService executorPool; + CambriaConsumer cambriaConsumer = null; + + try { + cambriaConsumer = new ConsumerBuilder() + .authenticatedBy(configuration.getPcimsApiKey(), configuration.getPcimsSecretKey()) + .knownAs(configuration.getCg(), configuration.getCid()).onTopic(configuration.getSdnrTopic()) + .usingHosts(configuration.getServers()).withSocketTimeout(configuration.getPollingTimeout() * 1000) + .build(); + + // create notification consumers for SNDR and policy + NotificationConsumer notificationConsumer = new NotificationConsumer(cambriaConsumer, + new NotificationCallback(this)); + + // start notification consumer threads + executorPool = Executors.newScheduledThreadPool(10); + executorPool.scheduleAtFixedRate(notificationConsumer, 0, configuration.getPollingInterval(), + TimeUnit.SECONDS); + } catch (MalformedURLException | GeneralSecurityException e) { + log.debug("exception during starting client", e); + } + + } + + /** + * subscribe to topic. + */ + private void subscribeToTopic(String topicName, String subscriberApiKey, String subscriberType) { + if (subscriberType.equals(PRODUCER)) { + try { + topicManager.allowProducer(topicName, subscriberApiKey); + } catch (HttpException | IOException e) { + log.debug("error while subscribing to a topic: {}", e); + } + } else if (subscriberType.equals(CONSUMER)) { + try { + topicManager.allowConsumer(topicName, subscriberApiKey); + } catch (HttpException | IOException e) { + log.debug("error while subscribing to a topic: {}", e); + } + } + + } + + @SuppressWarnings("unchecked") + private static T buildCambriaClient( + CambriaClientBuilders.AbstractAuthenticatedManagerBuilder client) + throws MalformedURLException, GeneralSecurityException { + return (T) client.build(); + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationConsumer.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationConsumer.java new file mode 100644 index 0000000..ba6b83d --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationConsumer.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * ============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 com.att.nsa.cambria.client.CambriaConsumer; +import org.onap.dcaegen2.services.sonhms.dmaap.DmaapClient.NotificationCallback; + +import java.io.IOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class NotificationConsumer implements Runnable { + + private static Logger log = LoggerFactory.getLogger(NotificationConsumer.class); + private CambriaConsumer cambriaConsumer; + private NotificationCallback notificationCallback; + + /** + * Parameterized Constructor. + */ + public NotificationConsumer(CambriaConsumer cambriaConsumer, NotificationCallback notificationCallback) { + super(); + this.cambriaConsumer = cambriaConsumer; + this.notificationCallback = notificationCallback; + } + + @Override + public void run() { + try { + Iterable msgs = cambriaConsumer.fetch(); + for (String msg : msgs) { + log.debug(msg); + notificationCallback.activateCallBack(msg); + } + } catch (IOException e) { + log.debug("exception when fetching msgs from dmaap", e); + } + + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationProducer.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationProducer.java new file mode 100644 index 0000000..e1db372 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationProducer.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * ============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 com.att.nsa.cambria.client.CambriaBatchingPublisher; +import java.io.IOException; +import java.security.GeneralSecurityException; + +public class NotificationProducer { + + private CambriaBatchingPublisher cambriaBatchingPublisher; + + + /** + * Parameterised constructor. + */ + public NotificationProducer(CambriaBatchingPublisher cambriaBatchingPublisher) { + super(); + this.cambriaBatchingPublisher = cambriaBatchingPublisher; + } + + /** + * sends notification to dmaap. + */ + public int sendNotification(String msg) throws GeneralSecurityException, IOException { + + int result = cambriaBatchingPublisher.send("", msg); + System.out.println(result); + return result; + + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java new file mode 100644 index 0000000..4d5d23b --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * ============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 com.att.nsa.cambria.client.CambriaBatchingPublisher; +import com.att.nsa.cambria.client.CambriaClientBuilders.PublisherBuilder; +import org.onap.dcaegen2.services.sonhms.Configuration; + +import java.io.IOException; +import java.security.GeneralSecurityException; + +public class PolicyDmaapClient { + + + /** + * Method stub for sending notification to policy. + */ + public boolean sendNotificationToPolicy(String msg) { + + Configuration configuration = Configuration.getInstance(); + CambriaBatchingPublisher cambriaBatchingPublisher; + try { + cambriaBatchingPublisher = new PublisherBuilder().usingHosts(configuration.getServers()) + .onTopic(configuration.getPolicyTopic()) + .authenticatedBy(configuration.getPcimsApiKey(), configuration.getPcimsSecretKey()).build(); + NotificationProducer notificationProducer = new NotificationProducer(cambriaBatchingPublisher); + notificationProducer.sendNotification(msg); + } catch (GeneralSecurityException | IOException e) { + return false; + } + return true; + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/entity/BufferedNotifications.java b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/BufferedNotifications.java new file mode 100644 index 0000000..34cce77 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/BufferedNotifications.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * ============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.entity; + +import java.sql.Timestamp; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.hibernate.annotations.CreationTimestamp; + +@Entity +@Table(name = "BUFFERED_NOTIFICATIONS") +public class BufferedNotifications { + + @Id + @Column(name = "notification", columnDefinition = "text") + private String notification; + + @Column(name = "cluster_id", columnDefinition = "text") + private String clusterId; + + @CreationTimestamp + @Column(name = "created_at", columnDefinition = "timestamp") + private Timestamp createdAt; + + public BufferedNotifications() { + + } + + /** + * Parameterised constructor. + */ + public BufferedNotifications(String notification, Timestamp createdAt, String clusterId) { + this.notification = notification; + this.createdAt = createdAt; + this.clusterId = clusterId; + } + + public String getNotification() { + return notification; + } + + public void setNotification(String notification) { + this.notification = notification; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public Timestamp getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Timestamp createdAt) { + this.createdAt = createdAt; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/entity/CellInfo.java b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/CellInfo.java new file mode 100644 index 0000000..0c546d6 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/CellInfo.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * ============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.entity; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "CELL_INFO") +public class CellInfo { + + @Id + @Column(name = "CELL_ID") + private String cellId; + + @Column(name = "PNF_NAME") + private String pnfName; + + public CellInfo() { + + } + + /** + * CellIdPnf Constructor. + */ + + public CellInfo(String cellId, String pnfName) { + super(); + this.cellId = cellId; + this.pnfName = pnfName; + } + + public String getCellId() { + return cellId; + } + + public void setCellId(String cellId) { + this.cellId = cellId; + } + + public String getPnfName() { + return pnfName; + } + + public void setPnfName(String pnfName) { + this.pnfName = pnfName; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/entity/ClusterDetails.java b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/ClusterDetails.java new file mode 100644 index 0000000..37dc5bd --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/ClusterDetails.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * ============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.entity; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "CLUSTER_DETAILS") +public class ClusterDetails { + + @Id + @Column(name = "CLUSTER_ID") + private String clusterId; + + @Column(name = "CLUSTER_INFO") + private String clusterInfo; + + @Column(name = "CHILD_THREAD_ID") + private long childThreadId; + + public ClusterDetails() { + + } + + /** + * Parameterised constructor. + */ + public ClusterDetails(String clusterId, String clusterInfo, long childThreadId) { + super(); + this.clusterId = clusterId; + this.clusterInfo = clusterInfo; + this.childThreadId = childThreadId; + } + + public long getChildThreadId() { + return childThreadId; + } + + public void setChildThreadId(long childThreadId) { + this.childThreadId = childThreadId; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getClusterInfo() { + return clusterInfo; + } + + public void setClusterInfo(String clusterInfo) { + this.clusterInfo = clusterInfo; + } + + @Override + public String toString() { + return "ClusterDetails [clusterId=" + clusterId + ", clusterInfo=" + clusterInfo + ", childThreadId=" + + childThreadId + "]"; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/entity/DmaapNotifications.java b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/DmaapNotifications.java new file mode 100644 index 0000000..2e30efc --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/DmaapNotifications.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * ============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.entity; + +import java.sql.Timestamp; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.hibernate.annotations.CreationTimestamp; + +@Entity +@Table(name = "DMAAP_NOTIFICATIONS") +public class DmaapNotifications { + + @Id + @Column(name = "notification", columnDefinition = "text") + private String notification; + + @CreationTimestamp + @Column(name = "created_at", columnDefinition = "timestamp") + private Timestamp createdAt; + + public DmaapNotifications() { + + } + + public DmaapNotifications(String notification, Timestamp createdAt) { + this.notification = notification; + this.createdAt = createdAt; + } + + public String getNotification() { + return notification; + } + + public void setNotification(String notification) { + this.notification = notification; + } + + public Timestamp getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Timestamp createdAt) { + this.createdAt = createdAt; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/entity/PciRequests.java b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/PciRequests.java new file mode 100644 index 0000000..79120ee --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/PciRequests.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * ============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.entity; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "PCI_REQUESTS") +public class PciRequests { + + @Id + @Column(name = "TRANSACTION_ID") + private String transactionId; + + @Column(name = "CHILD_THREAD_ID") + private long childThreadId; + + public PciRequests() { + + } + + /** + * Parameterised constructor. + */ + public PciRequests(String transactionId, long childThreadId) { + super(); + this.transactionId = transactionId; + this.childThreadId = childThreadId; + } + + public String getTransactionId() { + return transactionId; + } + + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; + } + + public long getChildThreadId() { + return childThreadId; + } + + public void setChildThreadId(long childThreadId) { + this.childThreadId = childThreadId; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/exceptions/ConfigDbNotFoundException.java b/src/main/java/org/onap/dcaegen2/services/sonhms/exceptions/ConfigDbNotFoundException.java new file mode 100644 index 0000000..e1f040b --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/exceptions/ConfigDbNotFoundException.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * ============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.exceptions; + +public class ConfigDbNotFoundException extends Exception { + + /** + * serial version. + */ + private static final long serialVersionUID = 1L; + + public ConfigDbNotFoundException(String message) { + super(message); + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/exceptions/OofNotFoundException.java b/src/main/java/org/onap/dcaegen2/services/sonhms/exceptions/OofNotFoundException.java new file mode 100644 index 0000000..0bbeff3 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/exceptions/OofNotFoundException.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * ============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.exceptions; + +public class OofNotFoundException extends Exception { + /** + * serial version. + */ + private static final long serialVersionUID = 1L; + + public OofNotFoundException(String message) { + super(message); + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellConfig.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellConfig.java new file mode 100644 index 0000000..1f4f62e --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellConfig.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * ============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 CellConfig { + + @JsonProperty(value = "LTE") + private Lte lte; + + public CellConfig() { + + } + + public CellConfig(Lte lte) { + super(); + this.lte = lte; + } + + public Lte getLte() { + return lte; + } + + public void setLte(Lte lte) { + this.lte = lte; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellNeighbourList.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellNeighbourList.java new file mode 100644 index 0000000..18fdac4 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellNeighbourList.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * ============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; + +public class CellNeighbourList { + + private String cellId; + private int physicalCellId; + private String neighbours; + + public String getCellId() { + return cellId; + } + + public void setCellId(String cellId) { + this.cellId = cellId; + } + + public int getPhysicalCellId() { + return physicalCellId; + } + + public void setPhysicalCellId(int physicalCellId) { + this.physicalCellId = physicalCellId; + } + + public String getNeighbours() { + return neighbours; + } + + public void setNeighbours(String neighbours) { + this.neighbours = neighbours; + } + + /** + * constructor. + */ + public CellNeighbourList() { + + } + + /** + * Parameterized constructor. + */ + public CellNeighbourList(String cellId, int physicalCellId, String neighbours) { + super(); + this.cellId = cellId; + this.physicalCellId = physicalCellId; + this.neighbours = neighbours; + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellPciPair.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellPciPair.java new file mode 100644 index 0000000..866c51e --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/CellPciPair.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * ============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 CellPciPair { + @JsonProperty("cellId") + private String cellId; + + @JsonProperty("physicalCellId") + private int physicalCellId; + + @Override + public String toString() { + return "CellPciPair [cellId=" + cellId + ", physicalCellId=" + physicalCellId + "]"; + } + + public CellPciPair() { + + } + + /** + * Parameterized constructor. + */ + public CellPciPair(String cellId, int physicalCellId) { + super(); + this.cellId = cellId; + this.physicalCellId = physicalCellId; + } + + public String getCellId() { + return cellId; + } + + public void setCellId(String cellId) { + this.cellId = cellId; + } + + public int getPhysicalCellId() { + return physicalCellId; + } + + public void setPhysicalCellId(int physicalCellId) { + this.physicalCellId = physicalCellId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = (prime * result) + ((cellId == null) ? 0 : cellId.hashCode()); + result = (prime * result) + physicalCellId; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + CellPciPair other = (CellPciPair) obj; + if (cellId == null) { + if (other.cellId != null) { + return false; + } + } else if (!cellId.equals(other.cellId)) { + return false; + } + return (physicalCellId == other.physicalCellId); + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Common.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Common.java new file mode 100644 index 0000000..8a54f76 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Common.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * ============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 Common { + + @JsonProperty(value = "CellIdentity") + private String cellIdentity; + + public Common() { + + } + + public Common(String cellIdentity) { + super(); + this.cellIdentity = cellIdentity; + } + + public String getCellIdentity() { + return cellIdentity; + } + + public void setCellIdentity(String cellIdentity) { + this.cellIdentity = cellIdentity; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Configurations.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Configurations.java new file mode 100644 index 0000000..e043aaf --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Configurations.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * ============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 Configurations { + @JsonProperty("data") + private Data data; + + /** + * constructor. + * + */ + public Configurations() { + + } + + /** + * Parameterized constructor. + * + */ + public Configurations(Data data) { + super(); + this.data = data; + } + + public Data getData() { + return data; + } + + public void setData(Data data) { + this.data = data; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Data.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Data.java new file mode 100644 index 0000000..43b6204 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Data.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * ============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 Data { + + @JsonProperty("FAPService") + private FapService fapservice; + + public Data() { + + } + + public Data(FapService fapservice) { + super(); + this.fapservice = fapservice; + } + + public FapService getFapservice() { + return fapservice; + } + + public void setFapservice(FapService fapservice) { + this.fapservice = fapservice; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/FapService.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/FapService.java new file mode 100644 index 0000000..90b6f23 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/FapService.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * ============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 FapService { + + @JsonProperty("alias") + private String alias; + + @JsonProperty("X0005b9Lte") + private X0005b9Lte x0005b9Lte; + + @JsonProperty("CellConfig") + private CellConfig cellConfig; + + public FapService() { + + } + + /** + * Parameterized constructor. + */ + public FapService(String alias, X0005b9Lte x0005b9Lte, CellConfig cellConfig) { + super(); + this.alias = alias; + this.x0005b9Lte = x0005b9Lte; + this.cellConfig = cellConfig; + } + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public CellConfig getCellConfig() { + return cellConfig; + } + + public void setCellConfig(CellConfig cellConfig) { + this.cellConfig = cellConfig; + } + + public X0005b9Lte getX0005b9Lte() { + return x0005b9Lte; + } + + public void setX0005b9Lte(X0005b9Lte x0005b9Lte) { + this.x0005b9Lte = x0005b9Lte; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/FapServiceList.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/FapServiceList.java new file mode 100644 index 0000000..1e38927 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/FapServiceList.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * ============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 FapServiceList { + + @Override + public String toString() { + return "FapServiceList [alias=" + alias + ", x0005b9Lte=" + x0005b9Lte + ", cellConfig=" + cellConfig + "]"; + } + + @JsonProperty("alias") + private String alias; + + @JsonProperty("X0005b9Lte") + private X0005b9Lte x0005b9Lte; + + @JsonProperty("CellConfig") + private NotificationCellConfig cellConfig; + + public FapServiceList() { + + } + + /** + * Parameterized Constructor. + */ + + public FapServiceList(String alias, X0005b9Lte x0005b9Lte, NotificationCellConfig cellConfig) { + super(); + this.alias = alias; + this.x0005b9Lte = x0005b9Lte; + this.cellConfig = cellConfig; + } + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public X0005b9Lte getX0005b9Lte() { + return x0005b9Lte; + } + + public void setX0005b9Lte(X0005b9Lte x0005b9Lte) { + this.x0005b9Lte = x0005b9Lte; + } + + public NotificationCellConfig getCellConfig() { + return cellConfig; + } + + public void setCellConfig(NotificationCellConfig cellConfig) { + this.cellConfig = cellConfig; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Lte.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Lte.java new file mode 100644 index 0000000..4ba5537 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Lte.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * ============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 Lte { + + @JsonProperty(value = "RAN") + private Ran ran; + + public Lte() { + + } + + public Lte(Ran ran) { + super(); + this.ran = ran; + } + + public Ran getRan() { + return ran; + } + + public void setRan(Ran ran) { + this.ran = ran; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/LteNeighborListInUseLteCell.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/LteNeighborListInUseLteCell.java new file mode 100644 index 0000000..961e5f0 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/LteNeighborListInUseLteCell.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * ============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 LteNeighborListInUseLteCell { + @JsonProperty("pnfName") + private String pnfName; + + @JsonProperty("enable") + private String enable; + + @JsonProperty("alias") + private String alias; + + @JsonProperty("mustInclude") + private String mustInclude; + + @JsonProperty("plmnid") + private String plmnId; + + @JsonProperty("cid") + private String cid; + + @JsonProperty("phyCellId") + private int phyCellId; + + @JsonProperty("blacklisted") + private String blacklisted; + + public LteNeighborListInUseLteCell() { + + } + + /** + * Parameterized Constructor. + */ + + public LteNeighborListInUseLteCell(String pnfName, String enable, String alias, String mustInclude, String plmnId, + String cid, int phyCellId, String blacklisted) { + super(); + this.pnfName = pnfName; + this.enable = enable; + this.alias = alias; + this.mustInclude = mustInclude; + this.plmnId = plmnId; + this.cid = cid; + this.phyCellId = phyCellId; + this.blacklisted = blacklisted; + } + + public String getMustInclude() { + return mustInclude; + } + + public void setMustInclude(String mustInclude) { + this.mustInclude = mustInclude; + } + + public int getPhyCellId() { + return phyCellId; + } + + public void setPhyCellId(int phyCellId) { + this.phyCellId = phyCellId; + } + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public String getEnable() { + return enable; + } + + public void setEnable(String enable) { + this.enable = enable; + } + + public String getBlacklisted() { + return blacklisted; + } + + public void setBlacklisted(String blacklisted) { + this.blacklisted = blacklisted; + } + + public String getCid() { + return cid; + } + + public void setCid(String cid) { + this.cid = cid; + } + + public String getPnfName() { + return pnfName; + } + + public void setPnfName(String pnfName) { + this.pnfName = pnfName; + } + + public String getPlmnid() { + return plmnId; + } + + public void setPlmnid(String plmnId) { + this.plmnId = plmnId; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/NeighborListInUse.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NeighborListInUse.java new file mode 100644 index 0000000..50df1d8 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NeighborListInUse.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * ============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; +import java.util.List; + +public class NeighborListInUse { + @JsonProperty("LTENeighborListInUseLTECell") + private List lteNeighborListInUseLteCell; + + @JsonProperty("LTECellNumberOfEntries") + private String lteCellNumberOfEntries; + + public NeighborListInUse() { + + } + + /** + * Parameterized Constructor. + */ + + public NeighborListInUse(List lteNeighborListInUseLteCell, + String lteCellNumberOfEntries) { + super(); + this.lteNeighborListInUseLteCell = lteNeighborListInUseLteCell; + this.lteCellNumberOfEntries = lteCellNumberOfEntries; + } + + public List getLteNeighborListInUseLteCell() { + return lteNeighborListInUseLteCell; + } + + public void setLteNeighborListInUseLteCell(List lteNeighborListInUseLteCell) { + this.lteNeighborListInUseLteCell = lteNeighborListInUseLteCell; + } + + public String getLteCellNumberOfEntries() { + return lteCellNumberOfEntries; + } + + public void setLteCellNumberOfEntries(String lteCellNumberOfEntries) { + this.lteCellNumberOfEntries = lteCellNumberOfEntries; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Notification.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Notification.java new file mode 100644 index 0000000..f74896a --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Notification.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * ============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 Notification { + + @JsonProperty("requestID") + private String requestId; + + @JsonProperty("AAI") + private Object aai; + + @JsonProperty("from") + private String from; + + @JsonProperty("version") + private String version; + + @JsonProperty("Action") + private String action; + + @JsonProperty("Payload") + private NotificationPayload payload; + + public Notification() { + + } + + /** + * Parameterized Constructor. + */ + + public Notification(String requestId, Object aai, String from, String version, String action, + NotificationPayload payload) { + super(); + this.requestId = requestId; + this.aai = aai; + this.from = from; + this.version = version; + this.action = action; + this.payload = payload; + } + + public NotificationPayload getPayload() { + return payload; + } + + public void setPayload(NotificationPayload payload) { + this.payload = payload; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getFrom() { + return from; + } + + public void setFrom(String from) { + this.from = from; + } + + public Object getAai() { + return aai; + } + + public void setAai(Object aai) { + this.aai = aai; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Override + public String toString() { + return "Notification [requestId=" + requestId + ", aai=" + aai + ", from=" + from + ", version=" + version + + ", action=" + action + ", payload=" + payload + "]"; + } + + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationCellConfig.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationCellConfig.java new file mode 100644 index 0000000..aa771fe --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationCellConfig.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * ============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 NotificationCellConfig { + + @JsonProperty("LTE") + private NotificationLte lte; + + public NotificationCellConfig() { + + } + + /** + * Parameterized Constructor. + */ + + public NotificationCellConfig(NotificationLte lte) { + super(); + this.lte = lte; + } + + public NotificationLte getLte() { + return lte; + } + + public void setLte(NotificationLte lte) { + this.lte = lte; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationLte.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationLte.java new file mode 100644 index 0000000..584db11 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationLte.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * ============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 NotificationLte { + + @JsonProperty("RAN") + private NotificationRan ran; + + public NotificationLte() { + + } + + /** + * Parameterized Constructor. + */ + + public NotificationLte(NotificationRan ran) { + super(); + this.ran = ran; + } + + public NotificationRan getRan() { + return ran; + } + + public void setRan(NotificationRan ran) { + this.ran = ran; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationPayload.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationPayload.java new file mode 100644 index 0000000..9fed1e7 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationPayload.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * ============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 NotificationPayload { + + @JsonProperty("RadioAccess") + private RadioAccess radioAccess; + + public NotificationPayload() { + + } + + /** + * Parameterized Constructor. + */ + + public NotificationPayload(RadioAccess radioAccess) { + super(); + this.radioAccess = radioAccess; + } + + public RadioAccess getRadioAccess() { + return radioAccess; + } + + public void setRadioAccess(RadioAccess radioAccess) { + this.radioAccess = radioAccess; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationRan.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationRan.java new file mode 100644 index 0000000..6215ebb --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/NotificationRan.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * ============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 NotificationRan { + + @JsonProperty("NeighborListInUse") + private NeighborListInUse neighborListInUse; + + @JsonProperty("CellIdentity") + private String cellIdentity; + + public NotificationRan() { + + } + + /** + * Parameterized Constructor. + */ + + public NotificationRan(NeighborListInUse neighborListInUse, String cellIdentity) { + super(); + this.neighborListInUse = neighborListInUse; + this.cellIdentity = cellIdentity; + } + + public NeighborListInUse getNeighborListInUse() { + return neighborListInUse; + } + + public void setNeighborListInUse(NeighborListInUse neighborListInUse) { + this.neighborListInUse = neighborListInUse; + } + + public String getCellIdentity() { + return cellIdentity; + } + + public void setCellIdentity(String cellIdentity) { + this.cellIdentity = cellIdentity; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Payload.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Payload.java new file mode 100644 index 0000000..dd10a1f --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Payload.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * ============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; +import java.util.List; + +public class Payload { + + @JsonProperty("Configurations") + private List configuration; + + public Payload() { + + } + + public Payload(List configuration) { + super(); + this.configuration = configuration; + } + + public List getConfiguration() { + return configuration; + } + + public void setConfiguration(List configuration) { + this.configuration = configuration; + } + + @Override + public String toString() { + return "Payload [configuration=" + configuration + "]"; + + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java new file mode 100644 index 0000000..076c7b5 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java @@ -0,0 +1,206 @@ +/******************************************************************************* + * ============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; + +import java.util.HashMap; +import java.util.Map; + +public class PolicyNotification { + + private String closedLoopControlName; + private long closedLoopAlarmStart; + private String closedLoopEventClient; + private String closedLoopEventStatus; + + @JsonProperty("target_type") + private String targetType; + + private String target; + + @JsonProperty("requestID") + private String requestId; + + @JsonProperty("AAI") + private Map aai; + + private String from; + private String version; + + @JsonProperty("Action") + private String action; + private String payload; + + /** + * constructor. + */ + public PolicyNotification() { + + } + + /** + * Constructor. + * + */ + public PolicyNotification(String closedLoopControlName, String requestId, Long alarmStartTime, String pnfName) { + this.closedLoopControlName = closedLoopControlName; + this.requestId = requestId; + this.closedLoopEventClient = "microservice.PCI"; + this.closedLoopEventStatus = "ONSET"; + this.closedLoopAlarmStart = alarmStartTime; + this.from = "PCIMS"; + this.version = "1.0.2"; + this.action = "ModifyConfig"; + this.target = "generic-vnf.vnf-id"; + this.targetType = "VNF"; + this.aai = new HashMap<>(); + aai.put("generic-vnf.is-closed-loop-disabled", "false"); + aai.put("generic-vnf.prov-status", "ACTIVE"); + aai.put("generic-vnf.vnf-id", pnfName); + } + + public long getClosedLoopAlarmStart() { + return closedLoopAlarmStart; + } + + public void setClosedLoopAlarmStart(long closedLoopAlarmStart) { + this.closedLoopAlarmStart = closedLoopAlarmStart; + } + + public String getClosedLoopEventClient() { + return closedLoopEventClient; + } + + public void setClosedLoopEventClient(String closedLoopEventClient) { + this.closedLoopEventClient = closedLoopEventClient; + } + + public String getClosedLoopEventStatus() { + return closedLoopEventStatus; + } + + public void setClosedLoopEventStatus(String closedLoopEventStatus) { + this.closedLoopEventStatus = closedLoopEventStatus; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getFrom() { + return from; + } + + public void setFrom(String from) { + this.from = from; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getClosedLoopControlName() { + return closedLoopControlName; + } + + public void setClosedLoopControlName(String closedLoopControlName) { + this.closedLoopControlName = closedLoopControlName; + } + + public String getPayload() { + return payload; + } + + public void setPayload(String payload) { + this.payload = payload; + } + + public String getTargetType() { + return targetType; + } + + public void setTargetType(String targetType) { + this.targetType = targetType; + } + + public String getTarget() { + return target; + } + + public void setTarget(String target) { + this.target = target; + } + + public Map getAai() { + return aai; + } + + public void setAai(Map aai) { + this.aai = aai; + } + + @Override + public String toString() { + return "PolicyNotification [closedLoopControlName=" + closedLoopControlName + ", closedLoopAlarmStart=" + + closedLoopAlarmStart + ", closedLoopEventClient=" + closedLoopEventClient + ", closedLoopEventStatus=" + + closedLoopEventStatus + ", targetType=" + targetType + ", target=" + target + ", requestId=" + + requestId + ", aai=" + aai + ", from=" + from + ", version=" + version + ", action=" + action + + ", payload=" + payload + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((aai == null) ? 0 : aai.hashCode()); + result = prime * result + ((action == null) ? 0 : action.hashCode()); + result = prime * result + (int) (closedLoopAlarmStart ^ (closedLoopAlarmStart >>> 32)); + result = prime * result + ((closedLoopControlName == null) ? 0 : closedLoopControlName.hashCode()); + result = prime * result + ((closedLoopEventClient == null) ? 0 : closedLoopEventClient.hashCode()); + result = prime * result + ((closedLoopEventStatus == null) ? 0 : closedLoopEventStatus.hashCode()); + result = prime * result + ((from == null) ? 0 : from.hashCode()); + result = prime * result + ((payload == null) ? 0 : payload.hashCode()); + result = prime * result + ((requestId == null) ? 0 : requestId.hashCode()); + result = prime * result + ((target == null) ? 0 : target.hashCode()); + result = prime * result + ((targetType == null) ? 0 : targetType.hashCode()); + result = prime * result + ((version == null) ? 0 : version.hashCode()); + return result; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/RadioAccess.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/RadioAccess.java new file mode 100644 index 0000000..775c14d --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/RadioAccess.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * ============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; +import java.util.List; + +public class RadioAccess { + + @JsonProperty("FAPServiceNumberOfEntries") + private String fapServiceNumberOfEntries; + + @JsonProperty("FAPServiceList") + private List fapServiceList; + + public RadioAccess() { + + } + + /** + * Parameterized Constructor. + */ + + public RadioAccess(String fapServiceNumberOfEntries, List fapServiceList) { + super(); + this.fapServiceNumberOfEntries = fapServiceNumberOfEntries; + this.fapServiceList = fapServiceList; + } + + public String getFapServiceNumberOfEntries() { + return fapServiceNumberOfEntries; + } + + public void setFapServiceNumberOfEntries(String fapServiceNumberOfEntries) { + this.fapServiceNumberOfEntries = fapServiceNumberOfEntries; + } + + public List getFapServiceList() { + return fapServiceList; + } + + public void setFapServiceList(List fapServiceList) { + this.fapServiceList = fapServiceList; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Ran.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Ran.java new file mode 100644 index 0000000..f2be944 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Ran.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * ============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 Ran { + + @JsonProperty(value = "Common") + private Common common; + + public Ran() { + + } + + /** + * Parameterized constructor. + */ + public Ran(Common common) { + super(); + this.common = common; + } + + public Common getCommon() { + return common; + } + + public void setCommon(Common common) { + this.common = common; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Response.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Response.java new file mode 100644 index 0000000..46237db --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Response.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * ============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 Response { + + @JsonProperty(value = "cellId") + private String cellId; + + private int pci; + + public String getCellId() { + return cellId; + } + + public void setCellId(String cellId) { + this.cellId = cellId; + } + + public int getPci() { + return pci; + } + + public void setPci(int pci) { + this.pci = pci; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/SdnrResponse.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/SdnrResponse.java new file mode 100644 index 0000000..7fb73b7 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/SdnrResponse.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * ============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 java.util.List; + +public class SdnrResponse { + + private List response; + + public List getResponse() { + return response; + } + + public void setResponse(List response) { + this.response = response; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/ThreadId.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/ThreadId.java new file mode 100644 index 0000000..37d741d --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/ThreadId.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * ============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; + +public class ThreadId { + + private long childThreadId; + + public long getChildThreadId() { + return childThreadId; + } + + public void setChildThreadId(long childThreadId) { + this.childThreadId = childThreadId; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/X0005b9Lte.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/X0005b9Lte.java new file mode 100644 index 0000000..d6dc61e --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/X0005b9Lte.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * ============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 X0005b9Lte { + + @JsonProperty("phyCellIdInUse") + private int phyCellIdInUse; + + @JsonProperty("pnfName") + private String pnfName; + + public X0005b9Lte() { + + } + + /** + * Parameterized Constructor. + */ + + public X0005b9Lte(int phyCellIdInUse, String pnfName) { + super(); + this.phyCellIdInUse = phyCellIdInUse; + this.pnfName = pnfName; + } + + public int getPhyCellIdInUse() { + return phyCellIdInUse; + } + + public void setPhyCellIdInUse(int phyCellIdInUse) { + this.phyCellIdInUse = phyCellIdInUse; + } + + public String getPnfName() { + return pnfName; + } + + public void setPnfName(String pnfName) { + this.pnfName = pnfName; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBody.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBody.java new file mode 100644 index 0000000..61e0421 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBody.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * ============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.restclient; + +import java.util.List; + +public class AsyncResponseBody { + + String transactionId = null; + String requestId = null; + String requestStatus = null; + String statusMessage = null; + List solutions; + + public String getTransactionId() { + return transactionId; + } + + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getRequestStatus() { + return requestStatus; + } + + @Override + public String toString() { + return "AsyncResponseBody [transactionId=" + transactionId + ", requestId=" + requestId + ", requestStatus=" + + requestStatus + ", statusMessage=" + statusMessage + ", solutions=" + solutions + "]"; + } + + public void setRequestStatus(String requestStatus) { + this.requestStatus = requestStatus; + } + + public String getStatusMessage() { + return statusMessage; + } + + public void setStatusMessage(String statusMessage) { + this.statusMessage = statusMessage; + } + + public List getSolutions() { + return solutions; + } + + public void setSolutions(List solutions) { + this.solutions = solutions; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfo.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfo.java new file mode 100644 index 0000000..edac16f --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfo.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * ============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.restclient; + +import java.util.ArrayList; +import java.util.List; + +public class CellInfo { + String networkId = null; + List cellIdList = new ArrayList<>(); + + public String getNetworkId() { + return networkId; + } + + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + public List getCellIdList() { + return cellIdList; + } + + public void setCellIdList(List cellIdList) { + this.cellIdList = cellIdList; + } + + + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRequestBody.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRequestBody.java new file mode 100644 index 0000000..2e5eeaa --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRequestBody.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * ============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.restclient; + +public class OofRequestBody { + + protected RequestInfo requestInfo = new RequestInfo(); + protected CellInfo cellInfo = new CellInfo(); + + public RequestInfo getRequestInfo() { + return requestInfo; + } + + public void setRequestInfo(RequestInfo requestInfo) { + this.requestInfo = requestInfo; + } + + public CellInfo getCellInfo() { + return cellInfo; + } + + public void setCellInfo(CellInfo cellInfo) { + this.cellInfo = cellInfo; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java new file mode 100644 index 0000000..a9ce305 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * ============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.restclient; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +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.utils.SonHandlerRestTemplate; + +import java.util.List; +import java.util.UUID; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.ResponseEntity; + +public class OofRestClient { + private static Logger log = LoggerFactory.getLogger(OofRestClient.class); + + private OofRestClient() { + + } + + /** + * rest client that pci uses to query the OOF for pci solutions. + * @throws OofNotFoundException when request to oof fails + */ + + public static String queryOof(int numSolutions, String transactionId, String requestType, + List cellIdList, String networkId, List optimizers) throws OofNotFoundException { + log.debug("inside queryoof"); + + ResponseEntity response = null; + Configuration configuration = Configuration.getInstance(); + try { + UUID requestUuid = UUID.randomUUID(); + String requestId = requestUuid.toString(); + String callbackUrl = configuration.getCallbackUrl(); + RequestInfo requestInfo = new RequestInfo(); + requestInfo.setTransactionId(transactionId); + requestInfo.setRequestId(requestId); + requestInfo.setCallbackUrl(callbackUrl); + String sourceId = configuration.getSourceId(); + requestInfo.setSourceId(sourceId); + requestInfo.setRequestType(requestType); + requestInfo.setNumSolutions(numSolutions); + requestInfo.setOptimizers(optimizers); + 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(); + cellInfo.setCellIdList(cellIdList); + cellInfo.setNetworkId(networkId); + OofRequestBody oofRequestBody = new OofRequestBody(); + oofRequestBody.setRequestInfo(requestInfo); + oofRequestBody.setCellInfo(cellInfo); + + ObjectMapper mapper = new ObjectMapper(); + String requestBody = mapper.writeValueAsString(oofRequestBody); + log.debug("requestBody{}", requestBody); + + String requestUrl = configuration.getOofService() + "/api/oof/v1/pci"; + log.debug("requestUrl {}", requestUrl); + + response = SonHandlerRestTemplate.sendPostRequestToOof(requestUrl, requestBody,new ParameterizedTypeReference() {}); + if (response == null) { + throw new OofNotFoundException("Request to oof failed"); + } + log.debug("response {}", response); + + return response.getBody(); + } catch (JsonProcessingException e) { + log.debug("exception{}", e); + + } + return response.getBody(); + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRequestBody.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRequestBody.java new file mode 100644 index 0000000..a7c9f08 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRequestBody.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * ============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.restclient; + +public class PolicyRequestBody { + + String configName = null; + String policyName = null; + String requestId = null; + + public String getConfigName() { + return configName; + } + + public void setConfigName(String configName) { + this.configName = configName; + } + + public String getPolicyName() { + return policyName; + } + + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRestClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRestClient.java new file mode 100644 index 0000000..7334df2 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRestClient.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * ============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.restclient; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.dcaegen2.services.sonhms.Configuration; +import org.onap.dcaegen2.services.sonhms.utils.SonHandlerRestTemplate; + +import java.util.UUID; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.ResponseEntity; + +public class PolicyRestClient { + private static Logger log = LoggerFactory.getLogger(PolicyRestClient.class); + + private PolicyRestClient() { + + } + + /** + * Fetches configuration from policy. + */ + public static String fetchConfigFromPolicy() { + log.debug("inside fetconfig from policy"); + + Configuration configuration = Configuration.getInstance(); + ResponseEntity response = null; + String configName = configuration.getConfigName(); + String policyName = configuration.getPolicyName(); + + try { + PolicyRequestBody policyRequestBody = new PolicyRequestBody(); + policyRequestBody.setConfigName(configName); + policyRequestBody.setPolicyName(policyName); + UUID requestUuid = UUID.randomUUID(); + String requestId = requestUuid.toString(); + policyRequestBody.setRequestId(requestId); + ObjectMapper mapper = new ObjectMapper(); + String requestBody; + requestBody = mapper.writeValueAsString(policyRequestBody); + + log.debug("policyRequestBody{}", requestBody); + String requestUrl = configuration.getPolicyService() + "/pdp/api/getConfig"; + response = SonHandlerRestTemplate.sendPostToPolicy(requestUrl, requestBody,new ParameterizedTypeReference() {}); + log.debug("policy response{}", response); + + return response.getBody(); + } catch (JsonProcessingException e) { + log.debug("exception", e); + } + return response.getBody(); + + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/RequestInfo.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/RequestInfo.java new file mode 100644 index 0000000..ff53b33 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/RequestInfo.java @@ -0,0 +1,101 @@ +/******************************************************************************* + * ============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.restclient; + +import java.util.List; + +public class RequestInfo { + String transactionId = null; + String requestId = null; + String callbackUrl = null; + String sourceId = null; + String requestType = null; + int numSolutions; + List optimizers = null; + + public void setOptimizers(List optimizers) { + this.optimizers = optimizers; + } + + public List getOptimizers() { + return optimizers; + } + + int timeout; + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getCallbackUrl() { + return callbackUrl; + } + + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public String getSourceId() { + return sourceId; + } + + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + public String getRequestType() { + return requestType; + } + + public void setRequestType(String requestType) { + this.requestType = requestType; + } + + public int getNumSolutions() { + return numSolutions; + } + + public void setNumSolutions(int numSolutions) { + this.numSolutions = numSolutions; + } + + public int getTimeout() { + return timeout; + } + + public void setTimeout(int timeout) { + this.timeout = timeout; + } + + public String getTransactionId() { + return transactionId; + } + + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClient.java new file mode 100644 index 0000000..0894146 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClient.java @@ -0,0 +1,141 @@ +/******************************************************************************* + * ============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.restclient; + +import org.onap.dcaegen2.services.sonhms.Configuration; +import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException; +import org.onap.dcaegen2.services.sonhms.model.CellPciPair; +import org.onap.dcaegen2.services.sonhms.utils.SonHandlerRestTemplate; + +import java.sql.Time; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.ResponseEntity; + + + +public class SdnrRestClient { + + private static final String DATETIMEFORMAT = "yyyy-MM-dd HH:mm:ss"; + private static Logger log = LoggerFactory.getLogger(SdnrRestClient.class); + + private SdnrRestClient() { + + } + + /** + * Method to get cell list from SDNR. + * + * @throws ConfigDbNotFoundException + * when request to configDB fails + */ + public static String getCellList(String networkId) throws ConfigDbNotFoundException { + Configuration configuration = Configuration.getInstance(); + String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis())); + String requestUrl = configuration.getSdnrService() + "/SDNCConfigDBAPI/getCellList" + "/" + networkId + "/" + + encode(ts); + return sendRequest(requestUrl); + } + + /** + * Method to get neibhbour list from SDNR. + * + * @throws ConfigDbNotFoundException + * when request to configDB fails + */ + public static List getNbrList(String cellId) throws ConfigDbNotFoundException { + Configuration configuration = Configuration.getInstance(); + String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis())); + String requestUrl = configuration.getSdnrService() + "/SDNCConfigDBAPI/getNbrList" + "/" + cellId + "/" + + encode(ts); + log.debug("request url: {}", requestUrl); + String response = sendRequest(requestUrl); + List nbrList = new ArrayList<>(); + JSONArray nbrListObj = new JSONArray(response); + for (int i = 0; i < nbrListObj.length(); i++) { + JSONObject cellObj = nbrListObj.getJSONObject(i); + CellPciPair cell = new CellPciPair(cellObj.getString("cellId"), cellObj.getInt("pciValue")); + nbrList.add(cell); + } + + return nbrList; + } + + /** + * Method to get PCI from SDNR. + * + * @throws ConfigDbNotFoundException + * when request to configDB fails + */ + public static int getPci(String cellId) throws ConfigDbNotFoundException { + Configuration configuration = Configuration.getInstance(); + String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis())); + String requestUrl = configuration.getSdnrService() + "/SDNCConfigDBAPI/getPCI" + "/" + cellId + "/" + + encode(ts); + String response = sendRequest(requestUrl); + JSONObject respObj = new JSONObject(response); + return respObj.getInt("value"); + } + + /** + * Method to get PNF name from SDNR. + * + * @throws ConfigDbNotFoundException + * when request to configDB fails + */ + public static String getPnfName(String cellId) throws ConfigDbNotFoundException { + Configuration configuration = Configuration.getInstance(); + String ts = new SimpleDateFormat(DATETIMEFORMAT).format(new Time(System.currentTimeMillis())); + String requestUrl = configuration.getSdnrService() + "/SDNCConfigDBAPI/getPnfName" + "/" + cellId + "/" + + encode(ts); + String response = sendRequest(requestUrl); + JSONObject responseObject = new JSONObject(response); + return responseObject.getString("value"); + } + + /** + * Method to encode url. + */ + private static String encode(String url) { + return url.replace(" ", "%20"); + } + + /** + * Method to send request. + */ + private static String sendRequest(String url) throws ConfigDbNotFoundException { + ResponseEntity response = SonHandlerRestTemplate.sendGetRequest(url, + new ParameterizedTypeReference() {}); + if (response.equals(null)) { + throw new ConfigDbNotFoundException("Cannot reach Config DB"); + } + return response.getBody(); + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/Solution.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/Solution.java new file mode 100644 index 0000000..66af930 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/Solution.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * ============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.restclient; + +import java.util.ArrayList; +import java.util.List; + +public class Solution { + String startTime = null; + String finishTime = null; + String networkId = null; + List pciSolutions = new ArrayList<>(); + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getFinishTime() { + return finishTime; + } + + public void setFinishTime(String finishTime) { + this.finishTime = finishTime; + } + + public String getNetworkId() { + return networkId; + } + + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + public List getPciSolutions() { + return pciSolutions; + } + + /** + * Sets PciSolutions. + */ + public void setPciSolutions(List pciSolutions) { + + this.pciSolutions = pciSolutions; + + } + + @Override + public String toString() { + return "Solutions [startTime=" + startTime + ", finishTime=" + finishTime + ", networkId=" + networkId + + ", pciSolutions=" + pciSolutions + "]"; + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SonSolution.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SonSolution.java new file mode 100644 index 0000000..25f474a --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/SonSolution.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * ============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.restclient; + +public class SonSolution { + + String cellId = null; + int pci; + + public String getCellId() { + return cellId; + } + + public void setCellId(String cellId) { + this.cellId = cellId; + } + + public int getPci() { + return pci; + } + + public void setPci(int pci) { + this.pci = pci; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/AppConfig.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/AppConfig.java new file mode 100644 index 0000000..a30288a --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/AppConfig.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * ============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.utils; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.http.converter.ByteArrayHttpMessageConverter; +import org.springframework.web.client.RestTemplate; + +@Configuration +public class AppConfig { + + + /** + * Rest Template bean. + */ + @Bean + public static RestTemplate initRestTemplateForPdfAsByteArrayAndSelfSignedHttps() { + RestTemplate restTemplate = new RestTemplate(useApacheHttpClientWithSelfSignedSupport()); + restTemplate.getMessageConverters().add(generateByteArrayHttpMessageConverter()); + return restTemplate; + } + + private static HttpComponentsClientHttpRequestFactory useApacheHttpClientWithSelfSignedSupport() { + CloseableHttpClient httpClient = HttpClients.custom().setSSLHostnameVerifier(new NoopHostnameVerifier()) + .build(); + HttpComponentsClientHttpRequestFactory useApacheHttpClient = new HttpComponentsClientHttpRequestFactory(); + useApacheHttpClient.setHttpClient(httpClient); + return useApacheHttpClient; + } + + private static ByteArrayHttpMessageConverter generateByteArrayHttpMessageConverter() { + ByteArrayHttpMessageConverter byteArrayHttpMessageConverter = new ByteArrayHttpMessageConverter(); + + List supportedApplicationTypes = new ArrayList(); + supportedApplicationTypes.add(new MediaType("application", "pdf")); + byteArrayHttpMessageConverter.setSupportedMediaTypes(supportedApplicationTypes); + return byteArrayHttpMessageConverter; + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/BeanUtil.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/BeanUtil.java new file mode 100644 index 0000000..63a738c --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/BeanUtil.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * ============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.utils; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Service; + +@Service +public class BeanUtil implements ApplicationContextAware { + private static ApplicationContext context; + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + context = applicationContext; + } + + public static T getBean(Class beanClass) { + return context.getBean(beanClass); + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java new file mode 100644 index 0000000..79d0c61 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java @@ -0,0 +1,344 @@ +/******************************************************************************* + * ============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.utils; + +import org.onap.dcaegen2.services.sonhms.ClusterDetailsComponent; +import org.onap.dcaegen2.services.sonhms.NotificationToClusterMapping; +import org.onap.dcaegen2.services.sonhms.child.Graph; +import org.onap.dcaegen2.services.sonhms.dao.ClusterDetailsRepository; +import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails; +import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException; +import org.onap.dcaegen2.services.sonhms.model.CellPciPair; +import org.onap.dcaegen2.services.sonhms.model.FapServiceList; +import org.onap.dcaegen2.services.sonhms.model.LteNeighborListInUseLteCell; +import org.onap.dcaegen2.services.sonhms.model.Notification; +import org.onap.dcaegen2.services.sonhms.restclient.SdnrRestClient; + +import fj.data.Either; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + + +public class ClusterUtils { + + private static Logger log = LoggerFactory.getLogger(ClusterUtils.class); + + public List getAllClusters() { + ClusterDetailsComponent clusterDetailsComponent = new ClusterDetailsComponent(); + return clusterDetailsComponent.getClusterDetails(); + } + + /** + * Get clusters for notifications. + */ + public NotificationToClusterMapping getClustersForNotification(Notification notification, + List clusterDetails) { + + NotificationToClusterMapping mapping = new NotificationToClusterMapping(); + + Map cellsInCluster = new HashMap<>(); + List newCells = new ArrayList<>(); + + List fapServiceList = notification.getPayload().getRadioAccess().getFapServiceList(); + + for (FapServiceList fapService : fapServiceList) { + + for (ClusterDetails clusterDetail : clusterDetails) { + + Set cellsInNotification = getCellsInNotification(fapService); + + Graph cluster = new Graph(clusterDetail.getClusterInfo()); + + Set clusterCells = getCellsInCluster(cluster); + + log.debug("cells in cluster {}", clusterCells); + + cellsInNotification.retainAll(clusterCells); + + if (!cellsInNotification.isEmpty()) { + log.debug("cell or it's neighbour in the cluster"); + cellsInCluster.put(fapService, clusterDetail.getClusterId()); + break; + } + } + + if (!cellsInCluster.containsKey(fapService)) { + newCells.add(fapService); + } + } + + mapping.setCellsinCluster(cellsInCluster); + mapping.setNewCells(newCells); + return mapping; + } + + /** + * Get cluster details from cluster ID. + */ + public Either getClusterDetailsFromClusterId(String clusterId, + List clusterDetails) { + + for (ClusterDetails clusterDetail : clusterDetails) { + if (clusterDetail.getClusterId().equals(clusterId)) { + return Either.left(clusterDetail); + } + } + return Either.right(404); + } + + /** + * Get clusters for Cell. + */ + public Either getClusterForCell(FapServiceList fapService, List newClusters) { + + if (newClusters.isEmpty()) { + return Either.right(404); + } + + + for (Graph cluster : newClusters) { + + Set cellsInNotification = getCellsInNotification(fapService); + Set clusterCells = getCellsInCluster(cluster); + + cellsInNotification.retainAll(clusterCells); + + if (!(cellsInNotification.isEmpty())) { + return Either.left(cluster); + } + + } + + return Either.right(404); + } + + private Set getCellsInNotification(FapServiceList fapService) { + Set cellsInNotification = new HashSet<>(); + cellsInNotification.add(fapService.getAlias()); + List nbrList = fapService.getCellConfig().getLte().getRan().getNeighborListInUse() + .getLteNeighborListInUseLteCell(); + for (LteNeighborListInUseLteCell nbr : nbrList) { + cellsInNotification.add(nbr.getAlias()); + } + + return cellsInNotification; + } + + private Set getCellsInCluster(Graph cluster) { + Map> cellPciNeighbourMap = cluster.getCellPciNeighbourMap(); + log.debug("cell_pci_map {}", cellPciNeighbourMap); + Set keys = cellPciNeighbourMap.keySet(); + Set clusterCells = new HashSet<>(); + for (CellPciPair cellPciPair : keys) { + log.debug("cells {}", cellPciPair.getCellId()); + clusterCells.add(cellPciPair.getCellId()); + } + + return clusterCells; + } + + /** + * Create cluster from notification. + */ + public Graph createCluster(FapServiceList fapService) throws ConfigDbNotFoundException { + + Graph cluster = new Graph(); + log.debug("cluster formation started"); + int phycellId = fapService.getX0005b9Lte().getPhyCellIdInUse(); + String cellId = fapService.getCellConfig().getLte().getRan().getCellIdentity(); + + CellPciPair val = new CellPciPair(); + val.setCellId(cellId); + val.setPhysicalCellId(phycellId); + List neighbourlist; + neighbourlist = fapService.getCellConfig().getLte().getRan().getNeighborListInUse() + .getLteNeighborListInUseLteCell(); + log.debug("Neighbor list size: {}", neighbourlist.size()); + + for (int i = 0; i < neighbourlist.size(); i++) { + String cell = neighbourlist.get(i).getAlias(); + int phy = neighbourlist.get(i).getPhyCellId(); + + log.debug("cellID: {}", cell); + log.debug("PCI: {}", phy); + CellPciPair val1 = new CellPciPair(); + val1.setCellId(cell); + val1.setPhysicalCellId(phy); + cluster.addEdge(val, val1); + log.debug("cluster: {}", cluster); + + List nbrList = SdnrRestClient.getNbrList(neighbourlist.get(i).getAlias()); + + for (CellPciPair nbr : nbrList) { + String cid = nbr.getCellId(); + int pci = nbr.getPhysicalCellId(); + CellPciPair val3 = new CellPciPair(); + val3.setCellId(cid); + val3.setPhysicalCellId(pci); + + cluster.addEdge(val1, val3); + } + } + + log.debug("final cluster: {}", cluster); + return cluster; + } + + /** + * Save cluster. + */ + public String saveCluster(Graph cluster, UUID clusterId, Long threadId) { + + String cellPciNeighbourString = cluster.getPciNeighbourJson(); + + log.debug("cluster hahsmap to string : {}", cellPciNeighbourString); + cluster.setGraphId(clusterId); + + ClusterDetails details = new ClusterDetails(); + details.setClusterId(clusterId.toString()); + details.setClusterInfo(cellPciNeighbourString); + details.setChildThreadId(threadId); + + ClusterDetailsRepository clusterDetailsRepository = BeanUtil.getBean(ClusterDetailsRepository.class); + clusterDetailsRepository.save(details); + + return clusterId.toString(); + } + + /** + * update cluster. + */ + public Graph modifyCluster(Graph cluster, FapServiceList fapser) { + + int phycellId = fapser.getX0005b9Lte().getPhyCellIdInUse(); + String cellId = fapser.getCellConfig().getLte().getRan().getCellIdentity(); + CellPciPair mainCellPciPair = new CellPciPair(); + mainCellPciPair.setCellId(cellId); + mainCellPciPair.setPhysicalCellId(phycellId); + List newNeighbourList; + newNeighbourList = fapser.getCellConfig().getLte().getRan().getNeighborListInUse() + .getLteNeighborListInUseLteCell(); + + Map> clusterMap; + clusterMap = cluster.getCellPciNeighbourMap(); + + // coe + + List tempCellPair = new ArrayList<>(); + for (Map.Entry> entry : clusterMap.entrySet()) { + CellPciPair oldClusterKeys = entry.getKey(); + tempCellPair.add(oldClusterKeys); + } + + for (CellPciPair entry : tempCellPair) { + String cell = entry.getCellId(); + int physicalCell = entry.getPhysicalCellId(); + CellPciPair mapVal = new CellPciPair(); + mapVal.setCellId(cell); + mapVal.setPhysicalCellId(physicalCell); + + if (cellId.equals(cell)) { + + // removes the old neighbours and adds new neighbours for that cell + cluster.updateVertex(mapVal, mainCellPciPair); + + } + + } + + /////// update cluster with new pci values for the same cell + + if (clusterMap.containsKey(mainCellPciPair)) { + ArrayList oldClusterArray; + oldClusterArray = clusterMap.get(mainCellPciPair); + oldClusterArray.clear(); + + for (int i = 0; i < newNeighbourList.size(); i++) { + String cid = newNeighbourList.get(i).getAlias(); + int phy = newNeighbourList.get(i).getPhyCellId(); + CellPciPair val2 = new CellPciPair(); + val2.setCellId(cid); + val2.setPhysicalCellId(phy); + cluster.addEdge(mainCellPciPair, val2); + } + + } + + for (CellPciPair entry : tempCellPair) { + String cell = entry.getCellId(); + int physicalCell = entry.getPhysicalCellId(); + CellPciPair mapVal = new CellPciPair(); + mapVal.setCellId(cell); + mapVal.setPhysicalCellId(physicalCell); + for (int j = 0; j < newNeighbourList.size(); j++) { + String cid1 = newNeighbourList.get(j).getAlias(); + int phy1 = newNeighbourList.get(j).getPhyCellId(); + CellPciPair val3 = new CellPciPair(); + val3.setCellId(cid1); + val3.setPhysicalCellId(phy1); + + if (cid1.equals(cell)) { + + // removes the old neighbours and adds new neighbours for that cell + cluster.updateVertex(mapVal, val3); + + } + + } + } + + for (int j = 0; j < newNeighbourList.size(); j++) { + String cid1 = newNeighbourList.get(j).getAlias(); + int phy1 = newNeighbourList.get(j).getPhyCellId(); + CellPciPair val3 = new CellPciPair(); + val3.setCellId(cid1); + val3.setPhysicalCellId(phy1); + if (clusterMap.containsKey(val3)) { + cluster.addEdge(mainCellPciPair, val3); + } + + } + + for (int k = 0; k < newNeighbourList.size(); k++) { + String cid2 = newNeighbourList.get(k).getAlias(); + int phy2 = newNeighbourList.get(k).getPhyCellId(); + CellPciPair val5 = new CellPciPair(); + val5.setCellId(cid2); + val5.setPhysicalCellId(phy2); + cluster.addEdge(mainCellPciPair, val5); + } + + log.debug("Modified Cluster {}", cluster); + + return cluster; + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/FileIo.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/FileIo.java new file mode 100644 index 0000000..7eaafbe --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/FileIo.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * ============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.utils; + +import java.io.BufferedReader; +import java.io.FileReader; + +public class FileIo { + + private FileIo() { + + } + + /** + * Reads from File. + */ + public static String readFromFile(String file) { + String content = ""; + try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) { + content = bufferedReader.readLine(); + String temp; + while ((temp = bufferedReader.readLine()) != null) { + content = content.concat(temp); + } + content = content.trim(); + } catch (Exception e) { + content = null; + } + return content; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java new file mode 100644 index 0000000..7745117 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java @@ -0,0 +1,162 @@ +/******************************************************************************* + * ============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.utils; + +import java.util.Collections; + +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +@Component +public class SonHandlerRestTemplate { + @Autowired + static RestTemplate restTemplate; + + private static final String AUTH = "Authorization"; + private static final String EXCEPTION_MSG = "Exception caught during request {}"; + private static final Logger log = org.slf4j.LoggerFactory.getLogger(SonHandlerRestTemplate.class); + + private SonHandlerRestTemplate() { + + } + + /** + * Send Post Request. + */ + + public static ResponseEntity sendPostRequest(String requestUrl, String requestBody, + ParameterizedTypeReference responseType) { + HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + headers.setContentType(MediaType.APPLICATION_JSON); + HttpEntity requestEntity = new HttpEntity<>(requestBody, headers); + try { + return restTemplate.exchange(requestUrl, HttpMethod.POST, requestEntity, responseType); + } catch (Exception e) { + log.debug(EXCEPTION_MSG, e.getMessage()); + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + + /** + * Send Post Request to policy. + */ + public static ResponseEntity sendPostToPolicy(String requestUrl, String requestBody, + ParameterizedTypeReference responseType) { + HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + headers.setContentType(MediaType.APPLICATION_JSON); + headers.add("ClientAuth", "cHl0aG9uOnRlc3Q="); + headers.add(AUTH, "Basic dGVzdHBkcDphbHBoYTEyMw== "); + headers.add("Environment", "TEST"); + HttpEntity requestEntity = new HttpEntity<>(requestBody, headers); + try { + return restTemplate.exchange(requestUrl, HttpMethod.POST, requestEntity, responseType); + } catch (Exception e) { + log.debug(EXCEPTION_MSG, e.getMessage()); + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + + /** + * Send Get Request. + */ + + public static ResponseEntity sendGetRequest(String requestUrl, ParameterizedTypeReference responseType) { + HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + HttpEntity requestEntity = new HttpEntity<>(headers); + try { + return restTemplate.exchange(requestUrl, HttpMethod.GET, requestEntity, responseType); + } catch (Exception e) { + log.debug(EXCEPTION_MSG, e.getMessage()); + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + + /** + * Send Get Request to SDNR. + */ + + public static ResponseEntity sendGetRequest(String requestUrl, String requestBody, + ParameterizedTypeReference responseType) { + HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Collections.singletonList(MediaType.TEXT_PLAIN)); + headers.setContentType(MediaType.APPLICATION_JSON); + headers.add(AUTH, "Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA=="); + HttpEntity requestEntity = new HttpEntity<>(requestBody, headers); + try { + return restTemplate.exchange(requestUrl, HttpMethod.POST, requestEntity, responseType); + } catch (Exception e) { + log.debug(EXCEPTION_MSG, e.getMessage()); + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + + /** + * Send Post Request1. + */ + + public static ResponseEntity sendPostRequest1(String requestUrl, String requestBody, + ParameterizedTypeReference responseType) { + HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + headers.setContentType(MediaType.APPLICATION_JSON); + headers.add(AUTH, "Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA=="); + HttpEntity requestEntity = new HttpEntity<>(requestBody, headers); + try { + return restTemplate.exchange(requestUrl, HttpMethod.POST, requestEntity, responseType); + } catch (Exception e) { + log.debug(EXCEPTION_MSG, e.getMessage()); + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + + /** + * Send Post Request to oof. + */ + + public static ResponseEntity sendPostRequestToOof(String requestUrl, String requestBody, + ParameterizedTypeReference responseType) { + HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + headers.setContentType(MediaType.APPLICATION_JSON); + headers.add(AUTH, "Basic cGNpX3Rlc3Q6cGNpX3Rlc3Rwd2Q="); + HttpEntity requestEntity = new HttpEntity<>(requestBody, headers); + try { + return restTemplate.exchange(requestUrl, HttpMethod.POST, requestEntity, responseType); + } catch (Exception e) { + log.debug(EXCEPTION_MSG, e.getMessage()); + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java new file mode 100644 index 0000000..07e7219 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ThreadUtils.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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.utils; + +import org.onap.dcaegen2.services.sonhms.EventHandler; +import org.onap.dcaegen2.services.sonhms.child.ChildThread; +import org.onap.dcaegen2.services.sonhms.child.Graph; +import org.onap.dcaegen2.services.sonhms.model.FapServiceList; +import org.onap.dcaegen2.services.sonhms.model.ThreadId; + +import java.util.List; +import java.util.UUID; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.LinkedBlockingQueue; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + + +public class ThreadUtils { + + private static Logger log = LoggerFactory.getLogger(ThreadUtils.class); + + /** + * Create thread. + */ + public Boolean createNewThread(List newClusters, BlockingQueue> childStatusQueue, + ExecutorService pool, EventHandler eventHandler) { + for (Graph cluster : newClusters) { + + BlockingQueue queue = new LinkedBlockingQueue<>(); + ThreadId threadId = new ThreadId(); + threadId.setChildThreadId(0); + ChildThread child = new ChildThread(childStatusQueue, cluster, queue, threadId); + pool.execute(child); + waitForThreadId(threadId); + UUID clusterId = UUID.randomUUID(); + + ClusterUtils clusterUtils = new ClusterUtils(); + clusterUtils.saveCluster(cluster, clusterId, threadId.getChildThreadId()); + EventHandler.addChildThreadMap(threadId.getChildThreadId(), child); + eventHandler.addChildStatus(threadId.getChildThreadId(), "processingNotifications"); + } + return true; + + } + + private void waitForThreadId(ThreadId threadId) { + + ThreadId thread = threadId; + try { + synchronized (thread) { + while (thread.getChildThreadId() == 0) { + thread.wait(); + } + } + } catch (InterruptedException e) { + + log.error("ChildThread queue error {}", e); + Thread.currentThread().interrupt(); + } + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 335ad96..5905adf 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,22 +1,24 @@ -#------------------------------------------------------------------------------- -# ============LICENSE_START======================================================= -# pcims +############################################################################### +# ============LICENSE_START======================================================= +# son-handler # ================================================================================ -# Copyright (C) 2018 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========================================================= -#------------------------------------------------------------------------------- +# 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========================================================= +# +############################################################################### + spring.datasource.url= jdbc:postgresql://pcims-db:5432/sonh_ms spring.datasource.username=postgres diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index f37bd58..160ff9c 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -1,23 +1,24 @@ + ============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========================================================= + + --> diff --git a/src/test/java/com/wipro/www/sonhms/ApplicationTest.java b/src/test/java/com/wipro/www/sonhms/ApplicationTest.java deleted file mode 100644 index 892e0c2..0000000 --- a/src/test/java/com/wipro/www/sonhms/ApplicationTest.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -public class ApplicationTest { - -} diff --git a/src/test/java/com/wipro/www/sonhms/BufferNotificationComponentTest.java b/src/test/java/com/wipro/www/sonhms/BufferNotificationComponentTest.java deleted file mode 100644 index 08779e4..0000000 --- a/src/test/java/com/wipro/www/sonhms/BufferNotificationComponentTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.wipro.www.sonhms.dao.BufferedNotificationsRepository; -import com.wipro.www.sonhms.entity.BufferedNotifications; -import com.wipro.www.sonhms.utils.BeanUtil; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -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.MockitoAnnotations; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.modules.junit4.PowerMockRunnerDelegate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.data.web.ProjectedPayload; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.web.client.RestTemplate; - -@RunWith(PowerMockRunner.class) -@PowerMockRunnerDelegate(SpringRunner.class) -@PrepareForTest({ BeanUtil.class }) -@SpringBootTest(classes = BufferNotificationComponent.class) -public class BufferNotificationComponentTest { - - @Mock - private BufferedNotificationsRepository bufferedNotificationsRepositoryMock; - - @InjectMocks - private BufferNotificationComponent bufferNotificationComponent; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - } - - @Test - public void bufferNotificationTest() { - BufferedNotifications bufferedNotifications = new BufferedNotifications(); - bufferedNotifications.setClusterId("clusterId"); - bufferedNotifications.setNotification("notification"); - PowerMockito.mockStatic(BeanUtil.class); - PowerMockito.when(BeanUtil.getBean(BufferedNotificationsRepository.class)) - .thenReturn(bufferedNotificationsRepositoryMock); - when(bufferedNotificationsRepositoryMock.save(bufferedNotifications)).thenReturn(bufferedNotifications); - BufferedNotifications bufferedNotificationsResult = new BufferedNotifications(); - bufferNotificationComponent.bufferNotification("notification", "clusterId"); - assertEquals(bufferedNotifications, bufferedNotificationsRepositoryMock.save(bufferedNotifications)); - - } - - @Test - public void getBufferedNotificationTest() { - List notificationsList = new ArrayList(); - notificationsList.add("NOTIF1"); - notificationsList.add("NOTIF2"); - String clusterId = "clusterId"; - PowerMockito.mockStatic(BeanUtil.class); - PowerMockito.when(BeanUtil.getBean(BufferedNotificationsRepository.class)) - .thenReturn(bufferedNotificationsRepositoryMock); - when(bufferedNotificationsRepositoryMock.getNotificationsFromQueue(clusterId)).thenReturn((notificationsList)); - - List testResult = new ArrayList(); - testResult = bufferNotificationComponent.getBufferedNotification(clusterId); - for (int i = 1; i <= testResult.size(); i++) { - assertEquals("NOTIF" + i, testResult.get(i - 1)); - } - } - - @Test - public void getClusterIdTest() { - String notification = "NOTIF1"; - PowerMockito.mockStatic(BeanUtil.class); - PowerMockito.when(BeanUtil.getBean(BufferedNotificationsRepository.class)) - .thenReturn(bufferedNotificationsRepositoryMock); - when(bufferedNotificationsRepositoryMock.getClusterIdForNotification(notification)).thenReturn(("clusterId")); - String clusterId = bufferNotificationComponent.getClusterId(notification); - assertEquals("clusterId", clusterId); - } - -} diff --git a/src/test/java/com/wipro/www/sonhms/ChildStatusUpdateStateTest.java b/src/test/java/com/wipro/www/sonhms/ChildStatusUpdateStateTest.java deleted file mode 100644 index ea426bf..0000000 --- a/src/test/java/com/wipro/www/sonhms/ChildStatusUpdateStateTest.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -public class ChildStatusUpdateStateTest { - -} diff --git a/src/test/java/com/wipro/www/sonhms/ClusterDetailsComponentTest.java b/src/test/java/com/wipro/www/sonhms/ClusterDetailsComponentTest.java deleted file mode 100644 index 4be6339..0000000 --- a/src/test/java/com/wipro/www/sonhms/ClusterDetailsComponentTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -import com.wipro.www.sonhms.dao.ClusterDetailsRepository; -import com.wipro.www.sonhms.entity.ClusterDetails; -import com.wipro.www.sonhms.utils.BeanUtil; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -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.MockitoAnnotations; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.modules.junit4.PowerMockRunnerDelegate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.data.web.ProjectedPayload; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.web.client.RestTemplate; - -@RunWith(PowerMockRunner.class) -@PowerMockRunnerDelegate(SpringRunner.class) -@PrepareForTest({BeanUtil.class}) -@SpringBootTest(classes = ClusterDetailsComponent.class) -public class ClusterDetailsComponentTest { - - @Mock - private ClusterDetailsRepository clusterDetailsRepositorymock; - - - @InjectMocks - private ClusterDetailsComponent clusterDetailsComponent; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - } - - @Test - public void getClusterDetailsTest() { - ClusterDetails clusterDetails = new ClusterDetails("clusterId", "clusterInfo", 1); - List list = new ArrayList(); - list.add(clusterDetails); - - PowerMockito.mockStatic(BeanUtil.class); - PowerMockito.when(BeanUtil.getBean(ClusterDetailsRepository.class)).thenReturn(clusterDetailsRepositorymock); - System.out.println(clusterDetailsRepositorymock); - when(clusterDetailsRepositorymock.getAllClusterDetails()).thenReturn((list)); - - List resultList = new ArrayList(); - resultList = clusterDetailsComponent.getClusterDetails(); - for (ClusterDetails each : resultList) { - assertEquals("clusterId", each.getClusterId()); - assertEquals("clusterInfo", each.getClusterInfo()); - assertEquals(1, each.getChildThreadId()); - - } - - } - - @Test - public void getChildThreadTest() { - String clusterId = "clusterId"; - - PowerMockito.mockStatic(BeanUtil.class); - PowerMockito.when(BeanUtil.getBean(ClusterDetailsRepository.class)).thenReturn(clusterDetailsRepositorymock); - when(clusterDetailsRepositorymock.getChildThreadForCluster(clusterId)).thenReturn((long)1); - long childThreadId = clusterDetailsComponent.getChildThread(clusterId); - assertEquals(1, childThreadId); - - } - - @Test - public void getClusterIdTest() { - long childThreadId = 1; - - PowerMockito.mockStatic(BeanUtil.class); - PowerMockito.when(BeanUtil.getBean(ClusterDetailsRepository.class)).thenReturn(clusterDetailsRepositorymock); - when(clusterDetailsRepositorymock.getClusterIdForChildThread(childThreadId)) - .thenReturn("clusterId"); - String clusterId = clusterDetailsComponent.getClusterId(childThreadId); - assertEquals("clusterId", clusterId); - } -} diff --git a/src/test/java/com/wipro/www/sonhms/ConfigPolicyTest.java b/src/test/java/com/wipro/www/sonhms/ConfigPolicyTest.java deleted file mode 100644 index 85b1c44..0000000 --- a/src/test/java/com/wipro/www/sonhms/ConfigPolicyTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import static org.junit.Assert.assertEquals; - -import com.wipro.www.sonhms.ConfigPolicy; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; - - -public class ConfigPolicyTest { - - @Test - public void configPolicyTest() { - ConfigPolicy configPolicy = ConfigPolicy.getInstance(); - Map config = new HashMap(); - config.put("policyName", "pcims_policy"); - configPolicy.setConfig(config); - assertEquals(config, configPolicy.getConfig()); - } -} diff --git a/src/test/java/com/wipro/www/sonhms/ConfigurationTest.java b/src/test/java/com/wipro/www/sonhms/ConfigurationTest.java deleted file mode 100644 index 06294dd..0000000 --- a/src/test/java/com/wipro/www/sonhms/ConfigurationTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import static org.junit.Assert.assertEquals; - -import com.wipro.www.sonhms.Configuration; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - - -public class ConfigurationTest { - Configuration configuration = Configuration.getInstance(); - - @Test - public void configurationTest() { - configuration.setBufferTime(60); - configuration.setCallbackUrl("/callbackUrl"); - configuration.setConfigName("configName"); - - List list = new ArrayList(); - list.add("server"); - configuration.setServers(list); - configuration.setCg("cg"); - configuration.setCid("cid"); - configuration.setManagerApiKey("managerApiKey"); - configuration.setManagerSecretKey("managerSecretKey"); - configuration.setMaximumClusters(5); - configuration.setMinCollision(5); - configuration.setMinConfusion(5); - configuration.setNumSolutions(1); - configuration.setOofService("oofService"); - configuration.setOptimizers(list); - configuration.setPcimsApiKey("pcimsApiKey"); - configuration.setPcimsSecretKey("pcimsSecretKey"); - configuration.setPolicyName("policyName"); - configuration.setPolicyService("policyService"); - configuration.setPolicyTopic("policyTopic"); - configuration.setPollingInterval(30); - configuration.setPollingTimeout(100); - configuration.setSdnrService("sdnrService"); - configuration.setSdnrTopic("sdnrTopic"); - configuration.setSourceId("sourceId"); - assertEquals(60, configuration.getBufferTime()); - assertEquals("/callbackUrl", configuration.getCallbackUrl()); - assertEquals("cg", configuration.getCg()); - assertEquals("cid", configuration.getCid()); - assertEquals("managerApiKey", configuration.getManagerApiKey()); - assertEquals("managerSecretKey", configuration.getManagerSecretKey()); - assertEquals(5, configuration.getMaximumClusters()); - assertEquals(5, configuration.getMinCollision()); - assertEquals(5, configuration.getMinConfusion()); - assertEquals(1, configuration.getNumSolutions()); - assertEquals("oofService", configuration.getOofService()); - assertEquals(list, configuration.getOptimizers()); - assertEquals("pcimsApiKey", configuration.getPcimsApiKey()); - assertEquals("pcimsSecretKey", configuration.getPcimsSecretKey()); - assertEquals("policyName", configuration.getPolicyName()); - assertEquals("policyService", configuration.getPolicyService()); - assertEquals("policyTopic", configuration.getPolicyTopic()); - assertEquals(30, configuration.getPollingInterval()); - assertEquals(100, configuration.getPollingTimeout()); - assertEquals("sdnrService", configuration.getSdnrService()); - assertEquals("sdnrTopic", configuration.getSdnrTopic()); - assertEquals(list, configuration.getServers()); - assertEquals("sourceId", configuration.getSourceId()); - } -} diff --git a/src/test/java/com/wipro/www/sonhms/SdnrNotificationHandlingStateTest.java b/src/test/java/com/wipro/www/sonhms/SdnrNotificationHandlingStateTest.java deleted file mode 100644 index d6e2dfc..0000000 --- a/src/test/java/com/wipro/www/sonhms/SdnrNotificationHandlingStateTest.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import org.junit.Test; - -public class SdnrNotificationHandlingStateTest { - - @Test - public void sdnrNotificationHandlingState() { - - } -} diff --git a/src/test/java/com/wipro/www/sonhms/SonContextTest.java b/src/test/java/com/wipro/www/sonhms/SonContextTest.java deleted file mode 100644 index e7e6790..0000000 --- a/src/test/java/com/wipro/www/sonhms/SonContextTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import com.wipro.www.sonhms.SdnrNotificationHandlingState; -import com.wipro.www.sonhms.SonContext; - -import java.util.List; -import java.util.concurrent.BlockingQueue; - -import org.junit.Test; - - - -public class SonContextTest { - - private BlockingQueue> childStatusUpdate; - - @Test - public void sonContextTest() { - SonContext sonContext = new SonContext(); - sonContext.setChildThreadId(1); - sonContext.setNotifToBeProcessed(true); - sonContext.setSdnrNotification("notification"); - sonContext.setChildStatusUpdate(childStatusUpdate); - NewNotification newNotification = new NewNotification(true); - sonContext.setNewNotification(newNotification); - SdnrNotificationHandlingState pciState = new SdnrNotificationHandlingState(); - sonContext.setPciState(pciState); - assertEquals(1, sonContext.getChildThreadId()); - assertTrue(sonContext.isNotifToBeProcessed()); - assertEquals("notification", sonContext.getSdnrNotification()); - assertEquals(pciState, sonContext.getPciState()); - assertEquals(childStatusUpdate, sonContext.getChildStatusUpdate()); - assertEquals(newNotification, sonContext.getNewNotification()); - - } -} diff --git a/src/test/java/com/wipro/www/sonhms/WaitStateTest.java b/src/test/java/com/wipro/www/sonhms/WaitStateTest.java deleted file mode 100644 index 10ae3d7..0000000 --- a/src/test/java/com/wipro/www/sonhms/WaitStateTest.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms; - -public class WaitStateTest { - -} diff --git a/src/test/java/com/wipro/www/sonhms/child/GraphTest.java b/src/test/java/com/wipro/www/sonhms/child/GraphTest.java deleted file mode 100644 index 2132f22..0000000 --- a/src/test/java/com/wipro/www/sonhms/child/GraphTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.child; - -import static org.junit.Assert.assertNotEquals; - -import com.wipro.www.sonhms.child.Graph; -import com.wipro.www.sonhms.model.CellPciPair; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; -import org.slf4j.Logger; - - - -public class GraphTest { - private static final Logger log = org.slf4j.LoggerFactory.getLogger(GraphTest.class); - - @Test - public void graphTest() { - - CellPciPair cpPair1 = new CellPciPair(); - cpPair1.setCellId("25"); - cpPair1.setPhysicalCellId(32); - - CellPciPair cpPair2 = new CellPciPair(); - cpPair2.setCellId("29"); - cpPair2.setPhysicalCellId(209); - - Graph graph = new Graph(); - - graph.addEdge(cpPair1, cpPair2); - - Map> map = new HashMap<>(); - - log.debug("graph {}", graph.getCellPciNeighbourMap()); - System.out.println("graph" + graph.getCellPciNeighbourMap()); - assertNotEquals(map, graph.getCellPciNeighbourMap()); - - } - -} diff --git a/src/test/java/com/wipro/www/sonhms/child/TestClusterModification.java b/src/test/java/com/wipro/www/sonhms/child/TestClusterModification.java deleted file mode 100644 index 148663e..0000000 --- a/src/test/java/com/wipro/www/sonhms/child/TestClusterModification.java +++ /dev/null @@ -1,188 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.child; - -import static org.junit.Assert.assertNotEquals; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.wipro.www.sonhms.child.ClusterModification; -import com.wipro.www.sonhms.child.Graph; -import com.wipro.www.sonhms.model.CellPciPair; -import com.wipro.www.sonhms.model.FapServiceList; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.ConcurrentModificationException; -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; - -public class TestClusterModification { - @Test - public void testClusterModification() { - - CellPciPair cpPair = new CellPciPair(); - cpPair.setCellId("32"); - cpPair.setPhysicalCellId(26); - - CellPciPair cpPair1 = new CellPciPair(); - cpPair1.setCellId("25"); - cpPair1.setPhysicalCellId(23); - - CellPciPair cpPair2 = new CellPciPair(); - cpPair2.setCellId("42"); - cpPair2.setPhysicalCellId(12); - - CellPciPair cpPair3 = new CellPciPair(); - cpPair3.setCellId("56"); - cpPair3.setPhysicalCellId(200); - - CellPciPair cpPair4 = new CellPciPair(); - cpPair4.setCellId("21"); - cpPair4.setPhysicalCellId(6); - - CellPciPair cpPair5 = new CellPciPair(); - cpPair5.setCellId("24"); - cpPair5.setPhysicalCellId(5); - - CellPciPair cpPair6 = new CellPciPair(); - cpPair6.setCellId("38"); - cpPair6.setPhysicalCellId(126); - - CellPciPair cpPair7 = new CellPciPair(); - cpPair7.setCellId("67"); - cpPair7.setPhysicalCellId(300); - - CellPciPair cpPair8 = new CellPciPair(); - cpPair8.setCellId("69"); - cpPair8.setPhysicalCellId(129); - - CellPciPair cpPair9 = new CellPciPair(); - cpPair9.setCellId("78"); - cpPair9.setPhysicalCellId(147); - - ArrayList al = new ArrayList(); - al.add(cpPair1); - al.add(cpPair2); - al.add(cpPair3); - - ArrayList al1 = new ArrayList(); - al1.add(cpPair4); - al1.add(cpPair5); - al1.add(cpPair6); - - ArrayList al2 = new ArrayList(); - al2.add(cpPair7); - al2.add(cpPair8); - al2.add(cpPair9); - - Map> map = new HashMap>(); - - map.put(cpPair, al); - map.put(cpPair1, al1); - map.put(cpPair2, al2); - map.put(cpPair3, new ArrayList()); - map.put(cpPair4, new ArrayList()); - map.put(cpPair5, new ArrayList()); - map.put(cpPair6, new ArrayList()); - map.put(cpPair7, new ArrayList()); - map.put(cpPair8, new ArrayList()); - map.put(cpPair9, new ArrayList()); - Graph cluster = new Graph(); - - cluster.setCellPciNeighbourMap(map); - - System.out.println("map before" + cluster.getCellPciNeighbourMap()); - - String notif = "{ \n" + "\"alias\":\"Cell1\",\n" + "\"X0005b9Lte\":{ \n" + "\"phyCellIdInUse\":\"89\",\n" - + "\"pnfName\":\"DU-1\"\n" + "},\n" + "\"CellConfig\":{ \n" + "\"LTE\":{ \n" + "\"RAN\":{ \n" - + "\"CellIdentity\":\"6\",\n" + "\"NeighborListInUse\":{ \n" + "\"LTECellNumberOfEntries\":\"2\",\n" - + "\"LTENeighborListInUseLTECell\":[ \n" + "{ \n" + "\"pnfName\":\"DU-2\",\n" - + "\"enable\":\"true\",\n" + "\"alias\":\"Cell10\",\n" + "\"mustInclude\":\"true\",\n" - + "\"plmnid\":\"123456\",\n" + "\"cid\":\"2\",\n" + "\"phyCellId\":\"22\",\n" - + "\"blacklisted\":\"false\"\n" + "},\n" + "{ \n" + "\"pnfName\":\"DU-3\",\n" - + "\"enable\":\"true\",\n" + "\"alias\":\"Cell15\",\n" + "\"mustInclude\":\"true\",\n" - + "\"plmnid\":\"123456\",\n" + "\"cid\":\"25\",\n" + "\"phyCellId\":\"35\",\n" - + "\"blacklisted\":\"false\"\n" + "}\n" + "]\n" + "}\n" + "}\n" + "}\n" + "}\n" + "}"; - - ObjectMapper mapper = new ObjectMapper(); - FapServiceList fapser = new FapServiceList(); - try { - fapser = mapper.readValue(notif, FapServiceList.class); - } catch (JsonParseException e) { - e.printStackTrace(); - } catch (JsonMappingException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - - CellPciPair cpPair11 = new CellPciPair(); - cpPair11.setCellId("2"); - cpPair11.setPhysicalCellId(22); - - CellPciPair cpPair12 = new CellPciPair(); - - cpPair12.setCellId("5"); - cpPair12.setPhysicalCellId(24); - - ArrayList al4 = new ArrayList(); - - al4.add(cpPair11); - al4.add(cpPair12); - - Map> newMap = new HashMap>(); - newMap.put(cpPair, al); - newMap.put(cpPair1, al4); - newMap.put(cpPair2, al2); - newMap.put(cpPair3, new ArrayList()); - newMap.put(cpPair4, new ArrayList()); - newMap.put(cpPair5, new ArrayList()); - newMap.put(cpPair6, new ArrayList()); - newMap.put(cpPair7, new ArrayList()); - newMap.put(cpPair8, new ArrayList()); - newMap.put(cpPair9, new ArrayList()); - newMap.put(cpPair11, new ArrayList()); - newMap.put(cpPair12, new ArrayList()); - - Graph newCluster = new Graph(); - newCluster.setCellPciNeighbourMap(newMap); - System.out.print("newCluster" + newCluster.getCellPciNeighbourMap()); - - ClusterModification mod = new ClusterModification(); - try { - // System.out.print("Cluster" + mod.clustermod(cluster, - // fapser).getCellPciNeighbourMap().toString()); - - assertNotEquals(newCluster, mod.clustermod(cluster, fapser)); - - } catch (NullPointerException e) { - e.printStackTrace(); - } catch (ConcurrentModificationException e) { - System.out.println("Concureent execption" + e); - - } - } - -} diff --git a/src/test/java/com/wipro/www/sonhms/child/TestDetection.java b/src/test/java/com/wipro/www/sonhms/child/TestDetection.java deleted file mode 100644 index 03ed787..0000000 --- a/src/test/java/com/wipro/www/sonhms/child/TestDetection.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.child; - - -import com.wipro.www.sonhms.child.Detection; -import com.wipro.www.sonhms.child.Graph; -import com.wipro.www.sonhms.model.CellPciPair; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; - - -public class TestDetection { - @Test - public void testDetection() { - - CellPciPair cpPair = new CellPciPair(); - cpPair.setCellId("32"); - cpPair.setPhysicalCellId(26); - - CellPciPair cpPair1 = new CellPciPair(); - cpPair1.setCellId("25"); - cpPair1.setPhysicalCellId(23); - - CellPciPair cpPair2 = new CellPciPair(); - cpPair2.setCellId("42"); - cpPair2.setPhysicalCellId(26); - - CellPciPair cpPair3 = new CellPciPair(); - cpPair3.setCellId("56"); - cpPair3.setPhysicalCellId(200); - - CellPciPair cpPair4 = new CellPciPair(); - cpPair4.setCellId("21"); - cpPair4.setPhysicalCellId(5); - - CellPciPair cpPair5 = new CellPciPair(); - cpPair5.setCellId("24"); - cpPair5.setPhysicalCellId(5); - - CellPciPair cpPair6 = new CellPciPair(); - cpPair6.setCellId("38"); - cpPair6.setPhysicalCellId(126); - - CellPciPair cpPair7 = new CellPciPair(); - cpPair7.setCellId("67"); - cpPair7.setPhysicalCellId(300); - - CellPciPair cpPair8 = new CellPciPair(); - cpPair8.setCellId("69"); - cpPair8.setPhysicalCellId(129); - - CellPciPair cpPair9 = new CellPciPair(); - cpPair9.setCellId("78"); - cpPair9.setPhysicalCellId(147); - - ArrayList al = new ArrayList(); - al.add(cpPair1); - al.add(cpPair2); - al.add(cpPair3); - - ArrayList al1 = new ArrayList(); - al1.add(cpPair4); - al1.add(cpPair5); - al1.add(cpPair6); - - ArrayList al2 = new ArrayList(); - al2.add(cpPair7); - al2.add(cpPair8); - al2.add(cpPair9); - - Map> map = new HashMap>(); - - map.put(cpPair, al); - map.put(cpPair1, al1); - map.put(cpPair2, al2); - map.put(cpPair3, new ArrayList()); - map.put(cpPair4, new ArrayList()); - map.put(cpPair5, new ArrayList()); - map.put(cpPair6, new ArrayList()); - map.put(cpPair7, new ArrayList()); - map.put(cpPair8, new ArrayList()); - map.put(cpPair9, new ArrayList()); - Graph cluster = new Graph(); - - cluster.setCellPciNeighbourMap(map); - - System.out.println("mapsssssss" + cluster.getCellPciNeighbourMap()); - Detection detect = new Detection(); - detect.detectCollisionConfusion(cluster); - System.out.println("result" + detect.detectCollisionConfusion(cluster)); - - } - -} diff --git a/src/test/java/com/wipro/www/sonhms/model/CellConfigTest.java b/src/test/java/com/wipro/www/sonhms/model/CellConfigTest.java deleted file mode 100644 index 68f8b40..0000000 --- a/src/test/java/com/wipro/www/sonhms/model/CellConfigTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class CellConfigTest { - - @Test - public void cellConfigTest() { - - Common common = new Common(); - common.setCellIdentity("cellIdentity"); - Ran ran = new Ran(); - ran.setCommon(common); - Lte lte = new Lte(); - lte.setRan(ran); - CellConfig cellConfig = new CellConfig(); - cellConfig.setLte(lte); - assertEquals(lte, cellConfig.getLte()); - assertEquals(ran, lte.getRan()); - assertEquals(common, ran.getCommon()); - } -} diff --git a/src/test/java/com/wipro/www/sonhms/model/CellNeighbourListTest.java b/src/test/java/com/wipro/www/sonhms/model/CellNeighbourListTest.java deleted file mode 100644 index 8acc0e8..0000000 --- a/src/test/java/com/wipro/www/sonhms/model/CellNeighbourListTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class CellNeighbourListTest { - - @Test - public void cellNeighbourListTest() { - CellNeighbourList cellNeighbourList = new CellNeighbourList(); - cellNeighbourList.setCellId("cellId"); - cellNeighbourList.setNeighbours("neighbour"); - cellNeighbourList.setPhysicalCellId(1); - assertEquals("cellId",cellNeighbourList.getCellId() ); - assertEquals("neighbour",cellNeighbourList.getNeighbours() ); - assertEquals(1,cellNeighbourList.getPhysicalCellId() ); - - } - -} diff --git a/src/test/java/com/wipro/www/sonhms/model/NotificationPayloadTest.java b/src/test/java/com/wipro/www/sonhms/model/NotificationPayloadTest.java deleted file mode 100644 index d1134fa..0000000 --- a/src/test/java/com/wipro/www/sonhms/model/NotificationPayloadTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import org.junit.Test; - -public class NotificationPayloadTest { - - @Test - public void notificationPayloadTest() { - - } - -} diff --git a/src/test/java/com/wipro/www/sonhms/model/NotificationTest.java b/src/test/java/com/wipro/www/sonhms/model/NotificationTest.java deleted file mode 100644 index 09c6c0a..0000000 --- a/src/test/java/com/wipro/www/sonhms/model/NotificationTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.wipro.www.sonhms.model.FapServiceList; -import com.wipro.www.sonhms.model.LteNeighborListInUseLteCell; -import com.wipro.www.sonhms.model.NeighborListInUse; -import com.wipro.www.sonhms.model.Notification; -import com.wipro.www.sonhms.model.NotificationCellConfig; -import com.wipro.www.sonhms.model.NotificationLte; -import com.wipro.www.sonhms.model.NotificationPayload; -import com.wipro.www.sonhms.model.NotificationRan; -import com.wipro.www.sonhms.model.RadioAccess; -import com.wipro.www.sonhms.model.X0005b9Lte; - -import java.io.IOException; -import java.util.ArrayList; - -import org.junit.Test; - -public class NotificationTest { - - @Test - public void notificationTest() { - - Notification notif = new Notification(); - LteNeighborListInUseLteCell lteNeighborListInUseLteCell = new LteNeighborListInUseLteCell("pnf1", "true", - "Cell10", "true", "123456", "5", 22, "false"); - - ArrayList list = new ArrayList<>(); - list.add(lteNeighborListInUseLteCell); - - NeighborListInUse neighborListInUse = new NeighborListInUse(list, "1"); - - NotificationRan notificationRan = new NotificationRan(neighborListInUse, "Cell25"); - NotificationLte notificationLte = new NotificationLte(notificationRan); - NotificationCellConfig notificationCell = new NotificationCellConfig(notificationLte); - X0005b9Lte lte = new X0005b9Lte(126, "pnf2"); - FapServiceList fap = new FapServiceList("Cell1", lte, notificationCell); - - ArrayList al = new ArrayList<>(); - al.add(fap); - - RadioAccess radioAccess = new RadioAccess("1", al); - NotificationPayload payload = new NotificationPayload(radioAccess); - - notif.setRequestId("9d2d790e-a5f0-11e8-98d0-529269fb1459"); - notif.setAai("{}"); - notif.setAction("NeighborListModified"); - notif.setFrom("SDNR"); - notif.setVersion("1.0.2"); - notif.setPayload(payload); - assertNotEquals("159", notif.getRequestId()); - - String test = "{\n" + " \"requestID\": \"9d2d790e-a5f0-11e8-98d0-529269fb1459\",\n" + " \"AAI\": {},\n" - + " \"from\": \"SDNR\",\n" + " \"version\": \"1.0.2\",\n" - + " \"Action\": \"NeighborListModified\",\n" + " \"Payload\": {\n" + "\n" + " \"RadioAccess\":{ \n" - + " \"FAPServiceNumberOfEntries\":\"2\",\n" + " \"FAPServiceList\":[ \n" + " { \n" - + " \"alias\":\"Cell1\",\n" + " \"X0005b9Lte\":{ \n" - + " \"phyCellIdInUse\":\"35\",\n" + " \"pnfName\":\"DU-1\"\n" - + " },\n" + " \"CellConfig\":{ \n" + " \"LTE\":{ \n" - + " \"RAN\":{ \n" + " \"CellIdentity\":\"Cell1\",\n" - + " \"NeighborListInUse\":{ \n" - + " \"LTECellNumberOfEntries\":\"2\",\n" - + " \"LTENeighborListInUseLTECell\":[ \n" + " { \n" - + " \"pnfName\":\"DU-2\",\n" - + " \"enable\":\"true\",\n" - + " \"alias\":\"Cell10\",\n" - + " \"mustInclude\":\"true\",\n" - + " \"plmnid\":\"123456\",\n" - + " \"cid\":\"2\",\n" - + " \"phyCellId\":\"22\",\n" - + " \"blacklisted\":\"false\"\n" + " },\n" - + " { \n" + " \"pnfName\":\"DU-3\",\n" - + " \"enable\":\"true\",\n" - + " \"alias\":\"Cell15\",\n" - + " \"mustInclude\":\"true\",\n" - + " \"plmnid\":\"123456\",\n" - + " \"cid\":\"5\",\n" - + " \"phyCellId\":\"24\",\n" - + " \"blacklisted\":\"false\"\n" + " }\n" - + " ]\n" + " }\n" + " }\n" - + " }\n" + " }\n" + " }\n" + " ]\n" + " }\n" + "}\n" + "}"; - - ObjectMapper mapper = new ObjectMapper(); - Notification notif1 = new Notification(); - try { - notif1 = mapper.readValue(test, Notification.class); - } catch (JsonParseException e) { - e.printStackTrace(); - } catch (JsonMappingException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - - assertNotEquals(notif, notif1); - assertEquals(notif.getAction(), notif1.getAction()); - assertEquals(notif.getAai().toString(), notif1.getAai().toString()); - - } - -} diff --git a/src/test/java/com/wipro/www/sonhms/model/PayloadTest.java b/src/test/java/com/wipro/www/sonhms/model/PayloadTest.java deleted file mode 100644 index 1c006f9..0000000 --- a/src/test/java/com/wipro/www/sonhms/model/PayloadTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import static org.junit.Assert.assertEquals; - -import com.wipro.www.sonhms.model.CellConfig; -import com.wipro.www.sonhms.model.Common; -import com.wipro.www.sonhms.model.Configurations; -import com.wipro.www.sonhms.model.Data; -import com.wipro.www.sonhms.model.FapService; -import com.wipro.www.sonhms.model.Lte; -import com.wipro.www.sonhms.model.Payload; -import com.wipro.www.sonhms.model.Ran; -import com.wipro.www.sonhms.model.X0005b9Lte; - -import java.util.ArrayList; - -import org.junit.Test; - - - -public class PayloadTest { - - @Test - public void payloadTest() { - Common common = new Common("cell1"); - - Ran ran = new Ran(common); - - Lte lte = new Lte(ran); - - CellConfig cellConfig = new CellConfig(lte); - - X0005b9Lte x0005b9Lte = new X0005b9Lte(0, "pnf2"); - - FapService fapService = new FapService("cell6", x0005b9Lte, cellConfig); - - Data data = new Data(fapService); - - Configurations config = new Configurations(data); - ArrayList al = new ArrayList<>(); - al.add(config); - - Payload payload = new Payload(al); - - assertEquals("pnf2", payload.getConfiguration().get(0).getData().getFapservice().getX0005b9Lte().getPnfName()); - - assertEquals("cell6", payload.getConfiguration().get(0).getData().getFapservice().getAlias()); - - } - -} diff --git a/src/test/java/com/wipro/www/sonhms/model/ResponseTest.java b/src/test/java/com/wipro/www/sonhms/model/ResponseTest.java deleted file mode 100644 index c413791..0000000 --- a/src/test/java/com/wipro/www/sonhms/model/ResponseTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.model; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class ResponseTest { - - @Test - public void respomseTest() { - Response response = new Response(); - response.setCellId("cellId"); - response.setPci(1); - assertEquals("cellId", response.getCellId()); - assertEquals(1, response.getPci()); - } - -} diff --git a/src/test/java/com/wipro/www/sonhms/restclient/AsyncResponseBodyTest.java b/src/test/java/com/wipro/www/sonhms/restclient/AsyncResponseBodyTest.java deleted file mode 100644 index 95afd77..0000000 --- a/src/test/java/com/wipro/www/sonhms/restclient/AsyncResponseBodyTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; - -import com.wipro.www.sonhms.restclient.AsyncResponseBody; -import com.wipro.www.sonhms.restclient.Solution; -import com.wipro.www.sonhms.restclient.SonSolution; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - - - -public class AsyncResponseBodyTest { - - @Test - public void asyncResponseBodyTest() { - AsyncResponseBody asyncResponseBody = new AsyncResponseBody(); - asyncResponseBody.setRequestId("e44a4165-3cf4-4362-89de-e2375eed97e7"); - asyncResponseBody.setRequestStatus("completed"); - SonSolution pciSolutions = new SonSolution(); - pciSolutions.setCellId("EXP001"); - pciSolutions.setPci(101); - List pciSolutionsList = new ArrayList(); - pciSolutionsList.add(pciSolutions); - Solution solutions = new Solution(); - solutions.setFinishTime("2018-10-01T00:40+01.00"); - solutions.setNetworkId("EXP001"); - solutions.setPciSolutions(pciSolutionsList); - solutions.setStartTime("2018-10-01T00:30+01:00"); - ArrayList solutionsList = new ArrayList(); - solutionsList.add(solutions); - asyncResponseBody.setSolutions(solutionsList); - asyncResponseBody.setStatusMessage("success"); - asyncResponseBody.setTransactionId("3df7b0e9-26d1-4080-ba42-28e8a3139689"); - } -} diff --git a/src/test/java/com/wipro/www/sonhms/restclient/CellInfoTest.java b/src/test/java/com/wipro/www/sonhms/restclient/CellInfoTest.java deleted file mode 100644 index b686f93..0000000 --- a/src/test/java/com/wipro/www/sonhms/restclient/CellInfoTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; - -import static org.junit.Assert.assertEquals; - -import com.wipro.www.sonhms.restclient.CellInfo; - -import java.util.ArrayList; -import java.util.List; -import org.junit.Test; - - -public class CellInfoTest { - @Test - public void cellInfoTest() { - List cellIdLists = new ArrayList<>(); - cellIdLists.add("cell1"); - - CellInfo cellInfo = new CellInfo(); - cellInfo.setNetworkId("NTWK001"); - cellInfo.setCellIdList(cellIdLists); - assertEquals("NTWK001", cellInfo.getNetworkId()); - assertEquals(cellIdLists, cellInfo.getCellIdList()); - - } -} diff --git a/src/test/java/com/wipro/www/sonhms/restclient/OofRequestBodyTest.java b/src/test/java/com/wipro/www/sonhms/restclient/OofRequestBodyTest.java deleted file mode 100644 index 493095b..0000000 --- a/src/test/java/com/wipro/www/sonhms/restclient/OofRequestBodyTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; - -import static org.junit.Assert.assertEquals; - -import com.wipro.www.sonhms.restclient.CellInfo; -import com.wipro.www.sonhms.restclient.OofRequestBody; -import com.wipro.www.sonhms.restclient.RequestInfo; - -import java.util.ArrayList; -import java.util.List; -import org.junit.Test; - - - -public class OofRequestBodyTest { - @Test - public void oofRequestBodyTest() { - - List cellIdLists = new ArrayList<>(); - cellIdLists.add("cell1"); - CellInfo cellInfo = new CellInfo(); - cellInfo.setNetworkId("NTWK001"); - cellInfo.setCellIdList(cellIdLists); - RequestInfo requestInfo = new RequestInfo(); - List optimizers = new ArrayList(); - optimizers.add("PCI"); - requestInfo.setCallbackUrl(""); - requestInfo.setNumSolutions(1); - requestInfo.setOptimizers(optimizers); - requestInfo.setRequestId("e44a4165-3cf4-4362-89de-e2375eed97e7"); - requestInfo.setRequestType("create"); - requestInfo.setSourceId("PCIHMS"); - requestInfo.setTimeout(60); - requestInfo.setTransactionId("3df7b0e9-26d1-4080-ba42-28e8a3139689"); - - OofRequestBody oofRequestBody = new OofRequestBody(); - oofRequestBody.setCellInfo(cellInfo); - oofRequestBody.setRequestInfo(requestInfo); - assertEquals(requestInfo, oofRequestBody.getRequestInfo()); - assertEquals(cellInfo, oofRequestBody.getCellInfo()); - } -} diff --git a/src/test/java/com/wipro/www/sonhms/restclient/OofRestClientTest.java b/src/test/java/com/wipro/www/sonhms/restclient/OofRestClientTest.java deleted file mode 100644 index 2f06f0a..0000000 --- a/src/test/java/com/wipro/www/sonhms/restclient/OofRestClientTest.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; - -public class OofRestClientTest { - -} diff --git a/src/test/java/com/wipro/www/sonhms/restclient/PciSolutionsTest.java b/src/test/java/com/wipro/www/sonhms/restclient/PciSolutionsTest.java deleted file mode 100644 index e7aac21..0000000 --- a/src/test/java/com/wipro/www/sonhms/restclient/PciSolutionsTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; - -import static org.junit.Assert.assertEquals; - -import com.wipro.www.sonhms.restclient.SonSolution; - -import org.junit.Test; - - -public class PciSolutionsTest { - @Test - public void pciSolutionsTest() { - SonSolution pciSolutions = new SonSolution(); - pciSolutions.setCellId("EXP001"); - pciSolutions.setPci(101); - assertEquals("EXP001", pciSolutions.getCellId()); - assertEquals(101, pciSolutions.getPci()); - } - -} diff --git a/src/test/java/com/wipro/www/sonhms/restclient/PolicyRequestBodyTest.java b/src/test/java/com/wipro/www/sonhms/restclient/PolicyRequestBodyTest.java deleted file mode 100644 index 0726c31..0000000 --- a/src/test/java/com/wipro/www/sonhms/restclient/PolicyRequestBodyTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; - -import static org.junit.Assert.assertEquals; - -import com.wipro.www.sonhms.restclient.PolicyRequestBody; - -import org.junit.Test; - - -public class PolicyRequestBodyTest { - @Test - public void policyRequestBodyTest() { - PolicyRequestBody policyRequestBody = new PolicyRequestBody(); - policyRequestBody.setConfigName("PCIMS_CONFIG_POLICY"); - policyRequestBody.setPolicyName("com.PCIMS_CONFIG_POLICY"); - policyRequestBody.setRequestId("60fe7fe6-2649-4f6c-8468-30eb03fd0527"); - assertEquals("PCIMS_CONFIG_POLICY", policyRequestBody.getConfigName()); - assertEquals("com.PCIMS_CONFIG_POLICY", policyRequestBody.getPolicyName()); - assertEquals("60fe7fe6-2649-4f6c-8468-30eb03fd0527", policyRequestBody.getRequestId()); - - } - -} diff --git a/src/test/java/com/wipro/www/sonhms/restclient/RequestInfoTest.java b/src/test/java/com/wipro/www/sonhms/restclient/RequestInfoTest.java deleted file mode 100644 index f21971b..0000000 --- a/src/test/java/com/wipro/www/sonhms/restclient/RequestInfoTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; - -import static org.junit.Assert.assertEquals; - -import com.wipro.www.sonhms.restclient.RequestInfo; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - - -public class RequestInfoTest { - @Test - public void requestInfoTest() { - RequestInfo requestInfo = new RequestInfo(); - List optimizers = new ArrayList(); - optimizers.add("PCI"); - requestInfo.setCallbackUrl(""); - requestInfo.setNumSolutions(1); - requestInfo.setOptimizers(optimizers); - requestInfo.setRequestId("e44a4165-3cf4-4362-89de-e2375eed97e7"); - requestInfo.setRequestType("create"); - requestInfo.setSourceId("PCIHMS"); - requestInfo.setTimeout(60); - requestInfo.setTransactionId("3df7b0e9-26d1-4080-ba42-28e8a3139689"); - assertEquals(1, requestInfo.getNumSolutions()); - assertEquals(optimizers, requestInfo.getOptimizers()); - assertEquals("create", requestInfo.getRequestType()); - assertEquals("PCIHMS", requestInfo.getSourceId()); - assertEquals("3df7b0e9-26d1-4080-ba42-28e8a3139689", requestInfo.getTransactionId()); - assertEquals("e44a4165-3cf4-4362-89de-e2375eed97e7", requestInfo.getRequestId()); - assertEquals(60, requestInfo.getTimeout()); - assertEquals("", requestInfo.getCallbackUrl()); - } - -} diff --git a/src/test/java/com/wipro/www/sonhms/restclient/SolutionsTest.java b/src/test/java/com/wipro/www/sonhms/restclient/SolutionsTest.java deleted file mode 100644 index 64985f6..0000000 --- a/src/test/java/com/wipro/www/sonhms/restclient/SolutionsTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * pcims - * ================================================================================ - * Copyright (C) 2018 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 com.wipro.www.sonhms.restclient; - -import static org.junit.Assert.assertEquals; - -import com.wipro.www.sonhms.restclient.Solution; -import com.wipro.www.sonhms.restclient.SonSolution; -import java.util.ArrayList; -import java.util.List; -import org.junit.Test; - - - -public class SolutionsTest { - - @Test - public void solutionsTest() { - - SonSolution pciSolutions = new SonSolution(); - pciSolutions.setCellId("EXP001"); - pciSolutions.setPci(101); - List pciSolutionsList = new ArrayList(); - pciSolutionsList.add(pciSolutions); - Solution solutions = new Solution(); - solutions.setFinishTime("2018-10-01T00:40+01.00"); - solutions.setNetworkId("EXP001"); - solutions.setPciSolutions(pciSolutionsList); - solutions.setStartTime("2018-10-01T00:30+01:00"); - assertEquals("2018-10-01T00:40+01.00", solutions.getFinishTime()); - assertEquals("EXP001", solutions.getNetworkId()); - assertEquals(pciSolutionsList, solutions.getPciSolutions()); - assertEquals("2018-10-01T00:30+01:00", solutions.getStartTime()); - - } - -} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/ApplicationTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/ApplicationTest.java new file mode 100644 index 0000000..1b3453a --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/ApplicationTest.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * ============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; + +public class ApplicationTest { + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponentTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponentTest.java new file mode 100644 index 0000000..19fe536 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/BufferNotificationComponentTest.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * ============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; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.onap.dcaegen2.services.sonhms.dao.BufferedNotificationsRepository; +import org.onap.dcaegen2.services.sonhms.entity.BufferedNotifications; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.PowerMockRunnerDelegate; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(PowerMockRunner.class) +@PowerMockRunnerDelegate(SpringRunner.class) +@PrepareForTest({ BeanUtil.class }) +@SpringBootTest(classes = BufferNotificationComponent.class) +public class BufferNotificationComponentTest { + + @Mock + private BufferedNotificationsRepository bufferedNotificationsRepositoryMock; + + @InjectMocks + private BufferNotificationComponent bufferNotificationComponent; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void bufferNotificationTest() { + BufferedNotifications bufferedNotifications = new BufferedNotifications(); + bufferedNotifications.setClusterId("clusterId"); + bufferedNotifications.setNotification("notification"); + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil.getBean(BufferedNotificationsRepository.class)) + .thenReturn(bufferedNotificationsRepositoryMock); + when(bufferedNotificationsRepositoryMock.save(bufferedNotifications)).thenReturn(bufferedNotifications); + bufferNotificationComponent.bufferNotification("notification", "clusterId"); + assertEquals(bufferedNotifications, bufferedNotificationsRepositoryMock.save(bufferedNotifications)); + + } + + @Test + public void getBufferedNotificationTest() { + List notificationsList = new ArrayList(); + notificationsList.add("NOTIF1"); + notificationsList.add("NOTIF2"); + String clusterId = "clusterId"; + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil.getBean(BufferedNotificationsRepository.class)) + .thenReturn(bufferedNotificationsRepositoryMock); + when(bufferedNotificationsRepositoryMock.getNotificationsFromQueue(clusterId)).thenReturn((notificationsList)); + + List testResult = new ArrayList(); + testResult = bufferNotificationComponent.getBufferedNotification(clusterId); + for (int i = 1; i <= testResult.size(); i++) { + assertEquals("NOTIF" + i, testResult.get(i - 1)); + } + } + + @Test + public void getClusterIdTest() { + String notification = "NOTIF1"; + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil.getBean(BufferedNotificationsRepository.class)) + .thenReturn(bufferedNotificationsRepositoryMock); + when(bufferedNotificationsRepositoryMock.getClusterIdForNotification(notification)).thenReturn(("clusterId")); + String clusterId = bufferNotificationComponent.getClusterId(notification); + assertEquals("clusterId", clusterId); + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponentTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponentTest.java new file mode 100644 index 0000000..22d0ccf --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/ClusterDetailsComponentTest.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * ============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; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.onap.dcaegen2.services.sonhms.dao.ClusterDetailsRepository; +import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.PowerMockRunnerDelegate; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(PowerMockRunner.class) +@PowerMockRunnerDelegate(SpringRunner.class) +@PrepareForTest({BeanUtil.class}) +@SpringBootTest(classes = ClusterDetailsComponent.class) +public class ClusterDetailsComponentTest { + + @Mock + private ClusterDetailsRepository clusterDetailsRepositorymock; + + + @InjectMocks + private ClusterDetailsComponent clusterDetailsComponent; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void getClusterDetailsTest() { + ClusterDetails clusterDetails = new ClusterDetails("clusterId", "clusterInfo", 1); + List list = new ArrayList(); + list.add(clusterDetails); + + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil.getBean(ClusterDetailsRepository.class)).thenReturn(clusterDetailsRepositorymock); + System.out.println(clusterDetailsRepositorymock); + when(clusterDetailsRepositorymock.getAllClusterDetails()).thenReturn((list)); + + List resultList = new ArrayList(); + resultList = clusterDetailsComponent.getClusterDetails(); + for (ClusterDetails each : resultList) { + assertEquals("clusterId", each.getClusterId()); + assertEquals("clusterInfo", each.getClusterInfo()); + assertEquals(1, each.getChildThreadId()); + + } + + } + + @Test + public void getChildThreadTest() { + String clusterId = "clusterId"; + + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil.getBean(ClusterDetailsRepository.class)).thenReturn(clusterDetailsRepositorymock); + when(clusterDetailsRepositorymock.getChildThreadForCluster(clusterId)).thenReturn((long)1); + long childThreadId = clusterDetailsComponent.getChildThread(clusterId); + assertEquals(1, childThreadId); + + } + + @Test + public void getClusterIdTest() { + long childThreadId = 1; + + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil.getBean(ClusterDetailsRepository.class)).thenReturn(clusterDetailsRepositorymock); + when(clusterDetailsRepositorymock.getClusterIdForChildThread(childThreadId)) + .thenReturn("clusterId"); + String clusterId = clusterDetailsComponent.getClusterId(childThreadId); + assertEquals("clusterId", clusterId); + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigPolicyTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigPolicyTest.java new file mode 100644 index 0000000..ca12095 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigPolicyTest.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * ============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; + +import static org.junit.Assert.assertEquals; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.onap.dcaegen2.services.sonhms.ConfigPolicy; + + +public class ConfigPolicyTest { + + @Test + public void configPolicyTest() { + ConfigPolicy configPolicy = ConfigPolicy.getInstance(); + Map config = new HashMap(); + config.put("policyName", "pcims_policy"); + configPolicy.setConfig(config); + assertEquals(config, configPolicy.getConfig()); + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java new file mode 100644 index 0000000..02a4f07 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * ============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; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; +import org.onap.dcaegen2.services.sonhms.Configuration; + + +public class ConfigurationTest { + Configuration configuration = Configuration.getInstance(); + + @Test + public void configurationTest() { + configuration.setBufferTime(60); + configuration.setCallbackUrl("/callbackUrl"); + configuration.setConfigName("configName"); + + List list = new ArrayList(); + list.add("server"); + configuration.setServers(list); + configuration.setCg("cg"); + configuration.setCid("cid"); + configuration.setManagerApiKey("managerApiKey"); + configuration.setManagerSecretKey("managerSecretKey"); + configuration.setMaximumClusters(5); + configuration.setMinCollision(5); + configuration.setMinConfusion(5); + configuration.setNumSolutions(1); + configuration.setOofService("oofService"); + configuration.setOptimizers(list); + configuration.setPcimsApiKey("pcimsApiKey"); + configuration.setPcimsSecretKey("pcimsSecretKey"); + configuration.setPolicyName("policyName"); + configuration.setPolicyService("policyService"); + configuration.setPolicyTopic("policyTopic"); + configuration.setPollingInterval(30); + configuration.setPollingTimeout(100); + configuration.setSdnrService("sdnrService"); + configuration.setSdnrTopic("sdnrTopic"); + configuration.setSourceId("sourceId"); + assertEquals(60, configuration.getBufferTime()); + assertEquals("/callbackUrl", configuration.getCallbackUrl()); + assertEquals("cg", configuration.getCg()); + assertEquals("cid", configuration.getCid()); + assertEquals("managerApiKey", configuration.getManagerApiKey()); + assertEquals("managerSecretKey", configuration.getManagerSecretKey()); + assertEquals(5, configuration.getMaximumClusters()); + assertEquals(5, configuration.getMinCollision()); + assertEquals(5, configuration.getMinConfusion()); + assertEquals(1, configuration.getNumSolutions()); + assertEquals("oofService", configuration.getOofService()); + assertEquals(list, configuration.getOptimizers()); + assertEquals("pcimsApiKey", configuration.getPcimsApiKey()); + assertEquals("pcimsSecretKey", configuration.getPcimsSecretKey()); + assertEquals("policyName", configuration.getPolicyName()); + assertEquals("policyService", configuration.getPolicyService()); + assertEquals("policyTopic", configuration.getPolicyTopic()); + assertEquals(30, configuration.getPollingInterval()); + assertEquals(100, configuration.getPollingTimeout()); + assertEquals("sdnrService", configuration.getSdnrService()); + assertEquals("sdnrTopic", configuration.getSdnrTopic()); + assertEquals(list, configuration.getServers()); + assertEquals("sourceId", configuration.getSourceId()); + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponentTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponentTest.java new file mode 100644 index 0000000..cc4d3ad --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponentTest.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * ============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; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.when; + +import fj.data.Either; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.onap.dcaegen2.services.sonhms.dao.DmaapNotificationsRepository; +import org.onap.dcaegen2.services.sonhms.model.Notification; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.PowerMockRunnerDelegate; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(PowerMockRunner.class) +@PowerMockRunnerDelegate(SpringRunner.class) +@PrepareForTest({ BeanUtil.class }) +@SpringBootTest(classes = DmaapNotificationsComponentTest.class) + +public class DmaapNotificationsComponentTest { + + @Mock + DmaapNotificationsRepository dmaapNotificationsRepositoryMock; + + @InjectMocks + DmaapNotificationsComponent component; + + static String notificationString; + + @BeforeClass + public static void setupTest() { + + notificationString = readFromFile("/notification1.json"); + } + + @Test + public void getDmaapNotificationsTestforLeft() { + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil.getBean(DmaapNotificationsRepository.class)) + .thenReturn(dmaapNotificationsRepositoryMock); + when(dmaapNotificationsRepositoryMock.getNotificationFromQueue()).thenReturn(notificationString); + + + Either result = component.getDmaapNotifications(); + //assertTrue(result.isLeft()); + assertNotNull(result.left().value()); + + when(dmaapNotificationsRepositoryMock.getNotificationFromQueue()).thenReturn("notification"); + + result = component.getDmaapNotifications(); + int resultRight = result.right().value(); + assertEquals(400, resultRight); + + } + + private static String readFromFile(String file) { + String content = new String(); + try { + + InputStream is = DmaapNotificationsComponentTest.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) { + content = null; + } + return content; + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/EventHandlerTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/EventHandlerTest.java new file mode 100644 index 0000000..a79e368 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/EventHandlerTest.java @@ -0,0 +1,150 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * pcims + * ================================================================================ + * Copyright (C) 2018 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; + +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.List; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import org.junit.Assert; +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.springframework.boot.test.context.SpringBootTest; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.dcaegen2.services.sonhms.child.Graph; +import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails; +import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException; +import org.onap.dcaegen2.services.sonhms.model.FapServiceList; +import org.onap.dcaegen2.services.sonhms.model.Notification; +import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils; +import org.onap.dcaegen2.services.sonhms.utils.ClusterUtilsTest; +import org.onap.dcaegen2.services.sonhms.utils.ThreadUtils; + +import fj.data.Either; + +@RunWith(MockitoJUnitRunner.class) +@SpringBootTest(classes = EventHandler.class) +public class EventHandlerTest { + + @Mock + ClusterUtils clusterutilsMock; + + @Mock + ExecutorService pool; + + @Mock + ThreadUtils threadUtilsMock; + + private static Notification notification; + private static List clusterDetails = new ArrayList<>(); + + @InjectMocks + EventHandler eventHandler; + + @Before + public void setup() { + + notification = new Notification(); + String notificationString = readFromFile("/notification3.json"); + String clusterInfo1 = readFromFile("/clusterInfo1.json"); + String clusterInfo2 = readFromFile("/clusterInfo2.json"); + String clusterInfo3 = readFromFile("/clusterInfo3.json"); + String clusterInfo4 = readFromFile("/clusterInfo4.json"); + ObjectMapper mapper = new ObjectMapper(); + + try { + notification = mapper.readValue(notificationString, Notification.class); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + System.out.println(notification.toString()); + + clusterDetails.add(new ClusterDetails("1", clusterInfo1, 35)); + clusterDetails.add(new ClusterDetails("2", clusterInfo2, 36)); + clusterDetails.add(new ClusterDetails("3", clusterInfo3, 37)); + clusterDetails.add(new ClusterDetails("4", clusterInfo4, 38)); + + } + + @Test + public void handleSdnrNotificationTest() { + + String clusterInfo7 = readFromFile("/clusterInfo7.json"); + Graph cluster = new Graph(clusterInfo7); + NotificationToClusterMapping mapping = new NotificationToClusterMapping(); + Map cellsinCluster = new HashMap<>(); + List newCells = new ArrayList<>(); + newCells.add(notification.getPayload().getRadioAccess().getFapServiceList().get(0)); + mapping.setCellsinCluster(cellsinCluster); + mapping.setNewCells(newCells); + Either existingCluster = Either.right(404); + + + Mockito.when(clusterutilsMock.getAllClusters()).thenReturn(clusterDetails); + Mockito.when(clusterutilsMock.getClustersForNotification(notification, clusterDetails)).thenReturn(mapping); + Mockito.when(clusterutilsMock.getClusterForCell(Mockito.any(), Mockito.any())).thenReturn(existingCluster); + Mockito.when(threadUtilsMock.createNewThread(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(true); + + try { + Mockito.when(clusterutilsMock.createCluster(Mockito.any())).thenReturn(cluster); + } catch (ConfigDbNotFoundException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + Assert.assertEquals(true, eventHandler.handleSdnrNotification(notification)); + + + + } + + 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) { + content = null; + } + return content; + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/MainThreadTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/MainThreadTest.java new file mode 100644 index 0000000..d06abbf --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/MainThreadTest.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * ============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; + +public class MainThreadTest { + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/TopicTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/TopicTest.java new file mode 100644 index 0000000..6ac6e75 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/TopicTest.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * ============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; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class TopicTest { + + @Test + public void topicTest() { + Topic topic=new Topic(); + topic.setConsumer("consumer"); + topic.setName("name"); + topic.setProducer("producer"); + assertEquals("consumer", topic.getConsumer()); + assertEquals("name", topic.getName()); + assertEquals("producer", topic.getProducer()); + + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/child/GraphTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/child/GraphTest.java new file mode 100644 index 0000000..3df7f93 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/child/GraphTest.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * ============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.child; + +import static org.junit.Assert.assertNotEquals; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.onap.dcaegen2.services.sonhms.child.Graph; +import org.onap.dcaegen2.services.sonhms.model.CellPciPair; +import org.slf4j.Logger; + + + +public class GraphTest { + private static final Logger log = org.slf4j.LoggerFactory.getLogger(GraphTest.class); + + @Test + public void graphTest() { + + CellPciPair cpPair1 = new CellPciPair(); + cpPair1.setCellId("25"); + cpPair1.setPhysicalCellId(32); + + CellPciPair cpPair2 = new CellPciPair(); + cpPair2.setCellId("29"); + cpPair2.setPhysicalCellId(209); + + Graph graph = new Graph(); + + graph.addEdge(cpPair1, cpPair2); + + Map> map = new HashMap<>(); + + log.debug("graph {}", graph.getCellPciNeighbourMap()); + System.out.println("graph" + graph.getCellPciNeighbourMap()); + System.out.println("graphJSON" + graph.getPciNeighbourJson()); + assertNotEquals(map, graph.getCellPciNeighbourMap()); + + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java new file mode 100644 index 0000000..03e735f --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java @@ -0,0 +1,111 @@ +/******************************************************************************* + * ============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.child; + +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.List; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.dcaegen2.services.sonhms.ConfigPolicy; +import org.onap.dcaegen2.services.sonhms.model.CellPciPair; +import org.onap.dcaegen2.services.sonhms.model.PolicyNotification; +import org.onap.dcaegen2.services.sonhms.utils.ClusterUtilsTest; + +public class TestChildThreadUtils { + + ChildThreadUtils childThreadUtils; + + @Before + public void setup() { + + ConfigPolicy configPolicy = ConfigPolicy.getInstance(); + + Map configPolicyMap = new HashMap<>(); + configPolicyMap.put("PCI_MODCONFIG_POLICY_NAME", "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459"); + configPolicy.setConfig(configPolicyMap); + childThreadUtils = new ChildThreadUtils(configPolicy); + } + + @Test + public void getNotificationStringTest() { + + String policy_notif = readFromFile("/policy_notification.json"); + PolicyNotification expected = new PolicyNotification(); + ObjectMapper mapper = new ObjectMapper(); + + try { + expected = mapper.readValue(policy_notif, PolicyNotification.class); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + String pnfName = "ncserver23"; + List cellPciPairs = new ArrayList<>(); + + cellPciPairs.add(new CellPciPair("Chn0330", 6)); + cellPciPairs.add(new CellPciPair("Chn0331", 7)); + String requestId = "a4130fd5-2291-4a83-8992-04e4c9f32731"; + Long alarmStart = Long.parseLong("1542445563201"); + + String result = childThreadUtils.getNotificationString(pnfName, cellPciPairs, requestId, alarmStart); + PolicyNotification actual = new PolicyNotification(); + try { + actual = mapper.readValue(result, PolicyNotification.class); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + Assert.assertEquals(expected.hashCode(), actual.hashCode()); + } + + 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; + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestDetection.java b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestDetection.java new file mode 100644 index 0000000..6e42cce --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestDetection.java @@ -0,0 +1,117 @@ +/******************************************************************************* + * ============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.child; + + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.onap.dcaegen2.services.sonhms.child.Detection; +import org.onap.dcaegen2.services.sonhms.child.Graph; +import org.onap.dcaegen2.services.sonhms.model.CellPciPair; + + +public class TestDetection { + @Test + public void testDetection() { + + CellPciPair cpPair = new CellPciPair(); + cpPair.setCellId("32"); + cpPair.setPhysicalCellId(26); + + CellPciPair cpPair1 = new CellPciPair(); + cpPair1.setCellId("25"); + cpPair1.setPhysicalCellId(23); + + CellPciPair cpPair2 = new CellPciPair(); + cpPair2.setCellId("42"); + cpPair2.setPhysicalCellId(26); + + CellPciPair cpPair3 = new CellPciPair(); + cpPair3.setCellId("56"); + cpPair3.setPhysicalCellId(200); + + CellPciPair cpPair4 = new CellPciPair(); + cpPair4.setCellId("21"); + cpPair4.setPhysicalCellId(5); + + CellPciPair cpPair5 = new CellPciPair(); + cpPair5.setCellId("24"); + cpPair5.setPhysicalCellId(5); + + CellPciPair cpPair6 = new CellPciPair(); + cpPair6.setCellId("38"); + cpPair6.setPhysicalCellId(126); + + CellPciPair cpPair7 = new CellPciPair(); + cpPair7.setCellId("67"); + cpPair7.setPhysicalCellId(300); + + CellPciPair cpPair8 = new CellPciPair(); + cpPair8.setCellId("69"); + cpPair8.setPhysicalCellId(129); + + CellPciPair cpPair9 = new CellPciPair(); + cpPair9.setCellId("78"); + cpPair9.setPhysicalCellId(147); + + ArrayList al = new ArrayList(); + al.add(cpPair1); + al.add(cpPair2); + al.add(cpPair3); + + ArrayList al1 = new ArrayList(); + al1.add(cpPair4); + al1.add(cpPair5); + al1.add(cpPair6); + + ArrayList al2 = new ArrayList(); + al2.add(cpPair7); + al2.add(cpPair8); + al2.add(cpPair9); + + Map> map = new HashMap>(); + + map.put(cpPair, al); + map.put(cpPair1, al1); + map.put(cpPair2, al2); + map.put(cpPair3, new ArrayList()); + map.put(cpPair4, new ArrayList()); + map.put(cpPair5, new ArrayList()); + map.put(cpPair6, new ArrayList()); + map.put(cpPair7, new ArrayList()); + map.put(cpPair8, new ArrayList()); + map.put(cpPair9, new ArrayList()); + Graph cluster = new Graph(); + + cluster.setCellPciNeighbourMap(map); + + System.out.println("mapsssssss" + cluster.getCellPciNeighbourMap()); + Detection detect = new Detection(); + detect.detectCollisionConfusion(cluster); + System.out.println("result" + detect.detectCollisionConfusion(cluster)); + + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestPnfUtils.java b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestPnfUtils.java new file mode 100644 index 0000000..e7f822f --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestPnfUtils.java @@ -0,0 +1,157 @@ +/******************************************************************************* + * ============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.child; + +import static org.junit.Assert.assertEquals; + +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.List; +import java.util.Map; +import java.util.Optional; + +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.PowerMockRunnerDelegate; +import org.slf4j.Logger; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.dcaegen2.services.sonhms.dao.CellInfoRepository; +import org.onap.dcaegen2.services.sonhms.entity.CellInfo; +import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException; +import org.onap.dcaegen2.services.sonhms.model.CellPciPair; +import org.onap.dcaegen2.services.sonhms.restclient.SdnrRestClient; +import org.onap.dcaegen2.services.sonhms.restclient.Solution; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; +import org.onap.dcaegen2.services.sonhms.utils.ClusterUtilsTest; + +@RunWith(PowerMockRunner.class) +@PowerMockRunnerDelegate(SpringRunner.class) +@PrepareForTest({BeanUtil.class, SdnrRestClient.class }) +@SpringBootTest(classes = PnfUtils.class) +public class TestPnfUtils { + + @Mock + private CellInfoRepository cellInfoRepositoryMock; + + private static final Logger log = org.slf4j.LoggerFactory.getLogger(TestPnfUtils.class); + private static List solutions = new ArrayList<>(); + private static Optional cellInfo; + private static Optional cellInfoNull; + + + @InjectMocks + PnfUtils pnfUtils; + + @BeforeClass + public static void setup() { + + + String solutionsString=readFromFile("/solutions.json"); + ObjectMapper mapper = new ObjectMapper(); + + try { + solutions=mapper.readValue(solutionsString,new TypeReference>(){}); + } catch (IOException e) { + log.debug("Exception in StateOof Test "+e); + e.printStackTrace(); + } + + } + @Before + public void setupTest() { + cellInfo = Optional.of(new CellInfo("EXP001","ncserver1")); + cellInfoNull = Optional.ofNullable(null); + pnfUtils = new PnfUtils(); + MockitoAnnotations.initMocks(this); + } + @Test + public void getPnfsTest() { + Map> pnfs = new HashMap<>(); + List cellpciPairList1=new ArrayList<>(); + cellpciPairList1.add(new CellPciPair("EXP001",101)); + List cellpciPairList2=new ArrayList<>(); + cellpciPairList2.add(new CellPciPair("EXP002",102)); + String pnfName="ncserver2"; + String cellId="EXP002"; + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.mockStatic(SdnrRestClient.class); + + PowerMockito.when(BeanUtil.getBean(CellInfoRepository.class)) + .thenReturn(cellInfoRepositoryMock); + + Mockito.when(cellInfoRepositoryMock.findById("EXP001")) + .thenReturn(cellInfo); + Mockito.when(cellInfoRepositoryMock.findById(cellId)) + .thenReturn(cellInfoNull); + try { + PowerMockito.when(SdnrRestClient.getPnfName(cellId)) + .thenReturn(pnfName); + PowerMockito.when(cellInfoRepositoryMock.save(new CellInfo(cellId, pnfName))).thenReturn(new CellInfo()); + } catch (ConfigDbNotFoundException e) { + e.printStackTrace(); + } + pnfs.put(pnfName, cellpciPairList2); + pnfs.put("ncserver1", cellpciPairList1); + System.out.println(solutions); + try { + assertEquals(pnfs,pnfUtils.getPnfs(solutions)); + } catch (ConfigDbNotFoundException e) { + log.debug("exception in stateOof test {}", e); + e.printStackTrace(); + } + } + 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) { + content = null; + } + return content; + } +} \ No newline at end of file diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClientTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClientTest.java new file mode 100644 index 0000000..63ba5bd --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClientTest.java @@ -0,0 +1,112 @@ +/******************************************************************************* + * ============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 com.att.nsa.cambria.client.CambriaTopicManager; + +import static org.mockito.Mockito.when; + + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +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.onap.dcaegen2.services.sonhms.Configuration; +import org.onap.dcaegen2.services.sonhms.NewNotification; +import org.mockito.MockitoAnnotations; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = DmaapClientTest.class) +public class DmaapClientTest { + + @Mock + private CambriaTopicManager topicManager; + + + @InjectMocks + DmaapClient client; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + private Boolean newNotif; + + @Test + public void getAllTopicsTest() { + Set topics = new HashSet(); + topics.add("topic1"); + topics.add("topic2"); + Configuration configuration = Configuration.getInstance(); + configuration.setBufferTime(60); + configuration.setCallbackUrl("/callbackUrl"); + configuration.setConfigName("configName"); + List list = new ArrayList(); + list.add("server"); + configuration.setServers(list); + configuration.setCg("cg"); + configuration.setCid("cid"); + configuration.setManagerApiKey("managerApiKey"); + configuration.setManagerSecretKey("managerSecretKey"); + configuration.setMaximumClusters(5); + configuration.setMinCollision(5); + configuration.setMinConfusion(5); + configuration.setNumSolutions(1); + configuration.setOofService("oofService"); + configuration.setOptimizers(list); + configuration.setPcimsApiKey("pcimsApiKey"); + configuration.setPcimsSecretKey("pcimsSecretKey"); + configuration.setPolicyName("policyName"); + configuration.setPolicyService("policyService"); + configuration.setPolicyTopic("policyTopic"); + configuration.setPollingInterval(30); + configuration.setPollingTimeout(100); + configuration.setSdnrService("sdnrService"); + configuration.setSdnrTopic("sdnrTopic"); + configuration.setSourceId("sourceId"); + NewNotification newNotification = new NewNotification(newNotif); + + try { + when(topicManager.getTopics()).thenReturn(topics); + client=Mockito.mock(DmaapClient.class); + client.initClient(newNotification); + Mockito.verify(client).initClient(newNotification); + // Mockito.verifycreateAndConfigureTopics(); + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationProducerTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationProducerTest.java new file mode 100644 index 0000000..c76b953 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationProducerTest.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * ============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.assertEquals; +import static org.mockito.Mockito.when; + +import com.att.nsa.cambria.client.CambriaBatchingPublisher; +import java.io.IOException; +import java.security.GeneralSecurityException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = NotificationProducerTest.class) +public class NotificationProducerTest { + + + @Mock + CambriaBatchingPublisher cambriaBatchingPublisher; + + @InjectMocks + NotificationProducer notificationProducer; + + @Test + public void notificationProducerTest() { + + + + try { + + when(cambriaBatchingPublisher.send(Mockito.anyString(), Mockito.anyString())).thenReturn(0); + int result=notificationProducer.sendNotification("msg"); + assertEquals(0, result); + } catch (GeneralSecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } +} + + diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/entity/BufferedNotificationsTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/entity/BufferedNotificationsTest.java new file mode 100644 index 0000000..12a3d4d --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/entity/BufferedNotificationsTest.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * ============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.entity; + +import static org.junit.Assert.assertEquals; + +import java.sql.Timestamp; + +import org.junit.Test; + +public class BufferedNotificationsTest { + + private Timestamp createdAt; + + @Test + public void bufferedNotificationsTest() { + BufferedNotifications bufferedNotifications=new BufferedNotifications(); + bufferedNotifications.setClusterId("clusterId"); + bufferedNotifications.setNotification("notification"); + bufferedNotifications.setCreatedAt(createdAt); + assertEquals("clusterId", bufferedNotifications.getClusterId()); + assertEquals("notification", bufferedNotifications.getNotification()); + assertEquals(createdAt, bufferedNotifications.getCreatedAt()); + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/entity/CellInfoTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/entity/CellInfoTest.java new file mode 100644 index 0000000..6732cb6 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/entity/CellInfoTest.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * ============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.entity; +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class CellInfoTest { + + @Test + public void cellInfoTest() { + CellInfo cellInfo=new CellInfo(); + cellInfo.setCellId("cellId"); + cellInfo.setPnfName("pnfName"); + assertEquals("cellId", cellInfo.getCellId()); + assertEquals("pnfName", cellInfo.getPnfName()); + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/entity/DmaapNotificationsTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/entity/DmaapNotificationsTest.java new file mode 100644 index 0000000..05ea72e --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/entity/DmaapNotificationsTest.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * ============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.entity; + +import static org.junit.Assert.assertEquals; + +import java.sql.Timestamp; + +import org.junit.Test; + +public class DmaapNotificationsTest { + + private Timestamp createdAt; + + @Test + public void dmaapNotififcationsTest() { + DmaapNotifications dmaapNotifications = new DmaapNotifications(); + dmaapNotifications.setNotification("notification"); + dmaapNotifications.setCreatedAt(createdAt); + assertEquals("notification", dmaapNotifications.getNotification()); + assertEquals(createdAt, dmaapNotifications.getCreatedAt()); + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/entity/PciRequestsTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/entity/PciRequestsTest.java new file mode 100644 index 0000000..bf22fd6 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/entity/PciRequestsTest.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * ============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.entity; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class PciRequestsTest { + + @Test + public void pciRequestsTest() { + PciRequests pciRequests=new PciRequests(); + pciRequests.setChildThreadId(1L); + pciRequests.setTransactionId("transactionId"); + assertEquals(1L, pciRequests.getChildThreadId()); + assertEquals("transactionId", pciRequests.getTransactionId()); + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/model/CellConfigTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/model/CellConfigTest.java new file mode 100644 index 0000000..94f58b1 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/model/CellConfigTest.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * ============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 static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class CellConfigTest { + + @Test + public void cellConfigTest() { + + Common common = new Common(); + common.setCellIdentity("cellIdentity"); + Ran ran = new Ran(); + ran.setCommon(common); + Lte lte = new Lte(); + lte.setRan(ran); + CellConfig cellConfig = new CellConfig(); + cellConfig.setLte(lte); + assertEquals(lte, cellConfig.getLte()); + assertEquals(ran, lte.getRan()); + assertEquals(common, ran.getCommon()); + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/model/CellNeighbourListTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/model/CellNeighbourListTest.java new file mode 100644 index 0000000..d9684dd --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/model/CellNeighbourListTest.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * ============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 static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class CellNeighbourListTest { + + @Test + public void cellNeighbourListTest() { + CellNeighbourList cellNeighbourList = new CellNeighbourList(); + cellNeighbourList.setCellId("cellId"); + cellNeighbourList.setNeighbours("neighbour"); + cellNeighbourList.setPhysicalCellId(1); + assertEquals("cellId",cellNeighbourList.getCellId() ); + assertEquals("neighbour",cellNeighbourList.getNeighbours() ); + assertEquals(1,cellNeighbourList.getPhysicalCellId() ); + + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/model/NotificationPayloadTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/model/NotificationPayloadTest.java new file mode 100644 index 0000000..4505bff --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/model/NotificationPayloadTest.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * ============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 org.junit.Test; + +public class NotificationPayloadTest { + + @Test + public void notificationPayloadTest() { + + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/model/NotificationTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/model/NotificationTest.java new file mode 100644 index 0000000..8ef4778 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/model/NotificationTest.java @@ -0,0 +1,128 @@ +/******************************************************************************* + * ============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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.IOException; +import java.util.ArrayList; + +import org.junit.Test; +import org.onap.dcaegen2.services.sonhms.model.FapServiceList; +import org.onap.dcaegen2.services.sonhms.model.LteNeighborListInUseLteCell; +import org.onap.dcaegen2.services.sonhms.model.NeighborListInUse; +import org.onap.dcaegen2.services.sonhms.model.Notification; +import org.onap.dcaegen2.services.sonhms.model.NotificationCellConfig; +import org.onap.dcaegen2.services.sonhms.model.NotificationLte; +import org.onap.dcaegen2.services.sonhms.model.NotificationPayload; +import org.onap.dcaegen2.services.sonhms.model.NotificationRan; +import org.onap.dcaegen2.services.sonhms.model.RadioAccess; +import org.onap.dcaegen2.services.sonhms.model.X0005b9Lte; + +public class NotificationTest { + + @Test + public void notificationTest() { + + Notification notif = new Notification(); + LteNeighborListInUseLteCell lteNeighborListInUseLteCell = new LteNeighborListInUseLteCell("pnf1", "true", + "Cell10", "true", "123456", "5", 22, "false"); + + ArrayList list = new ArrayList<>(); + list.add(lteNeighborListInUseLteCell); + + NeighborListInUse neighborListInUse = new NeighborListInUse(list, "1"); + + NotificationRan notificationRan = new NotificationRan(neighborListInUse, "Cell25"); + NotificationLte notificationLte = new NotificationLte(notificationRan); + NotificationCellConfig notificationCell = new NotificationCellConfig(notificationLte); + X0005b9Lte lte = new X0005b9Lte(126, "pnf2"); + FapServiceList fap = new FapServiceList("Cell1", lte, notificationCell); + + ArrayList al = new ArrayList<>(); + al.add(fap); + + RadioAccess radioAccess = new RadioAccess("1", al); + NotificationPayload payload = new NotificationPayload(radioAccess); + + notif.setRequestId("9d2d790e-a5f0-11e8-98d0-529269fb1459"); + notif.setAai("{}"); + notif.setAction("NeighborListModified"); + notif.setFrom("SDNR"); + notif.setVersion("1.0.2"); + notif.setPayload(payload); + assertNotEquals("159", notif.getRequestId()); + + String test = "{\n" + " \"requestID\": \"9d2d790e-a5f0-11e8-98d0-529269fb1459\",\n" + " \"AAI\": {},\n" + + " \"from\": \"SDNR\",\n" + " \"version\": \"1.0.2\",\n" + + " \"Action\": \"NeighborListModified\",\n" + " \"Payload\": {\n" + "\n" + " \"RadioAccess\":{ \n" + + " \"FAPServiceNumberOfEntries\":\"2\",\n" + " \"FAPServiceList\":[ \n" + " { \n" + + " \"alias\":\"Cell1\",\n" + " \"X0005b9Lte\":{ \n" + + " \"phyCellIdInUse\":\"35\",\n" + " \"pnfName\":\"DU-1\"\n" + + " },\n" + " \"CellConfig\":{ \n" + " \"LTE\":{ \n" + + " \"RAN\":{ \n" + " \"CellIdentity\":\"Cell1\",\n" + + " \"NeighborListInUse\":{ \n" + + " \"LTECellNumberOfEntries\":\"2\",\n" + + " \"LTENeighborListInUseLTECell\":[ \n" + " { \n" + + " \"pnfName\":\"DU-2\",\n" + + " \"enable\":\"true\",\n" + + " \"alias\":\"Cell10\",\n" + + " \"mustInclude\":\"true\",\n" + + " \"plmnid\":\"123456\",\n" + + " \"cid\":\"2\",\n" + + " \"phyCellId\":\"22\",\n" + + " \"blacklisted\":\"false\"\n" + " },\n" + + " { \n" + " \"pnfName\":\"DU-3\",\n" + + " \"enable\":\"true\",\n" + + " \"alias\":\"Cell15\",\n" + + " \"mustInclude\":\"true\",\n" + + " \"plmnid\":\"123456\",\n" + + " \"cid\":\"5\",\n" + + " \"phyCellId\":\"24\",\n" + + " \"blacklisted\":\"false\"\n" + " }\n" + + " ]\n" + " }\n" + " }\n" + + " }\n" + " }\n" + " }\n" + " ]\n" + " }\n" + "}\n" + "}"; + + ObjectMapper mapper = new ObjectMapper(); + Notification notif1 = new Notification(); + try { + notif1 = mapper.readValue(test, Notification.class); + } catch (JsonParseException e) { + e.printStackTrace(); + } catch (JsonMappingException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + assertNotEquals(notif, notif1); + assertEquals(notif.getAction(), notif1.getAction()); + assertEquals(notif.getAai().toString(), notif1.getAai().toString()); + + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/model/PayloadTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/model/PayloadTest.java new file mode 100644 index 0000000..a7f0a79 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/model/PayloadTest.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * ============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 static org.junit.Assert.assertEquals; + +import java.util.ArrayList; + +import org.junit.Test; +import org.onap.dcaegen2.services.sonhms.model.CellConfig; +import org.onap.dcaegen2.services.sonhms.model.Common; +import org.onap.dcaegen2.services.sonhms.model.Configurations; +import org.onap.dcaegen2.services.sonhms.model.Data; +import org.onap.dcaegen2.services.sonhms.model.FapService; +import org.onap.dcaegen2.services.sonhms.model.Lte; +import org.onap.dcaegen2.services.sonhms.model.Payload; +import org.onap.dcaegen2.services.sonhms.model.Ran; +import org.onap.dcaegen2.services.sonhms.model.X0005b9Lte; + + + +public class PayloadTest { + + @Test + public void payloadTest() { + Common common = new Common("cell1"); + + Ran ran = new Ran(common); + + Lte lte = new Lte(ran); + + CellConfig cellConfig = new CellConfig(lte); + + X0005b9Lte x0005b9Lte = new X0005b9Lte(0, "pnf2"); + + FapService fapService = new FapService("cell6", x0005b9Lte, cellConfig); + + Data data = new Data(fapService); + + Configurations config = new Configurations(data); + ArrayList al = new ArrayList<>(); + al.add(config); + + Payload payload = new Payload(al); + + assertEquals("pnf2", payload.getConfiguration().get(0).getData().getFapservice().getX0005b9Lte().getPnfName()); + + assertEquals("cell6", payload.getConfiguration().get(0).getData().getFapservice().getAlias()); + + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotificationTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotificationTest.java new file mode 100644 index 0000000..b99a9d7 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotificationTest.java @@ -0,0 +1,121 @@ +/******************************************************************************* + * ============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 static org.junit.Assert.assertEquals; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.HashMap; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Test; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.dcaegen2.services.sonhms.utils.ClusterUtilsTest; + +public class PolicyNotificationTest { + @Test + public void policyNotificationTest() { + PolicyNotification policyNotification=new PolicyNotification(); + Map aai=new HashMap<>(); + aai.put("test","test"); + String target="test"; + String targetType="targetType"; + String payload="payload"; + String closedLoopControlName="closedLoopControlName"; + String action="action"; + String version="version"; + String from="from"; + String requestId="requestId"; + String closedLoopEventStatus="closedLoopEventStatus"; + String closedLoopEventClient="closedLoopEventClient"; + long closedLoopAlarmStart=96587958; + policyNotification.setAai(aai); + assertEquals(aai,policyNotification.getAai()); + policyNotification.setTarget(target); + assertEquals(target,policyNotification.getTarget()); + policyNotification.setTargetType(targetType); + assertEquals(targetType,policyNotification.getTargetType()); + policyNotification.setPayload(payload); + assertEquals(payload,policyNotification.getPayload()); + policyNotification.setClosedLoopControlName(closedLoopControlName); + assertEquals(closedLoopControlName,policyNotification.getClosedLoopControlName()); + policyNotification.setAction(action); + assertEquals(action,policyNotification.getAction()); + policyNotification.setVersion(version); + assertEquals(version,policyNotification.getVersion()); + policyNotification.setFrom(from); + assertEquals(from,policyNotification.getFrom()); + policyNotification.setRequestId(requestId); + assertEquals(requestId,policyNotification.getRequestId()); + policyNotification.setClosedLoopEventStatus(closedLoopEventStatus); + assertEquals(closedLoopEventStatus,policyNotification.getClosedLoopEventStatus()); + policyNotification.setClosedLoopEventClient(closedLoopEventClient); + assertEquals(closedLoopEventClient,policyNotification.getClosedLoopEventClient()); + policyNotification.setClosedLoopAlarmStart(closedLoopAlarmStart); + assertEquals(closedLoopAlarmStart,policyNotification.getClosedLoopAlarmStart()); + + String notif1 = readFromFile("/policy_notification.json"); + String notif2 = readFromFile("/policy_notification.json"); + PolicyNotification policyNotification1 = new PolicyNotification(); + PolicyNotification policyNotification2 = new PolicyNotification(); + PolicyNotification policyNotification3 = new PolicyNotification(); + ObjectMapper mapper = new ObjectMapper(); + + try { + policyNotification1 = mapper.readValue(notif1, PolicyNotification.class); + policyNotification2 = mapper.readValue(notif2, PolicyNotification.class); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + Assert.assertEquals(policyNotification1.hashCode(), policyNotification2.hashCode()); + Assert.assertNotEquals(policyNotification1.hashCode(), policyNotification3.hashCode()); + + } + + 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; + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/model/ResponseTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/model/ResponseTest.java new file mode 100644 index 0000000..0fcdb1b --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/model/ResponseTest.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * ============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 static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class ResponseTest { + + @Test + public void respomseTest() { + Response response = new Response(); + response.setCellId("cellId"); + response.setPci(1); + assertEquals("cellId", response.getCellId()); + assertEquals(1, response.getPci()); + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/model/SdnrResponseTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/model/SdnrResponseTest.java new file mode 100644 index 0000000..a65f51b --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/model/SdnrResponseTest.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * ============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 static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +public class SdnrResponseTest { + + @Test + public void sdnrResponseTest() { + SdnrResponse sdnrResponse=new SdnrResponse(); + Response response=new Response(); + response.setCellId("cellId"); + response.setPci(2); + List responseList=new ArrayList<>(); + responseList.add(response); + sdnrResponse.setResponse(responseList); + assertEquals(responseList,sdnrResponse.getResponse()); + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/model/ThreadIdTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/model/ThreadIdTest.java new file mode 100644 index 0000000..ad23c3a --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/model/ThreadIdTest.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * ============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 static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class ThreadIdTest { + + @Test + public void threadIdtest() { + ThreadId threadId=new ThreadId(); + long Id=987957948; + threadId.setChildThreadId(Id); + assertEquals(Id,threadId.getChildThreadId()); + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBodyTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBodyTest.java new file mode 100644 index 0000000..085abbb --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/AsyncResponseBodyTest.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * ============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.restclient; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; +import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody; +import org.onap.dcaegen2.services.sonhms.restclient.Solution; +import org.onap.dcaegen2.services.sonhms.restclient.SonSolution; + + + +public class AsyncResponseBodyTest { + + @Test + public void asyncResponseBodyTest() { + AsyncResponseBody asyncResponseBody = new AsyncResponseBody(); + asyncResponseBody.setRequestId("e44a4165-3cf4-4362-89de-e2375eed97e7"); + asyncResponseBody.setRequestStatus("completed"); + SonSolution pciSolutions = new SonSolution(); + pciSolutions.setCellId("EXP001"); + pciSolutions.setPci(101); + List pciSolutionsList = new ArrayList(); + pciSolutionsList.add(pciSolutions); + Solution solutions = new Solution(); + solutions.setFinishTime("2018-10-01T00:40+01.00"); + solutions.setNetworkId("EXP001"); + solutions.setPciSolutions(pciSolutionsList); + solutions.setStartTime("2018-10-01T00:30+01:00"); + ArrayList solutionsList = new ArrayList(); + solutionsList.add(solutions); + asyncResponseBody.setSolutions(solutionsList); + asyncResponseBody.setStatusMessage("success"); + asyncResponseBody.setTransactionId("3df7b0e9-26d1-4080-ba42-28e8a3139689"); + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfoTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfoTest.java new file mode 100644 index 0000000..24ba1ae --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfoTest.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * ============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.restclient; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; +import org.onap.dcaegen2.services.sonhms.restclient.CellInfo; + + +public class CellInfoTest { + @Test + public void cellInfoTest() { + List cellIdLists = new ArrayList<>(); + cellIdLists.add("cell1"); + + CellInfo cellInfo = new CellInfo(); + cellInfo.setNetworkId("NTWK001"); + cellInfo.setCellIdList(cellIdLists); + assertEquals("NTWK001", cellInfo.getNetworkId()); + assertEquals(cellIdLists, cellInfo.getCellIdList()); + + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/OofRequestBodyTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/OofRequestBodyTest.java new file mode 100644 index 0000000..eb0d189 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/OofRequestBodyTest.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * ============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.restclient; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; +import org.onap.dcaegen2.services.sonhms.restclient.CellInfo; +import org.onap.dcaegen2.services.sonhms.restclient.OofRequestBody; +import org.onap.dcaegen2.services.sonhms.restclient.RequestInfo; + + + +public class OofRequestBodyTest { + @Test + public void oofRequestBodyTest() { + + List cellIdLists = new ArrayList<>(); + cellIdLists.add("cell1"); + CellInfo cellInfo = new CellInfo(); + cellInfo.setNetworkId("NTWK001"); + cellInfo.setCellIdList(cellIdLists); + RequestInfo requestInfo = new RequestInfo(); + List optimizers = new ArrayList(); + optimizers.add("PCI"); + requestInfo.setCallbackUrl(""); + requestInfo.setNumSolutions(1); + requestInfo.setOptimizers(optimizers); + requestInfo.setRequestId("e44a4165-3cf4-4362-89de-e2375eed97e7"); + requestInfo.setRequestType("create"); + requestInfo.setSourceId("PCIHMS"); + requestInfo.setTimeout(60); + requestInfo.setTransactionId("3df7b0e9-26d1-4080-ba42-28e8a3139689"); + + OofRequestBody oofRequestBody = new OofRequestBody(); + oofRequestBody.setCellInfo(cellInfo); + oofRequestBody.setRequestInfo(requestInfo); + assertEquals(requestInfo, oofRequestBody.getRequestInfo()); + assertEquals(cellInfo, oofRequestBody.getCellInfo()); + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClientTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClientTest.java new file mode 100644 index 0000000..4a9fed5 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClientTest.java @@ -0,0 +1,131 @@ +/******************************************************************************* + * ============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.restclient; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.dcaegen2.services.sonhms.Configuration; +import org.onap.dcaegen2.services.sonhms.exceptions.OofNotFoundException; +import org.onap.dcaegen2.services.sonhms.utils.SonHandlerRestTemplate; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.PowerMockRunnerDelegate; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(PowerMockRunner.class) +@PowerMockRunnerDelegate(SpringRunner.class) +@PrepareForTest({ SonHandlerRestTemplate.class,Configuration.class }) +@SpringBootTest(classes = OofRestClientTest.class) +public class OofRestClientTest { + Configuration configuration = Configuration.getInstance(); + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void queryOofTest() { + configuration.setBufferTime(60); + configuration.setCallbackUrl("/callbackUrl"); + configuration.setConfigName("configName"); + List list = new ArrayList(); + list.add("server"); + configuration.setServers(list); + configuration.setCg("cg"); + configuration.setCid("cid"); + configuration.setManagerApiKey("managerApiKey"); + configuration.setManagerSecretKey("managerSecretKey"); + configuration.setMaximumClusters(5); + configuration.setMinCollision(5); + configuration.setMinConfusion(5); + configuration.setNumSolutions(1); + configuration.setOofService("oofService"); + configuration.setOptimizers(list); + configuration.setPcimsApiKey("pcimsApiKey"); + configuration.setPcimsSecretKey("pcimsSecretKey"); + configuration.setPolicyName("policyName"); + configuration.setPolicyService("policyService"); + configuration.setPolicyTopic("policyTopic"); + configuration.setPollingInterval(30); + configuration.setPollingTimeout(100); + configuration.setSdnrService("sdnrService"); + configuration.setSdnrTopic("sdnrTopic"); + configuration.setSourceId("sourceId"); + String responseBody="{\n" + + " \"transactionId\": \"xxx-xxx-xxxx\",\n" + + " \"requestId\": \"yyy-yyy-yyyy\",\n" + + " \"requestStatus\": \"accepted\",\n" + + " \"statusMessage\": \"\"\n" + + "}"; + List cellIdList=new ArrayList(); + cellIdList.add("EXP001"); + List optimizers=new ArrayList(); + optimizers.add("pci"); + + PowerMockito.mockStatic(SonHandlerRestTemplate.class); + PowerMockito.mockStatic(Configuration.class); + PowerMockito.when(Configuration.getInstance()).thenReturn(configuration); + PowerMockito.when(SonHandlerRestTemplate.sendPostRequestToOof(Mockito.anyString(),Mockito.anyString() ,Matchers.>any())) + .thenReturn(ResponseEntity.ok(responseBody)); + + + try { + String result=OofRestClient.queryOof(1, "xxx-xxx-xxxx", "create", cellIdList, "NTWK005", optimizers); + assertEquals(ResponseEntity.ok(responseBody).getBody(), result); + + + } catch (OofNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + PowerMockito.when(SonHandlerRestTemplate.sendPostRequestToOof(Mockito.anyString(),Mockito.anyString() ,Matchers.>any())) + .thenReturn(null); + try { + String result=OofRestClient.queryOof(1, "xxx-xxx-xxxx", "create", cellIdList, "NTWK005", optimizers); + assertEquals(ResponseEntity.ok(responseBody).getBody(), result); + + + } catch (OofNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + +} + + + diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/PciSolutionsTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/PciSolutionsTest.java new file mode 100644 index 0000000..4f59435 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/PciSolutionsTest.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * ============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.restclient; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.onap.dcaegen2.services.sonhms.restclient.SonSolution; + + +public class PciSolutionsTest { + @Test + public void pciSolutionsTest() { + SonSolution pciSolutions = new SonSolution(); + pciSolutions.setCellId("EXP001"); + pciSolutions.setPci(101); + assertEquals("EXP001", pciSolutions.getCellId()); + assertEquals(101, pciSolutions.getPci()); + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRequestBodyTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRequestBodyTest.java new file mode 100644 index 0000000..5de8951 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRequestBodyTest.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * ============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.restclient; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.onap.dcaegen2.services.sonhms.restclient.PolicyRequestBody; + + +public class PolicyRequestBodyTest { + @Test + public void policyRequestBodyTest() { + PolicyRequestBody policyRequestBody = new PolicyRequestBody(); + policyRequestBody.setConfigName("PCIMS_CONFIG_POLICY"); + policyRequestBody.setPolicyName("com.PCIMS_CONFIG_POLICY"); + policyRequestBody.setRequestId("60fe7fe6-2649-4f6c-8468-30eb03fd0527"); + assertEquals("PCIMS_CONFIG_POLICY", policyRequestBody.getConfigName()); + assertEquals("com.PCIMS_CONFIG_POLICY", policyRequestBody.getPolicyName()); + assertEquals("60fe7fe6-2649-4f6c-8468-30eb03fd0527", policyRequestBody.getRequestId()); + + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRestClientTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRestClientTest.java new file mode 100644 index 0000000..387b958 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/PolicyRestClientTest.java @@ -0,0 +1,117 @@ +/******************************************************************************* + * ============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.restclient; + +import static org.junit.Assert.assertEquals; +import java.util.ArrayList; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.dcaegen2.services.sonhms.Configuration; +import org.onap.dcaegen2.services.sonhms.restclient.PolicyRestClient; +import org.onap.dcaegen2.services.sonhms.utils.SonHandlerRestTemplate; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.PowerMockRunnerDelegate; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(PowerMockRunner.class) +@PowerMockRunnerDelegate(SpringRunner.class) +@PrepareForTest({ SonHandlerRestTemplate.class, Configuration.class }) +@SpringBootTest(classes = PolicyRestClientTest.class) +public class PolicyRestClientTest { + + Configuration configuration = Configuration.getInstance(); + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void fetchConfigFromPolicyTest() { + + configuration.setBufferTime(60); + configuration.setCallbackUrl("/callbackUrl"); + configuration.setConfigName("configName"); + List list = new ArrayList(); + list.add("server"); + configuration.setServers(list); + configuration.setCg("cg"); + configuration.setCid("cid"); + configuration.setManagerApiKey("managerApiKey"); + configuration.setManagerSecretKey("managerSecretKey"); + configuration.setMaximumClusters(5); + configuration.setMinCollision(5); + configuration.setMinConfusion(5); + configuration.setNumSolutions(1); + configuration.setOofService("oofService"); + configuration.setOptimizers(list); + configuration.setPcimsApiKey("pcimsApiKey"); + configuration.setPcimsSecretKey("pcimsSecretKey"); + configuration.setPolicyName("policyName"); + configuration.setPolicyService("policyService"); + configuration.setPolicyTopic("policyTopic"); + configuration.setPollingInterval(30); + configuration.setPollingTimeout(100); + configuration.setSdnrService("sdnrService"); + configuration.setSdnrTopic("sdnrTopic"); + configuration.setSourceId("sourceId"); + String responseBody="{\n" + + "\"policyName\": \"com.Config_PCIMS_CONFIG_POLICY\",\n" + + "\"policyVersion\": \"1\",\n" + + "\"configBody\": \"{ \\\"PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS\\\":60,\n" + + "\\\"PCI_MODCONFIG_POLICY_NAME\\\":\\\"ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-\n" + + "529269fb1459\\\", \\\"PCI_OPTMIZATION_ALGO_CATEGORY_IN_OOF\\\":\\\"OOF-PCI-\n" + + "OPTIMIZATION\\\", \\\"PCI_SDNR_TARGET_NAME\\\":\\\"SDNR\\\" }\",\n" + + "\"policyClass\": \"Config\",\n" + + "\"policyConfigType\": \"Base\",\n" + + "\"ttlDate\": \"2018-08-29T06:28:16.830Z\",\n" + + "\"onapName\": \"DCAE\",\n" + + "\"configName\": \"PCIMS_CONFIG_POLICY\",\n" + + "\"configBodyType\": \"JSON\"\n" + + "}\n" + + ""; + PowerMockito.mockStatic(SonHandlerRestTemplate.class); + PowerMockito.mockStatic(Configuration.class); + PowerMockito.when(Configuration.getInstance()).thenReturn(configuration); + + PowerMockito.when(SonHandlerRestTemplate.sendPostToPolicy(Mockito.anyString(),Mockito.anyString() ,Matchers.>any())) + .thenReturn(ResponseEntity.ok(responseBody)); + String result=PolicyRestClient.fetchConfigFromPolicy(); + assertEquals(ResponseEntity.ok(responseBody).getBody(), result); + + + + + + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/RequestInfoTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/RequestInfoTest.java new file mode 100644 index 0000000..4d360d8 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/RequestInfoTest.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * ============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.restclient; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; +import org.onap.dcaegen2.services.sonhms.restclient.RequestInfo; + + +public class RequestInfoTest { + @Test + public void requestInfoTest() { + RequestInfo requestInfo = new RequestInfo(); + List optimizers = new ArrayList(); + optimizers.add("PCI"); + requestInfo.setCallbackUrl(""); + requestInfo.setNumSolutions(1); + requestInfo.setOptimizers(optimizers); + requestInfo.setRequestId("e44a4165-3cf4-4362-89de-e2375eed97e7"); + requestInfo.setRequestType("create"); + requestInfo.setSourceId("PCIHMS"); + requestInfo.setTimeout(60); + requestInfo.setTransactionId("3df7b0e9-26d1-4080-ba42-28e8a3139689"); + assertEquals(1, requestInfo.getNumSolutions()); + assertEquals(optimizers, requestInfo.getOptimizers()); + assertEquals("create", requestInfo.getRequestType()); + assertEquals("PCIHMS", requestInfo.getSourceId()); + assertEquals("3df7b0e9-26d1-4080-ba42-28e8a3139689", requestInfo.getTransactionId()); + assertEquals("e44a4165-3cf4-4362-89de-e2375eed97e7", requestInfo.getRequestId()); + assertEquals(60, requestInfo.getTimeout()); + assertEquals("", requestInfo.getCallbackUrl()); + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClientTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClientTest.java new file mode 100644 index 0000000..c13b698 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/SdnrRestClientTest.java @@ -0,0 +1,158 @@ +/******************************************************************************* + * ============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.restclient; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.dcaegen2.services.sonhms.Configuration; +import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException; +import org.onap.dcaegen2.services.sonhms.model.CellPciPair; +import org.onap.dcaegen2.services.sonhms.utils.SonHandlerRestTemplate; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.PowerMockRunnerDelegate; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.junit4.SpringRunner; +import org.slf4j.Logger; + +@RunWith(PowerMockRunner.class) +@PowerMockRunnerDelegate(SpringRunner.class) +@PrepareForTest({ SonHandlerRestTemplate.class,Configuration.class }) +@SpringBootTest(classes = SdnrRestClientTest.class) +public class SdnrRestClientTest { + + Configuration configuration = Configuration.getInstance(); + private static final Logger log = org.slf4j.LoggerFactory.getLogger(SdnrRestClient.class); + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void getCellListTest() { + + String responseBody="[\n" + + " \"string\"\n" + + "]"; + PowerMockito.mockStatic(SonHandlerRestTemplate.class); + PowerMockito.mockStatic(Configuration.class); + PowerMockito.when(Configuration.getInstance()).thenReturn(configuration); + PowerMockito.when(SonHandlerRestTemplate.sendGetRequest(Mockito.anyString(),Matchers.>any())) + .thenReturn(ResponseEntity.ok(responseBody)); + try { + String result=SdnrRestClient.getCellList("12345"); + assertEquals(ResponseEntity.ok(responseBody).getBody(),result); + } catch (ConfigDbNotFoundException e) { + log.debug("ConfigDbNotFoundException {}",e.toString());; + } + + } + + @Test + public void getNbrListTest() { + + String responseBody="[\n" + + " {\n" + + " \"cellId\": \"string\",\n" + + " \"pciValue\": 0\n" + + " }\n" + + "]"; + PowerMockito.mockStatic(SonHandlerRestTemplate.class); + PowerMockito.mockStatic(Configuration.class); + PowerMockito.when(Configuration.getInstance()).thenReturn(configuration); + PowerMockito.when(SonHandlerRestTemplate.sendGetRequest(Mockito.anyString(),Matchers.>any())) + .thenReturn(ResponseEntity.ok(responseBody)); + try { + List result=SdnrRestClient.getNbrList("1"); + List nbrList = new ArrayList<>(); + String response=ResponseEntity.ok(responseBody).getBody(); + JSONArray nbrListObj = new JSONArray(response); + for (int i = 0; i < nbrListObj.length(); i++) { + JSONObject cellObj = nbrListObj.getJSONObject(i); + CellPciPair cell = new CellPciPair(cellObj.getString("cellId"), cellObj.getInt("pciValue")); + nbrList.add(cell); + } + assertEquals(nbrList,result); + } catch (ConfigDbNotFoundException e) { + log.debug("ConfigDbNotFoundException {}",e.toString());; + } + + } + @Test + public void getPciTest() { + + String responseBody="{\n" + + " \"attribute-name\": \"string\",\n" + + " \"value\": 0\n" + + "}"; + PowerMockito.mockStatic(SonHandlerRestTemplate.class); + PowerMockito.mockStatic(Configuration.class); + PowerMockito.when(Configuration.getInstance()).thenReturn(configuration); + PowerMockito.when(SonHandlerRestTemplate.sendGetRequest(Mockito.anyString(),Matchers.>any())) + .thenReturn(ResponseEntity.ok(responseBody)); + try { + int result=SdnrRestClient.getPci("1"); + String response=ResponseEntity.ok(responseBody).getBody(); + JSONObject respObj = new JSONObject(response); + assertEquals(respObj.getInt("value"),result); + } catch (ConfigDbNotFoundException e) { + log.debug("ConfigDbNotFoundException {}",e.toString());; + } + + } + @Test + public void getPnfNameTest() { + + String responseBody="{\n" + + " \"attribute-name\": \"string\",\n" + + " \"value\": \"string\"\n" + + "}"; + PowerMockito.mockStatic(SonHandlerRestTemplate.class); + PowerMockito.mockStatic(Configuration.class); + PowerMockito.when(Configuration.getInstance()).thenReturn(configuration); + PowerMockito.when(SonHandlerRestTemplate.sendGetRequest(Mockito.anyString(),Matchers.>any())) + .thenReturn(ResponseEntity.ok(responseBody)); + try { + String result=SdnrRestClient.getPnfName("1"); + String response=ResponseEntity.ok(responseBody).getBody(); + JSONObject respObj = new JSONObject(response); + assertEquals(respObj.getString("value"),result); + } catch (ConfigDbNotFoundException e) { + log.debug("ConfigDbNotFoundException {}",e.toString());; + } + + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/SolutionsTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/SolutionsTest.java new file mode 100644 index 0000000..9decce0 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/SolutionsTest.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * ============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.restclient; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; +import org.onap.dcaegen2.services.sonhms.restclient.Solution; +import org.onap.dcaegen2.services.sonhms.restclient.SonSolution; + + + +public class SolutionsTest { + + @Test + public void solutionsTest() { + + SonSolution pciSolutions = new SonSolution(); + pciSolutions.setCellId("EXP001"); + pciSolutions.setPci(101); + List pciSolutionsList = new ArrayList(); + pciSolutionsList.add(pciSolutions); + Solution solutions = new Solution(); + solutions.setFinishTime("2018-10-01T00:40+01.00"); + solutions.setNetworkId("EXP001"); + solutions.setPciSolutions(pciSolutionsList); + solutions.setStartTime("2018-10-01T00:30+01:00"); + assertEquals("2018-10-01T00:40+01.00", solutions.getFinishTime()); + assertEquals("EXP001", solutions.getNetworkId()); + assertEquals(pciSolutionsList, solutions.getPciSolutions()); + assertEquals("2018-10-01T00:30+01:00", solutions.getStartTime()); + + } + +} diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtilsTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtilsTest.java new file mode 100644 index 0000000..dd3059a --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtilsTest.java @@ -0,0 +1,270 @@ +/******************************************************************************* + * ============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.utils; + +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.List; +import java.util.Map; +import java.util.UUID; + +import static org.junit.Assert.*; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.dcaegen2.services.sonhms.NotificationToClusterMapping; +import org.onap.dcaegen2.services.sonhms.child.Graph; +import org.onap.dcaegen2.services.sonhms.dao.ClusterDetailsRepository; +import org.onap.dcaegen2.services.sonhms.entity.ClusterDetails; +import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException; +import org.onap.dcaegen2.services.sonhms.model.CellPciPair; +import org.onap.dcaegen2.services.sonhms.model.FapServiceList; +import org.onap.dcaegen2.services.sonhms.model.Notification; +import org.onap.dcaegen2.services.sonhms.restclient.SdnrRestClient; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.PowerMockRunnerDelegate; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import fj.data.Either; + +@RunWith(PowerMockRunner.class) +@PowerMockRunnerDelegate(SpringRunner.class) +@PrepareForTest({ SdnrRestClient.class, BeanUtil.class }) +@SpringBootTest(classes = ClusterUtils.class) +public class ClusterUtilsTest { + + @Mock + private ClusterDetailsRepository clusterDetailsRepositoryMock; + + @InjectMocks + ClusterUtils clusterUtils; + + private static Notification notification1; + private static Notification notification2; + private static List clusterDetailsForGetClusterDetailsFromClusterIdTest; + private static Graph cluster; + private static List clusterDetails = new ArrayList<>(); + + @BeforeClass + public static void setup() { + + notification1 = new Notification(); + notification2 = new Notification(); + clusterDetailsForGetClusterDetailsFromClusterIdTest = new ArrayList(); + + String notificationString1 = readFromFile("/notification1.json"); + String notificationString2 = readFromFile("/notification2.json"); + String clusterDetailsListString=readFromFile("/ClusterDetailsTest.json"); + + String clusterInfo1 = readFromFile("/clusterInfo1.json"); + String clusterInfo2 = readFromFile("/clusterInfo2.json"); + String clusterInfo3 = readFromFile("/clusterInfo3.json"); + String clusterInfo4 = readFromFile("/clusterInfo4.json"); + String clusterInfo = readFromFile("/clusterInfo5.json"); + cluster=new Graph(clusterInfo); + + clusterDetails.add(new ClusterDetails("1", clusterInfo1, 35)); + clusterDetails.add(new ClusterDetails("2", clusterInfo2, 36)); + clusterDetails.add(new ClusterDetails("3", clusterInfo3, 37)); + clusterDetails.add(new ClusterDetails("4", clusterInfo4, 38)); + + + ObjectMapper mapper = new ObjectMapper(); + + try { + notification1 = mapper.readValue(notificationString1, Notification.class); + notification2 = mapper.readValue(notificationString2, Notification.class); + clusterDetailsForGetClusterDetailsFromClusterIdTest=mapper.readValue(clusterDetailsListString,new TypeReference>(){}); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + + } + + @Before + public void setupTest() { + clusterUtils = new ClusterUtils(); + MockitoAnnotations.initMocks(this); + } + + @Test + public void getClustersForNotificationTest(){ + + NotificationToClusterMapping expected = new NotificationToClusterMapping(); + Map cellsinCluster = new HashMap<>(); + cellsinCluster.put(notification1.getPayload().getRadioAccess().getFapServiceList().get(0), "2"); + expected.setCellsinCluster(cellsinCluster); + expected.setNewCells(new ArrayList()); + + NotificationToClusterMapping result = clusterUtils.getClustersForNotification(notification1, clusterDetails); + assertEquals(expected, result); + + expected = new NotificationToClusterMapping(); + List newCells = new ArrayList<>(); + newCells.add(notification2.getPayload().getRadioAccess().getFapServiceList().get(0)); + expected.setCellsinCluster(new HashMap<>()); + expected.setNewCells(newCells); + + result = clusterUtils.getClustersForNotification(notification2, clusterDetails); + assertEquals(expected, result); + } + + @Test + public void createClusterTest() throws ConfigDbNotFoundException { + + FapServiceList fapServiceList = notification1.getPayload().getRadioAccess().getFapServiceList().get(0); + + List nbrList = new ArrayList<>(); + + nbrList.add(new CellPciPair("44", 3)); + + PowerMockito.mockStatic(SdnrRestClient.class); + + PowerMockito.when(SdnrRestClient.getNbrList(Mockito.anyString())).thenReturn(nbrList); + + assertEquals(cluster, clusterUtils.createCluster(fapServiceList)); + + + + } + + @Test + public void getClusterDetailsFromClusterIdTest() { + ClusterDetails responseValue=null; + Integer responseVal = null; + Integer expectedValue=404; + Either response=clusterUtils.getClusterDetailsFromClusterId("0",clusterDetailsForGetClusterDetailsFromClusterIdTest); + assertTrue(response.isLeft()); + if(response.isLeft()) { + responseValue=response.left().value(); + } + assertEquals(clusterDetailsForGetClusterDetailsFromClusterIdTest.get(0),responseValue); + response=clusterUtils.getClusterDetailsFromClusterId("1",clusterDetailsForGetClusterDetailsFromClusterIdTest); + assertTrue(response.isLeft()); + if(response.isLeft()) { + responseValue=response.left().value(); + } + assertEquals(clusterDetailsForGetClusterDetailsFromClusterIdTest.get(1),responseValue); + response=clusterUtils.getClusterDetailsFromClusterId("9",clusterDetailsForGetClusterDetailsFromClusterIdTest); + assertTrue(response.isRight()); + if(response.isRight()) { + responseVal=response.right().value(); + } + assertEquals(expectedValue,responseVal); + + } + + @Test + public void saveClusterTest() { + ClusterDetails details = new ClusterDetails(); + details.setClusterId("123e4567-e89b-12d3-a456-426655440000"); + details.setClusterInfo("cellPciNeighbourString"); + details.setChildThreadId(978668); + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil.getBean(ClusterDetailsRepository.class)) + .thenReturn(clusterDetailsRepositoryMock); + Mockito.when(clusterDetailsRepositoryMock.save(details)).thenReturn(details); + Long threadId=(long) 978668; + clusterUtils.saveCluster(cluster, UUID.fromString("123e4567-e89b-12d3-a456-426655440000"),threadId); + assertEquals(details, clusterDetailsRepositoryMock.save(details)); + + } + + @Test + public void getClusterForCellTest() { + FapServiceList fapServiceList= notification1.getPayload().getRadioAccess().getFapServiceList().get(0); + String clusterInfo1=readFromFile("/clusterInfo1.json"); + String clusterInfo2=readFromFile("/clusterInfo2.json"); + Graph graph1=new Graph(clusterInfo1); + Graph graph2=new Graph(clusterInfo2); + List newClusters=new ArrayList(); + newClusters.add(graph1); + newClusters.add(graph2); + Either result=clusterUtils.getClusterForCell(fapServiceList, newClusters); + assertTrue(result.isLeft()); + + newClusters = new ArrayList<>(); + newClusters.add(graph1); + result=clusterUtils.getClusterForCell(fapServiceList, newClusters); + assertTrue(result.isRight()); + int resultRight=result.right().value(); + assertEquals(404, resultRight); + + List emptyList=new ArrayList(); + + result=clusterUtils.getClusterForCell(fapServiceList, emptyList); + assertTrue(result.isRight()); + resultRight=result.right().value(); + assertEquals(404, resultRight); + + } + + @Test + public void modifyClusterTest() { + + String clusterInfo = readFromFile("/clusterInfo2.json"); + String clusterInfo2 = readFromFile("/clusterInfo6.json"); + + Graph cluster = new Graph(clusterInfo); + Graph expected = new Graph(clusterInfo2); + + assertEquals(expected, clusterUtils.modifyCluster(cluster, notification1.getPayload().getRadioAccess().getFapServiceList().get(0))); + } + + 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) { + content = null; + } + return content; + } +} diff --git a/src/test/resources/ClusterDetailsTest.json b/src/test/resources/ClusterDetailsTest.json new file mode 100644 index 0000000..01839ae --- /dev/null +++ b/src/test/resources/ClusterDetailsTest.json @@ -0,0 +1,10 @@ +[{"clusterId":"0", +"clusterInfo":"", + "childThreadId":986476 +}, +{"clusterId":"1", +"clusterInfo":"", + "childThreadId":986475 +} +] + diff --git a/src/test/resources/clusterInfo1.json b/src/test/resources/clusterInfo1.json new file mode 100644 index 0000000..685d923 --- /dev/null +++ b/src/test/resources/clusterInfo1.json @@ -0,0 +1 @@ +[{"cellId":"29","physicalCellId":209,"neighbours":"[]"},{"cellId":"25","physicalCellId":32,"neighbours":"[{\"physicalCellId\":209,\"cellId\":\"29\"}]"}] diff --git a/src/test/resources/clusterInfo2.json b/src/test/resources/clusterInfo2.json new file mode 100644 index 0000000..6fe6d5e --- /dev/null +++ b/src/test/resources/clusterInfo2.json @@ -0,0 +1 @@ +[{"cellId":"45","physicalCellId":310,"neighbours":"[]"},{"cellId":"47","physicalCellId":302,"neighbours":"[{\"physicalCellId\":310,\"cellId\":\"45\"}]"}] diff --git a/src/test/resources/clusterInfo3.json b/src/test/resources/clusterInfo3.json new file mode 100644 index 0000000..71e7736 --- /dev/null +++ b/src/test/resources/clusterInfo3.json @@ -0,0 +1 @@ +[{"cellId":"72","physicalCellId":2,"neighbours":"[]"},{"cellId":"63","physicalCellId":5,"neighbours":"[{\"physicalCellId\":2,\"cellId\":\"72\"}]"}] diff --git a/src/test/resources/clusterInfo4.json b/src/test/resources/clusterInfo4.json new file mode 100644 index 0000000..4da8c07 --- /dev/null +++ b/src/test/resources/clusterInfo4.json @@ -0,0 +1 @@ +[{"cellId":"2","physicalCellId":20,"neighbours":"[]"},{"cellId":"5","physicalCellId":30,"neighbours":"[{\"physicalCellId\":20,\"cellId\":\"2\"}]"}] diff --git a/src/test/resources/clusterInfo5.json b/src/test/resources/clusterInfo5.json new file mode 100644 index 0000000..7612d10 --- /dev/null +++ b/src/test/resources/clusterInfo5.json @@ -0,0 +1 @@ +[{"cellId":"44","physicalCellId":3,"neighbours":"[]"},{"cellId":"48","physicalCellId":0,"neighbours":"[{\"physicalCellId\":3,\"cellId\":\"44\"}]"},{"cellId":"45","physicalCellId":310,"neighbours":"[{\"physicalCellId\":0,\"cellId\":\"48\"}]"}] diff --git a/src/test/resources/clusterInfo6.json b/src/test/resources/clusterInfo6.json new file mode 100644 index 0000000..88e0763 --- /dev/null +++ b/src/test/resources/clusterInfo6.json @@ -0,0 +1 @@ +[{"cellId":"48","physicalCellId":0,"neighbours":"[]"},{"cellId":"45","physicalCellId":310,"neighbours":"[{\"physicalCellId\":0,\"cellId\":\"48\"}]"},{"cellId":"47","physicalCellId":302,"neighbours":"[{\"physicalCellId\":310,\"cellId\":\"45\"}]"}] diff --git a/src/test/resources/clusterInfo7.json b/src/test/resources/clusterInfo7.json new file mode 100644 index 0000000..1d8dc7d --- /dev/null +++ b/src/test/resources/clusterInfo7.json @@ -0,0 +1 @@ +[{"cellId":"82","physicalCellId":32,"neighbours":"[]"},{"cellId":"81","physicalCellId":31,"neighbours":"[{\"physicalCellId\":32,\"cellId\":\"82\"}]"}] diff --git a/src/test/resources/notification1.json b/src/test/resources/notification1.json new file mode 100644 index 0000000..87f60e6 --- /dev/null +++ b/src/test/resources/notification1.json @@ -0,0 +1,45 @@ +{ + "requestID":"9d2d790e-a5f0-11e8-98d0-529269fb1459", + "AAI":{ + + }, + "from":"SDNR", + "version":"1.0.2", + "Action":"NeighborListModified", + "Payload":{ + "RadioAccess":{ + "FAPServiceNumberOfEntries":"1", + "FAPServiceList":[ + { + "alias":"45", + "X0005b9Lte":{ + "phyCellIdInUse":"310", + "pnfName":"ncserver2" + }, + "CellConfig":{ + "LTE":{ + "RAN":{ + "CellIdentity":"45", + "NeighborListInUse":{ + "LTECellNumberOfEntries":"1", + "LTENeighborListInUseLTECell":[ + { + "pnfName":"ncserver1", + "enable":"true", + "alias":"48", + "mustInclude":"true", + "plmnid":"ran-1", + "cid":"48", + "phyCellId":"0", + "blacklisted":"false" + } + ] + } + } + } + } + } + ] + } + } +} diff --git a/src/test/resources/notification2.json b/src/test/resources/notification2.json new file mode 100644 index 0000000..702b643 --- /dev/null +++ b/src/test/resources/notification2.json @@ -0,0 +1,55 @@ +{ + "requestID":"9d2d790e-a5f0-11e8-98d0-529269fb1459", + "AAI":{ + + }, + "from":"SDNR", + "version":"1.0.2", + "Action":"NeighborListModified", + "Payload":{ + "RadioAccess":{ + "FAPServiceNumberOfEntries":"1", + "FAPServiceList":[ + { + "alias":"120", + "X0005b9Lte":{ + "phyCellIdInUse":"2", + "pnfName":"ncserver2" + }, + "CellConfig":{ + "LTE":{ + "RAN":{ + "CellIdentity":"120", + "NeighborListInUse":{ + "LTECellNumberOfEntries":"3", + "LTENeighborListInUseLTECell":[ + { + "pnfName":"ncserver1", + "enable":"true", + "alias":"123", + "mustInclude":"true", + "plmnid":"ran-1", + "cid":"123", + "phyCellId":"6", + "blacklisted":"false" + }, + { + "pnfName":"ncserver1", + "enable":"true", + "alias":"49", + "mustInclude":"true", + "plmnid":"ran-1", + "cid":"124", + "phyCellId":"4", + "blacklisted":"false" + } + ] + } + } + } + } + } + ] + } + } +} diff --git a/src/test/resources/notification3.json b/src/test/resources/notification3.json new file mode 100644 index 0000000..4a3a2a0 --- /dev/null +++ b/src/test/resources/notification3.json @@ -0,0 +1,45 @@ +{ + "requestID":"9d2d790e-a5f0-11e8-98d0-529269fb1459", + "AAI":{ + + }, + "from":"SDNR", + "version":"1.0.2", + "Action":"NeighborListModified", + "Payload":{ + "RadioAccess":{ + "FAPServiceNumberOfEntries":"1", + "FAPServiceList":[ + { + "alias":"81", + "X0005b9Lte":{ + "phyCellIdInUse":"31", + "pnfName":"ncserver2" + }, + "CellConfig":{ + "LTE":{ + "RAN":{ + "CellIdentity":"81", + "NeighborListInUse":{ + "LTECellNumberOfEntries":"1", + "LTENeighborListInUseLTECell":[ + { + "pnfName":"ncserver1", + "enable":"true", + "alias":"82", + "mustInclude":"true", + "plmnid":"ran-1", + "cid":"82", + "phyCellId":"32", + "blacklisted":"false" + } + ] + } + } + } + } + } + ] + } + } +} diff --git a/src/test/resources/policy_notification.json b/src/test/resources/policy_notification.json new file mode 100644 index 0000000..b9a6910 --- /dev/null +++ b/src/test/resources/policy_notification.json @@ -0,0 +1,20 @@ +{ + + "closedLoopControlName":"ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459", + "closedLoopAlarmStart":1542445563201, + "closedLoopEventClient":"microservice.PCI", + "closedLoopEventStatus":"ONSET", + "target_type":"VNF", + "target":"generic-vnf.vnf-id", + "requestID":"a4130fd5-2291-4a83-8992-04e4c9f32731", + "from":"PCIMS", + "version":"1.0.2", + "payload":"{\"Configurations\":[{\"data\":{\"FAPService\":{\"alias\":\"Chn0330\",\"X0005b9Lte\":{\"phyCellIdInUse\":6,\"pnfName\":\"ncserver23\"},\"CellConfig\":{\"LTE\":{\"RAN\":{\"Common\":{\"CellIdentity\":\"Chn0330\"}}}}}}},{\"data\":{\"FAPService\":{\"alias\":\"Chn0331\",\"X0005b9Lte\":{\"phyCellIdInUse\":7,\"pnfName\":\"ncserver23\"},\"CellConfig\":{\"LTE\":{\"RAN\":{\"Common\":{\"CellIdentity\":\"Chn0331\"}}}}}}}]}", + "AAI":{ + "generic-vnf.prov-status":"ACTIVE", + "generic-vnf.is-closed-loop-disabled":"false", + "generic-vnf.vnf-id":"ncserver23" + }, + "Action":"ModifyConfig" + +} diff --git a/src/test/resources/solutions.json b/src/test/resources/solutions.json new file mode 100644 index 0000000..cf82283 --- /dev/null +++ b/src/test/resources/solutions.json @@ -0,0 +1 @@ +[{"startTime":"2016-10-01T00:30+01:00","finishTime":"2016-10-01T00:40+01.00","networkId":"NTWK005","pciSolutions":[{"cellId":"EXP001","pci":"101"},{"cellId":"EXP002","pci":"102"}]}] -- cgit 1.2.3-korg