Microservice created using springboot 3.2, generating the model and the controllers interfaces based on the OpenApi Spec using the OpenAPI generator plugin.
In addition to unit tests, automated tests were created for the APIs using the Karate platform.
ℹ️ Database scripts can be found in the folder resources
File | Description |
---|---|
schema.sql | SQL script to create the tables |
data.sql | SQL script to populate the tables |
EndPoint | Method | Description |
---|---|---|
/v1/customers/{id} | GET | Retrieve customer by id |
GET /v1/customers/1
200 - OK
{
"id": 1,
"firstName": "Aoife",
"lastName": "Murphy",
"birthday": "1980-12-13",
"addresses": [
{
"id": 1,
"street": "6 Bridge St.",
"eircode": "N36RP84",
"city": "Cork",
"county": "County Cork",
"country": "Ireland"
}
],
"emails": [
{
"id": 1,
"type": "WORK",
"email": "aoife.murphy@aib.ie"
},
{
"id": 2,
"type": "PERSONAL",
"email": "aoife.murphy@gmail.com"
}
],
"documents": [
{
"id": 1,
"type": "PPS",
"documentNumber": "48378IA"
},
{
"id": 2,
"type": "PASSPORT",
"documentNumber": "FA3891IU"
}
]
}
EndPoint | Method | Description |
---|---|---|
/v1/customers?pageNumber={pageNumber}&pageSize={pageSize}&firstName={firstName}&lastName={lastName} | GET | Retrieve customers list |
Parameter | Description | Example |
---|---|---|
pageNumber | Page number | 0 |
pageSize | Number of records per page | 10 |
firstName | First name | Aoife |
lastName | Last name | Murphy |
GET /v1/customers?pageSize=10&pageNumber=2&firstName=Aoife&lastName=Murphy
200 - OK
{
"totalElements": 4,
"totalPages": 1,
"size": 10,
"content": [
{
"id": 1,
"firstName": "Aoife",
"lastName": "Murphy",
"birthday": "1980-12-13"
},
{
"id": 2,
"firstName": "Kelly",
"lastName": "O’Brien",
"birthday": "1985-10-09"
},
{
"id": 3,
"firstName": "Ryan",
"lastName": "O’Sullivan",
"birthday": "1988-04-25"
},
{
"id": 4,
"firstName": "Duffy",
"lastName": "Connor",
"birthday": "1975-02-18"
}
],
"number": 0,
"sort": {
"empty": true,
"unsorted": true,
"sorted": false
},
"first": true,
"last": true,
"numberOfElements": 4,
"pageable": {
"offset": 0,
"sort": {
"empty": true,
"unsorted": true,
"sorted": false
},
"paged": true,
"unpaged": false,
"pageSize": 10,
"pageNumber": 0
},
"empty": false
}
EndPoint | Method | Description |
---|---|---|
/v1/customers | POST | Create a customer |
POST /v1/customers
{
"firstName": "Irwin",
"lastName": "Streich",
"birthday": "1977-09-23"
}
201 - Created
{
"id": 5,
"firstName": "Irwin",
"lastName": "Streich",
"birthday": "1977-09-23"
}
EndPoint | Method | Description |
---|---|---|
/v1/customers/{id} | PUT | Update a customer |
PUT /v1/customers/1
{
"firstName": "Irwin",
"lastName": "Streich",
"birthday": "1980-05-12"
}
200 - OK
EndPoint | Method | Description |
---|---|---|
/v1/customers/{id} | DELETE | Delete a customer |
DELETE /v1/customers/1
200 - OK
EndPoint | Method | Description |
---|---|---|
/v1/customers/{customerId}/addresses/{id} | GET | Retrieve address by id |
GET /v1/customers/1/addresses/1
200 - OK
{
"id": 1,
"street": "6 Bridge St.",
"eircode": "N36RP84",
"city": "Cork",
"county": "County Cork",
"country": "Ireland"
}
EndPoint | Method | Description |
---|---|---|
/v1/customers/{customerId}/addresses?pageNumber={pageNumber}&pageSize={pageSize}&street={street}&city={city}&county={county}&country={country}&eircode={eircode} | GET | Retrieve addresses list by customer id |
Parameter | Description | Example |
---|---|---|
pageNumber | Page number | 0 |
pageSize | Number of records per page | 10 |
street | Street | 6 Bridge St. |
city | City | Cork |
county | County | County Cork |
country | Country | Ireland |
eircode | Eircode | N36RP84 |
GET /v1/customers/1/addresses?pageSize=10&pageNumber=2&street=Bridge&city=Cork&country=Ireland&eircode=N36RP84
200 - OK
{
"totalElements": 1,
"totalPages": 1,
"size": 10,
"content": [
{
"id": 1,
"street": "6 Bridge St.",
"eircode": "N36RP84",
"city": "Cork",
"county": "County Cork",
"country": "Ireland"
}
],
"number": 0,
"sort": {
"empty": true,
"unsorted": true,
"sorted": false
},
"first": true,
"last": true,
"numberOfElements": 1,
"pageable": {
"offset": 0,
"sort": {
"empty": true,
"unsorted": true,
"sorted": false
},
"paged": true,
"unpaged": false,
"pageSize": 10,
"pageNumber": 0
},
"empty": false
}
EndPoint | Method | Description |
---|---|---|
/v1/customers/{customerId}/addresses | POST | Create an address by customer id |
POST /v1/customers/1/addresses
{
"street": "Hammes Highway",
"complement": "103",
"eircode": "N21RP11",
"city": "Mosciskifort",
"county": "Roscommon",
"country": "Ireland"
}
201 - Created
{
"id": 5,
"street": "Hammes Highway",
"complement": "103",
"eircode": "N21RP11",
"city": "Mosciskifort",
"county": "Roscommon",
"country": "Ireland"
}
EndPoint | Method | Description |
---|---|---|
/v1/customers/{customerId}/addresses/{id} | PUT | Update a address |
PUT /v1/customers/1/addresses/1
{
"street": "Hammes Highway",
"complement": "105",
"eircode": "N21RP11",
"city": "Dublin",
"county": "Co. Dublin",
"country": "Ireland"
}
200 - OK
EndPoint | Method | Description |
---|---|---|
/v1/customers/{customerId}/addresses/{id} | DELETE | Delete an address |
DELETE /v1/customers/1/addresses/1
200 - OK
EndPoint | Method | Description |
---|---|---|
/v1/customers/{customerId}/emails/{id} | GET | Retrieve email by id |
GET /v1/customers/1/emails/1
200 - OK
{
"id": 1,
"type": "WORK",
"email": "aoife.murphy@aib.ie"
}
EndPoint | Method | Description |
---|---|---|
/v1/customers/{customerId}/emails?pageNumber={pageNumber}&pageSize={pageSize}&email={email}&type={type} | GET | Retrieve emails list by customer id |
Parameter | Description | Example |
---|---|---|
pageNumber | Page number | 0 |
pageSize | Number of records per page | 10 |
aoife.murphy@aib.ie | ||
type | Type of the email | WORK |
GET /v1/customers/1/emails?pageSize=10&pageNumber=2&email=aoife.murphy&type=WORK
200 - OK
{
"totalElements": 2,
"totalPages": 1,
"size": 10,
"content": [
{
"id": 1,
"type": "WORK",
"email": "aoife.murphy@aib.ie"
},
{
"id": 2,
"type": "PERSONAL",
"email": "aoife.murphy@gmail.com"
}
],
"number": 0,
"sort": {
"empty": true,
"unsorted": true,
"sorted": false
},
"first": true,
"last": true,
"numberOfElements": 2,
"pageable": {
"offset": 0,
"sort": {
"empty": true,
"unsorted": true,
"sorted": false
},
"paged": true,
"unpaged": false,
"pageSize": 10,
"pageNumber": 0
},
"empty": false
}
EndPoint | Method | Description |
---|---|---|
/v1/customers/{customerId}/emails | POST | Create an email by customer id |
POST /v1/customers/1/emails
{
"type": "WORK",
"email": "aoife.murphy@guiness.ie"
}
201 - Created
{
"id": 10,
"type": "WORK",
"email": "aoife.murphy@guiness.ie"
}
EndPoint | Method | Description |
---|---|---|
/v1/customers/{customerId}/emails/{id} | PUT | Update an email |
PUT /v1/customers/1/emails/1
{
"type": "PERSONAL",
"email": "aoife.murphy@hotmail.com"
}
200 - OK
EndPoint | Method | Description |
---|---|---|
/v1/customers/{customerId}/emails/{id} | DELETE | Delete an email |
DELETE /v1/customers/1/emails/1
200 - OK
EndPoint | Method | Description |
---|---|---|
/v1/customers/{customerId}/documents/{id} | GET | Retrieve document by id |
GET /v1/customers/1/documents/1
200 - OK
{
"id": 1,
"type": "PASSPORT",
"documentNumber": "FU129837"
}
EndPoint | Method | Description |
---|---|---|
/v1/customers/{customerId}/documents?pageNumber={pageNumber}&pageSize={pageSize}&documentNumber={documentNumber}&type={type} | GET | Retrieve documents list by customer id |
Parameter | Description | Example |
---|---|---|
pageNumber | Page number | 0 |
pageSize | Number of records per page | 10 |
documentNumber | Document number | FU198329 |
type | Type of the document | PASSPORT |
GET /v1/customers/1/documents?pageSize=10&pageNumber=2&documentNumber=FU198829&type=PASSPORT
200 - OK
{
"totalElements": 2,
"totalPages": 1,
"size": 10,
"content": [
{
"id": 1,
"type": "PASSPORT",
"documentNumber": "FU193891"
},
{
"id": 2,
"type": "DRIVER_LICENSE",
"documentNumber": "5675487548GH"
}
],
"number": 0,
"sort": {
"empty": true,
"unsorted": true,
"sorted": false
},
"first": true,
"last": true,
"numberOfElements": 2,
"pageable": {
"offset": 0,
"sort": {
"empty": true,
"unsorted": true,
"sorted": false
},
"paged": true,
"unpaged": false,
"pageSize": 10,
"pageNumber": 0
},
"empty": false
}
EndPoint | Method | Description |
---|---|---|
/v1/customers/{customerId}/documents | POST | Create a document by customer id |
POST /v1/customers/1/documents
{
"type": "PPS",
"email": "46751M"
}
201 - Created
{
"id": 10,
"type": "PPS",
"email": "46751M"
}
EndPoint | Method | Description |
---|---|---|
/v1/customers/{customerId}/documents/{id} | PUT | Update a document |
PUT /v1/customers/1/documents/1
{
"type": "PASSPORT",
"email": "FU4673761"
}
200 - OK
EndPoint | Method | Description |
---|---|---|
/v1/customers/{customerId}/documents/{id} | DELETE | Delete a document |
DELETE /v1/customers/1/documents/1
200 - OK
Execute the unit tests using the command bellow:
mvn test
Execute the karate tests using the command bellow:
mvn test -Dkarate.env=local -Dtest=br.com.customer.karate.KarateTestRunner
Results can be found in the target/karate-reports folder
For the documentation of the APIs, access the link http://localhost:9081/swagger-ui/index.html
ℹ️ Postman collection can be found in the folder postman
mvn clean install
Run the command below to run the application.
java -jar -Dspring.profiles.active=[PROFILE] customer-service.jar
to build
docker build -f Dockerfile -t customer-service:1.0.0 .
to run as a container
docker run -d -p 9081:9081 --env PROFILE=local -i -t customer-service:1.0.0
9081
- Spring Boot 3.2
- Java 17
- MySQL 8
- Docker Compose
- Karate tests
- OpenApi Generator
Apache License v2.0