Ensure that Maven is installed before these commands can be run
Docker setup (without having to setup Maven on your host machine):
- Install Docker
- Clone repo & cd to repo root directory
- docker pull maven:latest
Option 1: (Mac - zsh)
docker run -it -v $(pwd):/{root-dir-folder-name} --name {container-name} -p 8080:8080 maven:latest bash
- Run maven image while mounting repo on host machine to Docker container and exposing port
Option 2: (Windows - Powershell)
docker run -it -v ${pwd}:/app --name {container-name} -p 8080:8080 maven:latest bash
- Run maven image while mounting repo on host machine to Docker container and exposing port
- (Optional) if exited container, start back up: docker start {container-name} -i
- Build: To build the app run
mvn install
- Run: To run the app run
mvn spring-boot:run
- Test (locally - requires MySQL configured with database set up): After running the app, we can access our app through the endpoints at localhost:{exposed-port} (localhost:8080) and appending any route specified in documentation (i.e. localhost:8080/events).
src/main/resources/application.properties
database properties are required to run the app successfully connecting to the database. Make sure to replace placeholder values.
- Run Tests: After building the app, run
mvn test
to execute all tests in the package
- All calls need to include a valid JWT (Bearer Token), which can be obtained from
/user/login
route, in the authorization headers GET /events
: Gets a list of events- Specify request parameters to filter returned events
id
(integer)address
(string)
- Sample Request:
- localhost:8080/events
- localhost:8080/events/1
- localhost:8080/events/byaddress/Columbia
- Specify request parameters to filter returned events
POST /events
: Creates an event with the specified event fields- Must specify request body
- Sample Request Body:
{ "address": "test address", "ageLimit": 21, "name": "test event", "description": "this is just a test event", "longitude": 10.0, "latitude": 20.0, "cost": 0.0, "media": "www.example.com", "startTimestamp": "2022-10-24T20:12:00.00+0000", "endTimestamp": "2022-10-25T20:12:00.00+0000" }
PUT /events
: Updates an existing event given the event request body- Sample Request: localhost:8080/events
- Must specify request body and a existing event ID in the body
- Sample Request Body:
{ "id": 1, "address": "test address update" }
DELETE /events
: Deletes an event given an existing event ID- Sample Request: localhost:8080/events/1
GET /filterEvents
: Gets filtered list of events given event fields and values that the user wants to filter on- Sample Request: localhost:8080/filterEvents?address=Columbia&name=Midterm
GET /events/statistics
: Gets event statistics data- Sample Request: localhost:8080/events/statistics
POST /user/register
: Registers a new user- Sample Request: localhost:8080/user/register
- Must specify request body
- Sample Request Body:
{ "firstName": "foo", "lastName": "bar", "age": 50, "username": "foobar", "password": "12345", "email": "[email protected]" }
POST /user/login
: login as the specified user- Returns JWT upon successful login which is then to be used as an authorization mechanism in any other non
/user/**
subsequent API calls (in order to be a valid request) - Sample Request: localhost:8080/user/login
- Sample Request Body:
{ "username": "foobar", "password": "12345" }
- Returns JWT upon successful login which is then to be used as an authorization mechanism in any other non
POST /populateEvents
: Populate database with events using Ticketmaster API- Sample Request: localhost:8080/populateEvents
- This is an entrypoint only available to service admin. Therefore, users will not be exposed to this entrypoint.
Our current Integration/E2E test strategy is automated and done manually.
Automated integration tests (in our **/*Integration*.java
test files) are done collectively along with unit tests every time our GitHub Actions workflow is run. Our test reports are automatically generated and highlight those results (view reports section for more detail).
Manual Integration/E2E tests are also done to simulate another layer of the testing environment with a separate test database and an opportunity for a human/engineer test oracle to verify correct output. The testing flow documentation is discussed in detail below.
We have also pre-populated some data in the database before the tests. Such as the following:
The following is a sample testing flow we have used to do integration and E2E tests (all being done using Postman):
We send POST /user/register
request, along with required request body (described in the above User Route Documentation section), to the service. Then we check the database to see whether the newly created user is added to the User table.
We send POST /user/login
request, along with the username and password we set in the previous step in the request body. Then, we will obtain a Json Web Token (JWT) as part of the response. We will denote such token as <JWT>
.
We send POST /events
request, along with an event following the format described in the Event Route Documentation section in the request body and adding <JWT>
in the authorization header. Then we check the database to see whether the newly created event is added in the Event table.
We send GET /events
request, along with <JWT>
in the authorization header. Then we check if the response contains all the events from the Event table, including the event we created in Step 3.
We send PUT /events
request, along with <JWT>
in the authorization header, and a request body containing the id of the event we created in Step 3 and one or multiple updated event attributes, following the format described in the Event Route Documentation section. Then we use GET /events/{id}
to check if the corresponding event is updated.
We send GET /events/filterEvents?<attribute1>=<value1>&<attribute2>=<value2>...
, along with <JWT>
in the authorization header. Then we check if the response contains events fit such filter.
We send GET /events/statistics
, along with <JWT>
in the authorization header. Then we check if the response contains event statistics.
We send DELETE /events/{id}
, along with <JWT>
in the authorization header. Then we send GET /events/{id}
to see if the response is an empty array.
Please note that the above sample flow is a "Golden Path" of the service. We have also tested with ill-formatted request bodies, missing JWT, non-existant events, filters that filter out all events, etc.
- All recent reports documents are now automated (through our GitHub Actions workflow) and published in the
service/reports/site
directory with every pull request merge into afeature/**
branch.- All recent report images published on this README are all up-to-date as a result of our automated GitHub Actions workflow that takes screenshots of reports after they are generated.
- Feature branches (
feature/**
) will get these report updates after a PR merge (which triggers the report publishing job in our Workflow) and subsequentlymain
will after the feature is merged into main.
- Directions:
- In app root directory:
mvn site
- Locate Checkstyle report in
target/site/checkstyle.html
- In app root directory:
- Most recent Checkstyle run:
- Directions:
- In app root directory:
mvn clean test
- Locate Checkstyle report in
target/site/jacoco/index.html
- In app root directory:
- Most recent Jacoco coverage run:
- Directions:
- In
service/
directory:mvn site
- Locate SpotBugs report in
target/site/spotbugs.html
- In
- Most recent SpotBugs coverage run:
- Any push and pull request triggers a Github Actions workflow run where each log can be located here
- Directions to run client:
- (Option 1) Start server locally (includes having local MySql Database setup with all tables and application.properties setup)
- (Option 2) Updating API calls in client (residing in
client/src/actions
) to point to production domain URL (EC2 instance) - In
client/
directory, runnpm install
- In
client/
directory, runnpm start
- Directions to build client:
- In
client/
directory, runnpm build
- In
- For user authentication we implemented authorization using JWT (JSON Web Token) tokens. The JWT architecture in our service application is built off of Spring Security following the guide: https://www.bezkoder.com/spring-boot-jwt-authentication/.
- A lot of the classes are extensions of the framework which make it either difficult to test or already tested by the 3PI. For this reason, some of the
security/**
files are excluded from Jacoco test coverage.