correct some rst files
[externalapi/nbi.git] / docs / architecture / NBI_R1_Developer_Guide.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3 .. Copyright 2018 ORANGE
4
5
6 =====================
7 NBI - Developer Guide
8 =====================
9 ************
10 Introduction
11 ************
12
13 NBI is a Java 8 web application built over Spring Framework. Using Spring Boot 1.5.10 dependencies, it runs as a standalone application with an embedded Tomcat server.
14
15 ************
16 Dependencies
17 ************
18 This project use various framework which are managed with Maven dependency management tool (see *pom.xml* file at root level) :
19
20 - Swagger annotations
21 - `Spring Framework <https://github.com/spring-projects/spring-boot>`_
22 - `JOLT <https://github.com/bazaarvoice/jolt>`_ to perform JsonToJson transformation
23 - `FasterXML/Jackson <https://github.com/FasterXML/jackson>`_ to perform JSON parsing
24 - `Wiremock <https://github.com/tomakehurst/wiremock>`_ to perform testing over HTTP mocked response
25
26
27 *************
28 Configuration
29 *************
30 A configuration file, *src/main/resources/application-localhost.properties* list all the component interface that can be configured depending on the environment were the app is deployed.
31 By default, the application runs with an embedded both MongoDB and MariaDB local instance.
32 This file also list configurations of all the REST interface maid from NBI to other ONAP component such as SDC, AA&I and SO.
33
34 ***********
35 Source tree
36 ***********
37 This application provides ServiceOrder, ServiceCatalag and ServiceInventory as main functional resources and HealthCheck. Each resource is implemented independently in a package corresponding to its name.
38
39 *commons , configuration, and exceptions* are shared technical classes that provided for all the application.
40
41
42 ***********************************
43 Running and testing the application
44 ***********************************
45
46 **Locally**
47
48 Ensure that you have a MongoDB and MariaDB instance running and properly configured in *application.properties* file.
49 Run *Application.java* class in your favorite IDE
50
51 Or through a terminal, ensure that your maven installation is works and run *mvn spring-boot:run* command to start the application.
52
53
54 **Docker**
55
56 Requirements: `Docker engine <https://docs.docker.com/engine/>`_ and `docker-compose <https://docs.docker.com/compose/>`_.
57
58 To start the application:
59     1. Generate the application .jar file: `$ mvn clean package`
60     2. Configure the **.env** file
61     3. Start the *MariaDB* and *MongoDB* services: `$ docker-compose up -d mongo mariadb`
62     4. Build and start the *NBI* service: `$ docker-compose up --build -d nbi`
63
64 You can view the log output of the application with the following command:
65
66 `$ docker-compose logs -f nbi`
67
68 **Testing**
69 When the app is running, you can access the API at :samp:`http://yourhostname:8080/nbi/api/v1` and fill the url with the name of the resources you asking for (/serviceSpecification, /service, /serviceOrder or /status)
70 You can run a test by using `VisualStudio RestClient plugin <https://github.com/Huachao/vscode-restclient>`_
71 See the *restclient* package at root level to find *.vscode/settings.json* configuration file and */json/* package with samples requests that can be run.
72 You can also trigger these endpoints with any RESTful client or automation framework.