Difficulties related to traffic congestion are very common in large cities such as Porto and Lisbon.
A useful approach to solve these issues is to offer all drivers in this city an application that provides information related to the roads congestion. BestPath allows drivers to choose other routes and more efficiently calculate the time of arrival at a destination.
Using GPS coordinates from buses that move in Porto, it's possible to calculate de average velocity. We can then infer whether or not there is traffic.
- Java 8+
- SpringBoot 2.2.6
- Maven 3+
- Intellij (Opcional)
To execute the application just run:
mvn clean compile spring-boot:run
-
Create SpringBoot project (Spring Assistant): 1.1 Group Id - ua.deti.bestpath 1.2 Artifact Id - bestpath 1.3 Version - 0.0.1 1.4 Project name - bestpath 1.5 Package name - ua.deti.bestpath
-
Implement the tests (Cucumber and Gherkin)
- Add the follow dependency to pom.xml
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>2.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>2.3.1</version>
<scope>test</scope>
</dependency>
-
Install the plugin
cucumber-java
-
On Run > Edit Configurations… open up the defaults list and select
Cucumber Java
-
For the default settings:
4.1 Main class - cucumber.api.cli.Main 4.2 Glue - stepdefs 4.3 Use classpath of module - bestpath
-
Right click on the first line of the feature (bestpath.feature) and select Run
Feature: bestpath
-
Create a new package named stepdefs in src/test/java
-
Notice how the package for our step definitions is the same name as the package we set in the Glue setting for the run configuration. This is so that the run configuration knows where to look for the step definitions when a feature file is run. Inside our package, we create a new class called DemoDefinitions and copy the step definitions from the previous run's output.
-
Running via Maven: we want to ensure that our Cucumber scenarios can be run as part of a Maven build process. Create a new class inside src/test/java named RunCucumberTest (you can see the code on this repository).
-
For each feature select the file (*.feature) that you want to run.
Some example to test the BestPath API:
Method | Description | URL |
---|---|---|
directions | Gives directions from 0 to 1 | http://localhost:8080/api/directions?lat0=8.681495&lon0=49.41461&lat1=8.687872&lon1=49.420318 |
geocode | Converts address to lat/lon | http://localhost:8080/api/geocode?text=Aveiro |
reverse | Convert lat/lon to address | http://localhost:8080/api/reverse?lat=40.635013&lon=-8.651136 |
speedlimit | Returns the speed limit in a location | http://localhost:8080/api/speedlimit?lat=40.635013&lon=-8.651136 |
avgspeed | Return the average speed in a location | http://localhost:8080/api/avgspeed?lat=40.635013&lon=-8.651136 |
- VM: 192.168.160.103
- Dashboard 192.168.160.87:9090
Note: UA VPN
- Each of the files with features should have only one feature.
- Catarina Silva - catarinaacsilva
This project is licensed under the MIT License - see the LICENSE file for details