Kesha Williams shows the course project in action.
- [Instructor] And next we have Ticket. So Ticket is defined in Ticket.java. So this domain entity represents the actual bug or enhancement request for a given application. And lastly, we have Release. Release is defined in Release.java. This domain entity represents a deployment release that can contain tickets and applications. Next, TrackZilla has a service layer which defines a common set of application operations, so let's look at one of the services.
So navigate to the service folder and double click on ApplicationService. So within this ApplicationService, you'll notice the TrackZilla application uses the DAO to communicate with the database, so you see the auto-wiring here of the DAO on line 14. You will also see the implementation of the CRUD functions throughout this file, along with use of the helper function applicationExists here on line 18 when creating a new application.
Now let's see the TrackZilla application in action. So let's launch the application. And as the application comes up, we will see the output logging in the bottom window. All right, the application has started. So let's navigate to Postman. Since the application exposes RESTful web services, Postman is the tool of choice when it comes to testing the services. Postman is free, easy to use, and allows you to save your web service calls to a collection for later use.
And I've provided the TrackZilla web service calls as a collection in JSON format that you can easily import. The file is included with the exercise files. So notice here we have calls to create applications, create tickets, to search for tickets, to search for tickets with releases, et cetera. So this is how we're going to test our code. There are also embedded unit tests if you prefer to exercise the code in that manner. So let's navigate back to the IntelliJ IDE and scroll down to the test folder and double click on TrackzillaControllerTest.
So this is the test file that contains all of our unit tests. So there are methods to test adding an application. We see that on line 29. Finding an application on line 51. We also have code to update an application here on line 69. There's also code that tests deleting an application on line 89, and also adding a ticket, as we see on line 108. Now let's talk about the H2 in-memory database, so let's navigate to that console.
So bring up a web browser. In this case, I'm using Firefox. And you can simply navigate to localhost:8080/console, and all of this extra stuff on the end will be added for you. Okay, so TrackZilla has an H2 in-memory database. Now, in-memory means once the application stops running, the database is no longer present and accessible and any data stored in it is gone. So now we're looking at the console. You'll want to make sure that your JDBC URL matches what I have here.
So it's jdbc:h2:mem:bugtracker, and your user name will be sa, and there's no password. So at this point, you can click Connect, and notice our database tables. So we see our entities, application, release, ticket, and some additional join tables. Now let's go back to Postman to test out our services. So navigate to Postman. And let's say we want to add a new application to our database.
So click on this link, tza application. Let's look at the body. It's a very simple application. Let's click Send. And notice now we have a status of 201 Created, so we should be able to navigate back to our H2 in-memory database and select from applications by clicking on it and clicking Run, and there we see the new application that we just added. Now, during this course, you will enhance the TrackZilla application to use inheritance mapping strategies, JPQL, various query types, and the criteria API to retrieve data.
Let's get started.
- Inheriting entities
- Mapping a superclass
- Querying through JPA
- Defining query parameters
- Creating a compile-time named query
- Using native queries
- Creating stored procedures
- Using the Criteria API
- Refining query results
- Switching between persistence providers