Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
19 changes: 7 additions & 12 deletions config/pmd/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@

<rule ref="category/java/bestpractices.xml">
<exclude name="GuardLogStatement"/>
<exclude name="JUnitTestContainsTooManyAsserts"/>
<exclude name="JUnitAssertionsShouldIncludeMessage"/>
<exclude name="JUnitTestsShouldIncludeAssert"/>
<exclude name="UnitTestContainsTooManyAsserts"/>
<exclude name="UnitTestAssertionsShouldIncludeMessage"/>
<exclude name="UnitTestShouldIncludeAssert"/>
<exclude name="UnusedFormalParameter"/>
</rule>
<rule ref="category/java/bestpractices.xml/UnusedPrivateField">
<properties>
<property name="ignoredAnnotations" value="Autowired" />
</properties>
<exclude name="LiteralsFirstInComparisons"/>
</rule>
<rule ref="category/java/codestyle.xml">
<exclude name="AtLeastOneConstructor"/>
Expand All @@ -25,7 +21,6 @@
<exclude name="MethodArgumentCouldBeFinal"/>
<exclude name="OnlyOneReturn"/>
<exclude name="TooManyStaticImports"/>
<exclude name="DefaultPackage"/>
<exclude name="CommentDefaultAccessModifier"/>
<exclude name="FieldNamingConventions"/>
<exclude name="UnnecessaryAnnotationValueElement"/>
Expand All @@ -36,6 +31,7 @@
<properties>
<!-- same as any other class -->
<property name="utilityClassPattern" value="[A-Z][a-zA-Z]+"/>
<property name="testClassPattern" value="[A-Z][a-zA-Z]+(FT|IT)?"/>
</properties>
</rule>
<rule ref="category/java/codestyle.xml/MethodNamingConventions">
Expand Down Expand Up @@ -68,9 +64,8 @@
<exclude name="UncommentedEmptyMethodBody"/>
</rule>
<rule ref="category/java/errorprone.xml">
<exclude name="BeanMembersShouldSerialize"/>
<exclude name="NonSerializableClass"/>
<exclude name="AvoidDuplicateLiterals"/>
<exclude name="DataflowAnomalyAnalysis"/>
</rule>
<rule ref="category/java/multithreading.xml">
<exclude name="UseConcurrentHashMap"/>
Expand All @@ -80,7 +75,7 @@
<rule ref="category/java/security.xml"/>
<rule ref="category/java/design.xml/ExcessiveImports">
<properties>
<property name="minimum" value="62.0" />
<property name="minimum" value="62" />
</properties>
</rule>
<rule ref="category/java/codestyle.xml/UseUnderscoresInNumericLiterals">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import static org.assertj.core.api.Assertions.assertThat;

