-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CCMSPUI-530 Created various mappers for mapping document entity for p…
…resentation layer Signed-off-by: Jamie Briggs <jamie.briggs@digital.justice.gov.uk>
- Loading branch information
Jamie Briggs
committed
Feb 6, 2025
1 parent
e35ce84
commit 22c3826
Showing
7 changed files
with
223 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
data-service/src/main/java/uk/gov/laa/ccms/data/mapper/DocumentMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package uk.gov.laa.ccms.data.mapper; | ||
|
||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
import uk.gov.laa.ccms.data.entity.NotificationDocument; | ||
import uk.gov.laa.ccms.data.model.Document; | ||
|
||
@Mapper(componentModel = "spring") | ||
public interface DocumentMapper { | ||
|
||
@Mapping(target = "text", source = "documentDescription") | ||
@Mapping(target = "channel", source = "documentChannel") | ||
@Mapping(target = "status", source = "documentStatus") | ||
Document mapToNotification(NotificationDocument notificationDocument); | ||
} |
16 changes: 16 additions & 0 deletions
16
data-service/src/main/java/uk/gov/laa/ccms/data/mapper/NoteMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package uk.gov.laa.ccms.data.mapper; | ||
|
||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
import uk.gov.laa.ccms.data.entity.NotificationNote; | ||
import uk.gov.laa.ccms.data.model.Note; | ||
|
||
@Mapper(componentModel = "spring") | ||
public interface NoteMapper { | ||
|
||
@Mapping(target = "user.username", source = "noteBy") | ||
@Mapping(target = "notesId", source = "noteId") | ||
@Mapping(target = "message", source = "noteText") | ||
@Mapping(target = "date", source = "noteDate") | ||
Note mapToNote(NotificationNote notificationNote); | ||
} |
20 changes: 20 additions & 0 deletions
20
data-service/src/main/java/uk/gov/laa/ccms/data/mapper/NotificationMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package uk.gov.laa.ccms.data.mapper; | ||
|
||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
import uk.gov.laa.ccms.data.entity.NotificationInfo; | ||
import uk.gov.laa.ccms.data.model.Notification; | ||
|
||
@Mapper(componentModel = "spring") | ||
public interface NotificationMapper { | ||
|
||
@Mapping(target = "user.loginId", source = "userLoginId") | ||
@Mapping(target = "user.username", source = "assignedTo") | ||
@Mapping(target = "assignDate", source = "dateAssigned") | ||
@Mapping(target = "providerCaseReferenceNumber", source = "providerCaseReference") | ||
@Mapping(target = "caseReferenceNumber", source = "lscCaseRefReference") | ||
@Mapping(target = "notificationType", source = "actionNotificationInd") | ||
@Mapping(target = "notificationOpenIndicator", source = "isOpen") | ||
Notification mapToNotification(NotificationInfo notification); | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
data-service/src/test/java/uk/gov/laa/ccms/data/mapper/DocumentMapperImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package uk.gov.laa.ccms.data.mapper; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import uk.gov.laa.ccms.data.entity.NotificationDocument; | ||
import uk.gov.laa.ccms.data.model.Document; | ||
|
||
@DisplayName("Document mapper implementation test") | ||
class DocumentMapperImplTest { | ||
|
||
DocumentMapper mapper = new DocumentMapperImpl(); | ||
|
||
@Test | ||
@DisplayName("Should map to document") | ||
void shouldMapToDocument(){ | ||
// Given | ||
NotificationDocument document = NotificationDocument.builder() | ||
.documentId(1L) | ||
.notificationId(2L) | ||
.documentChannel("Channel") | ||
.documentType("ADV_FRM") | ||
.documentDescription("Description") | ||
.documentStatus("Status") | ||
.edrmsDocumentid("EDRMS") | ||
.build(); | ||
// When | ||
Document result = mapper.mapToNotification(document); | ||
// Then | ||
assertEquals("1", result.getDocumentId()); | ||
assertEquals("Channel", result.getChannel()); | ||
assertEquals("ADV_FRM", result.getDocumentType()); | ||
assertEquals("Description", result.getText()); | ||
assertEquals("Status", result.getStatus()); | ||
|
||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
data-service/src/test/java/uk/gov/laa/ccms/data/mapper/NoteMapperImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package uk.gov.laa.ccms.data.mapper; | ||
|
||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.time.LocalDate; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import uk.gov.laa.ccms.data.entity.NotificationNote; | ||
import uk.gov.laa.ccms.data.model.Note; | ||
|
||
@DisplayName("Note mapper implementation test") | ||
class NoteMapperImplTest { | ||
|
||
NoteMapper mapper = new NoteMapperImpl(); | ||
|
||
@Test | ||
@DisplayName("Should map to note") | ||
void shouldMapToNote(){ | ||
// Given | ||
NotificationNote note = NotificationNote.builder() | ||
.noteId(1L) | ||
.noteBy("User Name") | ||
.noteDate(LocalDate.of(2025, 1, 1)) | ||
.notificationId(2L) | ||
.noteText("Note text") | ||
.build(); | ||
// When | ||
Note result = mapper.mapToNote(note); | ||
// Then | ||
assertEquals("1", result.getNotesId()); | ||
assertEquals("User Name", result.getUser().getUsername()); | ||
assertEquals(LocalDate.of(2025, 1, 1), result.getDate()); | ||
assertEquals("Note text", result.getMessage()); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
data-service/src/test/java/uk/gov/laa/ccms/data/mapper/NotificationMapperImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package uk.gov.laa.ccms.data.mapper; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.time.LocalDate; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import uk.gov.laa.ccms.data.entity.NotificationInfo; | ||
import uk.gov.laa.ccms.data.model.Notification; | ||
|
||
@DisplayName("Notification mapper implementation test") | ||
class NotificationMapperImplTest { | ||
|
||
NotificationMapper mapper = new NotificationMapperImpl(); | ||
|
||
@Test | ||
@DisplayName("Should map basic details") | ||
void shouldMapBasicDetails(){ | ||
// Given | ||
NotificationInfo notificationInfo = NotificationInfo.builder() | ||
.assignedTo("User Name") | ||
.userLoginId("User Login Id") | ||
.clientName("Client Name") | ||
.feeEarner("Fee Earner") | ||
.notificationId(1L) | ||
.providerFirmId(2L) | ||
.subject("NotificationInfo Subject") | ||
.dateAssigned(LocalDate.of(2024, 1, 1)) | ||
.dueDate(LocalDate.of(2025, 2, 1)) | ||
.status("Status") | ||
.isOpen(true) | ||
.actionNotificationInd("N") | ||
.lscCaseRefReference("LSC Case Ref") | ||
.providerCaseReference("Provider Case Ref") | ||
.feeEarnerPartyId(4L) | ||
.build(); | ||
|
||
// When | ||
Notification notificationResult = mapper.mapToNotification(notificationInfo); | ||
// Then | ||
assertEquals("User Login Id", notificationResult.getUser().getLoginId()); | ||
assertEquals("User Name", notificationResult.getUser().getUsername()); | ||
assertEquals("Client Name", notificationResult.getClientName()); | ||
assertEquals("Fee Earner", notificationResult.getFeeEarner()); | ||
assertEquals("1", notificationResult.getNotificationId()); | ||
assertEquals("2", notificationResult.getProviderFirmId()); | ||
assertEquals("NotificationInfo Subject", notificationResult.getSubject()); | ||
assertEquals(LocalDate.of(2024, 1, 1), notificationResult.getAssignDate()); | ||
assertEquals(LocalDate.of(2025, 2, 1), notificationResult.getDueDate()); | ||
assertEquals("N", notificationResult.getNotificationType()); | ||
assertEquals("Status", notificationResult.getStatus()); | ||
assertEquals(true, notificationResult.getNotificationOpenIndicator()); | ||
assertEquals("Provider Case Ref",notificationResult.getProviderCaseReferenceNumber()); | ||
assertEquals("LSC Case Ref", notificationResult.getCaseReferenceNumber()); | ||
} | ||
|
||
@Test | ||
@DisplayName("Should map notes") | ||
void shouldMapNotes(){ | ||
Assertions.fail("Test not implemented yet"); | ||
} | ||
|
||
@Test | ||
@DisplayName("Should map documents") | ||
void shouldMapDocuments(){ | ||
Assertions.fail("Test not implemented yet"); | ||
} | ||
|
||
@Test | ||
@DisplayName("Should map attachments") | ||
void shouldMapAttachments(){ | ||
Assertions.fail("Test not implemented yet"); | ||
} | ||
|
||
@Test | ||
@DisplayName("Should map available responses") | ||
void shouldMapAvailableResponses(){ | ||
Assertions.fail("Test not implemented yet"); | ||
} | ||
|
||
} |