0% found this document useful (0 votes)
14 views14 pages

Use Case Diagrams for Ticket Booking System

To generate a unit testing for online ticket booking system

Uploaded by

Vish P
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views14 pages

Use Case Diagrams for Ticket Booking System

To generate a unit testing for online ticket booking system

Uploaded by

Vish P
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

7.

Use Case Diagrams

 Use Case Diagram for User:


o Register
o Login
o View Events
o Select Event
o Select Seats
o Make Payment
o Receive Confirmation
o Manage Bookings
 Use Case Diagram for Admin:
o Login
o Manage Users
o Manage Events
o View Reports
 Use Case Diagram for Event Organizer:
o Login
o List Event
o Update Event
o Delete Event
o View Bookings

8. Detailed Use Case Descriptions

 Use Case: User Registration


o Actor: User
o Description: User registers by providing email and password.
o Preconditions: User is not logged in.
o Postconditions: User account is created and can log in.
o Flow:
1. User navigates to the registration page.
2. User enters email and password.
3. System validates the input.
4. System creates a new user account.
5. System sends a confirmation email to the user.
 Use Case: Book Ticket
o Actor: User
o Description: User books a ticket for an event.
o Preconditions: User is logged in and event is available.
o Postconditions: Ticket is reserved and payment is processed.
o Flow:
1. User selects an event.
2. User views available seats and selects desired seats.
3. User proceeds to payment.
4. System processes the payment.
5. System sends a booking confirmation to the user.

9. Glossary

 Event: An occurrence such as a movie, concert, or travel schedule for which tickets can
be booked.
 Booking: The process of reserving a seat for an event.
 Payment Gateway: A service that processes credit card payments for online and offline
businesses.

10. Appendices

 Appendix A: Example UI Mockups


 Appendix B: Example Database Schema
 Appendix C: API Documentation for Payment Gateway Integration

This SRS document provides a detailed outline of the requirements for an Online Ticket Booking
System, ensuring that all stakeholders have a clear understanding of the system functionalities
and constraints.

TO GENERATE UNIT TESTING FOR THE ONLINE TICKET BOOKING SYSTEM


To generate unit testing for the Online Ticket Booking System, we'll use Java along with JUnit. Below are
some examples of unit tests for the main functionalities of the system, including user registration, event
management, ticket booking, and payment processing.

1. User Registration and Authentication

Program: [Link]

public class User {


private String email;
private String password;

// Constructor
public User(String email, String password) {
[Link] = email;
[Link] = password;
}
// Getters
public String getEmail() {
return email;
}

public String getPassword() {


return password;
}
}
Program: [Link]

import [Link];
import [Link];

public class UserService {


private Map<String, User> users = new HashMap<>();

public boolean registerUser(String email, String password) {


if (email == null || [Link]() || password == null || [Link]()) {
return false;
}
if ([Link](email)) {
return false;
}
[Link](email, new User(email, password));
return true;
}
public boolean authenticateUser(String email, String password) {
User user = [Link](email);
return user != null && [Link]().equals(password);
}
}
Test: [Link]

import [Link];
import [Link];
import static [Link].*;

public class UserServiceTest {


private UserService userService;

@Before
public void setUp() {
userService = new UserService();
}

@Test
public void testRegisterUser() {
assertTrue([Link]("test@[Link]", "password123"));
assertFalse([Link]("test@[Link]", "password123")); //
Duplicate registration
assertFalse([Link]("", "password123")); // Invalid email
assertFalse([Link]("test@[Link]", "")); // Invalid password
}
@Test
public void testAuthenticateUser() {
[Link]("test@[Link]", "password123");
assertTrue([Link]("test@[Link]", "password123"));
assertFalse([Link]("test@[Link]", "wrongpassword"));
assertFalse([Link]("unknown@[Link]", "password123"));
}
}
2. Event Management

Program: [Link]

