Skip to content

CorndelWithSoftwire/AgentDiscoveriesApp-JavaHibernate

Repository files navigation

Agent Discoveries Application

Requirements

This project requires at least Java 8. If you want to run it from the command line then you'll need Maven 3 on your PATH as well.

You'll need MySQL server and MySQL workbench, this can be downloaded from here if you don't already have it. When running through the installer you can keep all the default options.

Setup

Open mysql workbench, choose the local mysql instance. Create a database called agentdiscoveries. Later, when you start the application it will create the necessary tables itself.

  • Copy AgentDiscoveries-Backend/src/main/resources/template_config.properties and rename the new copy config.properties. Update the database.username and database.password fields in your new file.
  • Copy AgentDiscoveries-Backend/src/main/resources/META-INF/template_persistence.xml and rename the new copy persistence.xml. Update the javax.persistence.jdbc.user and javax.persistence.jdbc.password fields in your new file.

Running the application

You will notice that there are 2 modules in this project - AgentDiscoveries-Backend and AgentDiscoveries-Frontend. The main build will build them both. There are instructions for running them separately at the bottom of this section.

Build

To build the project, you will need to run mvn clean package. The jar generated in the backend project will contain everything required for the website.

Run

To start the application from the command line, run

java -jar AgentDiscoveries-Backend/target/agentdiscoveries-backend-1.0-SNAPSHOT.jar

Checking the application has started

The application homepage can be found at http://localhost:8080.

There is also a health-check at http://localhost:8080/healthcheck. If there are any problems starting the application take a look at the logs first, it is probably a database or port already in use issue.

Test users

The app comes with some test users added by the migrations:

Username Password Role
test_user password User
test_agent password Agent
test_corrupt N/A User with a corrupt password
test_admin password Admin

These should be deleted in the production environment.

IntelliJ Configuration

In order to run your application directly using IntelliJ, you should first make sure the frontend project has been built (or else it can't serve the website!). You can ensure this is automatically done by adding a 'build step' to the run configuration: Either mvn build or npm run build in the frontend project.

Then, in the run configuration, set the main class to be AgentDiscoveriesApplication and you'll be able to use IntelliJ to run your project.

Alternatively, you can serve the frontend using a development server:

Frontend Development Server

To speed up front end development, there is a dev server you can run instead.

NB: You will still need to have the backend server running on port 8080!

To use this from the command line, run mvn clean package -Ddev

To use this from IntelliJ, set up a Maven build configuration with the working directory set to the AgentDiscoveries-Frontend project and the command Line option to clean package -Ddev.

This will set up a server at http://localhost:8081 (Note the difference!). The browser will automatically reload whenever you change any javascript or SASS.

Tests

Both the backend and frontend tests can be run with mvn test in the root directory.

Frontend Tests

These can be found in AgentDiscoveries-Frontend/app/test

To run the frontend unit tests in IntelliJ, follow the instructions for Mocha

From command line navigate to AgentDiscoveries-Frontend and then run npm test (or mvn test, but this may give less pretty output).

Backend Tests

These can be found in AgentDiscoveries-Backend/src/test/java

Unit Tests

These can be found in AgentDiscoveries-Backend/src/test/java/org/softwire/training/api/unit

N.B. Unit test files must have names ending with "Test.java"

To run in IntelliJ, right click on any test to run it individually, or the entire directory to 'Run tests in org.softwire.training.api.unit'.

Integration Tests

These can be found in AgentDiscoveries-Backend/src/test/java/org/softwire/training/api/integration

N.B. Integration test files must have names ending with "IT.java"

To run in IntelliJ:

  • Make sure the app is already running
  • Right click on any test to run it individually, or the entire directory to 'Run tests in org.softwire.training.api.integration'.

Changing WebDriverHelper.HEADLESS to false will cause a visible Chrome window to pop up, which is sometimes much easier to debug!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages