Skip to content
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 @@ -59,6 +59,7 @@ public enum CamundaProcessIdentifier {
BundleCreationNotify,
CreateSDONotify,
RaiseQueryNotifier,
JudgmentByAdmissionNotifier,
OtherPartyQueryRaisedNotifier,
NotifyLipGenericTemplateNotifier,
NotifyLipResetPinNotifier,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package uk.gov.hmcts.reform.civil.notification.handlers.judgmentbyadmission;

import uk.gov.hmcts.reform.civil.notification.handlers.AllPartiesEmailGenerator;

import java.util.List;

import org.springframework.stereotype.Component;

@Component
public class JudgmentByAdmissionAllPartiesEmailGenerator extends AllPartiesEmailGenerator {

public JudgmentByAdmissionAllPartiesEmailGenerator(JudgmentByAdmissionAppSolOneEmailDTOGenerator appSolOneEmailGenerator,
JudgmentByAdmissionDefendantEmailDTOGenerator defendantEmailDTOGenerator) {

super(List.of(appSolOneEmailGenerator,
defendantEmailDTOGenerator));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package uk.gov.hmcts.reform.civil.notification.handlers.judgmentbyadmission;

import static uk.gov.hmcts.reform.civil.utils.NotificationUtils.getApplicantLegalOrganizationName;
import static uk.gov.hmcts.reform.civil.utils.NotificationUtils.getDefendantNameBasedOnCaseType;

import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.notification.handlers.AppSolOneEmailDTOGenerator;
import uk.gov.hmcts.reform.civil.notify.NotificationsProperties;
import uk.gov.hmcts.reform.civil.service.OrganisationService;

import java.util.Map;

import org.springframework.stereotype.Component;

@Component
public class JudgmentByAdmissionAppSolOneEmailDTOGenerator extends AppSolOneEmailDTOGenerator {

private static final String REFERENCE_APP_SOL_ONE_TEMPLATE = "claimant-judgment-by-admission-%s";

private final NotificationsProperties notificationsProperties;

protected JudgmentByAdmissionAppSolOneEmailDTOGenerator(OrganisationService organisationService, NotificationsProperties notificationsProperties) {
super(organisationService);
this.notificationsProperties = notificationsProperties;
}

@Override
protected String getEmailTemplateId(CaseData caseData) {
return notificationsProperties.getNotifyClaimantLRJudgmentByAdmissionTemplate();
}

@Override
protected String getReferenceTemplate() {
return REFERENCE_APP_SOL_ONE_TEMPLATE;
}

@Override
protected Map<String, String> addCustomProperties(Map<String, String> properties, CaseData caseData) {
super.addCustomProperties(properties, caseData);
properties.put(LEGAL_ORG_NAME, getApplicantLegalOrganizationName(caseData, organisationService));
properties.put(DEFENDANT_NAME, getDefendantNameBasedOnCaseType(caseData));
return properties;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package uk.gov.hmcts.reform.civil.notification.handlers.judgmentbyadmission;

import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.notification.handlers.DefendantEmailDTOGenerator;
import uk.gov.hmcts.reform.civil.notify.NotificationsProperties;

import org.springframework.stereotype.Component;

@Component
public class JudgmentByAdmissionDefendantEmailDTOGenerator extends DefendantEmailDTOGenerator {

private static final String REFERENCE_DEFENDANT_TEMPLATE = "defendant-judgment-by-admission-%s";

private final NotificationsProperties notificationsProperties;

protected JudgmentByAdmissionDefendantEmailDTOGenerator(NotificationsProperties notificationsProperties) {
this.notificationsProperties = notificationsProperties;
}

@Override
protected String getEmailTemplateId(CaseData caseData) {
return notificationsProperties.getNotifyDefendantLIPJudgmentByAdmissionTemplate();
}

@Override
protected String getReferenceTemplate() {
return REFERENCE_DEFENDANT_TEMPLATE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package uk.gov.hmcts.reform.civil.notification.handlers.judgmentbyadmission;

import uk.gov.hmcts.reform.civil.notification.handlers.CamundaProcessIdentifier;
import uk.gov.hmcts.reform.civil.notification.handlers.Notifier;
import uk.gov.hmcts.reform.civil.notify.NotificationService;
import uk.gov.hmcts.reform.civil.service.CaseTaskTrackingService;

import org.springframework.stereotype.Component;

@Component
public class JudgmentByAdmissionNotifier extends Notifier {

public JudgmentByAdmissionNotifier(
NotificationService notificationService,
CaseTaskTrackingService caseTaskTrackingService,
JudgmentByAdmissionAllPartiesEmailGenerator partiesGenerator
) {
super(notificationService, caseTaskTrackingService, partiesGenerator);
}

@Override
protected String getTaskId() {
return CamundaProcessIdentifier.JudgmentByAdmissionNotifier.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package uk.gov.hmcts.reform.civil.notification.handlers.judgmentbyadmission;

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

import uk.gov.hmcts.reform.civil.notification.handlers.AllPartiesEmailGenerator;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
class JudgmentByAdmissionAllPartiesEmailGeneratorTest {

@Mock
private JudgmentByAdmissionAppSolOneEmailDTOGenerator appSolOneEmailGenerator;

@Mock
private JudgmentByAdmissionDefendantEmailDTOGenerator defendantEmailDTOGenerator;

@InjectMocks
private JudgmentByAdmissionAllPartiesEmailGenerator emailGenerator;

@Test
void shouldDoJudgmentByAdmissionAllPartiesEmailGeneratorWithCorrectDependencies() {
assertThat(emailGenerator).isInstanceOf(AllPartiesEmailGenerator.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package uk.gov.hmcts.reform.civil.notification.handlers.judgmentbyadmission;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.IdamUserDetails;
import uk.gov.hmcts.reform.civil.notify.NotificationsProperties;
import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder;
import uk.gov.hmcts.reform.civil.service.OrganisationService;
import uk.gov.hmcts.reform.civil.utils.NotificationUtils;

import java.util.HashMap;
import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.CLAIM_LEGAL_ORG_NAME_SPEC;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.DEFENDANT_NAME;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.LEGAL_ORG_NAME;

@ExtendWith(MockitoExtension.class)
class JudgmentByAdmissionAppSolOneEmailDTOGeneratorTest {

private static final String TEMPLATE_ID = "judgment-by-admission-template-id";
private static final String APPLICANT_SOL_EMAIL = "appsol@example.com";
private static final String APPLICANT_LEGAL_ORG_NAME = "Applicant Legal Org";
private static final String DEFENDANT = "Defendant Name";

@Mock
private OrganisationService organisationService;

@Mock
private NotificationsProperties notificationsProperties;

private JudgmentByAdmissionAppSolOneEmailDTOGenerator generator;

@BeforeEach
void setUp() {
generator = new JudgmentByAdmissionAppSolOneEmailDTOGenerator(organisationService, notificationsProperties);
}

@Test
void shouldReturnCorrectReferenceTemplate() {
assertThat(generator.getReferenceTemplate()).isEqualTo("claimant-judgment-by-admission-%s");
}

@Test
void shouldReturnCorrectEmailTemplateId() {
CaseData caseData = CaseDataBuilder.builder().build();
when(notificationsProperties.getNotifyClaimantLRJudgmentByAdmissionTemplate()).thenReturn(TEMPLATE_ID);

assertThat(generator.getEmailTemplateId(caseData)).isEqualTo(TEMPLATE_ID);
}

@Test
void shouldReturnCorrectEmailAddress() {
CaseData caseData = CaseDataBuilder.builder()
.applicantSolicitor1UserDetails(new IdamUserDetails().setEmail(APPLICANT_SOL_EMAIL))
.build();

assertThat(generator.getEmailAddress(caseData)).isEqualTo(APPLICANT_SOL_EMAIL);
}

@Test
void shouldAddCustomProperties() {
CaseData caseData = CaseDataBuilder.builder().build();
Map<String, String> properties = new HashMap<>();

try (MockedStatic<NotificationUtils> notificationUtilsMockedStatic = Mockito.mockStatic(NotificationUtils.class)) {
notificationUtilsMockedStatic
.when(() -> NotificationUtils.getApplicantLegalOrganizationName(caseData, organisationService))
.thenReturn(APPLICANT_LEGAL_ORG_NAME);
notificationUtilsMockedStatic
.when(() -> NotificationUtils.getDefendantNameBasedOnCaseType(caseData))
.thenReturn(DEFENDANT);

Map<String, String> updated = generator.addCustomProperties(properties, caseData);

assertThat(updated).containsEntry(CLAIM_LEGAL_ORG_NAME_SPEC, APPLICANT_LEGAL_ORG_NAME);
assertThat(updated).containsEntry(LEGAL_ORG_NAME, APPLICANT_LEGAL_ORG_NAME);
assertThat(updated).containsEntry(DEFENDANT_NAME, DEFENDANT);
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package uk.gov.hmcts.reform.civil.notification.handlers.judgmentbyadmission;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.Party;
import uk.gov.hmcts.reform.civil.notify.NotificationsProperties;
import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;

@ExtendWith(MockitoExtension.class)
class JudgmentByAdmissionDefendantEmailDTOGeneratorTest {

private static final String TEMPLATE_ID = "defendant-judgment-by-admission-template-id";

@Mock
private NotificationsProperties notificationsProperties;

@InjectMocks
private JudgmentByAdmissionDefendantEmailDTOGenerator generator;

@Test
void shouldReturnCorrectReferenceTemplate() {
assertThat(generator.getReferenceTemplate()).isEqualTo("defendant-judgment-by-admission-%s");
}

@Test
void shouldReturnCorrectEmailTemplateId() {
CaseData caseData = CaseDataBuilder.builder().build();
when(notificationsProperties.getNotifyDefendantLIPJudgmentByAdmissionTemplate()).thenReturn(TEMPLATE_ID);

assertThat(generator.getEmailTemplateId(caseData)).isEqualTo(TEMPLATE_ID);
}

@Test
void shouldReturnRespondent1EmailAddress() {
CaseData caseData = CaseDataBuilder.builder()
.respondent1(new Party().setPartyEmail("defendant@example.com"))
.build();

assertThat(generator.getEmailAddress(caseData)).isEqualTo("defendant@example.com");
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package uk.gov.hmcts.reform.civil.notification.handlers.judgmentbyadmission;

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

import uk.gov.hmcts.reform.civil.notification.handlers.NotifierTestBase;

import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;

class JudgmentByAdmissionNotifierTest extends NotifierTestBase {

@InjectMocks
private JudgmentByAdmissionNotifier notifier;

@Test
void shouldReturnCorrectTaskId() {
String taskId = notifier.getTaskId();

assertThat(taskId).isEqualTo("JudgmentByAdmissionNotifier");
}
}
Loading