public class Event {


private String title;
private String date;
private String location;
private int availableSeats;

// Constructor
public Event(String title, String date, String location, int availableSeats) {
[Link] = title;
[Link] = date;
[Link] = location;
[Link] = availableSeats;
}

// Getters and Setters


public String getTitle() {
return title;
}

public String getDate() {


return date;
}

public String getLocation() {


return location;
}

public int getAvailableSeats() {


return availableSeats;
}

public void setAvailableSeats(int availableSeats) {


[Link] = availableSeats;
}
}
Program: [Link]

import [Link];
import [Link];

public class EventService {


private Map<String, Event> events = new HashMap<>();

public boolean addEvent(String title, String date, String location, int availableSeats) {
if (title == null || [Link]() || date == null || [Link]() || location == null ||
[Link]() || availableSeats <= 0) {
return false;
}
[Link](title, new Event(title, date, location, availableSeats));
return true;
}

public Event getEvent(String title) {


return [Link](title);
}

public boolean updateEventSeats(String title, int seats) {


Event event = [Link](title);
if (event != null && seats >= 0) {
[Link](seats);
return true;
}
return false;
}
}
Test: [Link]

import [Link];
import [Link];
import static [Link].*;

public class EventServiceTest {


private EventService eventService;

@Before
public void setUp() {
eventService = new EventService();
}

@Test
public void testAddEvent() {
assertTrue([Link]("Concert", "2024-08-20", "Stadium", 100));
assertFalse([Link]("Concert", "2024-08-20", "Stadium", 100)); //
Duplicate event
assertFalse([Link]("", "2024-08-20", "Stadium", 100)); // Invalid title
assertFalse([Link]("Concert", "", "Stadium", 100)); // Invalid date
assertFalse([Link]("Concert", "2024-08-20", "", 100)); // Invalid location
assertFalse([Link]("Concert", "2024-08-20", "Stadium", -10)); // Invalid
seats
}

@Test
public void testGetEvent() {
[Link]("Concert", "2024-08-20", "Stadium", 100);
Event event = [Link]("Concert");
assertNotNull(event);
assertEquals("Concert", [Link]());
assertEquals("2024-08-20", [Link]());
assertEquals("Stadium", [Link]());
assertEquals(100, [Link]());
}

@Test
public void testUpdateEventSeats() {
[Link]("Concert", "2024-08-20", "Stadium", 100);
assertTrue([Link]("Concert", 90));
assertFalse([Link]("Concert", -10)); // Invalid seats
assertFalse([Link]("Unknown Event", 50)); // Non-existent
event
}
}
3. Ticket Booking and Seat Selection

Program: [Link]

public class Booking {


private String eventTitle;
private String userEmail;
private int seats;

// Constructor
public Booking(String eventTitle, String userEmail, int seats) {
[Link] = eventTitle;
[Link] = userEmail;
[Link] = seats;
}

// Getters
public String getEventTitle() {
return eventTitle;
}

public String getUserEmail() {


return userEmail;
}

public int getSeats() {


return seats;
}
}
Program: [Link]

import [Link];
import [Link];

public class BookingService {


private List<Booking> bookings = new ArrayList<>();
private EventService eventService;

public BookingService(EventService eventService) {


[Link] = eventService;
}

public boolean bookTicket(String eventTitle, String userEmail, int seats) {


Event event = [Link](eventTitle);
if (event != null && [Link]() >= seats && seats > 0) {
[Link](new Booking(eventTitle, userEmail, seats));
[Link](eventTitle, [Link]() - seats);
return true;
}
return false;
}

public List<Booking> getBookings() {


return bookings;
}
}
Test: [Link]

import [Link];
import [Link];
import static [Link].*;

