Exam Coversheet
To be completed by the student:
Student number:
_________________________________________________
Name:
*2412mm132A*
_________________________________________________
Group/Class:
_________________________________________________
To be completed by the lecturer
Exam Name Java Fundamentals
Exam Code 1915IN248Z
Exam Date 12-06-2025
Time 12:00
Classroom Multiple (see timetables)
Length (in minutes) 120
Academic Year 2024-2025
Education Period 2.4
Opportunity/Chance 1
Examiners Mark de Haan
Wim-Jan Hilgenbos
Faculty Engineering, Design and Computing
Cluster ICT
Programme + full time/part time Information Technology fulltime
Location Haarlem
Number of pages (incl. coversheet) 5
Number of questions 6
Passmark 55
Allowed tools/aids Computer, Eclipse/IntelliJ/Internet, Pen and Paper
Answer sheet
Additional comments/details Online communication means not allowed
(* delete if not applicable)
In te vullen door de toetsorganisatie:
Surveillanten:
Bijzondere voorzieningen:
Voorziening: Aantal: Opmerking:
Dyslexie
A3
Overig
Exam Java Advanced
A Book Review API
Introduction
For this exam, you will have to develop an application using Spring Boot. Your task is to create a
simplified book review API using Java Spring Boot.
The exam has been divided into parts with parts with assignments. Individual assignments can be
skipped or made in a different order than given, if the student wishes to do so. We strongly advise
reading through the exam before starting the assignments.
Requirements
The code you submit needs to meet the following requirements:
1. The code adheres strictly to specifications in the assignments
2. Coding standards apply:
a. Java Naming Conventions
b. Each statement is on a separate line
c. No more than 30 lines to a method
d. Use comments to explain the what and why of your code, but keep it brief
e. Use proper formatting (use your IDE to do so)
f. Use packages to logically group your classes.
3. Write your own code. Copying and pasting from others is not allowed
4. The usage of AI tools (ChatGPT, Github Copilot) is allowed
5. The application must start up without errors to receive a grade.
Grading
The assignments are graded according to the following specification:
Assignment Max. points
1 10
2 30
3 20
4 20
5 20
6 0
Total 100
Part 1: Setup and Data Persistence
1. Set up a new Spring Boot project with:
• Project type: Maven
• Language: Java
• Spring Boot version: 3.5.0
• Group name: nl.inholland.exam
• Artifact/name: your first name (no spaces, use only lowercase letters a-z)
• Packaging: Jar
• Java version: 21
• Dependencies: Spring Boot DevTools, Spring Web, Spring Data JPA, H2 database
• Optional dependency: Lombok
Create the following entity classes with appropriate annotations:
Book
• long id (auto generated)
• String title
• String author
• Genre genre
• List<Review> reviews
Review
• long id (auto generated)
• String reviewer
• String comment
• int rating
• Book book
Implement Genre as an enum with the possible values FANTASY, HISTORY,
SCIENCE_FICTION, NONFICTION and ROMANCE
Ensure relationships are mapped correctly.
You are allowed to use Lombok to generate getters, setters and constructors for these model
classes.
Part 2: REST API design and implementation
1. Provide the specified operations below using RESTful best practices via controllers and
services. The functionalities should be available under /books and /reviews using the
appropriate HTTP methods. The required functionalities are:
• Get all books (including reviews)
• Create a book (with title, author and genre)
• Create a review (with book id, reviewer, comment and rating
Ensure the review rating is bounded (between 1 and 5). How you implement this is up to you.
Test your endpoints using a REST API testing tool, such as Insomnia or Postman to ensure the
API behaves according to the requirements.
Part 3: Service logic and unit testing
1. Implement business logic in the method of the service layer where reviews are created, to
ensure a reviewer does not review the same book twice. If a review with the same reviewer
already exists for the book, the service method should throw an IllegalStateException.
2. Also ensure that a review is at least 20 characters long. Otherwise, throw an
IllegalArgumentException.
3. Create unit tests for this method using JUnit and Mockito. The repository functionality should
be mocked. Test the successful creation of the review and the throwing of the correct
exceptions, in three separate unit test methods.
Part 4: Stream API
1. Add an endpoint to /books/{id}/summary that returns a BookSummaryDTO for the book with
the specified id. The DTO should contain the following fields:
• long bookId
• String title
• double averageRating
• long ratingCount
In the BookService, use the Stream API to calculate the average rating. If there are no
reviews, return 0.0.
Part 5: Security
1. Create a request filter that blocks all request not containing this HTTP header:
Authorization: Bearer LIBRARY-ACCESS
Any request that does not contain this header with the specified value, should receive a HTTP
403 response.
Part 6: Assignment completion
1. Create a zip archive from the root of the project, and make sure that it the file only contains:
• /src folder and all contents
• pom.xml
If you’ve written any data seeding code for testing purposes, make sure to remove or disable it
before handing in your code.
The name of your zip archive is the same as your artifactId suffixed with “.zip”, e.g. john.zip.
Uploading in a different kind of archive (.rar, .7z) will lead to a point deduction.
Do not add files like:
• /target folder and contents
• /.idea folder and contents
• /.mvn folder and content
• .iml files
• mvnw and mvnw.cmd
Upload your zip archive to Moodle. This completes the exam.