From f93f9afe8d92bbf00912934d0ee022542b656775 Mon Sep 17 00:00:00 2001 From: elinuxhenrik Date: Thu, 17 Feb 2022 16:28:01 +0100 Subject: [PATCH] Remove rApp Catalogue Issue-ID: NONRTRIC-717 Signed-off-by: elinuxhenrik Change-Id: I5d6c621bd43f6482d768be37b360cb4a950cad7c --- docs/api-docs.rst | 17 -- docs/conf.py | 9 +- docs/developer-guide.rst | 5 - docs/overview.rst | 3 + docs/release-notes.rst | 17 -- docs/requirements-docs.txt | 6 +- pom.xml | 1 - r-app-catalogue/.gitignore | 3 - r-app-catalogue/Dockerfile | 48 --- r-app-catalogue/README.md | 27 -- r-app-catalogue/api/rac-api.json | 252 ---------------- r-app-catalogue/api/rac-api.yaml | 181 ----------- r-app-catalogue/config/application.yaml | 30 -- .../config/r-app-catalogue-keystore.jks | Bin 3641 -> 0 bytes r-app-catalogue/eclipse-formatter.xml | 314 ------------------- r-app-catalogue/pom.xml | 331 --------------------- .../api/GeneralRappCatalogueControllerAdvisor.java | 61 ---- .../rappcatalogue/api/ServicesApiDelegateImpl.java | 147 --------- .../rappcatalogue/configuration/TomcatConfig.java | 56 ---- .../rappcatalogue/exception/HeaderException.java | 30 -- .../exception/InvalidServiceException.java | 27 -- .../exception/ServiceNotFoundException.java | 27 -- .../org/oransc/rappcatalogue/HttpsRequestTest.java | 113 ------- .../GeneralRappCatalogueControllerAdvisorTest.java | 78 ----- .../api/ServicesApiDelegateImplTest.java | 275 ----------------- 25 files changed, 7 insertions(+), 2051 deletions(-) delete mode 100644 r-app-catalogue/.gitignore delete mode 100644 r-app-catalogue/Dockerfile delete mode 100644 r-app-catalogue/README.md delete mode 100644 r-app-catalogue/api/rac-api.json delete mode 100644 r-app-catalogue/api/rac-api.yaml delete mode 100644 r-app-catalogue/config/application.yaml delete mode 100644 r-app-catalogue/config/r-app-catalogue-keystore.jks delete mode 100644 r-app-catalogue/eclipse-formatter.xml delete mode 100644 r-app-catalogue/pom.xml delete mode 100644 r-app-catalogue/src/main/java/org/oransc/rappcatalogue/api/GeneralRappCatalogueControllerAdvisor.java delete mode 100644 r-app-catalogue/src/main/java/org/oransc/rappcatalogue/api/ServicesApiDelegateImpl.java delete mode 100644 r-app-catalogue/src/main/java/org/oransc/rappcatalogue/configuration/TomcatConfig.java delete mode 100644 r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/HeaderException.java delete mode 100644 r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/InvalidServiceException.java delete mode 100644 r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/ServiceNotFoundException.java delete mode 100644 r-app-catalogue/src/test/java/org/oransc/rappcatalogue/HttpsRequestTest.java delete mode 100644 r-app-catalogue/src/test/java/org/oransc/rappcatalogue/api/GeneralRappCatalogueControllerAdvisorTest.java delete mode 100644 r-app-catalogue/src/test/java/org/oransc/rappcatalogue/api/ServicesApiDelegateImplTest.java diff --git a/docs/api-docs.rst b/docs/api-docs.rst index 29207b8f..b87b7891 100644 --- a/docs/api-docs.rst +++ b/docs/api-docs.rst @@ -22,7 +22,6 @@ The core Non-RT RIC consists of several parts, with available APIs described in * The A1 Policy Management Service * The Information Coordinator Service * DMaaP Adaptor -* The Non-RT-RIC App Catalogue * K8S Helm Chart LCM Manager (Initial) **** A1 Policy Management Service @@ -75,22 +74,6 @@ The API is also described in Swagger-JSON and YAML: "DMaaP Mediator Producer API", ":download:`link <../dmaap-mediator-producer/api/swagger.json>`", ":download:`link <../dmaap-mediator-producer/api/swagger.yaml>`" -Non-RT-RIC App Catalogue (Initial) -================================== - -The Service Catalogue provides a way for services to register themselves for other services to discover. - -See `Service Catalogue API <./rac-api.html>`_ for full details of the API. - -The API is also described in Swagger-JSON and YAML: - - -.. csv-table:: - :header: "API name", "|swagger-icon|", "|yaml-icon|" - :widths: 10,5, 5 - - "Service Catalogue API", ":download:`link <../r-app-catalogue/api/rac-api.json>`", ":download:`link <../r-app-catalogue/api/rac-api.yaml>`" - K8S Helm Chart LCM Manager (Initial) ==================================== diff --git a/docs/conf.py b/docs/conf.py index 4ee69983..87a9b71c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -8,21 +8,14 @@ linkcheck_ignore = [ 'http://localhost.*', 'http://127.0.0.1.*', 'https://gerrit.o-ran-sc.org.*', - './rac-api.html', #Generated file that doesn't exist at link check. './ics-api.html', #Generated file that doesn't exist at link check. - './dmaap-adaptor-api.html' #Generated file that doesn't exist at link check. + './dmaap-adaptor-api.html', #Generated file that doesn't exist at link check. './dmaap-mediator-producer-api.html' #Generated file that doesn't exist at link check. ] extensions = ['sphinxcontrib.redoc', 'sphinx.ext.intersphinx',] redoc = [ - { - 'name': 'RAC API', - 'page': 'rac-api', - 'spec': '../r-app-catalogue/api/rac-api.json', - 'embed': True, - }, { 'name': 'ICS API', 'page': 'ics-api', diff --git a/docs/developer-guide.rst b/docs/developer-guide.rst index a3c34220..af206e7e 100644 --- a/docs/developer-guide.rst +++ b/docs/developer-guide.rst @@ -58,11 +58,6 @@ Then start the container by running the following command: | docker run nonrtric-information-coordinator-service | +--------------------------------------------------------------------+ -Initial Non-RT-RIC App Catalogue --------------------------------- - -See the README.md file in the *r-app-catalogue* directory in the Gerrit repo for more details how to run the component. - DMaaP Adaptor Service --------------------- diff --git a/docs/overview.rst b/docs/overview.rst index 19194f41..f598d5ad 100644 --- a/docs/overview.rst +++ b/docs/overview.rst @@ -195,6 +195,9 @@ Register for Non-RT-RIC Apps. * Non-RT-RIC Apps can be registered / queried. * Limited functionality/integration for now. * *More work required in coming releases as the rApp concept matures*. +* Repo: *portal/nonrtric-plt-rappcatalogue* + +More details available at the `documentation site `_. Initial K8S Helm Chart LCM Manager ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 81fb0358..3e8dc268 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -76,23 +76,6 @@ Version history Information Coordinator Service +------------+----------+------------------+--------------------+ -Version history Service Catalogue -================================= - -+------------+----------+------------------+----------------+ -| **Date** | **Ver.** | **Author** | **Comment** | -| | | | | -+------------+----------+------------------+----------------+ -| 2020-12-03 | 1.0.0 | Henrik Andersson | Cherry Release | -| | | | | -+------------+----------+------------------+----------------+ -| 2020-12-03 | 1.0.2 | Henrik Andersson | E Maintenance | -| | | | Release | -| | | | Non root user | -| | | | in Docker | -+------------+----------+------------------+----------------+ - - Version history Helm Manager ============================ diff --git a/docs/requirements-docs.txt b/docs/requirements-docs.txt index 78db6850..692a79f0 100644 --- a/docs/requirements-docs.txt +++ b/docs/requirements-docs.txt @@ -1,11 +1,11 @@ tox -Sphinx>=2,<4 +Sphinx doc8 docutils setuptools six -sphinx_rtd_theme>=0.4.3 -sphinxcontrib-needs>=0.2.3 +sphinx_rtd_theme +sphinxcontrib-needs sphinxcontrib-swaggerdoc sphinx_bootstrap_theme sphinxcontrib-redoc diff --git a/pom.xml b/pom.xml index 1a7d8886..3ec1617f 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,6 @@ a1-policy-management-service information-coordinator-service - r-app-catalogue helm-manager dmaap-adaptor-java diff --git a/r-app-catalogue/.gitignore b/r-app-catalogue/.gitignore deleted file mode 100644 index ad56f2de..00000000 --- a/r-app-catalogue/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.swagger-codegen-ignore -.swagger-codegen/ -api/README.md diff --git a/r-app-catalogue/Dockerfile b/r-app-catalogue/Dockerfile deleted file mode 100644 index ed4be958..00000000 --- a/r-app-catalogue/Dockerfile +++ /dev/null @@ -1,48 +0,0 @@ -# -# ============LICENSE_START======================================================= -# Copyright (C) 2020 Nordix Foundation. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= -# -FROM openjdk:11-jre-slim - -ARG JAR - -WORKDIR /opt/app/r-app-catalogue -RUN mkdir -p /var/log/r-app-catalogue -RUN mkdir -p /opt/app/r-app-catalogue/etc/cert/ - -EXPOSE 8680 8633 - -ADD /config/application.yaml /opt/app/r-app-catalogue/config/application.yaml -ADD /config/r-app-catalogue-keystore.jks /opt/app/r-app-catalogue/etc/cert/keystore.jks -ADD target/${JAR} /opt/app/r-app-catalogue/r-app-catalogue.jar - -ARG user=nonrtric -ARG group=nonrtric - -RUN groupadd $user && \ - useradd -r -g $group $user -RUN chown -R $user:$group /opt/app/r-app-catalogue -RUN chown -R $user:$group /var/log/r-app-catalogue - -USER ${user} - -CMD ["java", "-jar", "/opt/app/r-app-catalogue/r-app-catalogue.jar"] - - - - diff --git a/r-app-catalogue/README.md b/r-app-catalogue/README.md deleted file mode 100644 index 863713db..00000000 --- a/r-app-catalogue/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# O-RAN-SC Non-RT RIC rAPP Catalogue - -The O-RAN Non-RT RIC rApp Catalogue provides an OpenApi 3.0 REST API for services to register themselves and discover -other services. - -**NOTE!** The definition of the REST API is done in the `api/rac-api.json` file. The yaml version of the file is -generated during compilation. - -The application is a SpringBoot application generated using the openapitools openapi-generator-maven-plugin. - -To start the application run: -`mvn spring-boot:run` - -## License - -Copyright (C) 2020 Nordix Foundation. 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. diff --git a/r-app-catalogue/api/rac-api.json b/r-app-catalogue/api/rac-api.json deleted file mode 100644 index 64f19d82..00000000 --- a/r-app-catalogue/api/rac-api.json +++ /dev/null @@ -1,252 +0,0 @@ -{ - "openapi": "3.0.0", - "info": { - "title": "rAPP Catalogue API", - "description": "The Non RT-RIC Service Catalogue provides a way for services to register themselves for other services to discover.", - "version": "1.0.0" - }, - "servers": [ - { - "url": "/" - } - ], - "paths": { - "/services": { - "get": { - "summary": "Services", - "deprecated": false, - "operationId": "getServices", - "responses": { - "200": { - "description": "Services", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/service" - } - } - } - } - } - }, - "tags": [ - "rAPP Catalogue API" - ] - } - }, - "/services/{serviceName}": { - "get": { - "summary": "Individual Service", - "deprecated": false, - "operationId": "getIndividualService", - "responses": { - "200": { - "description": "Service", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/service" - } - } - } - }, - "404": { - "description": "Service is not found", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/error_information" - } - } - } - } - }, - "parameters": [ - { - "in": "path", - "name": "serviceName", - "description": "serviceName", - "schema": { - "type": "string" - }, - "required": true, - "example": "DroneIdentifier" - } - ], - "tags": [ - "rAPP Catalogue API" - ] - }, - "put": { - "summary": "Create or update a Service", - "deprecated": false, - "operationId": "putIndividualService", - "responses": { - "200": { - "description": "Service updated" - }, - "201": { - "description": "Service created", - "headers": { - "Location": { - "schema": { - "type": "string" - }, - "description": "URL to the created Service" - } - } - }, - "400": { - "description": "Provided service is not correct", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/error_information" - }, - "example": { - "detail": "Service is missing required property: version", - "status": 400 - } - } - } - } - }, - "parameters": [ - { - "name": "serviceName", - "in": "path", - "required": true, - "schema": { - "type": "string" - }, - "example": "DroneIdentifier" - } - ], - "requestBody": { - "description": "Service to create/update", - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/inputService" - } - } - } - }, - "tags": [ - "rAPP Catalogue API" - ] - }, - "delete": { - "summary": "Remove a Service from the catalogue", - "deprecated": false, - "operationId": "deleteIndividualService", - "responses": { - "204": { - "description": "Service deleted" - } - }, - "parameters": [ - { - "name": "serviceName", - "in": "path", - "required": true, - "schema": { - "type": "string" - }, - "example": "DroneIdentifier" - } - ], - "tags": [ - "rAPP Catalogue API" - ] - } - } - }, - "components": { - "schemas": { - "inputService": { - "description": "A Service to register", - "type": "object", - "title": "inputService", - "required": [ - "version" - ], - "properties": { - "version": { - "description": "Version of the Service", - "type": "string", - "example": "1.0.0" - }, - "display_name": { - "description": "Display name for the Service", - "type": "string", - "example": "Drone Identifier" - }, - "description": { - "description": "Description of the Service", - "type": "string", - "example": "Detects if a UE is a drone" - } - } - }, - "service": { - "description": "A Service", - "type": "object", - "title": "service", - "required": [ - "name", - "version", - "registrationDate" - ], - "properties": { - "name": { - "description": "Unique identifier of the Service", - "type": "string", - "example": "DroneIdentifier" - }, - "version": { - "description": "Version of the Service", - "type": "string", - "example": "1.0.0" - }, - "display_name": { - "description": "Display name for the Service", - "type": "string", - "example": "Drone Identifier" - }, - "description": { - "description": "Description of the Service", - "type": "string", - "example": "Detects if a UE is a drone" - }, - "registrationDate": { - "description": "Date when the Service was registered in the catalogue", - "type": "string", - "example": "2020-11-03" - } - } - }, - "error_information": { - "description": "Problem as defined in https://tools.ietf.org/html/rfc7807", - "type": "object", - "title": "error_information", - "properties": { - "detail": { - "description": "A human-readable explanation specific to this occurrence of the problem.", - "type": "string", - "example": "Service not found" - }, - "status": { - "format": "int32", - "description": "The HTTP status code for this occurrence of the problem.", - "type": "integer", - "example": 404 - } - } - } - } - } -} diff --git a/r-app-catalogue/api/rac-api.yaml b/r-app-catalogue/api/rac-api.yaml deleted file mode 100644 index 9ba6c398..00000000 --- a/r-app-catalogue/api/rac-api.yaml +++ /dev/null @@ -1,181 +0,0 @@ -openapi: 3.0.0 -info: - title: rAPP Catalogue API - description: The Non RT-RIC Service Catalogue provides a way for services to register - themselves for other services to discover. - version: 1.0.0 -servers: -- url: / -paths: - /services: - get: - tags: - - rAPP Catalogue API - summary: Services - operationId: getServices - responses: - "200": - description: Services - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/service' - deprecated: false - /services/{serviceName}: - get: - tags: - - rAPP Catalogue API - summary: Individual Service - operationId: getIndividualService - parameters: - - name: serviceName - in: path - description: serviceName - required: true - style: simple - explode: false - schema: - type: string - example: DroneIdentifier - responses: - "200": - description: Service - content: - application/json: - schema: - $ref: '#/components/schemas/service' - "404": - description: Service is not found - content: - application/json: - schema: - $ref: '#/components/schemas/error_information' - deprecated: false - put: - tags: - - rAPP Catalogue API - summary: Create or update a Service - operationId: putIndividualService - parameters: - - name: serviceName - in: path - required: true - style: simple - explode: false - schema: - type: string - example: DroneIdentifier - requestBody: - description: Service to create/update - content: - application/json: - schema: - $ref: '#/components/schemas/inputService' - required: true - responses: - "200": - description: Service updated - "201": - description: Service created - headers: - Location: - description: URL to the created Service - style: simple - explode: false - schema: - type: string - "400": - description: Provided service is not correct - content: - application/json: - schema: - $ref: '#/components/schemas/error_information' - example: - detail: "Service is missing required property: version" - status: 400 - deprecated: false - delete: - tags: - - rAPP Catalogue API - summary: Remove a Service from the catalogue - operationId: deleteIndividualService - parameters: - - name: serviceName - in: path - required: true - style: simple - explode: false - schema: - type: string - example: DroneIdentifier - responses: - "204": - description: Service deleted - deprecated: false -components: - schemas: - inputService: - title: inputService - required: - - version - type: object - properties: - version: - type: string - description: Version of the Service - example: 1.0.0 - display_name: - type: string - description: Display name for the Service - example: Drone Identifier - description: - type: string - description: Description of the Service - example: Detects if a UE is a drone - description: A Service to register - service: - title: service - required: - - name - - registrationDate - - version - type: object - properties: - name: - type: string - description: Unique identifier of the Service - example: DroneIdentifier - version: - type: string - description: Version of the Service - example: 1.0.0 - display_name: - type: string - description: Display name for the Service - example: Drone Identifier - description: - type: string - description: Description of the Service - example: Detects if a UE is a drone - registrationDate: - type: string - description: Date when the Service was registered in the catalogue - example: 2020-11-03 - description: A Service - error_information: - title: error_information - type: object - properties: - detail: - type: string - description: A human-readable explanation specific to this occurrence of - the problem. - example: Service not found - status: - type: integer - description: The HTTP status code for this occurrence of the problem. - format: int32 - example: 404 - description: Problem as defined in https://tools.ietf.org/html/rfc7807 diff --git a/r-app-catalogue/config/application.yaml b/r-app-catalogue/config/application.yaml deleted file mode 100644 index 1ef0bdcc..00000000 --- a/r-app-catalogue/config/application.yaml +++ /dev/null @@ -1,30 +0,0 @@ - # ========================LICENSE_START================================= - # Copyright (C) 2021 Nordix Foundation. 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=================================== - -spring: - profiles: - active: prod -server: - # Configuration of the HTTP/REST server. The parameters are defined and handled by the springboot framework. - # See springboot documentation. - port : 8633 - http-port: 8680 - ssl: - key-store-type: JKS - key-store: /opt/app/r-app-catalogue/etc/cert/keystore.jks - key-store-password: r-app-catalogue - key-password: r-app-catalogue - key-alias: server-cert diff --git a/r-app-catalogue/config/r-app-catalogue-keystore.jks b/r-app-catalogue/config/r-app-catalogue-keystore.jks deleted file mode 100644 index 192fe173951fcb9e958b3996f5270c01cceab681..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3641 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/r-app-catalogue/pom.xml b/r-app-catalogue/pom.xml deleted file mode 100644 index 67be912a..00000000 --- a/r-app-catalogue/pom.xml +++ /dev/null @@ -1,331 +0,0 @@ - - - - 4.0.0 - - - org.springframework.boot - spring-boot-starter-parent - 2.6.2 - - - org.o-ran-sc.nonrtric - r-app-catalogue - 1.1.0-SNAPSHOT - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - - - - 11 - 1.5.22 - 2.9.2 - 0.2.1 - 5.3.1 - 3.0.31 - 2.12.2 - 1.24.3 - 0.8.6 - 0.30.0 - - - - - io.swagger - swagger-annotations - ${swagger-annotations.version} - - - com.fasterxml.jackson.core - jackson-annotations - - - org.springframework - spring-beans - - - org.springframework.boot - spring-boot-autoconfigure - - - org.springframework - spring-web - - - org.springframework.boot - spring-boot - - - org.springframework - spring-webmvc - - - org.springframework - spring-context - - - io.springfox - springfox-swagger2 - ${springfox.version} - - - io.springfox - springfox-core - ${springfox.version} - - - io.springfox - springfox-spring-web - ${springfox.version} - - - io.springfox - springfox-spi - ${springfox.version} - - - org.assertj - assertj-core - - - org.apache.tomcat.embed - tomcat-embed-core - - - org.openapitools - jackson-databind-nullable - ${jackson-databind-nullable.version} - - - javax.validation - validation-api - - - com.fasterxml.jackson.core - jackson-databind - - - org.yaml - snakeyaml - runtime - - - - org.springframework - spring-test - test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.mockito - mockito-junit-jupiter - test - - - org.mockito - mockito-core - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - org.springframework.boot - spring-boot-starter-test - test - - - org.apache.httpcomponents - httpclient - test - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.openapitools - openapi-generator-maven-plugin - ${openapi-generator-maven-plugin.version} - - - - generate - - - ${project.basedir}/api/rac-api.json - spring - org.oransc.rappcatalogue.api - org.oransc.rappcatalogue.model - org.oransc.rappcatalogue - - true - true - - - - - - - io.swagger.codegen.v3 - swagger-codegen-maven-plugin - ${swagger-codegen-maven-plugin.version} - - - - generate - - - ${project.basedir}/api/rac-api.json - openapi-yaml - ${project.basedir}/api/ - - rac-api.yaml - - - - - - - net.revelc.code.formatter - formatter-maven-plugin - ${formatter-maven-plugin.version} - - ${project.basedir}/eclipse-formatter.xml - - - - - com.diffplug.spotless - spotless-maven-plugin - ${spotless-maven-plugin.version} - - - - - com,java,javax,org - - - - - - - org.jacoco - jacoco-maven-plugin - ${jacoco-maven-plugin.version} - - - default-prepare-agent - - prepare-agent - - - - default-report - prepare-package - - report - - - - - - io.fabric8 - docker-maven-plugin - ${docker-maven-plugin.version} - false - - - generate-r-app-catalogue-image - package - - build - - - ${env.CONTAINER_PULL_REGISTRY} - - - o-ran-sc/nonrtric-r-app-catalogue:${project.version} - - try - ${basedir} - Dockerfile - - ${project.build.finalName}.jar - - - ${project.version} - - - - - - - - push-r-app-catalogue-image - - build - push - - - ${env.CONTAINER_PULL_REGISTRY} - ${env.CONTAINER_PUSH_REGISTRY} - - - o-ran-sc/nonrtric-r-app-catalogue:${project.version} - - ${basedir} - Dockerfile - - ${project.build.finalName}.jar - - - ${project.version} - latest - - - - - - - - - - - diff --git a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/api/GeneralRappCatalogueControllerAdvisor.java b/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/api/GeneralRappCatalogueControllerAdvisor.java deleted file mode 100644 index 072a5a0e..00000000 --- a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/api/GeneralRappCatalogueControllerAdvisor.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2020 Nordix Foundation. 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=================================== - */ - -package org.oransc.rappcatalogue.api; - -import static org.springframework.http.HttpStatus.BAD_REQUEST; -import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; -import static org.springframework.http.HttpStatus.NOT_FOUND; - -import org.oransc.rappcatalogue.exception.HeaderException; -import org.oransc.rappcatalogue.exception.InvalidServiceException; -import org.oransc.rappcatalogue.exception.ServiceNotFoundException; -import org.oransc.rappcatalogue.model.ErrorInformation; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; - -@ControllerAdvice -public class GeneralRappCatalogueControllerAdvisor extends ResponseEntityExceptionHandler { - @ExceptionHandler(InvalidServiceException.class) - public ResponseEntity handleInvalidServiceException(InvalidServiceException ex) { - - return new ResponseEntity<>(getErrorInformation(ex, BAD_REQUEST), BAD_REQUEST); - } - - @ExceptionHandler(ServiceNotFoundException.class) - public ResponseEntity handleServiceNotFoundException(ServiceNotFoundException ex) { - - return new ResponseEntity<>(getErrorInformation(ex, NOT_FOUND), NOT_FOUND); - } - - @ExceptionHandler(HeaderException.class) - public ResponseEntity handleHeaderException(HeaderException ex) { - - return new ResponseEntity<>(getErrorInformation(ex, INTERNAL_SERVER_ERROR), INTERNAL_SERVER_ERROR); - } - - private ErrorInformation getErrorInformation(Exception cause, HttpStatus status) { - ErrorInformation errorInfo = new ErrorInformation(); - errorInfo.setDetail(cause.getMessage()); - errorInfo.setStatus(status.value()); - return errorInfo; - } -} diff --git a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/api/ServicesApiDelegateImpl.java b/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/api/ServicesApiDelegateImpl.java deleted file mode 100644 index 4615d69c..00000000 --- a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/api/ServicesApiDelegateImpl.java +++ /dev/null @@ -1,147 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2020 Nordix Foundation. 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=================================== - */ - -package org.oransc.rappcatalogue.api; - -import java.io.IOException; -import java.sql.Date; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.ConcurrentHashMap; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.oransc.rappcatalogue.exception.HeaderException; -import org.oransc.rappcatalogue.exception.InvalidServiceException; -import org.oransc.rappcatalogue.exception.ServiceNotFoundException; -import org.oransc.rappcatalogue.model.InputService; -import org.oransc.rappcatalogue.model.Service; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.context.request.NativeWebRequest; - -@org.springframework.stereotype.Service -public class ServicesApiDelegateImpl implements ServicesApiDelegate { - - private static final String LOCATION_HEADER = "Location"; - - @Autowired - private NativeWebRequest nativeWebRequest; - - private ConcurrentHashMap registeredServices = new ConcurrentHashMap<>(); - - ServicesApiDelegateImpl(NativeWebRequest nativeWebRequest) { - this.nativeWebRequest = nativeWebRequest; - } - - @Override - public Optional getRequest() { - return Optional.of(nativeWebRequest); - } - - @Override - public ResponseEntity getIndividualService(String serviceName) throws ServiceNotFoundException { - Service service = registeredServices.get(serviceName); - if (service != null) { - return ResponseEntity.ok(service); - } else { - throw new ServiceNotFoundException(serviceName); - } - } - - @Override - public ResponseEntity> getServices() { - return ResponseEntity.ok(new ArrayList<>(registeredServices.values())); - } - - @Override - public ResponseEntity putIndividualService(String serviceName, InputService inputService) - throws InvalidServiceException, HeaderException { - if (isServiceValid(inputService)) { - if (registeredServices.put(serviceName, createService(serviceName, inputService)) == null) { - try { - Optional request = getRequest(); - if (request.isPresent()) { - addLocationHeaderToResponse(serviceName, request.get()); - } - } catch (HeaderException e) { - registeredServices.remove(serviceName); - throw e; - } - return new ResponseEntity<>(HttpStatus.CREATED); - } else { - return new ResponseEntity<>(HttpStatus.OK); - } - } else { - throw new InvalidServiceException(); - } - } - - private void addLocationHeaderToResponse(String serviceName, NativeWebRequest request) throws HeaderException { - try { - HttpServletRequest nativeRequest = request.getNativeRequest(HttpServletRequest.class); - HttpServletResponse nativeResponse = request.getNativeResponse(HttpServletResponse.class); - if (nativeRequest != null && nativeResponse != null) { - StringBuffer requestURL = nativeRequest.getRequestURL(); - nativeResponse.addHeader(LOCATION_HEADER, requestURL.toString()); - nativeResponse.getWriter().print(""); - } else { - throw new HeaderException(LOCATION_HEADER, serviceName, - new Exception("Native Request or Response missing")); - } - } catch (IOException e) { - throw new HeaderException(LOCATION_HEADER, serviceName, e); - } - } - - @Override - public ResponseEntity deleteIndividualService(String serviceName) { - registeredServices.remove(serviceName); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - /* - * java:S2589: Boolean expressions should not be gratuitous. Even though the - * version property is marked as @NotNull, it might be null coming from the - * client, hence the null check is needed. - */ - @SuppressWarnings("java:S2589") - private boolean isServiceValid(InputService service) { - String version = service.getVersion(); - return version != null && !version.isBlank(); - } - - private Service createService(String serviceName, InputService inputService) { - Service service = new Service(); - service.setName(serviceName); - service.setDescription(inputService.getDescription()); - service.setDisplayName(inputService.getDisplayName()); - service.setVersion(inputService.getVersion()); - service.setRegistrationDate(getTodaysDate()); - return service; - } - - private String getTodaysDate() { - long millis = System.currentTimeMillis(); - Date date = new Date(millis); - return date.toString(); - } -} diff --git a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/configuration/TomcatConfig.java b/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/configuration/TomcatConfig.java deleted file mode 100644 index a04a3323..00000000 --- a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/configuration/TomcatConfig.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2021 Nordix Foundation. 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=================================== - */ - -package org.oransc.rappcatalogue.configuration; - -import org.apache.catalina.connector.Connector; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; -import org.springframework.boot.web.servlet.server.ServletWebServerFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * Configure embedded Tomcat - */ - -@Configuration -public class TomcatConfig { - - @Value("${server.http-port}") - private int httpPort = 0; - - // Embedded Tomcat with HTTP and HTTPS support - @Bean - public ServletWebServerFactory servletContainer() { - TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); - - if (httpPort > 0) { - tomcat.addAdditionalTomcatConnectors(getHttpConnector(httpPort)); - } - return tomcat; - } - - private static Connector getHttpConnector(int httpPort) { - Connector connector = new Connector(TomcatServletWebServerFactory.DEFAULT_PROTOCOL); - connector.setScheme("http"); - connector.setPort(httpPort); - connector.setSecure(false); - return connector; - } -} diff --git a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/HeaderException.java b/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/HeaderException.java deleted file mode 100644 index 8f64449f..00000000 --- a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/HeaderException.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2020 Nordix Foundation. 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=================================== - */ - -package org.oransc.rappcatalogue.exception; - -public class HeaderException extends Exception { - - private static final long serialVersionUID = -7798178963078284655L; - - public HeaderException(String header, String serviceName, Exception cause) { - super(String.format("Unable to set header %s in put response for service %s. Cause: %s", header, serviceName, - cause.getMessage())); - } - -} diff --git a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/InvalidServiceException.java b/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/InvalidServiceException.java deleted file mode 100644 index 45ec7692..00000000 --- a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/InvalidServiceException.java +++ /dev/null @@ -1,27 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2020 Nordix Foundation. 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=================================== - */ - -package org.oransc.rappcatalogue.exception; - -public class InvalidServiceException extends Exception { - private static final long serialVersionUID = 3849219105170316564L; - - public InvalidServiceException() { - super("Service is missing required property: version"); - } -} diff --git a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/ServiceNotFoundException.java b/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/ServiceNotFoundException.java deleted file mode 100644 index 8411cf42..00000000 --- a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/ServiceNotFoundException.java +++ /dev/null @@ -1,27 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2020 Nordix Foundation. 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=================================== - */ - -package org.oransc.rappcatalogue.exception; - -public class ServiceNotFoundException extends Exception { - private static final long serialVersionUID = 6579271315716003988L; - - public ServiceNotFoundException(String serviceName) { - super(String.format("Service %s not found", serviceName)); - } -} diff --git a/r-app-catalogue/src/test/java/org/oransc/rappcatalogue/HttpsRequestTest.java b/r-app-catalogue/src/test/java/org/oransc/rappcatalogue/HttpsRequestTest.java deleted file mode 100644 index 8a66e14b..00000000 --- a/r-app-catalogue/src/test/java/org/oransc/rappcatalogue/HttpsRequestTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2021 Nordix Foundation. 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=================================== - */ - -package org.oransc.rappcatalogue; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import javax.net.ssl.SSLContext; - -import org.apache.http.client.HttpClient; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.ssl.SSLContextBuilder; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.boot.test.web.client.TestRestTemplate.HttpClientOption; -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.boot.web.server.AbstractConfigurableWebServerFactory; -import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.util.ResourceUtils; -import org.springframework.web.client.ResourceAccessException; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@TestPropertySource( - properties = { // - "server.ssl.key-store=./config/r-app-catalogue-keystore.jks", // - "server.http-port=0"}) -public class HttpsRequestTest { - - @Value("${server.ssl.key-store-password}") - private String keyStorePassword; // inject password from config - - @Value("${server.ssl.key-store}") - private String keyStore; // inject keyStore from config - - @LocalServerPort - private int port; - - @Autowired - private AbstractConfigurableWebServerFactory webServerFactory; - - @Test - public void testSsl() { - assertEquals(true, this.webServerFactory.getSsl().isEnabled()); - } - - @Test - public void rest_OverPlainHttp_GetsBadRequestRequiresTLS() throws Exception { - TestRestTemplate template = new TestRestTemplate(); - ResponseEntity responseEntity = - template.getForEntity("http://localhost:" + port + "/services", String.class); - assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode()); - assertTrue(responseEntity.getBody().contains("This combination of host and port requires TLS")); - } - - @Test - public void rest_WithoutSSLConfiguration_ThrowsSSLExceptionUnableFindValidCertPath() throws Exception { - TestRestTemplate template = new TestRestTemplate(); - - ResourceAccessException thrown = assertThrows(ResourceAccessException.class, () -> { - template.getForEntity("https://localhost:" + port + "/services", String.class); - }); - assertTrue(thrown.getMessage().contains("unable to find valid certification path to requested target")); - } - - @Test - public void rest_WithTwoWaySSL_AuthenticatesAndGetsExpectedResponse() throws Exception { - - SSLContext sslContext = new SSLContextBuilder().loadKeyMaterial(ResourceUtils.getFile(keyStore), - keyStorePassword.toCharArray(), keyStorePassword.toCharArray()).build(); - - SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(sslContext); - HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build(); - HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient); - RestTemplateBuilder rtb = - new RestTemplateBuilder().requestFactory(() -> factory).rootUri("https://localhost:" + port); - - TestRestTemplate template = new TestRestTemplate(rtb, null, null, HttpClientOption.SSL); - - ResponseEntity responseEntity = template.getForEntity("/services", String.class); - assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); - assertEquals("[]", responseEntity.getBody()); - } - -} diff --git a/r-app-catalogue/src/test/java/org/oransc/rappcatalogue/api/GeneralRappCatalogueControllerAdvisorTest.java b/r-app-catalogue/src/test/java/org/oransc/rappcatalogue/api/GeneralRappCatalogueControllerAdvisorTest.java deleted file mode 100644 index 24afa09e..00000000 --- a/r-app-catalogue/src/test/java/org/oransc/rappcatalogue/api/GeneralRappCatalogueControllerAdvisorTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2020 Nordix Foundation. 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=================================== - */ - -package org.oransc.rappcatalogue.api; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.http.HttpStatus.BAD_REQUEST; -import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; -import static org.springframework.http.HttpStatus.NOT_FOUND; - -import org.junit.jupiter.api.Test; -import org.oransc.rappcatalogue.exception.HeaderException; -import org.oransc.rappcatalogue.exception.InvalidServiceException; -import org.oransc.rappcatalogue.exception.ServiceNotFoundException; -import org.oransc.rappcatalogue.model.ErrorInformation; -import org.springframework.http.ResponseEntity; - -class GeneralRappCatalogueControllerAdvisorTest { - - @Test - void handleInvalidServiceException_shouldReturnBadRequestWithMessage() { - GeneralRappCatalogueControllerAdvisor advisorUnderTest = new GeneralRappCatalogueControllerAdvisor(); - - InvalidServiceException exception = new InvalidServiceException(); - - ResponseEntity response = advisorUnderTest.handleInvalidServiceException(exception); - - assertThat(response.getStatusCode()).isEqualTo(BAD_REQUEST); - ErrorInformation body = (ErrorInformation) response.getBody(); - assertThat(body.getStatus()).isEqualTo(BAD_REQUEST.value()); - assertThat(body.getDetail()).isEqualTo("Service is missing required property: version"); - } - - @Test - void handleServiceNotFoundException_shouldReturnNotFoundWithMessage() { - GeneralRappCatalogueControllerAdvisor advisorUnderTest = new GeneralRappCatalogueControllerAdvisor(); - - ServiceNotFoundException exception = new ServiceNotFoundException("Name"); - - ResponseEntity response = advisorUnderTest.handleServiceNotFoundException(exception); - - assertThat(response.getStatusCode()).isEqualTo(NOT_FOUND); - ErrorInformation body = (ErrorInformation) response.getBody(); - assertThat(body.getStatus()).isEqualTo(NOT_FOUND.value()); - assertThat(body.getDetail()).isEqualTo("Service Name not found"); - } - - @Test - void handleHeaderException_shouldReturnInternalServerErrorWithMessage() { - GeneralRappCatalogueControllerAdvisor advisorUnderTest = new GeneralRappCatalogueControllerAdvisor(); - - String serviceName = "Service"; - HeaderException exception = new HeaderException("Header", serviceName, new Exception("Cause")); - - ResponseEntity response = advisorUnderTest.handleHeaderException(exception); - - assertThat(response.getStatusCode()).isEqualTo(INTERNAL_SERVER_ERROR); - ErrorInformation body = (ErrorInformation) response.getBody(); - assertThat(body.getStatus()).isEqualTo(INTERNAL_SERVER_ERROR.value()); - assertThat(body.getDetail()) - .isEqualTo("Unable to set header Header in put response for service " + serviceName + ". Cause: Cause"); - } -} diff --git a/r-app-catalogue/src/test/java/org/oransc/rappcatalogue/api/ServicesApiDelegateImplTest.java b/r-app-catalogue/src/test/java/org/oransc/rappcatalogue/api/ServicesApiDelegateImplTest.java deleted file mode 100644 index dd10a650..00000000 --- a/r-app-catalogue/src/test/java/org/oransc/rappcatalogue/api/ServicesApiDelegateImplTest.java +++ /dev/null @@ -1,275 +0,0 @@ - -package org.oransc.rappcatalogue.api; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.springframework.http.HttpStatus.CREATED; -import static org.springframework.http.HttpStatus.NO_CONTENT; -import static org.springframework.http.HttpStatus.OK; - -import java.io.IOException; -import java.io.PrintWriter; -import java.sql.Date; -import java.util.Arrays; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; -import org.oransc.rappcatalogue.exception.HeaderException; -import org.oransc.rappcatalogue.exception.InvalidServiceException; -import org.oransc.rappcatalogue.exception.ServiceNotFoundException; -import org.oransc.rappcatalogue.model.InputService; -import org.oransc.rappcatalogue.model.Service; -import org.springframework.http.ResponseEntity; -import org.springframework.web.context.request.NativeWebRequest; - -@ExtendWith(MockitoExtension.class) -class ServicesApiDelegateImplTest { - - @Mock - NativeWebRequest webRequestMock; - - private static final String INVALID_SERVICE_MESSAGE = "Service is missing required property: version"; - private static final String SERVICE_NAME = "Service Name"; - private static final String SERVICE_DESCRIPTION = "description"; - private static final String SERVICE_VERSION = "1.0"; - private static final String SERVICE_DISPLAY_NAME = "Display Name"; - - @Test - void getAddedService_shouldReturnService() throws Exception { - ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(webRequestMock); - - InputService service = new InputService(); - service.setDescription(SERVICE_DESCRIPTION); - service.setVersion(SERVICE_VERSION); - service.setDisplayName(SERVICE_DISPLAY_NAME); - - whenPrintResponseShouldWork(); - - delegateUnderTest.putIndividualService(SERVICE_NAME, service); - - ResponseEntity response = delegateUnderTest.getIndividualService(SERVICE_NAME); - - assertThat(response.getStatusCode()).isEqualTo(OK); - assertThat(response.getBody().getName()).isEqualTo(SERVICE_NAME); - } - - @Test - void getMissingService_shouldThrowException() { - ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(null); - - Exception exception = assertThrows(ServiceNotFoundException.class, () -> { - delegateUnderTest.getIndividualService(SERVICE_NAME); - }); - - String expectedMessage = "Service " + SERVICE_NAME + " not found"; - String actualMessage = exception.getMessage(); - - assertThat(actualMessage).isEqualTo(expectedMessage); - } - - @Test - void putNewValidService_shouldBeCreatedAndRegisteredAndUrlToNewServiceAddedToLocationHeaderInResponse() - throws Exception { - ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(webRequestMock); - - InputService service = new InputService(); - service.setDescription(SERVICE_DESCRIPTION); - service.setVersion(SERVICE_VERSION); - service.setDisplayName(SERVICE_DISPLAY_NAME); - - String urlToCreatedService = "URL to created Service"; - HttpServletResponse servletResponseMock = whenPrintResponseShouldWork(urlToCreatedService); - - ResponseEntity putResponse = delegateUnderTest.putIndividualService(SERVICE_NAME, service); - - assertThat(putResponse.getStatusCode()).isEqualTo(CREATED); - verify(servletResponseMock).addHeader("Location", urlToCreatedService); - - ResponseEntity getResponse = delegateUnderTest.getIndividualService(SERVICE_NAME); - - assertThat(getResponse.getStatusCode()).isEqualTo(OK); - Service body = getResponse.getBody(); - assertThat(body.getName()).isEqualTo(SERVICE_NAME); - assertThat(body.getRegistrationDate()).isEqualTo(getTodaysDate()); - } - - @Test - void putModifiedService_shouldBeModified() throws Exception { - ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(webRequestMock); - - InputService service = new InputService(); - service.setDescription(SERVICE_DESCRIPTION); - service.setVersion(SERVICE_VERSION); - service.setDisplayName(SERVICE_DISPLAY_NAME); - - whenPrintResponseShouldWork(); - - delegateUnderTest.putIndividualService(SERVICE_NAME, service); - - String newDescription = "New description"; - service.setDescription(newDescription); - ResponseEntity putResponse = delegateUnderTest.putIndividualService(SERVICE_NAME, service); - - assertThat(putResponse.getStatusCode()).isEqualTo(OK); - - ResponseEntity getResponse = delegateUnderTest.getIndividualService(SERVICE_NAME); - - assertThat(getResponse.getStatusCode()).isEqualTo(OK); - assertThat(getResponse.getBody().getDescription()).isEqualTo(newDescription); - } - - @Test - void putServiceWithVersionNull_shouldThrowException() { - ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(null); - - InputService service = new InputService(); - service.setDescription(SERVICE_DESCRIPTION); - service.setDisplayName(SERVICE_DISPLAY_NAME); - - Exception exception = assertThrows(InvalidServiceException.class, () -> { - delegateUnderTest.putIndividualService(SERVICE_NAME, service); - }); - - assertThat(exception.getMessage()).isEqualTo(INVALID_SERVICE_MESSAGE); - } - - @Test - void putServiceWithBlankVersion_shouldThrowException() { - ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(null); - - InputService service = new InputService(); - service.setVersion(""); - service.setDescription(SERVICE_DESCRIPTION); - service.setDisplayName(SERVICE_DISPLAY_NAME); - - Exception exception = assertThrows(InvalidServiceException.class, () -> { - delegateUnderTest.putIndividualService(SERVICE_NAME, service); - }); - - assertThat(exception.getMessage()).isEqualTo(INVALID_SERVICE_MESSAGE); - } - - @Test - void putServiceWhenIoExceptionAddingHeader_shouldThrowExceptionAndNoServiceCreated() throws Exception { - ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(webRequestMock); - - whenGetRequestUrlThenReturnUrl(); - HttpServletResponse servletResponseMock = mock(HttpServletResponse.class); - when(webRequestMock.getNativeResponse(HttpServletResponse.class)).thenReturn(servletResponseMock); - when(servletResponseMock.getWriter()).thenThrow(new IOException("Error")); - - InputService service = new InputService(); - service.setVersion("1.0"); - service.setDescription(SERVICE_DESCRIPTION); - service.setDisplayName(SERVICE_DISPLAY_NAME); - - Exception exception = assertThrows(HeaderException.class, () -> { - delegateUnderTest.putIndividualService(SERVICE_NAME, service); - }); - - assertThat(exception.getMessage()) - .isEqualTo("Unable to set header Location in put response for service " + SERVICE_NAME + ". Cause: Error"); - - ResponseEntity> response = delegateUnderTest.getServices(); - assertThat(response.getBody()).isEmpty(); - } - - @Test - void getServices_shouldProvideArrayOfAddedServiceNames() throws Exception { - ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(webRequestMock); - - InputService service1 = new InputService(); - service1.setDescription("description 1"); - service1.setVersion(SERVICE_VERSION); - service1.setDisplayName("Display Name 1"); - - InputService service2 = new InputService(); - service2.setDescription("description 2"); - service2.setVersion(SERVICE_VERSION); - service2.setDisplayName("Display Name 2"); - - whenPrintResponseShouldWork(); - - String serviceName1 = "Service Name 1"; - delegateUnderTest.putIndividualService(serviceName1, service1); - String serviceName2 = "Service Name 2"; - delegateUnderTest.putIndividualService(serviceName2, service2); - - ResponseEntity> response = delegateUnderTest.getServices(); - - assertThat(response.getStatusCode()).isEqualTo(OK); - List services = response.getBody(); - assertThat(services).hasSize(2); - List expectedServiceNames = Arrays.asList(serviceName1, serviceName2); - assertThat(expectedServiceNames).contains(services.get(0).getName()) // - .contains(services.get(1).getName()); - } - - @Test - void deleteService_shouldBeOk() throws Exception { - ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(webRequestMock); - - InputService service = new InputService(); - service.setDescription(SERVICE_DESCRIPTION); - service.setVersion(SERVICE_VERSION); - service.setDisplayName(SERVICE_DISPLAY_NAME); - - whenPrintResponseShouldWork(); - - delegateUnderTest.putIndividualService(SERVICE_NAME, service); - - ResponseEntity> servicesResponse = delegateUnderTest.getServices(); - - assertThat(servicesResponse.getBody()).hasSize(1); - - ResponseEntity deleteResponse = delegateUnderTest.deleteIndividualService(SERVICE_NAME); - - assertThat(deleteResponse.getStatusCode()).isEqualTo(NO_CONTENT); - - servicesResponse = delegateUnderTest.getServices(); - - assertThat(servicesResponse.getBody()).isEmpty(); - } - - private void whenGetRequestUrlThenReturnUrl() { - whenGetRequestUrlThenReturnUrl("URL"); - } - - private void whenGetRequestUrlThenReturnUrl(String url) { - HttpServletRequest servletRequestMock = mock(HttpServletRequest.class); - when(webRequestMock.getNativeRequest(HttpServletRequest.class)).thenReturn(servletRequestMock); - when(servletRequestMock.getRequestURL()).thenReturn(new StringBuffer(url)); - } - - private HttpServletResponse whenPrintResponseShouldWork() { - return whenPrintResponseShouldWork("URL"); - } - - private HttpServletResponse whenPrintResponseShouldWork(String url) { - whenGetRequestUrlThenReturnUrl(url); - HttpServletResponse servletResponseMock = mock(HttpServletResponse.class); - when(webRequestMock.getNativeResponse(HttpServletResponse.class)).thenReturn(servletResponseMock); - PrintWriter printWriterMock = mock(PrintWriter.class); - try { - when(servletResponseMock.getWriter()).thenReturn(printWriterMock); - } catch (IOException e) { - // Nothing - } - return servletResponseMock; - } - - private String getTodaysDate() { - long millis = System.currentTimeMillis(); - Date date = new Date(millis); - return date.toString(); - } -} -- 2.16.6