public class AuditControllerFT extends FunctionalTestBase {
class AuditControllerFT extends FunctionalTestBase {

@DisplayName("Should fail to update an audit record as they are immutable")
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import static org.assertj.core.api.Assertions.assertThat;

public class CaptureSessionControllerFT extends FunctionalTestBase {
class CaptureSessionControllerFT extends FunctionalTestBase {
@Test
@DisplayName("Scenario: Delete capture session with recordings")
void shouldNotDeleteCaptureSessionWithRecordings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import static org.assertj.core.api.Assertions.assertThat;

public class CourtControllerFT extends FunctionalTestBase {
class CourtControllerFT extends FunctionalTestBase {
@DisplayName("Scenario: Create and update a court")
@Test
void createAndUpdateCourt() throws JsonProcessingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import static org.assertj.core.api.Assertions.assertThat;

public class InviteControllerFT extends FunctionalTestBase {
class InviteControllerFT extends FunctionalTestBase {
@DisplayName("Create a portal invite for new user")
@Test
void createPortalInvite() throws JsonProcessingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import static org.assertj.core.api.Assertions.assertThat;

public class MediaServiceControllerFT extends FunctionalTestBase {
class MediaServiceControllerFT extends FunctionalTestBase {

@DisplayName("Should return links to play back a vod on demand")
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import static org.assertj.core.api.Assertions.assertThat;

public class RecordingControllerFT extends FunctionalTestBase {
class RecordingControllerFT extends FunctionalTestBase {
@DisplayName("Scenario: Restore recording")
@Test
void undeleteRecording() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import static org.assertj.core.api.Assertions.assertThat;

public class ReportControllerFT extends FunctionalTestBase {
class ReportControllerFT extends FunctionalTestBase {
@DisplayName("Scenario: Should format Duration and date correctly")
@Test
void shouldFormatDurationAndDateCorrectly() throws JsonProcessingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import static org.assertj.core.api.Assertions.assertThat;

public class UserControllerFT extends FunctionalTestBase {
class UserControllerFT extends FunctionalTestBase {
@DisplayName("Scenario: Create/update a user")
@Test
void shouldCreateUser() throws JsonProcessingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
import static org.junit.jupiter.api.Assertions.assertEquals;

@SpringBootTest
public class GovNotifyFT {
private final String toEmailAddress = "[email protected]";
private final String fromEmailAddress = "[email protected]";
private final String caseReference = "123456";
private final String courtName = "Court Name";
private final String userFirstName = "John";
private final String userLastName = "Doe";
class GovNotifyFT {
private static final String TO_EMAIL_ADDRESS = "[email protected]";
private static final String FROM_EMAIL_ADDRESS = "[email protected]";
private static final String CASE_REFERENCE = "123456";
private static final String COURT_NAME = "Court Name";
private static final String USER_FIRST_NAME = "John";
private static final String USER_LAST_NAME = "Doe";

@Value("${portal.url")
private String portalUrl;
Expand All @@ -31,18 +31,18 @@ public class GovNotifyFT {

private User createUser() {
var user = new User();
user.setFirstName(userFirstName);
user.setLastName(userLastName);
user.setEmail(toEmailAddress);
user.setFirstName(USER_FIRST_NAME);
user.setLastName(USER_LAST_NAME);
user.setEmail(TO_EMAIL_ADDRESS);
return user;
}

private Case createCase() {
var court = new Court();
court.setName(courtName);
court.setName(COURT_NAME);
var forCase = new Case();
forCase.setCourt(court);
forCase.setReference(caseReference);
forCase.setReference(CASE_REFERENCE);
return forCase;
}

Expand All @@ -59,7 +59,7 @@ void recordingReady() {
var forCase = createCase();

var response = client.recordingReady(user, forCase);
assertEquals(fromEmailAddress, response.getFromEmail());
assertEquals(FROM_EMAIL_ADDRESS, response.getFromEmail());
assertEquals("[Do Not Reply] HMCTS Pre-recorded Evidence Portal – New Video", response.getSubject());
compareBody(
"""
Expand All @@ -86,7 +86,7 @@ void recordingEdited() {
var forCase = createCase();

var response = client.recordingEdited(user, forCase);
assertEquals(fromEmailAddress, response.getFromEmail());
assertEquals(FROM_EMAIL_ADDRESS, response.getFromEmail());
assertEquals("[Do Not Reply] HMCTS Pre-recorded Evidence Portal – Edited Video", response.getSubject());
compareBody(
"""
Expand All @@ -112,7 +112,7 @@ void portalInvite() {
var user = createUser();

var response = client.portalInvite(user);
assertEquals(fromEmailAddress, response.getFromEmail());
assertEquals(FROM_EMAIL_ADDRESS, response.getFromEmail());
assertEquals("[Do Not Reply] HMCTS Pre-recorded Evidence Portal Invitation", response.getSubject());
compareBody(
"""
Expand Down Expand Up @@ -158,9 +158,9 @@ void casePendingClosure() {
var date = Timestamp.valueOf("2021-01-01 00:00:00.0");

var response = client.casePendingClosure(user, forCase, date);
assertEquals(fromEmailAddress, response.getFromEmail());
assertEquals(FROM_EMAIL_ADDRESS, response.getFromEmail());
assertEquals(
"[Do Not Reply] Pre-recorded Evidence: Case reference " + caseReference + " access update",
"[Do Not Reply] Pre-recorded Evidence: Case reference " + CASE_REFERENCE + " access update",
response.getSubject()
);
compareBody(
Expand All @@ -181,9 +181,9 @@ void caseClosed() {
var forCase = createCase();

var response = client.caseClosed(user, forCase);
assertEquals(fromEmailAddress, response.getFromEmail());
assertEquals(FROM_EMAIL_ADDRESS, response.getFromEmail());
assertEquals(
"[Do Not Reply] Pre-recorded Evidence: Case reference " + caseReference + " access update",
"[Do Not Reply] Pre-recorded Evidence: Case reference " + CASE_REFERENCE + " access update",
response.getSubject()
);
compareBody(
Expand All @@ -204,9 +204,9 @@ void caseClosureCancelled() {
var forCase = createCase();

var response = client.caseClosureCancelled(user, forCase);
assertEquals(fromEmailAddress, response.getFromEmail());
assertEquals(FROM_EMAIL_ADDRESS, response.getFromEmail());
assertEquals(
"[Do Not Reply] Pre-recorded Evidence: Case reference " + caseReference + " access update",
"[Do Not Reply] Pre-recorded Evidence: Case reference " + CASE_REFERENCE + " access update",
response.getSubject()
);
compareBody(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static uk.gov.hmcts.reform.preapi.config.OpenAPIConfiguration.X_USER_ID_HEADER;

public class XUserIdFilterFT extends FunctionalTestBase {
class XUserIdFilterFT extends FunctionalTestBase {

private static final String ENDPOINT = "/roles";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import static uk.gov.hmcts.reform.preapi.config.OpenAPIConfiguration.X_USER_ID_HEADER;

@SpringBootTest(classes = { Application.class }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@SuppressWarnings("PMD.JUnit5TestShouldBePackagePrivate")
@SuppressWarnings({"PMD.JUnit5TestShouldBePackagePrivate", "PMD.GodClass"})
public class FunctionalTestBase {
protected static final String CONTENT_TYPE_VALUE = "application/json";
protected static final String COURTS_ENDPOINT = "/courts";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AuditTest extends IntegrationTestBase {

@Test
@Transactional
public void testSaveAndRetrieveAudit() throws JsonProcessingException {
void testSaveAndRetrieveAudit() throws JsonProcessingException {
Audit audit = new Audit();
audit.setTableName("TestTable");
audit.setTableRecordId(UUID.randomUUID());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public void testAuditWithParticipants() {

audit.get().getAuditDetails().get("participants")
.forEach(node -> {
System.out.println(node);
assertThat(node.asText()).isIn(List.of(
participant1.getId().toString(), participant2.getId().toString()));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import static org.assertj.core.api.Assertions.assertThat;

@SpringBootTest(classes = Application.class)
public class UserTermsAcceptedTest extends IntegrationTestBase {
class UserTermsAcceptedTest extends IntegrationTestBase {

@Test
@Transactional
public void testSaveAndRetrieve() {
void testSaveAndRetrieve() {
var user = HelperFactory.createDefaultTestUser();
entityManager.persist(user);
entityManager.flush();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.Comparator;
import java.util.UUID;

public class AuditServiceIT extends IntegrationTestBase {
class AuditServiceIT extends IntegrationTestBase {

@Autowired
private AuditService auditService;
Expand Down Expand Up @@ -108,7 +108,7 @@ private CaptureSession getCaptureSession() {

@Transactional
@Test
public void testInternalAudit() {
void testInternalAudit() {
var court = getCreateCourt();
courtService.upsert(court);

Expand All @@ -132,7 +132,7 @@ public void testInternalAudit() {

@Transactional
@Test
public void testDeleteAuditCase() {
void testDeleteAuditCase() {
mockAdminUser();

var caseDTO = getCase();
Expand All @@ -158,7 +158,7 @@ public void testDeleteAuditCase() {

@Transactional
@Test
public void testDeleteAuditBooking() {
void testDeleteAuditBooking() {
mockAdminUser();

var caseDTO = getCase();
Expand Down Expand Up @@ -187,7 +187,7 @@ public void testDeleteAuditBooking() {

@Transactional
@Test
public void testDeleteAuditCaptureSession() {
void testDeleteAuditCaptureSession() {
mockAdminUser();

var booking = getBooking();
Expand Down Expand Up @@ -222,7 +222,7 @@ public void testDeleteAuditCaptureSession() {

@Transactional
@Test
public void testDeleteAuditRecording() {
void testDeleteAuditRecording() {
mockAdminUser();

var captureSession = getCaptureSession();
Expand All @@ -243,7 +243,8 @@ public void testDeleteAuditRecording() {
var auditResultsCreated = auditService.getAuditsByTableRecordId(recording.getId());
recordingService.deleteById(recording.getId());

var auditResults = auditService.getAuditsByTableRecordId(recording.getId());
var auditResults = auditService.getAuditsByTableRecordId(recording.getId()).stream()
.sorted(Comparator.comparing(Audit::getCreatedAt)).toList();
Assertions.assertEquals(0, auditResultsEmpty.size());
Assertions.assertEquals(1, auditResultsCreated.size());
Assertions.assertEquals(2, auditResults.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,10 @@ void testSearchByCaptureSessionStatus() {
null,
null).getContent();
assertThat(findEitherStandbyOrProcessing).hasSize(2);
assertThat(findEitherStandbyOrProcessing.stream().map(BookingDTO::getId).anyMatch(b -> b == booking1.getId()))
.isTrue();
assertThat(findEitherStandbyOrProcessing.stream().map(BookingDTO::getId).anyMatch(b -> b == booking2.getId()))
.isTrue();
assertThat(findEitherStandbyOrProcessing.stream().map(BookingDTO::getId)
.anyMatch(b -> b.equals(booking1.getId()))).isTrue();
assertThat(findEitherStandbyOrProcessing.stream().map(BookingDTO::getId)
.anyMatch(b -> b.equals(booking2.getId()))).isTrue();

var findOnlyWithNoRecording = bookingService.searchBy(null,
null,
Expand Down
Loading