Assignment 1
Lab 1: Hotel Reservation System - Implementation Complete
Summary
Completed Lab 1 requirements including unit tests, JPA annotations, and reservation cancellation feature for the hotel booking REST API.
Changes Made
1. Unit Testing
- Implemented test methods in
RoomTestclass using JUnit and AssertJ - Added tests for successful reservation, failed reservation, successful cancellation, and failed cancellation scenarios
- All domain logic properly tested
2. Missing Annotations Restored
-
ReservationController: Added
@RestController,@RequestMapping,@PostMapping,@DeleteMapping,@PathVariable -
RoomEntity: Added
@Entity,@Table,@Id,@Columnwith proper mappings -
ReservationEntity: Added
@Entity,@Table,@Id,@Column,@OneToOne,@JoinColumnwith correct column names
3. Reservation Cancellation Feature
- Added
cancelReservation()method toRoomdomain class with validation - Implemented
cancelReservation(Long)inReservationService - Added
DELETE /api/reservations/{id}endpoint inReservationController - Created unit and integration tests for cancellation functionality
- Room availability is properly restored after cancellation
API Endpoints
-
POST /api/reservations/reserve?roomNumber={number}&guestName={name}- Create reservation -
DELETE /api/reservations/{id}- Cancel reservation