The tests are currently using the live H2 database which is fine for now as we are only using it as a dummy database anyway. Once we connect to the real database, the H2 database will only be used for testing to avoid hitting the live database.
This kind of endpoints would normally be secured. However since we are still in the development phase, they are open to anyone, as is the H2 web interface.
This project uses Lombok to handle POJO boilerplate.
In order to compile from an IDE, you'll need to install the Lombok plugin otherwise you'll get errors in the MeterRead class. Details on how to do this are available here.
Add a Spring Boot run configuration with main class
uk.co.scottishpower.techtest.TechTestApplication
and run it. No extra configuraton needed.
A maven wrapper is bundled with the application so you don't need to have it installed.
You can of course use an existing maven installation, in which case you'd use mvn instead of ./mvnw in the below commands.
You need to have JAVA_HOME set in your environment and pointing to a Java JDK >= 1.8.
Go to the tech-test folder in your terminal and run:
./mvnw clean install
Run this command in the tech-test folder to bring up the application:
./mvnw spring-boot:run
The endpoint to retrieve a reading is available at:
I've also enabled Swagger to make it easy to understand and interact with the REST endpoints. This is available at:
In order to provide easy access to the data that is available, I've enabled the H2 web interface which is located at:
The default credentials have not been changed so all you need to do to access it is update the JDBC URL to
jdbc:h2:mem:testdb
and click Connect.
Once in there you can use
SELECT * FROM METER_READ
to view the meter readings. For convenience, I have loaded 100 meter readings generated using Mockaroo.
You can also use this to view the the table schema:
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'METER_READ'