Skip to content

S28 2346: Re-enable Functional Test #987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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 @@ -742,67 +742,60 @@ void getBookingsSortByFinishedAt() throws JsonProcessingException {
assertThat(responseData2.get(2).getId()).isEqualTo(booking1.getId());
}

/*
@DisplayName("Scenario: Search for a booking by schedule date")
@Test
void searchBookingByScheduleDate() throws JsonProcessingException {
var dateToSearchStr = LocalDate.now().plusWeeks(1).toString();

var bookingId = doPostRequest("/testing-support/create-well-formed-booking", false)
@DisplayName("Scenario: Search for a booking by schedule date")
void searchBookingByScheduleDate() {
var bookingId = doPostRequest("/testing-support/create-well-formed-booking", null)
.body()
.jsonPath()
.getUUID("bookingId");

Response bookingResponse = doGetRequest(BOOKINGS_ENDPOINT + "?scheduledFor=" + dateToSearchStr, true);

var dateToSearchStr = LocalDate.now().plusWeeks(1).toString();
var bookingResponse = doGetRequest(BOOKINGS_ENDPOINT + "?scheduledFor=" + dateToSearchStr,
TestingSupportRoles.SUPER_USER);
var bookings = bookingResponse.body().jsonPath().getList("_embedded.bookingDTOList", BookingDTO.class);

assertThat(bookingResponse.statusCode()).isEqualTo(200);
assertThat(bookings.stream().anyMatch(b -> b.getId().equals(bookingId))).isTrue();

dateToSearchStr = LocalDate.now().toString();

bookingResponse = doGetRequest(BOOKINGS_ENDPOINT + "?scheduledFor=" + dateToSearchStr, true);

bookingResponse = doGetRequest(BOOKINGS_ENDPOINT + "?scheduledFor=" + dateToSearchStr,
TestingSupportRoles.SUPER_USER);
bookings = bookingResponse.body().jsonPath().getList("_embedded.bookingDTOList", BookingDTO.class);

assertThat(bookingResponse.statusCode()).isEqualTo(200);
assertThat(bookings.stream().noneMatch(b -> b.getId().equals(bookingId))).isTrue();
}

@DisplayName("Scenario: Search for a booking by schedule date and case reference")
@Test
void searchBookingByScheduleDateAndCaseReference() throws JsonProcessingException {
var dateToSearchStr = LocalDate.now().plusWeeks(1).toString();

var bookingId = doPostRequest("/testing-support/create-well-formed-booking", false)
@DisplayName("Scenario: Search for a booking by schedule date and case reference")
void searchBookingByScheduleDateAndCaseReference() {
var bookingId = doPostRequest("/testing-support/create-well-formed-booking", null)
.body()
.jsonPath()
.getUUID("bookingId");

Response bookingResponse = doGetRequest(BOOKINGS_ENDPOINT + "?scheduledFor=" + dateToSearchStr
+ "&caseReference=4567890123", true);

var dateToSearchStr = LocalDate.now().plusWeeks(1).toString();
var bookingResponse = doGetRequest(BOOKINGS_ENDPOINT + "?scheduledFor=" + dateToSearchStr
+ "&caseReference=4567890123", TestingSupportRoles.SUPER_USER);
var bookings = bookingResponse.body().jsonPath().getList("_embedded.bookingDTOList", BookingDTO.class);

assertResponseCode(bookingResponse, 200);
assertThat(bookings.stream().anyMatch(b -> b.getId().equals(bookingId))).isTrue();
}

@DisplayName("Scenario: Search for a booking by partial case reference")
@Test
void searchBookingByPartialCaseReference() throws JsonProcessingException {
var bookingId = doPostRequest("/testing-support/create-well-formed-booking", false)
@DisplayName("Scenario: Search for a booking by partial case reference")
void searchBookingByPartialCaseReference() {
var bookingId = doPostRequest("/testing-support/create-well-formed-booking", null)
.body()
.jsonPath()
.getUUID("bookingId");

Response bookingResponse = doGetRequest(BOOKINGS_ENDPOINT + "?caseReference=456789", true);

var bookingResponse = doGetRequest(BOOKINGS_ENDPOINT + "?caseReference=456789", TestingSupportRoles.SUPER_USER);
var bookings = bookingResponse.body().jsonPath().getList("_embedded.bookingDTOList", BookingDTO.class);

assertThat(bookingResponse.statusCode()).isEqualTo(200);
assertThat(bookings.stream().anyMatch(b -> b.getId().equals(bookingId))).isTrue();
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,33 @@ void updateCaseStatusAuthError() throws JsonProcessingException {
}
}

@Test
@DisplayName("Create a case without participants")
void createCaseWithoutParticipants() throws JsonProcessingException {
var dto = createCase();
dto.setParticipants(Set.of());
var putResponse = putCase(dto);
assertResponseCode(putResponse, 400);

assertThat(putResponse.jsonPath().getString("participants"))
.isEqualTo("Participants must consist of at least 1 defendant and 1 witness");
}

@Test
@DisplayName("Update a case without participants")
void updateCaseWithoutParticipants() throws JsonProcessingException {
var dto = createCase();
var putResponse = putCase(dto);
assertResponseCode(putResponse, 201);
assertMatchesDto(dto);

dto.setParticipants(Set.of());
var putResponse2 = putCase(dto);

assertThat(putResponse2.jsonPath().getString("participants"))
.isEqualTo("Participants must consist of at least 1 defendant and 1 witness");
}

private Response putCase(CreateCaseDTO dto, TestingSupportRoles role) throws JsonProcessingException {
return doPutRequest(
CASES_ENDPOINT + "/" + dto.getId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
public interface CaptureSessionRepository extends JpaRepository<CaptureSession, UUID> {
Optional<CaptureSession> findByIdAndDeletedAtIsNull(UUID captureSessionId);

int countAllByBooking_CaseId_IdAndStatus(UUID caseId, RecordingStatus status);

List<CaptureSession> findAllByStatus(RecordingStatus status);

List<CaptureSession> findAllByStartedAtIsBetweenAndDeletedAtIsNull(Timestamp fromTime,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package uk.gov.hmcts.reform.preapi.repositories;

import jakarta.transaction.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
Expand All @@ -18,7 +16,6 @@
public interface ShareBookingRepository extends JpaRepository<ShareBooking, UUID> {
List<ShareBooking> findAllByDeletedAtIsNotNull();


@Query(
"""
SELECT s FROM ShareBooking s
Expand Down Expand Up @@ -49,27 +46,6 @@ List<ShareBooking> searchAll(

List<ShareBooking> findAllByBookingAndDeletedAtIsNull(Booking booking);

@Query("""
update ShareBooking e
set e.deletedAt=CURRENT_TIMESTAMP
where e.booking=:booking
and e.deletedAt is null
"""
)
@Modifying
@Transactional
void deleteAllByBooking(Booking booking);

@Query(
"""
SELECT s FROM ShareBooking s
WHERE s.sharedWith.id = ?1
AND s.deletedAt IS NULL
AND s.booking.caseId.court.id = ?2
"""
)
List<ShareBooking> findAllSharesForUserByCourt(UUID userId, UUID courtId);

Page<ShareBooking> findByBooking_IdOrderBySharedWith_FirstNameAsc(UUID bookingId, Pageable pageable);

List<ShareBooking> findAllBySharedWith_IdAndDeletedAtIsNull(UUID userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
public class ShareBookingService {

private final ShareBookingRepository shareBookingRepository;

private final BookingRepository bookingRepository;

private final UserRepository userRepository;

private final EmailServiceFactory emailServiceFactory;
Expand Down