Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void setUp() {
}

@Test
public void testToSummaryMapping() {
public void toSummary_validReservation_shouldMapToSummaryDTO() {
ReservationResponseSummary summary = reservationMapper.toSummary(reservation);
assertNotNull(summary);
assertEquals(reservation.getId(), summary.id());
Expand All @@ -60,7 +60,7 @@ public void testToSummaryMapping() {
}

@Test
public void testToDetailMapping() {
public void toDetail_validReservation_shouldMapToDetailDTO() {
ReservationResponseDetail detail = reservationMapper.toDetail(reservation);
assertNotNull(detail);
assertEquals(reservation.getId(), detail.id());
Expand All @@ -73,7 +73,7 @@ public void testToDetailMapping() {
}

@Test
public void testToEntityMapping() {
public void toEntity_validRequest_shouldMapToReservationEntity() {
Reservation entity = reservationMapper.toEntity(reservationRequest, bookingStatus, new User(),new Accommodation(),false);
assertNotNull(entity);
assertEquals(reservationRequest.guestNumber(), entity.getGuestNumber());
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/SleepUp/SU/reservation/ReservationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class ReservationTest {
private UserRepository userRepository;

@Test
public void testFindByUserId() {
public void repository_findByUserId_shouldReturnNonEmptyReservationList() {
Long userId = 2L; // User2 as per your sample data

List<Reservation> reservations = reservationRepository.findByUser_Id(userId);
Expand All @@ -55,7 +55,7 @@ public void testFindByUserId() {
}

@Test
public void testFindByUserId_Service() {
public void service_getMyReservationsAllTime_shouldReturnNonEmptySummaryList() {
Long userId = 2L; // User2 as per your sample data

List<ReservationResponseSummary> reservations = reservationServiceImpl.getMyReservations(userId, ReservationTime.ALL);
Expand All @@ -67,7 +67,7 @@ public void testFindByUserId_Service() {
}

@Test
public void testController(){
public void controller_getMyReservationsAllTime_shouldReturnNonEmptySummaryList(){
User savedUser = userRepository.findByUsername("User2")
.orElseThrow(() -> new RuntimeException("TestUser not found"));
CustomUserDetails principal = new CustomUserDetails(savedUser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private Reservation createTestReservation() {
@Nested
class getAllReservationsToAdminReservationTest{
@Test
void getAllReservationsToAdmin_shouldReturnAllReservations() {
void getAllReservations_reservationsExist_shouldReturnSummaryList() {
Reservation reservation1 = new Reservation();
Reservation reservation2 = new Reservation();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void setup() {
}

@Test
public void testHealthUp() throws Exception {
public void health_connectionIsValid_shouldReturnStatusUp() throws Exception {
when(dataSource.getConnection()).thenReturn(connection);
when(connection.isValid(5)).thenReturn(true);

Expand All @@ -36,7 +36,7 @@ public void testHealthUp() throws Exception {
}

@Test
public void testHealthDownInvalid() throws Exception {
public void health_connectionIsInvalid_shouldReturnStatusDown() throws Exception {
when(dataSource.getConnection()).thenReturn(connection);
when(connection.isValid(5)).thenReturn(false);

Expand All @@ -48,7 +48,7 @@ public void testHealthDownInvalid() throws Exception {
}

@Test
public void testHealthDownException() throws Exception {
public void health_getConnectionThrowsException_shouldReturnStatusDown() throws Exception {
when(dataSource.getConnection()).thenThrow(new SQLException("DB error"));

Health health = healthIndicator.health();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class HealthControllerTest {


@Test
public void testHealthUp() throws Exception {
public void getHealth_statusIsUp_shouldReturnOkAndStatusUp() throws Exception {
HealthComponent healthComponent = Health.up().build();
when(healthEndpoint.health()).thenReturn(healthComponent);

Expand All @@ -45,7 +45,7 @@ public void testHealthUp() throws Exception {
}

@Test
public void testHealthDown() throws Exception {
public void getHealth_statusIsDown_shouldReturnServiceUnavailableAndStatusDown() throws Exception {
HealthComponent healthComponent = Health.down().build();
when(healthEndpoint.health()).thenReturn(healthComponent);

Expand Down
Loading