mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-17 04:59:21 +00:00
📍Use lombok, reformat, and optimize the code (#1560)
* Use lombok, reformat, and optimize the code * Fix merge conflicts and some sonar issues Co-authored-by: va1m <va1m@email.com>
This commit is contained in:
@@ -23,19 +23,20 @@
|
||||
|
||||
package com.iluwatar.transactionscript;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
import javax.sql.DataSource;
|
||||
import org.h2.jdbcx.JdbcDataSource;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* Tests {@link Hotel}
|
||||
*/
|
||||
public class HotelTest {
|
||||
class HotelTest {
|
||||
|
||||
private static final String H2_DB_URL = "jdbc:h2:~/test";
|
||||
|
||||
@@ -54,20 +55,20 @@ public class HotelTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bookingRoomShouldChangeBookedStatusToTrue() throws Exception {
|
||||
void bookingRoomShouldChangeBookedStatusToTrue() throws Exception {
|
||||
hotel.bookRoom(1);
|
||||
assertTrue(dao.getById(1).get().isBooked());
|
||||
}
|
||||
|
||||
@Test()
|
||||
public void bookingRoomWithInvalidIdShouldRaiseException() {
|
||||
void bookingRoomWithInvalidIdShouldRaiseException() {
|
||||
assertThrows(Exception.class, () -> {
|
||||
hotel.bookRoom(getNonExistingRoomId());
|
||||
});
|
||||
}
|
||||
|
||||
@Test()
|
||||
public void bookingRoomAgainShouldRaiseException() {
|
||||
void bookingRoomAgainShouldRaiseException() {
|
||||
assertThrows(Exception.class, () -> {
|
||||
hotel.bookRoom(1);
|
||||
hotel.bookRoom(1);
|
||||
@@ -75,12 +76,12 @@ public class HotelTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void NotBookingRoomShouldNotChangeBookedStatus() throws Exception {
|
||||
void NotBookingRoomShouldNotChangeBookedStatus() throws Exception {
|
||||
assertFalse(dao.getById(1).get().isBooked());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cancelRoomBookingShouldChangeBookedStatus() throws Exception {
|
||||
void cancelRoomBookingShouldChangeBookedStatus() throws Exception {
|
||||
hotel.bookRoom(1);
|
||||
assertTrue(dao.getById(1).get().isBooked());
|
||||
hotel.cancelRoomBooking(1);
|
||||
@@ -88,14 +89,14 @@ public class HotelTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cancelRoomBookingWithInvalidIdShouldRaiseException() {
|
||||
void cancelRoomBookingWithInvalidIdShouldRaiseException() {
|
||||
assertThrows(Exception.class, () -> {
|
||||
hotel.cancelRoomBooking(getNonExistingRoomId());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cancelRoomBookingForUnbookedRoomShouldRaiseException() {
|
||||
void cancelRoomBookingForUnbookedRoomShouldRaiseException() {
|
||||
assertThrows(Exception.class, () -> {
|
||||
hotel.cancelRoomBooking(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user