# Delphi API (Java)
## Overview

- Java JDK 11
- Spring Boot
- Hibernate
- Postgres 11.5+
- Google Bigtable (GCP)

## Java Code Style
The Coding style is based on the Google Java Style Guide, with the following minor changes:

- indentation changed from 2 spaces to 4 spaces
- right margin changed from 100 to 120 columns
- import layout table groupings

####Code Style
You can import the code style file `intellij-java-google-style-custom.xml` into IntelliJ via 
**File→Settings→Editor→Code Style**. Reformatting code in the IDE will be correct after selecting
the new profile.

## Run the project
1. Import the project as a Maven project to IDEA
2. Install Lombok plugin **Preferences/settings -> Plugins -> search Lombok**
3. Import Run Configurations and credentials
    1. Make sure Run configuration xml files are in place and visible to Idea:  
    files are in `.run/` directory e.g. `.run/stage_pg_stage_bt_app.run.xml`. They should appear in Idea's `Run configurations` menu automatically         
    *for Idea versions older than 2020.1 - move xml files to `.idea/runConfigurations` (and probably remove 'run' from file names)*
    2. Prepare Postgres DB properties override files  
    create DB override files for all envs e.g. `.mine/pg_db_stage.yml` using AWS secrets manager  
    look for instructions and properties template in `.mine/EXAMPLE-pg_db_local.yml`
    3. Prepare Google cloud credentials (gcc) files
        1. Get gcc files for different envs`*`
        2. Add them to `.mine/` folder like `./mine/gcc_stage.json`
4. [Enable OpenVPN](https://data-analytics.atlassian.net/wiki/spaces/IN/pages/218398877/OpenVPN+user+guide)
5. Run `clean` `install` goals from Maven lifecycle
6. Click the Run button in IDEA
7. Enjoy

`*`please contact someone from the development team to get gcc.json files for (dev/qa/stage)

## Generate swagger documentation
To generate documentation run `mvn swagger-codegen:generate` command

## Running IT tests
Prerequisite:
 - Docker should be installed and active
 - LIQUIBASE_SCRIPTS env variable should point to liquibase scripts folder: delphi-api/liquibase
 - IT tests should followed maven-failsafe-plugin default name convention: *IT.java, *IT*.java, *ITCase.java
 - **integration.tests.enable=true** environment variable being used as enable/disable switch for the tests execution. Integration tests are disabled by default.

Run maven goals: `mvn clean verify -D integration.tests.enable=true -D env.LIQUIBASE_SCRIPTS=PATH_TO_LIQUIBASE_SCRIPTS`