This is a rest service to match buyer interests with seller with the adequate quanities and energy sources, built with kotlin and spring boot using the TDD and BDD approach.
For running the application you need to have Java and Maven installed on your system:
Technologies:
To run and pass the tests.
mvn clean
mvn install
mvn test
There are several ways to run a Spring Boot application on your local machine.
One way is to execute the java -jar
command on the energy-marketplace-0.0.1-SNAPSHOT.jar
bundle in the target folder.
Alternatively you can use the Spring Boot Maven plugin like on the project directory :
mvn spring-boot:run
The easiest way to check the service functionalities is to use the Swagger UI:
http://localhost:8080/swagger-ui/index.html#/
This service works with the assumption that:
- its in a microservice environment where each service is built to deliver single business capability
- there are other sevices to manage customers information, verification of certificate, payments etc.
With this service:
- buyer can create new certificate interest"
- buyer can view all created certificate interests"
- seller can create new certificate"
- seller can view the list of all created certificates"
- seller can see all open buyer interest"
- seller can match interest with appropriate volume of certificates
http://localhost:8080/api/v1/certificates/interests
{
"buyerId": "2002",
"energySource": "SOLAR",
"quantity": 300
}
{
"id": 5,
"energySource": "SOLAR",
"quantity": 300,
"buyerId": "2002",
"sellerId": "",
"status": "OPEN"
}
http://localhost:8080/api/v1/certificates/interests/buyer/2002
[
{
"id": 5,
"energySource": "SOLAR",
"quantity": 300,
"buyerId": "2002",
"sellerId": "",
"status": "OPEN"
}
]
http://localhost:8080/api/v1/certificates/
{
"energySource": "WATER",
"issueDate": "2021-10-17",
"issuer": "First Dutch Energy",
"ownerId": "1001",
"quantity": 300
}
{
"id": 4,
"ownerId": "1001",
"energySource": "WATER",
"quantity": 300,
"issuer": "First Dutch Energy",
"issueDate": "2021-10-17"
}
http://localhost:8080/api/v1/certificates/owner/1001
[
{
"id": 3,
"ownerId": "1001",
"energySource": "WIND",
"quantity": 200,
"issuer": "First Dutch Energy",
"issueDate": "2021-10-17"
},
{
"id": 4,
"ownerId": "1001",
"energySource": "WATER",
"quantity": 300,
"issuer": "First Dutch Energy",
"issueDate": "2021-10-17"
}
]
http://localhost:8080/api/v1/certificates/interests
[
{
"id": 5,
"energySource": "SOLAR",
"quantity": 300,
"buyerId": "2002",
"sellerId": "",
"status": "OPEN"
}
]
6. Sample Request and Response for seller to match certifcates(IDs of certificate(s)) with open interest
http://localhost:8080/api/v1/certificates/
{
"certificateIds": [
1,2
],
"interestId": 5,
"sellerId": "1001"
}
{
"id": 5,
"energySource": "SOLAR",
"quantity": 300,
"buyerId": "2002",
"sellerId": "1001",
"status": "CLOSED"
}
- The service runs on port 8080"
- To change the port go to the application folder in the src/main/resource/ and change the port as desired
server.port = 8080