diff options
119 files changed, 9122 insertions, 750 deletions
diff --git a/LICENSE.txt b/LICENSE.txt index 8d36830..22e7ef8 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,7 +1,7 @@ /* * ============LICENSE_START========================================== * =================================================================== -* Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. +* Copyright (c) 2018 NOKIA Intellectual Property. All rights reserved. * =================================================================== * * Unless otherwise specified, all software contained herein is licensed @@ -33,7 +33,4 @@ * limitations under the License. * * ============LICENSE_END============================================ -* -* -*/ - +*/
\ No newline at end of file diff --git a/mvn-phase-lib.sh b/mvn-phase-lib.sh deleted file mode 100755 index 8354a61..0000000 --- a/mvn-phase-lib.sh +++ /dev/null @@ -1,387 +0,0 @@ -#!/bin/bash - -# ================================================================================ -# Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -# - - -#MVN_PROJECT_MODULEID="$1" -#MVN_PHASE="$2" -#PROJECT_ROOT=$(dirname $0) - -FQDN="${MVN_PROJECT_GROUPID}.${MVN_PROJECT_ARTIFACTID}" -if [ "$MVN_PROJECT_MODULEID" == "__" ]; then - MVN_PROJECT_MODULEID="" -fi - -if [[ "$MVN_PROJECT_VERSION" == *SNAPSHOT ]]; then - echo "=> for SNAPSHOT artifact build" - MVN_DEPLOYMENT_TYPE='SNAPSHOT' -else - echo "=> for STAGING/RELEASE artifact build" - MVN_DEPLOYMENT_TYPE='STAGING' -fi -echo "MVN_DEPLOYMENT_TYPE is [$MVN_DEPLOYMENT_TYPE]" - - -TIMESTAMP=$(date +%C%y%m%dT%H%M%S) - -# expected environment variables -if [ -z "${MVN_NEXUSPROXY}" ]; then - echo "MVN_NEXUSPROXY environment variable not set. Cannot proceed" - exit -fi -MVN_NEXUSPROXY_HOST=$(echo "$MVN_NEXUSPROXY" |cut -f3 -d'/' | cut -f1 -d':') -echo "=> Nexus Proxy at $MVN_NEXUSPROXY_HOST, $MVN_NEXUSPROXY" - -if [ -z "$WORKSPACE" ]; then - WORKSPACE=$(pwd) -fi - -if [ -z "$SETTINGS_FILE" ]; then - echo "SETTINGS_FILE environment variable not set. Cannot proceed" - exit -fi - - - -# mvn phase in life cycle -MVN_PHASE="$2" - -echo "MVN_PROJECT_MODULEID is [$MVN_PROJECT_MODULEID]" -echo "MVN_PHASE is [$MVN_PHASE]" -echo "MVN_PROJECT_GROUPID is [$MVN_PROJECT_GROUPID]" -echo "MVN_PROJECT_ARTIFACTID is [$MVN_PROJECT_ARTIFACTID]" -echo "MVN_PROJECT_VERSION is [$MVN_PROJECT_VERSION]" -echo "MVN_NEXUSPROXY is [$MVN_NEXUSPROXY]" -echo "MVN_RAWREPO_BASEURL_UPLOAD is [$MVN_RAWREPO_BASEURL_UPLOAD]" -echo "MVN_RAWREPO_BASEURL_DOWNLOAD is [$MVN_RAWREPO_BASEURL_DOWNLOAD]" -MVN_RAWREPO_HOST=$(echo "$MVN_RAWREPO_BASEURL_UPLOAD" | cut -f3 -d'/' |cut -f1 -d':') -echo "MVN_RAWREPO_HOST is [$MVN_RAWREPO_HOST]" -echo "MVN_RAWREPO_SERVERID is [$MVN_RAWREPO_SERVERID]" -echo "MVN_DOCKERREGISTRY_DAILY is [$MVN_DOCKERREGISTRY_DAILY]" -echo "MVN_DOCKERREGISTRY_RELEASE is [$MVN_DOCKERREGISTRY_RELEASE]" - -echo "MVN_PYPISERVER_SERVERID [$MVN_PYPISERVER_SERVERID]" -echo "MVN_PYPISERVER_BASEURL is [$MVN_PYPISERVER_BASEURL]" - - - -clean_templated_files() -{ - TEMPLATE_FILES=$(find . -name "*-template") - for F in $TEMPLATE_FILES; do - F2=$(echo "$F" | sed 's/-template$//') - rm -f "$F2" - done -} -clean_tox_files() -{ - TOX_FILES=$(find . -name ".tox") - TOX_FILES="$TOX_FILES $(find . -name 'venv-tox')" - for F in $TOX_FILES; do - rm -rf "$F" - done -} - -expand_templates() -{ - # set up env variables, get ready for template resolution - # NOTE: CCSDK artifacts do not distinguish REALESE vs SNAPSHOTs - export ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.ccsdk.platform.plugins" - export ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_snapshots="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.ccsdk.platform.plugins" - export ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_blueprints_releases="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.ccsdk.platform.blueprints" - export ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_blueprints_snapshots="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.ccsdk.platform.blueprints" - - export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_releases="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2/releases" - export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_snapshots="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2/snapshots" - export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_releases="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2.platform.plugins/releases" - export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_snapshots="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2.platform.plugins/snapshots" - export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_blueprints_releases="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2.platform.blueprints/releases" - export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_blueprints_snapshots="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2.platform.blueprints/snapshots" - - export ONAPTEMPLATE_PYPIURL_org_onap_dcaegen2="$MVN_PYPISERVER_BASEURL" - - export ONAPTEMPLATE_DOCKERREGURL_org_onap_dcaegen2_releases="$MVN_DOCKERREGISTRY_DAILY" - export ONAPTEMPLATE_DOCKERREGURL_org_onap_dcaegen2_snapshots="$MVN_DOCKERREGISTRY_DAILY/snapshots" - - - TEMPLATE_FILES=$(find . -name "*-template") - for F in $TEMPLATE_FILES; do - F2=$(echo "$F" | sed 's/-template$//') - cp "$F" "$F2" - MOD=$(stat --format '%a' "$F") - chmod "$MOD" "$F2" - done - - - TEMPLATES=$(env |grep ONAPTEMPLATE) - if [ -z "$TEMPLATES" ]; then - return 0 - fi - - echo "====> Resolving the following temaplate from environment variables " - echo "[$TEMPLATES]" - SELFFILE=$(echo "$0" | rev | cut -f1 -d '/' | rev) - for TEMPLATE in $TEMPLATES; do - KEY=$(echo "$TEMPLATE" | cut -f1 -d'=') - VALUE=$(echo "$TEMPLATE" | cut -f2 -d'=') - VALUE2=$(echo "$TEMPLATE" | cut -f2 -d'=' |sed 's/\//\\\//g') - set +e - FILES=$(grep -rl "$KEY") - set -e - - if [ -z "$FILES" ]; then - continue - fi - - # assuming FILES is not longer than 2M bytes, the limit for variable value max size on this VM - for F in $FILES; do - if [[ $F == *"$SELFFILE" ]]; then - continue - fi - if [[ "$F" == *-template ]]; then - continue - fi - - echo "======> Resolving template $KEY to value $VALUE for file $F" - sed -i "s/{{[[:space:]]*$KEY[[:space:]]*}}/$VALUE2/g" "$F" - #cat "$F" - done - - #if [ ! -z "$FILES" ]; then - # echo "====> Resolving template $VALUE to value $VALUE" - # #CMD="grep -rl \"$VALUE\" | tr '\n' '\0' | xargs -0 sed -i \"s/{{[[:space:]]*$VALUE[[:space:]]*}}/$VALUE/g\"" - # grep -rl "$KEY" | tr '\n' '\0' | xargs -0 sed -i 's/$KEY/$VALUE2/g' - # #echo $CMD - # #eval $CMD - #fi - done - echo "====> Done template reolving" -} - - -run_tox_test() -{ - set -x - CURDIR=$(pwd) - TOXINIS=$(find . -name "tox.ini") - for TOXINI in "${TOXINIS[@]}"; do - DIR=$(echo "$TOXINI" | rev | cut -f2- -d'/' | rev) - cd "${CURDIR}/${DIR}" - rm -rf ./venv-tox ./.tox - virtualenv ./venv-tox - source ./venv-tox/bin/activate - pip install --upgrade pip - pip install --upgrade tox argparse - pip freeze - tox - deactivate - rm -rf ./venv-tox ./.tox - done -} - -build_wagons() -{ - rm -rf ./*.wgn venv-pkg - - SETUPFILES=$(find . -name "setup.py") - for SETUPFILE in $SETUPFILES; do - PLUGIN_DIR=$(echo "$SETUPFILE" |rev | cut -f 2- -d '/' |rev) - PLUGIN_NAME=$(grep 'name' "$SETUPFILE" | cut -f2 -d'=' | sed 's/[^0-9a-zA-Z\.]*//g') - PLUGIN_VERSION=$(grep 'version' "$SETUPFILE" | cut -f2 -d'=' | sed 's/[^0-9\.]*//g') - - echo "In $PLUGIN_DIR, $PLUGIN_NAME, $PLUGIN_VERSION" - - virtualenv ./venv-pkg - source ./venv-pkg/bin/activate - pip install --upgrade pip - pip install wagon - wagon create --format tar.gz "$PLUGIN_DIR" - deactivate - rm -rf venv-pkg - - PKG_FILE_NAMES=( "${PLUGIN_NAME}-${PLUGIN_VERSION}"*.wgn ) - echo Built package: "${PKG_FILE_NAMES[@]}" - done -} - - -upload_raw_file() -{ - # Extract the username and password to the nexus repo from the settings file - USER=$(xpath -q -e "//servers/server[id='$MVN_RAWREPO_SERVERID']/username/text()" "$SETTINGS_FILE") - PASS=$(xpath -q -e "//servers/server[id='$MVN_RAWREPO_SERVERID']/password/text()" "$SETTINGS_FILE") - NETRC=$(mktemp) - echo "machine $MVN_RAWREPO_HOST login $USER password $PASS" > "$NETRC" - - REPO="$MVN_RAWREPO_BASEURL_UPLOAD" - - OUTPUT_FILE=$(echo "$1" | sed -e "s/^.\///") - EXT=$(echo "$OUTPUT_FILE" | rev |cut -f1 -d '.' |rev) - if [ "$EXT" == 'yaml' ]; then - OUTPUT_FILE_TYPE='text/x-yaml' - elif [ "$EXT" == 'json' ]; then - OUTPUT_FILE_TYPE='application/json' - elif [ "$EXT" == 'sh' ]; then - OUTPUT_FILE_TYPE='text/x-shellscript' - elif [ "$EXT" == 'gz' ]; then - OUTPUT_FILE_TYPE='application/gzip' - elif [ "$EXT" == 'wgn' ]; then - OUTPUT_FILE_TYPE='application/gzip' - else - OUTPUT_FILE_TYPE='application/octet-stream' - fi - - - if [ "$MVN_DEPLOYMENT_TYPE" == 'SNAPSHOT' ]; then - SEND_TO="${REPO}/${MVN_PROJECT_GROUPID}/snapshots" - elif [ "$MVN_DEPLOYMENT_TYPE" == 'STAGING' ]; then - SEND_TO="${REPO}/{$MVN_PROJECT_GROUPID}/releases" - else - echo "Unreconfnized deployment type, quit" - exit - fi - if [ ! -z "$MVN_PROJECT_MODULEID" ]; then - SEND_TO="$SEND_TO/$MVN_PROJECT_MODULEID" - fi - - echo "Sending ${OUTPUT_FILE} to Nexus: ${SEND_TO}" - curl -vkn --netrc-file "${NETRC}" --upload-file "${OUTPUT_FILE}" -X PUT -H "Content-Type: $OUTPUT_FILE_TYPE" "${SEND_TO}/${OUTPUT_FILE}-${MVN_PROJECT_VERSION}-${TIMESTAMP}" - curl -vkn --netrc-file "${NETRC}" --upload-file "${OUTPUT_FILE}" -X PUT -H "Content-Type: $OUTPUT_FILE_TYPE" "${SEND_TO}/${OUTPUT_FILE}-${MVN_PROJECT_VERSION}" - curl -vkn --netrc-file "${NETRC}" --upload-file "${OUTPUT_FILE}" -X PUT -H "Content-Type: $OUTPUT_FILE_TYPE" "${SEND_TO}/${OUTPUT_FILE}" -} - - - -upload_wagons_and_type_yamls() -{ - WAGONS=$(ls -1 ./*.wgn) - for WAGON in $WAGONS ; do - WAGON_NAME=$(echo "$WAGON" | cut -f1 -d '-') - WAGON_VERSION=$(echo "$WAGON" | cut -f2 -d '-') - WAGON_TYPEFILE=$(grep -rl "$WAGON_NAME" | grep yaml | head -1) - - upload_raw_file "$WAGON" - upload_raw_file "$WAGON_TYPEFILE" - done -} - -upload_files_of_extension() -{ - FILES=$(ls -1 ./*."$1") - for F in $FILES ; do - upload_raw_file "$F" - done -} - - -generate_pypirc_then_publish() -{ - set +x - USER=$(xpath -e "//servers/server[id='$MVN_PYPISERVER_SERVERID']/username/text()" "$SETTINGS_FILE") - PASS=$(xpath -e "//servers/server[id='$MVN_PYPISERVER_SERVERID']/password/text()" "$SETTINGS_FILE") - - if [[ "$MVN_PYPISERVER_BASEURL" != */ ]]; then - MVN_PYPISERVER_BASEURL="${MVN_PYPISERVER_BASEURL}/" - fi - - - cat > ~/.pypirc <<EOL -[distutils] -index-servers = - $MVN_PYPISERVER_SERVERID - -[$MVN_PYPISERVER_SERVERID] -repository: $MVN_PYPISERVER_BASEURL -username: $USER -password: $PASS -EOL - - # this may fail if a package of same version exists - python setup.py sdist register -r "$MVN_PYPISERVER_SERVERID" upload -r "$MVN_PYPISERVER_SERVERID" - set -x -} - - - -build_and_push_docker() -{ - IMAGENAME="onap/${FQDN}.${MVN_PROJECT_MODULEID}" - IMAGENAME=$(echo "$IMAGENAME" | sed -e 's/_*$//g' -e 's/\.*$//g') - IMAGENAME=$(echo "$IMAGENAME" | tr '[:upper:]' '[:lower:]') - - # use the major and minor version of the MVN artifact version as docker image version - VERSION="${MVN_PROJECT_VERSION//[^0-9.]/}" - VERSION2=$(echo "$VERSION" | cut -f1-2 -d'.') - - LFQI="${IMAGENAME}:${VERSION}-${TIMESTAMP}" - # build a docker image - docker build --rm -f ./Dockerfile -t "${LFQI}" ./ - - REPO="" - if [ $MVN_DEPLOYMENT_TYPE == "SNAPSHOT" ]; then - REPO=$MVN_DOCKERREGISTRY_DAILY - elif [ $MVN_DEPLOYMENT_TYPE == "STAGING" ]; then - # there seems to be no staging docker registry? set to use SNAPSHOT also - #REPO=$MVN_DOCKERREGISTRY_RELEASE - REPO=$MVN_DOCKERREGISTRY_DAILY - else - echo "Fail to determine DEPLOYMENT_TYPE" - REPO=$MVN_DOCKERREGISTRY_DAILY - fi - echo "DEPLOYMENT_TYPE is: $MVN_DEPLOYMENT_TYPE, repo is $REPO" - - if [ ! -z "$REPO" ]; then - USER=$(xpath -e "//servers/server[id='$REPO']/username/text()" "$SETTINGS_FILE") - PASS=$(xpath -e "//servers/server[id='$REPO']/password/text()" "$SETTINGS_FILE") - if [ -z "$USER" ]; then - echo "Error: no user provided" - fi - if [ -z "$PASS" ]; then - echo "Error: no password provided" - fi - [ -z "$PASS" ] && PASS_PROVIDED="<empty>" || PASS_PROVIDED="<password>" - echo docker login "$REPO" -u "$USER" -p "$PASS_PROVIDED" - docker login "$REPO" -u "$USER" -p "$PASS" - - if [ $MVN_DEPLOYMENT_TYPE == "SNAPSHOT" ]; then - REPO="$REPO/snapshots" - elif [ $MVN_DEPLOYMENT_TYPE == "STAGING" ]; then - # there seems to be no staging docker registry? set to use SNAPSHOT also - #REPO=$MVN_DOCKERREGISTRY_RELEASE - REPO="$REPO" - else - echo "Fail to determine DEPLOYMENT_TYPE" - REPO="$REPO/unknown" - fi - - OLDTAG="${LFQI}" - PUSHTAGS="${REPO}/${IMAGENAME}:${VERSION2}-${TIMESTAMP} ${REPO}/${IMAGENAME}:${VERSION2} ${REPO}/${IMAGENAME}:${VERSION2}-latest" - for NEWTAG in ${PUSHTAGS} - do - echo "tagging ${OLDTAG} to ${NEWTAG}" - docker tag "${OLDTAG}" "${NEWTAG}" - echo "pushing ${NEWTAG}" - docker push "${NEWTAG}" - OLDTAG="${NEWTAG}" - done - fi - -} - - - diff --git a/mvn-phase-script.sh b/mvn-phase-script.sh deleted file mode 100755 index a6dce1b..0000000 --- a/mvn-phase-script.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash - -# ================================================================================ -# Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -# - - -set -ex - - -echo "running script: [$0] for module [$1] at stage [$2]" - -MVN_PROJECT_MODULEID="$1" -MVN_PHASE="$2" -PROJECT_ROOT=$(dirname $0) - -# expected environment variables -if [ -z "${MVN_NEXUSPROXY}" ]; then - echo "MVN_NEXUSPROXY environment variable not set. Cannot proceed" - exit 1 -fi -if [ -z "$SETTINGS_FILE" ]; then - echo "SETTINGS_FILE environment variable not set. Cannot proceed" - exit 2 -fi - - -source "${PROJECT_ROOT}"/mvn-phase-lib.sh - - -# This is the base for where "deploy" will upload -# MVN_NEXUSPROXY is set in the pom.xml -REPO=$MVN_NEXUSPROXY/content/sites/raw/$MVN_PROJECT_GROUPID - -TIMESTAMP=$(date +%C%y%m%dT%H%M%S) -export BUILD_NUMBER="${TIMESTAMP}" - - -shift 2 - -case $MVN_PHASE in -clean) - echo "==> clean phase script" - clean_templated_files - clean_tox_files - rm -rf ./venv-* ./*.wgn ./site ./coverage.xml ./xunit-results.xml - ;; -generate-sources) - echo "==> generate-sources phase script" - expand_templates - ;; -compile) - echo "==> compile phase script" - ;; -test) - echo "==> test phase script" - set +e - run_tox_test - set -e - ;; -package) - echo "==> package phase script" - ;; -install) - echo "==> install phase script" - ;; -deploy) - echo "==> deploy phase script" - case $MVN_PROJECT_MODULEID in - *) - #generate_pypirc_then_publish - ;; - esac - ;; -*) - echo "==> unprocessed phase" - ;; -esac - @@ -1,282 +1,254 @@ -<?xml version="1.0"?> +<?xml version="1.0" encoding="UTF-8"?> <!-- -================================================================================ -Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. -================================================================================ -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -============LICENSE_END========================================================= - + ============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========================================================= --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <groupId>org.onap.dcaegen2.services</groupId> + <artifactId>son-handler</artifactId> + <name>dcaegen2-services-son-handler</name> + <version>1.0.0-SNAPSHOT</version> + + <!--parent> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-parent</artifactId> + <version>2.0.4.RELEASE</version> + </parent--> + <parent> <groupId>org.onap.oparent</groupId> <artifactId>oparent</artifactId> <version>1.2.1</version> <relativePath/> </parent> - <parent> - <!--- CHANGE THE FOLLOWING 3 OBJECTS for your own repo --> - <groupId>org.onap.dcaegen2.services</groupId> - <artifactId>son-handler</artifactId> - <name>dcaegen2-services-son-handler</name> - <version>1.0.0-SNAPSHOT</version> - <url>http://maven.apache.org</url> + + <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <sonar.skip>true</sonar.skip> - <sonar.sources>.</sonar.sources> - <!-- customize the SONARQUBE URL --> - <!-- sonar.host.url>http://localhost:9000</sonar.host.url --> - <!-- below are language dependent --> - <!-- for Python --> - <sonar.language>py</sonar.language> - <sonar.pluginName>Python</sonar.pluginName> - <sonar.inclusions>**/*.py</sonar.inclusions> - <!-- for JavaScaript --> - <!-- - <sonar.language>js</sonar.language> - <sonar.pluginName>JS</sonar.pluginName> - <sonar.inclusions>**/*.js</sonar.inclusions> - --> + <maven.compiler.source>1.8</maven.compiler.source> + <maven.compiler.target>1.8</maven.compiler.target> </properties> + + <dependencies> + <dependency> + <!-- Import dependency management from Spring Boot --> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-dependencies</artifactId> + <version>2.0.4.RELEASE</version> + <type>pom</type> + <scope>import</scope> + </dependency> + <dependency> + <groupId>com.att.nsa</groupId> + <artifactId>cambriaClient</artifactId> + <version>0.0.1</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + <version>2.9.6</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>2.9.6</version> + </dependency> +<!-- https://mvnrepository.com/artifact/javax.json/javax.json-api --> +<dependency> + <groupId>javax.json</groupId> + <artifactId>javax.json-api</artifactId> + <version>1.1.2</version> + </dependency> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + <version>2.0.4.RELEASE</version> + </dependency> + <dependency> + <groupId>org.postgresql</groupId> + <artifactId>postgresql</artifactId> + <version>42.2.4</version> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-data-jpa</artifactId> + <version>2.0.4.RELEASE</version> + </dependency> +<dependency> + <groupId>org.springframework.data</groupId> + <artifactId>spring-data-commons-core</artifactId> + <version>1.0.0.RELEASE</version> +</dependency> + + + +<!-- https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-mapper-asl --> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-mapper-asl</artifactId> + <version>1.9.13</version> + </dependency> + <dependency> + <groupId>org.hibernate.javax.persistence</groupId> + <artifactId>hibernate-jpa-2.0-api</artifactId> + <version>1.0.1.Final</version> + </dependency> +<!-- https://mvnrepository.com/artifact/org.springframework/spring-beans --> +<dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + <version>5.0.8.RELEASE</version> +</dependency> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> +<version>2.0.4.RELEASE</version> + <scope>test</scope> + <!-- exclusions> + <exclusion> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </exclusion> + </exclusions--> + </dependency> + <!-- https://mvnrepository.com/artifact/org.mockito/mockito-core --> + +<dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <version>1.10.16</version> + <scope>test</scope> +</dependency> + + +<dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>test</scope> + </dependency> + <!-- https://mvnrepository.com/artifact/org.powermock/powermock-module-junit4 --> +<!-- https://mvnrepository.com/artifact/org.powermock/powermock-api-mockito --> +<dependency> + <groupId>org.powermock</groupId> + <artifactId>powermock-api-mockito</artifactId> + <version>1.6.4</version> + <scope>test</scope> +</dependency> +<!-- https://mvnrepository.com/artifact/org.powermock/powermock-module-junit4 --> +<dependency> + <groupId>org.powermock</groupId> + <artifactId>powermock-module-junit4</artifactId> + <version>1.6.4</version> + <scope>test</scope> +</dependency> + + + + + </dependencies> + <build> - <finalName>${project.artifactId}-${project.version}</finalName> - <pluginManagement> - <plugins> - <!-- the following plugins are invoked from oparent, we do not need them --> - <plugin> - <groupId>org.sonatype.plugins</groupId> - <artifactId>nexus-staging-maven-plugin</artifactId> - <version>1.6.7</version> - <configuration> - <skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-deploy-plugin</artifactId> - <!-- This version supports the "deployAtEnd" parameter --> - <version>2.8</version> - <configuration> - <skip>true</skip> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-enforcer-plugin</artifactId> - <version>3.0.0-M1</version> - <configuration> - <skip>true</skip> - </configuration> - </plugin> - <!-- first disable the default Java plugins at various stages --> - <!-- maven-resources-plugin is called during "*resource" phases by default behavior. it prepares the resources - dir. we do not need it --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-resources-plugin</artifactId> - <version>2.6</version> - <configuration> - <skip>true</skip> - </configuration> - </plugin> - <!-- maven-compiler-plugin is called during "compile" phases by default behavior. we do not need it --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.1</version> - <configuration> - <skip>true</skip> - </configuration> - </plugin> - <!-- maven-jar-plugin is called during "compile" phase by default behavior. we do not need it --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <version>2.4</version> - <executions> - <execution> - <id>default-jar</id> - <phase/> - </execution> - </executions> - </plugin> - <!-- maven-install-plugin is called during "install" phase by default behavior. it tries to copy stuff under - target dir to ~/.m2. we do not need it --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-install-plugin</artifactId> - <version>2.4</version> - <configuration> - <skip>true</skip> - </configuration> - </plugin> - <!-- maven-surefire-plugin is called during "test" phase by default behavior. it triggers junit test. - we do not need it --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <version>2.12.4</version> - <configuration> - <skipTests>true</skipTests> - </configuration> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <version>1.2.1</version> - <configuration> - <executable>${session.executionRootDirectory}/mvn-phase-script.sh</executable> - <environmentVariables> - <!-- make mvn properties as env for our script --> - <!-- make mvn properties as env for our script --> - <MVN_PROJECT_GROUPID>${project.groupId}</MVN_PROJECT_GROUPID> - <MVN_PROJECT_ARTIFACTID>${project.artifactId}</MVN_PROJECT_ARTIFACTID> - <MVN_PROJECT_VERSION>${project.version}</MVN_PROJECT_VERSION> - <MVN_NEXUSPROXY>${onap.nexus.url}</MVN_NEXUSPROXY> - <MVN_RAWREPO_BASEURL_UPLOAD>${onap.nexus.rawrepo.baseurl.upload}</MVN_RAWREPO_BASEURL_UPLOAD> - <MVN_RAWREPO_BASEURL_DOWNLOAD>${onap.nexus.rawrepo.baseurl.download}</MVN_RAWREPO_BASEURL_DOWNLOAD> - <MVN_RAWREPO_SERVERID>${onap.nexus.rawrepo.serverid}</MVN_RAWREPO_SERVERID> - <MVN_DOCKERREGISTRY_SNAPSHOT>${onap.nexus.dockerregistry.snapshot}</MVN_DOCKERREGISTRY_SNAPSHOT> - <MVN_DOCKERREGISTRY_RELEASE>${onap.nexus.dockerregistry.release}</MVN_DOCKERREGISTRY_RELEASE> - <MVN_DOCKERREGISTRY_SNAPSHOT_SERVERID>${onap.nexus.dockerregistry.snapshot.serverid}</MVN_DOCKERREGISTRY_SNAPSHOT_SERVERID> - <MVN_DOCKERREGISTRY_RELEASE_SERVERID>${onap.nexus.dockerregistry.release.serverid}</MVN_DOCKERREGISTRY_RELEASE_SERVERID> - <MVN_PYPISERVER_BASEURL>${onap.nexus.pypiserver.baseurl}</MVN_PYPISERVER_BASEURL> - <MVN_PYPISERVER_SERVERID>${onap.nexus.pypiserver.serverid}</MVN_PYPISERVER_SERVERID> - </environmentVariables> - </configuration> - </plugin> - </plugins> - </pluginManagement> <plugins> - <!-- plugin> - <artifactId>maven-assembly-plugin</artifactId> - <version>2.4.1</version> - <configuration> - <descriptors> - <descriptor>assembly/dep.xml</descriptor> - </descriptors> - </configuration> - <executions> - <execution> - <id>make-assembly</id> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - </execution> - </executions> - </plugin --> - <!-- now we configure custom action (calling a script) at various lifecycle phases --> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <version>1.2.1</version> - <executions> - <execution> - <id>clean phase script</id> - <phase>clean</phase> - <goals> - <goal>exec</goal> - </goals> - <configuration> - <arguments> - <argument>__</argument> - <argument>clean</argument> - </arguments> - </configuration> - </execution> - <execution> - <id>generate-sources script</id> - <phase>generate-sources</phase> - <goals> - <goal>exec</goal> - </goals> - <configuration> - <arguments> - <argument>__</argument> - <argument>generate-sources</argument> - </arguments> - </configuration> - </execution> - <execution> - <id>compile script</id> - <phase>compile</phase> - <goals> - <goal>exec</goal> - </goals> - <configuration> - <arguments> - <argument>__</argument> - <argument>compile</argument> - </arguments> - </configuration> - </execution> - <execution> - <id>package script</id> - <phase>package</phase> - <goals> - <goal>exec</goal> - </goals> - <configuration> - <arguments> - <argument>__</argument> - <argument>package</argument> - </arguments> - </configuration> - </execution> - <execution> - <id>test script</id> - <phase>test</phase> - <goals> - <goal>exec</goal> - </goals> - <configuration> - <arguments> - <argument>__</argument> - <argument>test</argument> - </arguments> - </configuration> - </execution> - <execution> - <id>install script</id> - <phase>install</phase> - <goals> - <goal>exec</goal> - </goals> - <configuration> - <arguments> - <argument>__</argument> - <argument>install</argument> - </arguments> - </configuration> - </execution> - <execution> - <id>deploy script</id> - <phase>deploy</phase> - <goals> - <goal>exec</goal> - </goals> - <configuration> - <arguments> - <argument>__</argument> - <argument>deploy</argument> - </arguments> - </configuration> - </execution> - </executions> - </plugin> - </plugins> + <plugin> + <artifactId>maven-checkstyle-plugin</artifactId> + <executions> + <execution> + <id>onap-java-style</id> + <goals> + <goal>check</goal> + </goals> + <phase>process-sources</phase> + <configuration> + <!-- Use Google Java Style Guide: + https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml + with minor changes --> + <configLocation>onap-checkstyle/onap-java-style.xml</configLocation> + <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory --> + <sourceDirectories> + <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory> + </sourceDirectories> + <includeResources>true</includeResources> + <includeTestSourceDirectory>false</includeTestSourceDirectory> + <includeTestResources>false</includeTestResources> + <excludes> + </excludes> + <consoleOutput>true</consoleOutput> + <failsOnViolation>false</failsOnViolation> + <violationSeverity>warning</violationSeverity> + </configuration> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>org.onap.oparent</groupId> + <artifactId>checkstyle</artifactId> + <version>1.2.3-SNAPSHOT</version> + <scope>compile</scope> + </dependency> + </dependencies> + </plugin> + <!--plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <versionRange>2.17,)</versionRange> + <goals> + <goal>check</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore /> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin--> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <version>2.0.4.RELEASE</version> + <executions> + <execution> + <goals> + <goal>repackage</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> </build> </project> + + diff --git a/settings.xml b/settings.xml new file mode 100644 index 0000000..49821bc --- /dev/null +++ b/settings.xml @@ -0,0 +1,515 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you 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. +--> + +<!-- + | This is the configuration file for Maven. It can be specified at two levels: + | + | 1. User Level. This settings.xml file provides configuration for a single user, + | and is normally provided in ${user.home}/.m2/settings.xml. + | + | NOTE: This location can be overridden with the CLI option: + | + | -s /path/to/user/settings.xml + | + | 2. Global Level. This settings.xml file provides configuration for all Maven + | users on a machine (assuming they're all using the same Maven + | installation). It's normally provided in + | ${maven.home}/conf/settings.xml. + | + | NOTE: This location can be overridden with the CLI option: + | + | -gs /path/to/global/settings.xml + | + | The sections in this sample file are intended to give you a running start at + | getting the most out of your Maven installation. Where appropriate, the default + | values (values used when the setting is not specified) are provided. + | + |--> +<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> + <!-- localRepository + | The path to the local repository maven will use to store artifacts. + | + | Default: ${user.home}/.m2/repository + <localRepository>/path/to/local/repo</localRepository> + --> + + <!-- interactiveMode + | This will determine whether maven prompts you when it needs input. If set to false, + | maven will use a sensible default value, perhaps based on some other setting, for + | the parameter in question. + | + | Default: true + <interactiveMode>true</interactiveMode> + --> + + <!-- offline + | Determines whether maven should attempt to connect to the network when executing a build. + | This will have an effect on artifact downloads, artifact deployment, and others. + | + | Default: false + <offline>false</offline> + --> + + <!-- pluginGroups + | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e. + | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers + | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list. + |--> + <pluginGroups> + <!-- pluginGroup + | Specifies a further group identifier to use for plugin lookup. + <pluginGroup>com.your.plugins</pluginGroup> + --> + </pluginGroups> + + <!-- proxies + | This is a list of proxies which can be used on this machine to connect to the network. + | Unless otherwise specified (by system property or command-line switch), the first proxy + | specification in this list marked as active will be used. + |--> + <proxies> + <proxy> + <id>optional</id> + <active>true</active> + <protocol>http</protocol> + <username>RA388944</username> + <password>brown@123</password> + <host>proxy2.wipro.com</host> + <port>8080</port> + <nonProxyHosts>local.net|some.host.com</nonProxyHosts> + </proxy> + + <proxy> + <id>optional1</id> + <active>true</active> + <protocol>https</protocol> + <username>RA388944</username> + <password>brown@123</password> + <host>proxy2.wipro.com</host> + <port>8080</port> + <nonProxyHosts>local.net|some.host.com</nonProxyHosts> + </proxy> + </proxies> + + <!-- servers + | This is a list of authentication profiles, keyed by the server-id used within the system. + | Authentication profiles can be used whenever maven must make a connection to a remote server. + |--> + <servers> + <!-- server + | Specifies the authentication information to use when connecting to a particular server, identified by + | a unique name within the system (referred to by the 'id' attribute below). + | + | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are + | used together. + | + <server> + <id>deploymentRepo</id> + <username>repouser</username> + <password>repopwd</password> + </server> + --> + + <!-- Another sample, using keys to authenticate. + <server> + <id>siteServer</id> + <privateKey>/path/to/private/key</privateKey> + <passphrase>optional; leave empty if not used.</passphrase> + </server> + --> + </servers> + + <!-- mirrors + | This is a list of mirrors to be used in downloading artifacts from remote repositories. + | + | It works like this: a POM may declare a repository to use in resolving certain artifacts. + | However, this repository may have problems with heavy traffic at times, so people have mirrored + | it to several places. + | + | That repository definition will have a unique id, so we can create a mirror reference for that + | repository, to be used as an alternate download site. The mirror site will be the preferred + | server for that repository. + |--> + + <!-- profiles + | This is a list of profiles which can be activated in a variety of ways, and which can modify + | the build process. Profiles provided in the settings.xml are intended to provide local machine- + | specific paths and repository locations which allow the build to work in the local environment. + | + | For example, if you have an integration testing plugin - like cactus - that needs to know where + | your Tomcat instance is installed, you can provide a variable here such that the variable is + | dereferenced during the build process to configure the cactus plugin. + | + | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles + | section of this document (settings.xml) - will be discussed later. Another way essentially + | relies on the detection of a system property, either matching a particular value for the property, + | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a + | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'. + | Finally, the list of active profiles can be specified directly from the command line. + | + | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact + | repositories, plugin repositories, and free-form properties to be used as configuration + | variables for plugins in the POM. + | + |--> + + + + + + <profiles> + <profile> + <id>onap-settings</id> + <properties> + <onap.nexus.url>https://nexus.onap.org</onap.nexus.url> + <onap.nexus.rawrepo.baseurl.upload>https://nexus.onap.org/content/sites/raw</onap.nexus.rawrepo.baseurl.upload> + <onap.nexus.rawrepo.baseurl.download>https://nexus.onap.org/service/local/repositories/raw/content</onap.nexus.rawrepo.baseurl.download> + <onap.nexus.rawrepo.serverid>ecomp-raw</onap.nexus.rawrepo.serverid> + + <!-- properties for Nexus Docker registry --> + <onap.nexus.dockerregistry.daily>nexus3.onap.org:10003</onap.nexus.dockerregistry.daily> + <onap.nexus.dockerregistry.release>nexus3.onap.org:10002</onap.nexus.dockerregistry.release> + <docker.pull.registry>nexus3.onap.org:10001</docker.pull.registry> + <docker.push.registry>nexus3.onap.org:10003</docker.push.registry> + </properties> +</profile> + <profile> + + <id>10_nexus</id> + + <!--Enable snapshots for the built in central repo to direct --> + <!--all requests to nexus via the mirror --> + <repositories> + <repository> + <id>10_nexus</id> + <url>http://repo.maven.apache.org/maven2/</url> + <releases><enabled>true</enabled></releases> + <snapshots><enabled>true</enabled></snapshots> + </repository> + </repositories> + + <pluginRepositories> + <pluginRepository> + <id>10_nexus</id> + <url>http://repo.maven.apache.org/maven2/</url> + <releases><enabled>true</enabled></releases> + <snapshots><enabled>true</enabled></snapshots> + </pluginRepository> + </pluginRepositories> + + </profile> +<profile> + <id>lifecycle-mapping</id> + <repositories> + <repository> + <id>lifecycle-mapping</id> + <name>lifecycle-mapping</name> + <url>https://simulation.tudelft.nl/maven/</url> + <releases> + <enabled>true</enabled> + <updatePolicy>never</updatePolicy> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + </repositories> + <pluginRepositories> + <pluginRepository> + <id>lifecycle-mapping</id> + <name>lifecycle-mapping</name> + <url>https://simulation.tudelft.nl/maven/</url> + <releases> + <enabled>true</enabled> + <updatePolicy>never</updatePolicy> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> + </profile> + <profile> + <id>20_openecomp-public</id> + <repositories> + <repository> + <id>20_openecomp-public</id> + <name>20_openecomp-public</name> + <url>https://nexus.onap.org/content/repositories/public/</url> + <releases> + <enabled>true</enabled> + <updatePolicy>daily</updatePolicy> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + </repositories> + <pluginRepositories> + <pluginRepository> + <id>20_openecomp-public</id> + <name>20_openecomp-public</name> + <url>https://nexus.onap.org/content/repositories/public/</url> + <releases> + <enabled>true</enabled> + <updatePolicy>daily</updatePolicy> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> + </profile> + <profile> + <id>30_openecomp-staging</id> + <repositories> + <repository> + <id>30_openecomp-staging</id> + <name>30_openecomp-staging</name> + <url>https://nexus.onap.org/content/repositories/staging/</url> + <releases> + <enabled>true</enabled> + <updatePolicy>daily</updatePolicy> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + </repositories> + <pluginRepositories> + <pluginRepository> + <id>30_openecomp-staging</id> + <name>30_openecomp-staging</name> + <url>https://nexus.onap.org/content/repositories/staging/</url> + <releases> + <enabled>true</enabled> + <updatePolicy>daily</updatePolicy> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> + </profile> + <profile> + <id>40_openecomp-release</id> + <repositories> + <repository> + <id>40_openecomp-release</id> + <name>40_openecomp-release</name> + <url>https://nexus.onap.org/content/repositories/releases/</url> + <releases> + <enabled>true</enabled> + <updatePolicy>daily</updatePolicy> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + </repositories> + <pluginRepositories> + <pluginRepository> + <id>40_openecomp-release</id> + <name>40_openecomp-release</name> + <url>https://nexus.onap.org/content/repositories/releases/</url> + <releases> + <enabled>true</enabled> + <updatePolicy>daily</updatePolicy> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> + </profile> + + <profile> + <id>50_openecomp-snapshots</id> + <repositories> + <repository> + <id>50_openecomp-snapshot</id> + <name>50_openecomp-snapshot</name> + <url>https://nexus.onap.org/content/repositories/snapshots/</url> + <releases> + <enabled>false</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </repository> + </repositories> + <pluginRepositories> + <pluginRepository> + <id>50_openecomp-snapshot</id> + <name>50_openecomp-snapshot</name> + <url>https://nexus.onap.org/content/repositories/snapshots/</url> + <releases> + <enabled>false</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> + </profile> + <profile> + <id>60_opendaylight-release</id> + <repositories> + <repository> + <id>60_opendaylight-mirror</id> + <name>60_opendaylight-mirror</name> + <url>https://nexus.opendaylight.org/content/repositories/public/</url> + <releases> + <enabled>true</enabled> + <updatePolicy>daily</updatePolicy> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + </repositories> + <pluginRepositories> + <pluginRepository> + <id>60_opendaylight-mirror</id> + <name>60_opendaylight-mirror</name> + <url>https://nexus.opendaylight.org/content/repositories/public/</url> + <releases> + <enabled>true</enabled> + <updatePolicy>daily</updatePolicy> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> + </profile> + + <profile> + <id>70_opendaylight-snapshots</id> + <repositories> + <repository> + <id>70_opendaylight-snapshot</id> + <name>70_opendaylight-snapshot</name> + <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url> + <releases> + <enabled>false</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </repository> + </repositories> + <pluginRepositories> + <pluginRepository> + <id>70_opendaylight-snapshot</id> + <name>70_opendaylight-snapshot</name> + <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url> + <releases> + <enabled>false</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> + </profile> + +<!--Sandeep><--> + <profile> + <id>opendaylight-release</id> + <repositories> + <repository> + <id>opendaylight-mirror</id> + <name>opendaylight-mirror</name> + <url>https://nexus.opendaylight.org/content/repositories/public/</url> + <releases> + <enabled>true</enabled> + <updatePolicy>never</updatePolicy> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + </repositories> + <pluginRepositories> + <pluginRepository> + <id>opendaylight-mirror</id> + <name>opendaylight-mirror</name> + <url>https://nexus.opendaylight.org/content/repositories/public/</url> + <releases> + <enabled>true</enabled> + <updatePolicy>never</updatePolicy> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> + </profile> + + <profile> + <id>opendaylight-snapshots</id> + <repositories> + <repository> + <id>opendaylight-snapshot</id> + <name>opendaylight-snapshot</name> + <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url> + <releases> + <enabled>false</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </repository> + </repositories> + <pluginRepositories> + <pluginRepository> + <id>opendaylight-snapshot</id> + <name>opendaylight-snapshot</name> + <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url> + <releases> + <enabled>false</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> + </profile> + + + </profiles> + + <activeProfiles> + <activeProfile>onap-settings</activeProfile> + <activeProfile>10_nexus</activeProfile> + <activeProfile>20_openecomp-public</activeProfile> + <activeProfile>30_openecomp-staging</activeProfile> + <activeProfile>40_openecomp-release</activeProfile> + <activeProfile>50_openecomp-snapshots</activeProfile> + <activeProfile>60_opendaylight-release</activeProfile> + <activeProfile>70_opendaylight-snapshots</activeProfile> + <activeProfile>lifecycle-mapping</activeProfile> + </activeProfiles> + +</settings> diff --git a/src/main/docker/postgres_scripts/Dockerfile b/src/main/docker/postgres_scripts/Dockerfile new file mode 100644 index 0000000..9ccb016 --- /dev/null +++ b/src/main/docker/postgres_scripts/Dockerfile @@ -0,0 +1,7 @@ +from busybox + +RUN mkdir /docker-entrypoint-initdb.d + +ADD createdb.sql /tmp + + diff --git a/src/main/docker/postgres_scripts/createdb.sql b/src/main/docker/postgres_scripts/createdb.sql new file mode 100644 index 0000000..dc843e7 --- /dev/null +++ b/src/main/docker/postgres_scripts/createdb.sql @@ -0,0 +1,25 @@ +CREATE DATABASE sonh_ms; +\c sonh_ms +CREATE TABLE DMAAP_NOTIFICATIONS( + notification TEXT PRIMARY KEY NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); +CREATE TABLE BUFFERED_NOTIFICATIONS( + notification TEXT PRIMARY KEY NOT NULL, + cluster_id TEXT NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); +CREATE TABLE CLUSTER_DETAILS( + cluster_id TEXT PRIMARY KEY NOT NULL, + cluster_info TEXT NOT NULL, + child_thread_id BIGINT UNIQUE NOT NULL +); +CREATE TABLE CELL_INFO( + cell_id TEXT PRIMARY KEY NOT NULL, + pnf_name TEXT NOT NULL +); +CREATE TABLE PCI_REQUESTS( + transaction_id TEXT PRIMARY KEY, + child_thread_id BIGINT UNIQUE NOT NULL +); + diff --git a/src/main/docker/postgres_scripts/init_db.sh b/src/main/docker/postgres_scripts/init_db.sh new file mode 100644 index 0000000..cbc27a6 --- /dev/null +++ b/src/main/docker/postgres_scripts/init_db.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +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/Dockerfile b/src/main/docker/son-handler/Dockerfile new file mode 100644 index 0000000..6e50fb1 --- /dev/null +++ b/src/main/docker/son-handler/Dockerfile @@ -0,0 +1,17 @@ +FROM java:openjdk-8 + +ADD config.json /etc/config.json + +ADD policy.crt /policy.crt + +RUN keytool -import -file /policy.crt -alias policycert -keystore /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/cacerts -storepass changeit -noprompt + +COPY pci-handler-1.0-SNAPSHOT.jar application.jar + +ADD entrypoint.sh . + +RUN chmod +x entrypoint.sh + +EXPOSE 8080 + +ENTRYPOINT ["./entrypoint.sh"] diff --git a/src/main/docker/son-handler/config.json b/src/main/docker/son-handler/config.json new file mode 100644 index 0000000..6cdf863 --- /dev/null +++ b/src/main/docker/son-handler/config.json @@ -0,0 +1,48 @@ +{ + "topics":[ + { + "name": "PCI-NOTIF-TOPIC-NGHBR-LIST-CHANGE-INFO", + "producer": "SDNR_API_KEY", + "consumer": "PCIMS_API_KEY" + }, + { + "name": "DCAE_CL_OUTPUT", + "producer": "PCIMS_API_KEY", + "consumer": "POLICY_API_KEY" + }, + { + "name": "SDNR-CL", + "producer": "POLICY_API_KEY", + "consumer": "SDNR_API_KEY" + }, + { + "name": "SDNR-CL-RSP", + "producer": "SDNR_API_KEY", + "consumer": "POLICY_API_KEY" + } + ], + "sdnrTopic": "PCI-NOTIF-TOPIC-NGHBR-LIST-CHANGE-INFO", + "policyTopic": "DCAE_CL_OUTPUT", + "servers": ["DMAAP_SERVER:3904"], + "managerApiKey": "MANAGER_API_KEY", + "managerSecretKey": "MANAGER_SECRET_KEY", + "pcimsApiKey": "PCIMS_API_KEY", + "pcimsSecretKey": "PCIMS_SECRET_KEY", + "cg": "pcims-cg", + "cid": "pcims-cid", + "pollingTimeout": "60", + "pollingInterval": "20", + "minCollision": "5", + "minConfusion": "5", + "sdnrService": "http://SDNR_SERVICE", + "oofService": "http://OOF_SERVICE", + "policyService": "https://POLICY_SERVICE", + "sourceId": "PCIHMS", + "callbackUrl": "http://pcims.onap:8080/callbackUrl", + "policyName": "com.Config_PCIMS_CONFIG_POLICY.1.xml", + "configName": "PCIMS_CONFIG_POLICY", + "optimizers": ["pci"], + "bufferTime": "60000", + "numSolutions": "1", + "maximumClusters": "5" +} diff --git a/src/main/docker/son-handler/entrypoint.sh b/src/main/docker/son-handler/entrypoint.sh new file mode 100644 index 0000000..bf69065 --- /dev/null +++ b/src/main/docker/son-handler/entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +sed -i s/DMAAP_SERVER/$DMAAPSERVER/ /etc/config.json +sed -i s/SDNR_SERVICE/$SDNRSERVICE/ /etc/config.json +sed -i s/OOF_SERVICE/$OOFSERVICE/ /etc/config.json +sed -i s/POLICY_SERVICE/$POLICYSERVICE/ /etc/config.json +sed -i s/PCIMS_SERVICE_HOST/$PCIMS_SERVICE_HOST/ /etc/config.json +sed -i s/MANAGER_API_KEY/$MANAGERAPIKEY/ /etc/config.json +sed -i s/MANAGER_SECRET_KEY/$MANAGERSECRETKEY/ /etc/config.json +sed -i s/PCIMS_API_KEY/$PCIMSAPIKEY/ /etc/config.json +sed -i s/PCIMS_SECRET_KEY/$PCIMSSECRETKEY/ /etc/config.json +sed -i s/SDNR_API_KEY/$SDNRAPIKEY/ /etc/config.json +sed -i s/POLICY_API_KEY/$POLICYAPIKEY/ /etc/config.json +java -jar application.jar + diff --git a/src/main/docker/son-handler/policy.crt b/src/main/docker/son-handler/policy.crt new file mode 100644 index 0000000..e017bf4 --- /dev/null +++ b/src/main/docker/son-handler/policy.crt @@ -0,0 +1,27 @@ +-----BEGIN CERTIFICATE-----
+MIIEkzCCA3ugAwIBAgIIaG5i2/yYcycwDQYJKoZIhvcNAQELBQAwRzELMAkGA1UE
+BhMCVVMxDTALBgNVBAoMBE9OQVAxDjAMBgNVBAsMBU9TQUFGMRkwFwYDVQQDDBBp
+bnRlcm1lZGlhdGVDQV85MB4XDTE4MTAxMTIyMDkwNVoXDTE5MDQxMTIyMDkwNVow
+bzEPMA0GA1UEAwwGcG9saWN5MQ8wDQYJKoZIhvcNAQkBFgAxHzAdBgNVBAsMFnBv
+bGljeUBwb2xpY3kub25hcC5vcmcxDjAMBgNVBAsMBU9TQUFGMQ0wCwYDVQQKDARP
+TkFQMQswCQYDVQQGEwJVUzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
+ALdwMkNAqr43X9eBdGV9xT+Gi2usZC8GdOvAuEJ0srqdLY1baSMrGDY6sN4o5o/X
+fD+wwoaTYtnrrESC13BEoXRo7vIuqxKnNjqkljHcgk09m8BaBB5zQQQULoeEEVIV
+7c9+agrE+Jg3BPsilyWnJco6zLPpjSuTlqEvCtUjk6aQ+dS8ItHN26c/W42AuyLn
+iofaWY2HZdhOZJg6UetyITOywQ5o3vl09tE+zPzk7cixsxVUJy2aunUuDcrFiyKf
+tSX3XBAxaspgVtnNrUheudwkWc5pdBFNYSJS8NSCc7yDuAz0AfrCS7Tcd4IZG7Lw
+zJjMoIj0fOsinFViPkiyAA8CAwEAAaOCAVkwggFVMAkGA1UdEwQCMAAwDgYDVR0P
+AQH/BAQDAgXgMCAGA1UdJQEB/wQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjBUBgNV
+HSMETTBLgBSB95lbELnIjN7zUl7qTmmgQz6s3aEwpC4wLDEOMAwGA1UECwwFT1NB
+QUYxDTALBgNVBAoMBE9OQVAxCzAJBgNVBAYTAlVTggEHMB0GA1UdDgQWBBTO1RjR
+xvjgraJ+1nZUENDKSngpITCBoAYDVR0RBIGYMIGVggZwb2xpY3mCBSoucGRwghwq
+LnBkcC5vbmFwLnN2Yy5jbHVzdGVyLmxvY2FsggZicm1zZ3eCC2JybXNndy5vbmFw
+ggZkcm9vbHOCC2Ryb29scy5vbmFwggNwYXCCCHBhcC5vbmFwggNwZHCCCHBkcC5v
+bmFwgh5wb2xpY3kuYXBpLnNpbXBsZWRlbW8ub25hcC5vcmcwDQYJKoZIhvcNAQEL
+BQADggEBAHuhhuTD5zcrBaPGU7NT9V82BwrCPfEH2UTxracU/P/3YRQ4yBcnnyX4
+FznNAHJOrNnwdz7kht0XLV2Td5iI+Gs0X5AVlQE2paSgiJRXPkwU7un5xk7a6cbN
+7lnx5RcAxVBi6Nf078cSPu0I+E344MUoYwKb4haBKTB2lN48W7HxzePdnWZiPhrR
+iTIKwUa1WvKPG9KpbOZDbukCfStPeMb2i0G3rk4T/Vr1cDRLyG8u1nnJEHeAoU+t
+SWAq9bKpspFW0rRd2m8jOcql9ja7OUSgU0Qt10xoUQrkogS3Y8P8ib0Nf/kuyTnJ
+aAchKp0OSx2z8HceBCQPEJsR5Cj1h2M=
+-----END CERTIFICATE-----
diff --git a/src/main/java/com/wipro/www/sonhms/Application.java b/src/main/java/com/wipro/www/sonhms/Application.java new file mode 100644 index 0000000..4c831b4 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/Application.java @@ -0,0 +1,128 @@ +/******************************************************************************* + * ============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<HashMap<String, Object>> 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<String, Object> 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 new file mode 100644 index 0000000..6074a31 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/BufferNotificationComponent.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * ============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<String> 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 new file mode 100644 index 0000000..62d485f --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/BufferNotificationState.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..ef76bdb --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/BufferedNotificationHandlingState.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..b8d0cf4 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/ChildStatusUpdateState.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * ============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<String> 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<Thread> 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 new file mode 100644 index 0000000..6683085 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/ChildTriggeringState.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..939f9e1 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/ClusterDetailsComponent.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * ============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<ClusterDetails> 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 new file mode 100644 index 0000000..6d2994f --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/ConfigPolicy.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * ============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<String, Object> config; + + protected ConfigPolicy() { + + } + + /** + * Get instance of class. + */ + public static ConfigPolicy getInstance() { + if (instance == null) { + instance = new ConfigPolicy(); + } + return instance; + } + + public Map<String, Object> getConfig() { + return config; + } + + public void setConfig(Map<String, Object> 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 new file mode 100644 index 0000000..fb53f9b --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/Configuration.java @@ -0,0 +1,281 @@ +/******************************************************************************* + * ============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<Topic> topics; + private String sdnrTopic; + private String policyTopic; + private List<String> 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<String> 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<String> getServers() { + return servers; + } + + public void setServers(List<String> 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<String> getOptimizers() { + return optimizers; + } + + public void setOptimizers(List<String> 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<Topic> getTopics() { + return topics; + } + + public void setTopics(List<Topic> 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 new file mode 100644 index 0000000..2b6c843 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/MainThread.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * ============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<List<String>>(), 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 new file mode 100644 index 0000000..2b8516d --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/MainThreadComponent.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..5d4f704 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/NewNotification.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..1487b5e --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/ResourceCleanupState.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..2637790 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/SdnrNotificationHandlingState.java @@ -0,0 +1,259 @@ +/******************************************************************************* + * ============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<Long, ChildThread> 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<FapServiceList> 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> 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<FapServiceList> 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<LteNeighborListInUseLteCell> 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<CellPciPair> 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> clusterDetails) { + + String cellId = fapService.getCellConfig().getLte().getRan().getCellIdentity(); + Map<CellPciPair, ArrayList<CellPciPair>> cellPciNeighbourMap; + + for (ClusterDetails clusterDetail : clusterDetails) { + Graph cluster = new Graph(clusterDetail.getClusterInfo()); + cellPciNeighbourMap = cluster.getCellPciNeighbourMap(); + Set<CellPciPair> keys = cellPciNeighbourMap.keySet(); + Iterator<CellPciPair> traverse = keys.iterator(); + while (traverse.hasNext()) { + CellPciPair key = traverse.next(); + String currentCellId = key.getCellId(); + if (cellId.equals(currentCellId)) { + return clusterDetail; + } + } + } + + return null; + } + + private List<ClusterDetails> getAllClusters() { + ClusterDetailsComponent clusterDetailsComponent = new ClusterDetailsComponent(); + return clusterDetailsComponent.getClusterDetails(); + } + + public static void addChildThreadMap(Long childThreadId, ChildThread child) { + childThreadMap.put(childThreadId, child); + } + + public static Map<Long, ChildThread> 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 new file mode 100644 index 0000000..491dccc --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/SonContext.java @@ -0,0 +1,122 @@ +/******************************************************************************* + * ============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<Long, String> childStatus; + private BlockingQueue<List<String>> 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<List<String>> 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<List<String>> getChildStatusUpdate() { + return childStatusUpdate; + } + + public void setChildStatusUpdate(BlockingQueue<List<String>> 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 new file mode 100644 index 0000000..8923614 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/SonController.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..5b57850 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/SonRequestsComponent.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..c287c6b --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/SonState.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..3be2087 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/Topic.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..a74f795 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/WaitState.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * ============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<String> 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<String> 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 new file mode 100644 index 0000000..718cc46 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/child/ChildThread.java @@ -0,0 +1,245 @@ +/******************************************************************************* + * ============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<List<String>> childStatusUpdate; + private BlockingQueue<FapServiceList> queue = new LinkedBlockingQueue<>(); + // static BlockingQueue<AsyncResponseBody> asynchronousResponse = new + // LinkedBlockingQueue<>(); + private static Map<Long, AsyncResponseBody> 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<List<String>> childStatusUpdate, Graph cluster, + BlockingQueue<FapServiceList> 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<Long, AsyncResponseBody> 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<String, ArrayList<Integer>> collisionConfusionResult = detect.detectCollisionConfusion(cluster); + Boolean trigger = clusterFormation.triggerOrWait(collisionConfusionResult); + + if (!trigger) { + collisionConfusionResult = clusterFormation.waitForNotification(collisionConfusionResult, cluster); + } + oof.triggerOof(collisionConfusionResult, networkId); + + if (isNotificationsBuffered()) { + List<FapServiceList> 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<FapServiceList> bufferNotification() { + + // Processing Buffered notifications + + List<FapServiceList> 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 new file mode 100644 index 0000000..7b3d5bf --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/child/ClusterFormation.java @@ -0,0 +1,144 @@ +/******************************************************************************* + * ============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<FapServiceList> queue; + private ClusterModification clusterModification; + private Detection detect; + Properties confProp; + ClusterDetails details = new ClusterDetails(); + + public ClusterFormation() { + this.detect = new Detection(); + } + + /** + * parameterized constructor. + * + */ + public ClusterFormation(BlockingQueue<FapServiceList> 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<String, ArrayList<Integer>> collisionConfusionResult) { + // determine collision or confusion + + Configuration configuration = Configuration.getInstance(); + int collisionSum = 0; + int confusionSum = 0; + + for (Map.Entry<String, ArrayList<Integer>> entry : collisionConfusionResult.entrySet()) { + + ArrayList<Integer> 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<String, ArrayList<Integer>> waitForNotification(Map<String, ArrayList<Integer>> 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 new file mode 100644 index 0000000..9926cf4 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/child/ClusterModification.java @@ -0,0 +1,147 @@ +/******************************************************************************* + * ============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<LteNeighborListInUseLteCell> newNeighbourList; + newNeighbourList = fapser.getCellConfig().getLte().getRan().getNeighborListInUse() + .getLteNeighborListInUseLteCell(); + + Map<CellPciPair, ArrayList<CellPciPair>> clusterMap; + clusterMap = cluster.getCellPciNeighbourMap(); + + // coe + + List<CellPciPair> tempCellPair = new ArrayList<>(); + for (Map.Entry<CellPciPair, ArrayList<CellPciPair>> 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<CellPciPair> 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 new file mode 100644 index 0000000..fc2e941 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/child/Detection.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * ============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<String, ArrayList<Integer>> detectCollisionConfusion(Graph cluster) { + + Map<CellPciPair, ArrayList<CellPciPair>> clusterMap = cluster.getCellPciNeighbourMap(); + HashMap<String, ArrayList<Integer>> hash = new HashMap<>(); + + for (Map.Entry<CellPciPair, ArrayList<CellPciPair>> entry : clusterMap.entrySet()) { + int collisionCount = 0; + int confusionCount = 0; + CellPciPair val = entry.getKey(); + String cellId = val.getCellId(); + int pci = val.getPhysicalCellId(); + ArrayList<CellPciPair> arr; + // getting colision and confusion count + ArrayList<Integer> 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 new file mode 100644 index 0000000..5e48dfc --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/child/Graph.java @@ -0,0 +1,202 @@ +/******************************************************************************* + * ============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<CellPciPair, ArrayList<CellPciPair>> cellPciNeighbourMap; + private UUID graphId; + + /** + * Parameterized constructor. + */ + @SuppressWarnings("unchecked") + public Graph(String clusterInfo) { + JSONArray cells = new JSONArray(clusterInfo); + + Map<CellPciPair, ArrayList<CellPciPair>> 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<CellPciPair> 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<CellPciPair, ArrayList<CellPciPair>> getCellPciNeighbourMap() { + return cellPciNeighbourMap; + } + + public void setCellPciNeighbourMap(Map<CellPciPair, ArrayList<CellPciPair>> 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<CellPciPair>()); + } + } + + /** + * 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<CellPciPair, ArrayList<CellPciPair>> entry : this.cellPciNeighbourMap.entrySet()) { + + ArrayList<CellPciPair> 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<CellNeighbourList> cells = new ArrayList<>(); + + for (Entry<CellPciPair, ArrayList<CellPciPair>> 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 new file mode 100644 index 0000000..3215c46 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/child/StateOof.java @@ -0,0 +1,271 @@ +/******************************************************************************* + * ============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<List<String>> childStatusUpdate; + + public StateOof() { + + } + + /** + * Parameterized Constructor. + * + */ + public StateOof(BlockingQueue<List<String>> childStatusUpdate) { + super(); + this.childStatusUpdate = childStatusUpdate; + } + + /** + * Triggers OOF. + * @throws OofNotFoundException when trigger oof fails + */ + public void triggerOof(Map<String, ArrayList<Integer>> result, String networkId) throws OofNotFoundException { + // check for 0 collision and 0 confusion + ArrayList<String> cellidList = new ArrayList<>(); + ArrayList<String> cellIds = new ArrayList<>(); + + for (Map.Entry<String, ArrayList<Integer>> entry : result.entrySet()) { + String key = entry.getKey(); + ArrayList<Integer> arr; + arr = entry.getValue(); + if (!arr.isEmpty()) { + Set<Integer> 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<String> optimizers = config.getOptimizers(); + + String oofResponse = OofRestClient.queryOof(numSolutions, transactionId.toString(), "create", cellidList, + networkId, optimizers); + log.debug("Synchronous Response {}", oofResponse); + + List<String> 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<Solution> solutions; + solutions = async.getSolutions(); + + Map<String, List<CellPciPair>> pnfs = getPnfs(solutions); + + for (Map.Entry<String, List<CellPciPair>> entry : pnfs.entrySet()) { + String pnfName = entry.getKey(); + List<CellPciPair> 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<CellPciPair> cellPciPairs, String networkId) { + ArrayList<Configurations> 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<String, List<CellPciPair>> getPnfs(List<Solution> solutions) throws ConfigDbNotFoundException { + + Map<String, List<CellPciPair>> pnfs = new HashMap<>(); + + for (Solution solution : solutions) { + List<SonSolution> 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> cellInfo = cellInfoRepository.findById(cellId); + if (cellInfo.isPresent()) { + pnfName = cellInfo.get().getPnfName(); + } else { + pnfName = SdnrRestClient.getPnfName(cellId); + cellInfoRepository.save(new CellInfo(cellId, pnfName)); + } + if (pnfs.containsKey(pnfName)) { + pnfs.get(pnfName).add(new CellPciPair(cellId, pci)); + } else { + List<CellPciPair> cellPciPairs = new ArrayList<>(); + cellPciPairs.add(new CellPciPair(cellId, pci)); + pnfs.put(pnfName, cellPciPairs); + } + } + + } + return pnfs; + } + +} diff --git a/src/main/java/com/wipro/www/sonhms/dao/BufferedNotificationsRepository.java b/src/main/java/com/wipro/www/sonhms/dao/BufferedNotificationsRepository.java new file mode 100644 index 0000000..bdbdb6e --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/dao/BufferedNotificationsRepository.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * ============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<BufferedNotifications, String> { + + @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<String> 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 new file mode 100644 index 0000000..c4e1f8b --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/dao/CellInfoRepository.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * ============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<CellInfo, String> { + + // 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 new file mode 100644 index 0000000..a833fbf --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/dao/ClusterDetailsRepository.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * ============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<ClusterDetails, String> { + + @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<ClusterDetails> 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 new file mode 100644 index 0000000..1ac2ff4 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/dao/DmaapNotificationsRepository.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * ============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<DmaapNotifications, String> { + + @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 new file mode 100644 index 0000000..6b0458d --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/dao/SonRequestsRepository.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * ============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<PciRequests, String> { + + @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 new file mode 100644 index 0000000..051b00e --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/dmaap/DmaapClient.java @@ -0,0 +1,215 @@ +/******************************************************************************* + * ============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<Topic> topics = configuration.getTopics(); + + for (Topic topic : topics) { + Set<String> 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<String> 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<String> getAllTopicsFromDmaap() { + Set<String> 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 extends CambriaClient> T buildCambriaClient( + CambriaClientBuilders.AbstractAuthenticatedManagerBuilder<? extends CambriaClient> 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 new file mode 100644 index 0000000..1bdbac2 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/dmaap/NotificationConsumer.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * ============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<String> 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 new file mode 100644 index 0000000..7dd505f --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/dmaap/NotificationProducer.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * ============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<String> servers; + private String apiKey; + private String secret; + + /** + * Parameterised constructor. + */ + public NotificationProducer(List<String> 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 new file mode 100644 index 0000000..f1491b4 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/dmaap/PolicyDmaapClient.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..9ac10aa --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/entity/BufferedNotifications.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 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 new file mode 100644 index 0000000..e2bb326 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/entity/CellInfo.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..59868eb --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/entity/ClusterDetails.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..925a9e6 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/entity/DmaapNotifications.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..cce914d --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/entity/PciRequests.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..70127b5 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/exceptions/ConfigDbNotFoundException.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..fb95a0f --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/exceptions/OofNotFoundException.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..1fab733 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/CellConfig.java @@ -0,0 +1,47 @@ +/*- + * ============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 new file mode 100644 index 0000000..5bbff6d --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/CellNeighbourList.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..fb4c91a --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/CellPciPair.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..f317467 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/Common.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..f5dcd7e --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/Configurations.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..6bff144 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/Data.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..c949922 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/FapService.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..96cde4c --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/FapServiceList.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..871f100 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/Lte.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..fe85d47 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/LteNeighborListInUseLteCell.java @@ -0,0 +1,135 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..d240a88 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/NeighborListInUse.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * ============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> lteNeighborListInUseLteCell; + + @JsonProperty("LTECellNumberOfEntries") + private String lteCellNumberOfEntries; + + public NeighborListInUse() { + + } + + /** + * Parameterized Constructor. + */ + + public NeighborListInUse(List<LteNeighborListInUseLteCell> lteNeighborListInUseLteCell, + String lteCellNumberOfEntries) { + super(); + this.lteNeighborListInUseLteCell = lteNeighborListInUseLteCell; + this.lteCellNumberOfEntries = lteCellNumberOfEntries; + } + + public List<LteNeighborListInUseLteCell> getLteNeighborListInUseLteCell() { + return lteNeighborListInUseLteCell; + } + + public void setLteNeighborListInUseLteCell(List<LteNeighborListInUseLteCell> 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 new file mode 100644 index 0000000..417e443 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/Notification.java @@ -0,0 +1,112 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..a3acaf0 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/NotificationCellConfig.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..f1e26e7 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/NotificationLte.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..fea882b --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/NotificationPayload.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..cc0e085 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/NotificationRan.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..9f10acb --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/Payload.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * ============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<Configurations> configuration; + + public Payload() { + + } + + public Payload(List<Configurations> configuration) { + super(); + this.configuration = configuration; + } + + public List<Configurations> getConfiguration() { + return configuration; + } + + public void setConfiguration(List<Configurations> 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 new file mode 100644 index 0000000..e367b0b --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/PolicyNotification.java @@ -0,0 +1,179 @@ +/******************************************************************************* + * ============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<String, String> 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<String, String> getAai() { + return aai; + } + + public void setAai(Map<String, String> 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 new file mode 100644 index 0000000..cc1ee4a --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/RadioAccess.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * ============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> fapServiceList; + + public RadioAccess() { + + } + + /** + * Parameterized Constructor. + */ + + public RadioAccess(String fapServiceNumberOfEntries, List<FapServiceList> fapServiceList) { + super(); + this.fapServiceNumberOfEntries = fapServiceNumberOfEntries; + this.fapServiceList = fapServiceList; + } + + public String getFapServiceNumberOfEntries() { + return fapServiceNumberOfEntries; + } + + public void setFapServiceNumberOfEntries(String fapServiceNumberOfEntries) { + this.fapServiceNumberOfEntries = fapServiceNumberOfEntries; + } + + public List<FapServiceList> getFapServiceList() { + return fapServiceList; + } + + public void setFapServiceList(List<FapServiceList> 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 new file mode 100644 index 0000000..d4dda3a --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/Ran.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..e34c10f --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/Response.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..b57b20e --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/SdnrResponse.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * ============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> response; + + public List<Response> getResponse() { + return response; + } + + public void setResponse(List<Response> 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 new file mode 100644 index 0000000..d0139f2 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/ThreadId.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..cb52715 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/model/X0005b9Lte.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..94e6919 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/restclient/AsyncResponseBody.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * ============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<Solution> 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<Solution> getSolutions() { + return solutions; + } + + public void setSolutions(List<Solution> 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 new file mode 100644 index 0000000..77d4003 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/restclient/CellInfo.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * ============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<String> cellIdList = new ArrayList<>(); + + public String getNetworkId() { + return networkId; + } + + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + public List<String> getCellIdList() { + return cellIdList; + } + + public void setCellIdList(List<String> 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 new file mode 100644 index 0000000..edee572 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/restclient/OofRequestBody.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..7b95d90 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/restclient/OofRestClient.java @@ -0,0 +1,101 @@ +/******************************************************************************* + * ============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<String> cellIdList, String networkId, List<String> 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 new file mode 100644 index 0000000..e9e7b0d --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/restclient/PolicyRequestBody.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..7c286af --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/restclient/PolicyRestClient.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..6dcbf63 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/restclient/RequestInfo.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * ============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<String> optimizers = null; + + public void setOptimizers(List<String> optimizers) { + this.optimizers = optimizers; + } + + public List<String> 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 new file mode 100644 index 0000000..c37791f --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/restclient/SdnrRestClient.java @@ -0,0 +1,137 @@ +/******************************************************************************* + * ============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<CellPciPair> 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<CellPciPair> 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 new file mode 100644 index 0000000..765501a --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/restclient/Solution.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * ============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<SonSolution> 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<SonSolution> getPciSolutions() { + return pciSolutions; + } + + /** + * Sets PciSolutions. + */ + public void setPciSolutions(List<SonSolution> 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 new file mode 100644 index 0000000..4872fc7 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/restclient/SonSolution.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..9d7cdb3 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/utils/BeanUtil.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * ============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> T getBean(Class<T> 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 new file mode 100644 index 0000000..929ae95 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/utils/FileIo.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..4e4e411 --- /dev/null +++ b/src/main/java/com/wipro/www/sonhms/utils/HttpRequester.java @@ -0,0 +1,284 @@ +/******************************************************************************* + * ============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/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..335ad96 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,30 @@ +#------------------------------------------------------------------------------- +# ============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========================================================= +#------------------------------------------------------------------------------- +spring.datasource.url= jdbc:postgresql://pcims-db:5432/sonh_ms + +spring.datasource.username=postgres + +spring.datasource.password=password + +spring.jpa.hibernate.ddl-auto=validate + +spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false + +spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 0000000..f37bd58 --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============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========================================================= +--> +<configuration> + <appender name="FILE-THREAD" class="ch.qos.logback.classic.sift.SiftingAppender"> + <discriminator> + <key>logFileName</key> + <defaultValue>log</defaultValue> + </discriminator> + + <sift> + <appender name="file-${logFileName}" class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>/var/log/onap/pci-handler/${logFileName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logFileName}.%i.log.zip</fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>5</maxIndex> + </rollingPolicy> + <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>%d{dd-MM-yyyy HH:mm:ss.SSS} %magenta([%thread]) %highlight(%-5level) %logger{36}.%M - %msg%n</pattern> + </encoder> + </appender> + </sift> + </appender> + <root level="debug"> + <appender-ref ref="FILE-THREAD" /> + </root> +</configuration> diff --git a/src/test/java/com/wipro/www/sonhms/ApplicationTest.java b/src/test/java/com/wipro/www/sonhms/ApplicationTest.java new file mode 100644 index 0000000..892e0c2 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/ApplicationTest.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..08779e4 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/BufferNotificationComponentTest.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * ============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<String> notificationsList = new ArrayList<String>(); + 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<String> testResult = new ArrayList<String>(); + 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 new file mode 100644 index 0000000..ea426bf --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/ChildStatusUpdateStateTest.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..4be6339 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/ClusterDetailsComponentTest.java @@ -0,0 +1,118 @@ +/******************************************************************************* + * ============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<ClusterDetails> list = new ArrayList<ClusterDetails>(); + 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<ClusterDetails> resultList = new ArrayList<ClusterDetails>(); + 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 new file mode 100644 index 0000000..85b1c44 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/ConfigPolicyTest.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * ============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<String, Object> config = new HashMap<String, Object>(); + 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 new file mode 100644 index 0000000..06294dd --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/ConfigurationTest.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * ============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<String> list = new ArrayList<String>(); + 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 new file mode 100644 index 0000000..d6e2dfc --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/SdnrNotificationHandlingStateTest.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..e7e6790 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/SonContextTest.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * ============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<List<String>> 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 new file mode 100644 index 0000000..10ae3d7 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/WaitStateTest.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..2132f22 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/child/GraphTest.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * ============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<CellPciPair, ArrayList<CellPciPair>> 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 new file mode 100644 index 0000000..148663e --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/child/TestClusterModification.java @@ -0,0 +1,188 @@ +/******************************************************************************* + * ============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<CellPciPair> al = new ArrayList<CellPciPair>(); + al.add(cpPair1); + al.add(cpPair2); + al.add(cpPair3); + + ArrayList<CellPciPair> al1 = new ArrayList<CellPciPair>(); + al1.add(cpPair4); + al1.add(cpPair5); + al1.add(cpPair6); + + ArrayList<CellPciPair> al2 = new ArrayList<CellPciPair>(); + al2.add(cpPair7); + al2.add(cpPair8); + al2.add(cpPair9); + + Map<CellPciPair, ArrayList<CellPciPair>> map = new HashMap<CellPciPair, ArrayList<CellPciPair>>(); + + map.put(cpPair, al); + map.put(cpPair1, al1); + map.put(cpPair2, al2); + map.put(cpPair3, new ArrayList<CellPciPair>()); + map.put(cpPair4, new ArrayList<CellPciPair>()); + map.put(cpPair5, new ArrayList<CellPciPair>()); + map.put(cpPair6, new ArrayList<CellPciPair>()); + map.put(cpPair7, new ArrayList<CellPciPair>()); + map.put(cpPair8, new ArrayList<CellPciPair>()); + map.put(cpPair9, new ArrayList<CellPciPair>()); + 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<CellPciPair> al4 = new ArrayList<CellPciPair>(); + + al4.add(cpPair11); + al4.add(cpPair12); + + Map<CellPciPair, ArrayList<CellPciPair>> newMap = new HashMap<CellPciPair, ArrayList<CellPciPair>>(); + newMap.put(cpPair, al); + newMap.put(cpPair1, al4); + newMap.put(cpPair2, al2); + newMap.put(cpPair3, new ArrayList<CellPciPair>()); + newMap.put(cpPair4, new ArrayList<CellPciPair>()); + newMap.put(cpPair5, new ArrayList<CellPciPair>()); + newMap.put(cpPair6, new ArrayList<CellPciPair>()); + newMap.put(cpPair7, new ArrayList<CellPciPair>()); + newMap.put(cpPair8, new ArrayList<CellPciPair>()); + newMap.put(cpPair9, new ArrayList<CellPciPair>()); + newMap.put(cpPair11, new ArrayList<CellPciPair>()); + newMap.put(cpPair12, new ArrayList<CellPciPair>()); + + 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 new file mode 100644 index 0000000..03ed787 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/child/TestDetection.java @@ -0,0 +1,117 @@ +/******************************************************************************* + * ============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<CellPciPair> al = new ArrayList<CellPciPair>(); + al.add(cpPair1); + al.add(cpPair2); + al.add(cpPair3); + + ArrayList<CellPciPair> al1 = new ArrayList<CellPciPair>(); + al1.add(cpPair4); + al1.add(cpPair5); + al1.add(cpPair6); + + ArrayList<CellPciPair> al2 = new ArrayList<CellPciPair>(); + al2.add(cpPair7); + al2.add(cpPair8); + al2.add(cpPair9); + + Map<CellPciPair, ArrayList<CellPciPair>> map = new HashMap<CellPciPair, ArrayList<CellPciPair>>(); + + map.put(cpPair, al); + map.put(cpPair1, al1); + map.put(cpPair2, al2); + map.put(cpPair3, new ArrayList<CellPciPair>()); + map.put(cpPair4, new ArrayList<CellPciPair>()); + map.put(cpPair5, new ArrayList<CellPciPair>()); + map.put(cpPair6, new ArrayList<CellPciPair>()); + map.put(cpPair7, new ArrayList<CellPciPair>()); + map.put(cpPair8, new ArrayList<CellPciPair>()); + map.put(cpPair9, new ArrayList<CellPciPair>()); + 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 new file mode 100644 index 0000000..68f8b40 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/model/CellConfigTest.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..8acc0e8 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/model/CellNeighbourListTest.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..d1134fa --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/model/NotificationPayloadTest.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..09c6c0a --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/model/NotificationTest.java @@ -0,0 +1,127 @@ +/******************************************************************************* + * ============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<LteNeighborListInUseLteCell> 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<FapServiceList> 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 new file mode 100644 index 0000000..1c006f9 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/model/PayloadTest.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * ============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<Configurations> 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 new file mode 100644 index 0000000..c413791 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/model/ResponseTest.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..95afd77 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/restclient/AsyncResponseBodyTest.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * ============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<SonSolution> pciSolutionsList = new ArrayList<SonSolution>(); + 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<Solution> solutionsList = new ArrayList<Solution>(); + 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 new file mode 100644 index 0000000..b686f93 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/restclient/CellInfoTest.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * ============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<String> 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 new file mode 100644 index 0000000..493095b --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/restclient/OofRequestBodyTest.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * ============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<String> cellIdLists = new ArrayList<>(); + cellIdLists.add("cell1"); + CellInfo cellInfo = new CellInfo(); + cellInfo.setNetworkId("NTWK001"); + cellInfo.setCellIdList(cellIdLists); + RequestInfo requestInfo = new RequestInfo(); + List<String> optimizers = new ArrayList<String>(); + 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 new file mode 100644 index 0000000..2f06f0a --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/restclient/OofRestClientTest.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..e7aac21 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/restclient/PciSolutionsTest.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..0726c31 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/restclient/PolicyRequestBodyTest.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 0000000..f21971b --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/restclient/RequestInfoTest.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * ============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<String> optimizers = new ArrayList<String>(); + 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 new file mode 100644 index 0000000..64985f6 --- /dev/null +++ b/src/test/java/com/wipro/www/sonhms/restclient/SolutionsTest.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * ============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<SonSolution> pciSolutionsList = new ArrayList<SonSolution>(); + 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()); + + } + +} |