Skip to content

Commit

Permalink
CCMSPUI-530 Completed NotificationRepositoryIntegrationTest
Browse files Browse the repository at this point in the history
Signed-off-by: Jamie Briggs <jamie.briggs@digital.justice.gov.uk>
  • Loading branch information
Jamie Briggs committed Feb 5, 2025
1 parent a899823 commit 06135c0
Show file tree
Hide file tree
Showing 17 changed files with 281 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@Testcontainers
@DirtiesContext
public interface IntegrationTestInterface {
public interface OracleIntegrationTestInterface {

OracleContainerSingleton oracleContainerSingleton = OracleContainerSingleton.getInstance();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
package uk.gov.laa.ccms.data.repository;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.time.LocalDate;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
import org.springframework.test.context.jdbc.SqlMergeMode;
import org.springframework.transaction.annotation.Transactional;
import uk.gov.laa.ccms.data.OracleIntegrationTestInterface;
import uk.gov.laa.ccms.data.entity.NotificationAction;
import uk.gov.laa.ccms.data.entity.NotificationAttachment;
import uk.gov.laa.ccms.data.entity.NotificationDocument;
import uk.gov.laa.ccms.data.entity.NotificationInfo;
import uk.gov.laa.ccms.data.entity.NotificationNote;

@SpringBootTest
@SqlMergeMode(SqlMergeMode.MergeMode.MERGE)
@Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, scripts = "/sql/get_notif_info_create_schema.sql")
@Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, scripts = "/sql/get_notif_info_drop_schema.sql")
@Sql(executionPhase = ExecutionPhase.BEFORE_TEST_CLASS, scripts = {
"/sql/get_notif_info_create_schema.sql",
"/sql/get_notif_info_relationships_create_schema.sql"
})
@Sql(executionPhase = ExecutionPhase.AFTER_TEST_CLASS, scripts = {
"/sql/get_notif_info_drop_schema.sql",
"/sql/get_notif_info_relationships_drop_schema.sql",
})
@DisplayName("Notification Repository Integration Tests")
public class NotificationRepositoryIntegrationTest {
public class NotificationRepositoryIntegrationTest implements OracleIntegrationTestInterface {

@Autowired
private NotificationRepository repository;
Expand Down Expand Up @@ -43,4 +58,97 @@ void setup(){
.isOpen(true)
.build();
}

@Test
@DisplayName("Should return notification")
void shouldReturnNotification(){
// Given
long notificationId = 1L;
// When
NotificationInfo result = repository.findById(notificationId).orElse(null);
// Then
assertEquals(1L, result.getNotificationId());
assertEquals("test_user", result.getUserId());
assertEquals("test_login", result.getUserLoginId());
assertEquals(10L, result.getProviderFirmId());
assertEquals(LocalDate.of(2025, 1, 1), result.getDateAssigned());
assertEquals("Subject", result.getSubject());
assertEquals(LocalDate.of(2027, 1, 1), result.getDueDate());
assertEquals("JBriggs", result.getAssignedTo());
assertEquals("open", result.getStatus());
assertEquals("1001", result.getLscCaseRefReference());
assertEquals("First Case Reference", result.getProviderCaseReference());
assertEquals("Jamie Briggs", result.getClientName());
assertEquals("Fee", result.getFeeEarner());
assertEquals("Briggs", result.getPersonLastName());
assertEquals(3001L, result.getFeeEarnerPartyId());
assertEquals("N", result.getActionNotificationInd());
assertEquals(true, result.getIsOpen());
}

@Test
@Transactional
@DisplayName("Should return notification with notes")
public void shouldReturnNotificationWithNotes(){
// Given
long notificationId = 1L;
// When
NotificationInfo result = repository.findById(notificationId).orElse(null);
// Then
NotificationNote note = result.getNotes().getFirst();
assertEquals(1, note.getNoteId());
assertEquals(1, note.getNotificationId());
assertEquals(LocalDate.of(2025, 1, 1), note.getNoteDate());
assertEquals("Here is the body of text for this note", note.getNoteText());
assertEquals("Jamie Briggs", note.getNoteBy());
}

@Test
@Transactional
@DisplayName("Should return notification with documents")
public void shouldReturnNotificationWithDocuments(){
// Given
long notificationId = 1L;
// When
NotificationInfo result = repository.findById(notificationId).orElse(null);
// Then
NotificationDocument document = result.getDocuments().getFirst();
assertEquals(1, document.getDocumentId());
assertEquals(1, document.getNotificationId());
assertEquals("Channel", document.getDocumentChannel());
assertEquals("Type", document.getDocumentType());
assertEquals("Document description", document.getDocumentDescription());
assertEquals("Status", document.getDocumentStatus());
assertEquals("EDRMS ID", document.getEdrmsDocumentid());
}

@Test
@Transactional
@DisplayName("Should return notification with attachments")
public void shouldReturnNotificationWithAttachments(){
// Given
long notificationId = 1L;
// When
NotificationInfo result = repository.findById(notificationId).orElse(null);
// Then
NotificationAttachment attachment = result.getAttachments().getFirst();
assertEquals(1, attachment.getAttachmentId());
assertEquals(1, attachment.getNotificationId());
assertEquals("Attachment Title", attachment.getAttachmentTitle());
assertEquals("Attachment description", attachment.getAttachmentDescription());
}

@Test
@Transactional
@DisplayName("Should return notification with actions")
public void shouldReturnNotificationWithActions(){
long notificationId = 1L;
// When
NotificationInfo result = repository.findById(notificationId).orElse(null);
// Then
NotificationAction action = result.getActions().getFirst();
assertEquals(1, action.getNextActionId());
assertEquals(1, action.getNotificationId());
assertEquals("Action to complete", action.getNextAction());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
import org.springframework.data.domain.Pageable;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.SqlMergeMode;
import uk.gov.laa.ccms.data.IntegrationTestInterface;
import uk.gov.laa.ccms.data.OracleIntegrationTestInterface;
import uk.gov.laa.ccms.data.entity.NotificationInfo;

@SpringBootTest
@SqlMergeMode(MERGE)
@Sql(executionPhase=BEFORE_TEST_CLASS,scripts= "/sql/get_notif_info_create_schema.sql")
@Sql(executionPhase=AFTER_TEST_CLASS,scripts= "/sql/get_notif_info_drop_schema.sql")
@DisplayName("Notification Info Repository Integration Test")
class NotificationSearchRepositoryIntegrationTest implements IntegrationTestInterface {
class NotificationSearchRepositoryIntegrationTest implements OracleIntegrationTestInterface {

private NotificationSearchRepository notificationRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.springframework.data.domain.Pageable;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.SqlMergeMode;
import uk.gov.laa.ccms.data.IntegrationTestInterface;
import uk.gov.laa.ccms.data.OracleIntegrationTestInterface;
import uk.gov.laa.ccms.data.model.AssessmentSummaryEntityLookupDetail;
import uk.gov.laa.ccms.data.model.AwardTypeLookupDetail;
import uk.gov.laa.ccms.data.model.CaseStatusLookupDetail;
Expand All @@ -32,7 +32,7 @@
@SqlMergeMode(MERGE)
@Sql(executionPhase=BEFORE_TEST_METHOD,scripts="/sql/lookup_create_schema.sql" )
@Sql(executionPhase=AFTER_TEST_METHOD,scripts="/sql/lookup_drop_schema.sql")
public class LookupServiceIntegrationTest implements IntegrationTestInterface {
public class LookupServiceIntegrationTest implements OracleIntegrationTestInterface {

@Autowired
private LookupService lookupService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
import org.springframework.data.domain.Pageable;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.SqlMergeMode;
import uk.gov.laa.ccms.data.IntegrationTestInterface;
import uk.gov.laa.ccms.data.OracleIntegrationTestInterface;
import uk.gov.laa.ccms.data.model.PriorAuthorityTypeDetails;


@SpringBootTest
@SqlMergeMode(MERGE)
@Sql(executionPhase=BEFORE_TEST_METHOD,scripts="/sql/prior_authority_create_schema.sql" )
@Sql(executionPhase=AFTER_TEST_METHOD,scripts="/sql/prior_authority_drop_schema.sql")
public class PriorAuthorityServiceIntegrationTest implements IntegrationTestInterface {
public class PriorAuthorityServiceIntegrationTest implements OracleIntegrationTestInterface {

@Autowired
private PriorAuthorityService priorAuthorityService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
import org.springframework.data.domain.Pageable;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.SqlMergeMode;
import uk.gov.laa.ccms.data.IntegrationTestInterface;
import uk.gov.laa.ccms.data.OracleIntegrationTestInterface;
import uk.gov.laa.ccms.data.model.ProceedingDetail;
import uk.gov.laa.ccms.data.model.ProceedingDetails;

@SpringBootTest
@SqlMergeMode(MERGE)
@Sql(executionPhase = BEFORE_TEST_METHOD, scripts = "/sql/proceedings_create_schema.sql")
@Sql(executionPhase = AFTER_TEST_METHOD, scripts = "/sql/proceedings_drop_schema.sql")
public class ProceedingServiceIntegrationTest implements IntegrationTestInterface {
public class ProceedingServiceIntegrationTest implements OracleIntegrationTestInterface {

@Autowired
private ProceedingService proceedingService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.SqlMergeMode;
import uk.gov.laa.ccms.data.IntegrationTestInterface;
import uk.gov.laa.ccms.data.OracleIntegrationTestInterface;
import uk.gov.laa.ccms.data.model.ContactDetail;
import uk.gov.laa.ccms.data.model.OfficeDetail;
import uk.gov.laa.ccms.data.model.ProviderDetail;
Expand All @@ -23,7 +23,7 @@
@SqlMergeMode(MERGE)
@Sql(executionPhase = BEFORE_TEST_METHOD, scripts = "/sql/providers_create_schema.sql")
@Sql(executionPhase = AFTER_TEST_METHOD, scripts = "/sql/providers_drop_schema.sql")
public class ProviderServiceIntegrationTest implements IntegrationTestInterface {
public class ProviderServiceIntegrationTest implements OracleIntegrationTestInterface {

@Autowired
private ProviderService providerService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
import org.springframework.data.domain.Pageable;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.SqlMergeMode;
import uk.gov.laa.ccms.data.IntegrationTestInterface;
import uk.gov.laa.ccms.data.OracleIntegrationTestInterface;
import uk.gov.laa.ccms.data.model.ScopeLimitationDetails;

@SpringBootTest
@SqlMergeMode(MERGE)
@Sql(executionPhase = BEFORE_TEST_METHOD, scripts = "/sql/scope_limitations_create_schema.sql")
@Sql(executionPhase = AFTER_TEST_METHOD, scripts = "/sql/scope_limitations_drop_schema.sql")
public class ScopeLimitationServiceIntegrationTest implements IntegrationTestInterface {
public class ScopeLimitationServiceIntegrationTest implements OracleIntegrationTestInterface {

@Autowired
private ScopeLimitationService scopeLimitationService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.springframework.data.domain.Pageable;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.SqlMergeMode;
import uk.gov.laa.ccms.data.IntegrationTestInterface;
import uk.gov.laa.ccms.data.OracleIntegrationTestInterface;
import uk.gov.laa.ccms.data.model.UserDetail;
import uk.gov.laa.ccms.data.model.UserDetails;

Expand All @@ -28,7 +28,7 @@
@Sql(executionPhase=BEFORE_TEST_METHOD,scripts="/sql/users_create_schema.sql" )
@Sql(executionPhase=AFTER_TEST_METHOD,scripts="/sql/providers_drop_schema.sql")
@Sql(executionPhase=AFTER_TEST_METHOD,scripts="/sql/users_drop_schema.sql")
public class UserServiceIntegrationTest implements IntegrationTestInterface {
public class UserServiceIntegrationTest implements OracleIntegrationTestInterface {

@Autowired
private UserService userService;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
CREATE TABLE XXCCMS.XXCCMS_NOTIFICATION_NOTES_V (
NOTE_ID NUMBER NOT NULL PRIMARY KEY,
NOTIFICATION_ID NUMBER NOT NULL,
NOTE_DATE DATE NOT NULL,
NOTE_TEXT VARCHAR2(2000) NOT NULL,
NOTE_BY VARCHAR2(360)
);

CREATE TABLE XXCCMS.XXCCMS_NOTIFICATION_DOCS_V (
DOCUMENT_ID NUMBER NOT NULL PRIMARY KEY,
NOTIFICATION_ID NUMBER NOT NULL,
DOCUMENT_CHANNEL VARCHAR2(30) NOT NULL,
DOCUMENT_TYPE VARCHAR2(30),
DOCUMENT_DESCRIPTION VARCHAR2(255),
DOCUMENT_STATUS VARCHAR2(80) NOT NULL,
EDRMS_DOCUMENT_ID VARCHAR2(50)
);

CREATE TABLE XXCCMS.XXCCMS_NOTIFICATION_ATTMNTS_V (
ATTACHMENT_ID NUMBER NOT NULL PRIMARY KEY,
NOTIFICATION_ID NUMBER NOT NULL,
ATTACHMENT_TITLE VARCHAR2(80) NOT NULL,
ATTACHMENT_DESCRIPTION VARCHAR2(255)
);

CREATE TABLE XXCCMS.XXCCMS_NOTIFICATION_ACTIONS_V (
NEXT_ACTION_ID NUMBER NOT NULL PRIMARY KEY,
NOTIFICATION_ID NUMBER NOT NULL,
NEXT_ACTION VARCHAR2(150)
);



INSERT INTO XXCCMS.XXCCMS_NOTIFICATION_NOTES_V (NOTE_ID,
NOTIFICATION_ID,
NOTE_DATE,
NOTE_TEXT,
NOTE_BY)
VALUES(1, 1,
TO_DATE('2025-01-01', 'YYYY-MM-DD'),
'Here is the body of text for this note',
'Jamie Briggs');

INSERT INTO XXCCMS.XXCCMS_NOTIFICATION_DOCS_V (DOCUMENT_ID,
NOTIFICATION_ID,
DOCUMENT_CHANNEL,
DOCUMENT_TYPE,
DOCUMENT_DESCRIPTION,
DOCUMENT_STATUS,
EDRMS_DOCUMENT_ID)
VALUES(1,
1,
'Channel',
'Type',
'Document description',
'Status',
'EDRMS ID');

INSERT INTO XXCCMS.XXCCMS_NOTIFICATION_ATTMNTS_V (NOTIFICATION_ID,
ATTACHMENT_ID,
ATTACHMENT_TITLE,
ATTACHMENT_DESCRIPTION)
VALUES (1,
1,
'Attachment Title',
'Attachment description');

INSERT INTO XXCCMS.XXCCMS_NOTIFICATION_ACTIONS_V (NOTIFICATION_ID,
NEXT_ACTION_ID,
NEXT_ACTION)
VALUES (1, 1,
'Action to complete');
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DROP TABLE XXCCMS.XXCCMS_NOTIFICATION_NOTES_V;
DROP TABLE XXCCMS.XXCCMS_NOTIFICATION_DOCS_V;
DROP TABLE XXCCMS.XXCCMS_NOTIFICATION_ATTMNTS_V;
DROP TABLE XXCCMS.XXCCMS_NOTIFICATION_ACTIONS_V;
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,26 @@
import lombok.RequiredArgsConstructor;
import org.hibernate.annotations.Immutable;

/**
* Represents a notification action entity from the <b>XXCCMS_NOTIFICATION_ACTIONS_V</b> database
* view.
*
* <p>This entity captures details about a notification's action. It provides a single field for
* describing the action which needs to be taken.</p>
*
* <p>This class is immutable, and its instances can be created using the builder pattern.</p>
*
* @author Jamie Briggs
* @see NotificationInfo
*/
@Entity
@Table(name = "XXCCMS_NOTIFICATION_ACTIONS_V", schema = "XXCCMS")
@Getter
@Builder
@Immutable
@AllArgsConstructor
@RequiredArgsConstructor
public class NotificationActions {
public class NotificationAction {

@Id
@Column(name = "NEXT_ACTION_ID", nullable = false)
Expand Down
Loading

0 comments on commit 06135c0

Please sign in to comment.