Skip to content

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 RoomTest class 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, @Column with proper mappings
  • ReservationEntity: Added @Entity, @Table, @Id, @Column, @OneToOne, @JoinColumn with correct column names

3. Reservation Cancellation Feature

  • Added cancelReservation() method to Room domain class with validation
  • Implemented cancelReservation(Long) in ReservationService
  • Added DELETE /api/reservations/{id} endpoint in ReservationController
  • 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

Merge request reports

Loading