📍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:
va1m
2021-03-13 13:19:21 +01:00
committed by GitHub
parent 0e26a6adb5
commit 5cf2fe009b
681 changed files with 2472 additions and 4966 deletions
@@ -23,6 +23,18 @@
package com.iluwatar.transactionscript;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.h2.jdbcx.JdbcDataSource;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
@@ -31,15 +43,6 @@ import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.mockito.Mockito.*;
/**
* Tests {@link HotelDaoImpl}.
*/
@@ -90,7 +93,7 @@ public class HotelDaoImplTest {
public class NonExistingRoom {
@Test
public void addingShouldResultInSuccess() throws Exception {
void addingShouldResultInSuccess() throws Exception {
try (var allRooms = dao.getAll()) {
assumeTrue(allRooms.count() == 1);
}
@@ -104,7 +107,7 @@ public class HotelDaoImplTest {
}
@Test
public void deletionShouldBeFailureAndNotAffectExistingRooms() throws Exception {
void deletionShouldBeFailureAndNotAffectExistingRooms() throws Exception {
final var nonExistingRoom = new Room(2, "Double", 80, false);
var result = dao.delete(nonExistingRoom);
@@ -113,7 +116,7 @@ public class HotelDaoImplTest {
}
@Test
public void updationShouldBeFailureAndNotAffectExistingRooms() throws Exception {
void updationShouldBeFailureAndNotAffectExistingRooms() throws Exception {
final var nonExistingId = getNonExistingRoomId();
final var newRoomType = "Double";
final var newPrice = 80;
@@ -125,7 +128,7 @@ public class HotelDaoImplTest {
}
@Test
public void retrieveShouldReturnNoRoom() throws Exception {
void retrieveShouldReturnNoRoom() throws Exception {
assertFalse(dao.getById(getNonExistingRoomId()).isPresent());
}
}
@@ -138,7 +141,7 @@ public class HotelDaoImplTest {
public class ExistingRoom {
@Test
public void addingShouldResultInFailureAndNotAffectExistingRooms() throws Exception {
void addingShouldResultInFailureAndNotAffectExistingRooms() throws Exception {
var existingRoom = new Room(1, "Single", 50, false);
var result = dao.add(existingRoom);
@@ -148,7 +151,7 @@ public class HotelDaoImplTest {
}
@Test
public void deletionShouldBeSuccessAndRoomShouldBeNonAccessible() throws Exception {
void deletionShouldBeSuccessAndRoomShouldBeNonAccessible() throws Exception {
var result = dao.delete(existingRoom);
Assertions.assertTrue(result);
@@ -157,7 +160,7 @@ public class HotelDaoImplTest {
}
@Test
public void updationShouldBeSuccessAndAccessingTheSameRoomShouldReturnUpdatedInformation() throws
void updationShouldBeSuccessAndAccessingTheSameRoomShouldReturnUpdatedInformation() throws
Exception {
final var newRoomType = "Double";
final var newPrice = 80;
@@ -204,21 +207,21 @@ public class HotelDaoImplTest {
}
@Test
public void addingARoomFailsWithExceptionAsFeedbackToClient() {
void addingARoomFailsWithExceptionAsFeedbackToClient() {
assertThrows(Exception.class, () -> {
dao.add(new Room(2, "Double", 80, false));
});
}
@Test
public void deletingARoomFailsWithExceptionAsFeedbackToTheClient() {
void deletingARoomFailsWithExceptionAsFeedbackToTheClient() {
assertThrows(Exception.class, () -> {
dao.delete(existingRoom);
});
}
@Test
public void updatingARoomFailsWithFeedbackToTheClient() {
void updatingARoomFailsWithFeedbackToTheClient() {
final var newRoomType = "Double";
final var newPrice = 80;
final var newBookingStatus = false;
@@ -228,14 +231,14 @@ public class HotelDaoImplTest {
}
@Test
public void retrievingARoomByIdFailsWithExceptionAsFeedbackToClient() {
void retrievingARoomByIdFailsWithExceptionAsFeedbackToClient() {
assertThrows(Exception.class, () -> {
dao.getById(existingRoom.getId());
});
}
@Test
public void retrievingAllRoomsFailsWithExceptionAsFeedbackToClient() {
void retrievingAllRoomsFailsWithExceptionAsFeedbackToClient() {
assertThrows(Exception.class, () -> {
dao.getAll();
});