We will need a new Java app to read in a CSV file from a directory. The contents will then need to be sent to a REST API endpoint, in JSON format, and saved to a SQL database.
- Create a console app to read in a CSV file from a directory.
- Parse the CSV file of which the contents are: - Customer Ref - Customer Name - Address Line 1 - Address Line 2 - Town - County - Country - Postcode
- Loop through the rows of the CSV file and send each row to a REST API POST endpoint, in JSON format.
- The REST API should then save the content to a database table. Format can match the CSV file.
- Create a REST API GET endpoint to retrieve the customer information, passing in a customer ref to filter the data. Contents should be returned in JSON format.
- Some documentation or Wiki to explain the approach taken.
Where possible, a Test-Driven Development (TDD) approach should be taken.
There are 2 applications required to fulfill the brief:
- Console app
- REST API
There will 2 other projects as part of the solution:
- Common - A project containing models that will be used in both applications.
- Tests - A project containing tests, testing various aspects of both applications.
This will read a local .csv file, parse it checking for required fields and format. The parsed data will then be uploaded row-by-row to the API.
This application will be developed using a Test-Driven approach using Specflow for Behaviour Driven Development in several stages.
- Load and parse the CSV
- Authenticate with the API using a Client ID and secret taken from config/environment.
- Iterate over each row of data uploading each row, one by one, to the REST API.
The REST API will have 3 endpoints and will use OpenAPI to self-document the API and assist future development.
- /auth - GET
- /customer - POST
- /customer/{customerRef} - GET
To use the customer API, will require that requests are authenticated using a bearer token obtained from the /auth endpoint.
For the purposes of this exercise, credentials will be taken from application configuration/environment variables rather than being stored on an application by application basis in a database or other data store.
Data types for the CSV fields are assumed to be strings with the excpetion of the customer ref field, which will use GUID/UUID to prevent easy enumeration of customer data.
All fields except Address Line 2 will be required
Customer data will not be normalised and addresses will be stored alongside their name and customer ref.
Unfortunately due to having to do this over a few evenings, around family life and other commitments, I was unable to fully realise a BDD approach and felt I had to "just get it done".