public class BookingServiceTest {


private EventService eventService;
private BookingService bookingService;

@Before
public void setUp() {
eventService = new EventService();
bookingService = new BookingService(eventService);
[Link]("Concert", "2024-08-20", "Stadium", 100);
}

@Test
public void testBookTicket() {
assertTrue([Link]("Concert", "user@[Link]", 5));
assertFalse([Link]("Concert", "user@[Link]", 0)); // Invalid
seats
assertFalse([Link]("Concert", "user@[Link]", 200)); // Not
enough seats
assertFalse([Link]("Unknown Event", "user@[Link]", 5)); //
Non-existent event
}

@Test
public void testGetBookings() {
[Link]("Concert", "user1@[Link]", 5);
[Link]("Concert", "user2@[Link]", 10);
assertEquals(2, [Link]().size());
}
}
4. Payment Processing

For payment processing, we can mock the payment gateway interactions to test our code without
actually making real payments.

Program: [Link]

public class PaymentService {


public boolean processPayment(String userEmail, double amount) {
// Mock payment processing
if (userEmail == null || [Link]() || amount <= 0) {
return false;
}
// Assume payment is always successful for valid inputs
return true;
}
}
Test: [Link]

import [Link];
import [Link];
import static [Link].*;

public class PaymentServiceTest {


private PaymentService paymentService;

@Before
public void setUp() {
paymentService = new PaymentService();
}

@Test
public void testProcessPayment() {
assertTrue([Link]("user@[Link]", 100.00));
assertFalse([Link]("", 100.00)); // Invalid email
assertFalse([Link]("user@[Link]", -50.00)); // Invalid
amount
assertFalse([Link](null, 100.00)); // Null email
}
}
Running the Tests

To run the tests, you can use any IDE that supports JUnit (such as Eclipse or IntelliJ IDEA) or
run them using the command line with Maven or Gradle.
These unit tests ensure that each individual component of the Online Ticket Booking System
behaves as expected. As your system evolves, you can expand these tests or add more complex
integration tests.

Common questions

Powered by AI

The robustness of the EventService class against invalid data input relies on checking for null or empty strings and ensuring available seats are greater than zero when adding a new event. This prevents adding events with missing essential information or negative seats, but does not handle more complex validation such as date formatting or duplicate detection with detailed error information.

The glossary provides precise definitions for terms such as 'Event,' 'Booking,' and 'Payment Gateway,' clarifying their meanings within the system context. This helps ensure all stakeholders have a consistent and comprehensive understanding of the terms used throughout the document.

The BookingService checks feasibility by verifying the event's existence, ensuring enough available seats, and confirming seats requested are positive before proceeding with booking. If these conditions aren't met, the booking process halts.

The mechanism for handling duplicate events involves checking if an event with the same title, date, and location already exists during the addEvent method. If an event is detected as a duplicate, the method returns false, thereby preventing the addition.

Detailed use case descriptions contribute by clearly outlining actors, preconditions, postconditions, and the specific flow of each function, which guides developers in implementing features accurately and assures designers that user interactions are systematically thought through with all edge cases addressed.

The user registration use case ensures a valid account creation by first checking if the user is not already logged in, and then the user navigates to the registration page to enter an email and password. The system validates these inputs before creating a new user account, and a confirmation email is sent to the user.

Unit tests ensure correctness by testing scenarios such as successful registration, duplicate registration, and invalid input for registration. For authentication, they test correct login details, intentional incorrect passwords, and non-existent users, thus thoroughly evaluating both user registration and login logic against expected outcomes.

The PaymentService processes payments by assuming any non-null email and positive amount lead to successful transaction, which may not account for actual payment gateway failures, errors, security validation (e.g., card checks), or transaction rollback if there are issues post-booking. It's a basic mock integration without external API error handling.

The primary responsibilities of an admin in the online ticket booking system are logging in, managing users, managing events, and viewing reports.

The use case diagram for a user includes activities such as registering, logging in, viewing events, selecting events and seats, making payments, receiving confirmations, and managing bookings. In contrast, an event organizer's diagram involves logging in, listing, updating, deleting events, and viewing bookings, focusing more on event management than user interaction.

You might also like