Skip to content

Commit

Permalink
VIH-9905 add new professional templates (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
shaed-parkar authored Nov 15, 2023
1 parent a698f31 commit 88f5cf3
Show file tree
Hide file tree
Showing 16 changed files with 428 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ public class GetTemplateTests : AcApiTest
[TestCase(NotificationType.ExistingUserLipConfirmationMultiDay)]
[TestCase(NotificationType.NewHearingReminderLipSingleDay)]
[TestCase(NotificationType.NewHearingReminderLipMultiDay)]
[TestCase(NotificationType.NewUserRepresentativeWelcome)]
[TestCase(NotificationType.NewUserRepresentativeConfirmation)]
[TestCase(NotificationType.NewUserRepresentativeConfirmationMultiDay)]
[TestCase(NotificationType.ExistingUserRepresentativeConfirmation)]
[TestCase(NotificationType.ExistingUserRepresentativeConfirmationMultiDay)]
[TestCase(NotificationType.NewHearingReminderRepresentativeSingleDay)]
[TestCase(NotificationType.NewHearingReminderRepresentativeMultiDay)]
public async Task should_return_okay_and_template(NotificationType notificationType)
{
// act
Expand All @@ -64,6 +71,8 @@ public async Task should_return_okay_and_template(NotificationType notificationT
response.Parameters.Should().NotBeNullOrWhiteSpace();
response.NotifyTemplateId.Should().NotBeEmpty();
response.Id.Should().BePositive();
var notifyTemplate = await NotifyClient.GetTemplateByIdAsync(response.NotifyTemplateId.ToString());
notifyTemplate.Should().NotBeNull();
}
}
}
9 changes: 8 additions & 1 deletion NotificationApi/NotificationApi.Contract/NotificationType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ public enum NotificationType
ExistingUserLipConfirmation = 44,
ExistingUserLipConfirmationMultiDay = 45,
NewHearingReminderLipSingleDay = 46,
NewHearingReminderLipMultiDay = 47
NewHearingReminderLipMultiDay = 47,
NewUserRepresentativeWelcome = 48,
NewUserRepresentativeConfirmation = 49,
NewUserRepresentativeConfirmationMultiDay = 50,
ExistingUserRepresentativeConfirmation = 51,
ExistingUserRepresentativeConfirmationMultiDay = 52,
NewHearingReminderRepresentativeSingleDay = 53,
NewHearingReminderRepresentativeMultiDay = 54,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,4 @@ public class MultiDayHearingReminderRequest
/// The total number of days in the multi-day booking
/// </summary>
public int TotalDays { get; set; }

/// <summary>
/// The name of the person the participant is representing (if applicable)
/// </summary>
public string Representee { get; set; }
}
72 changes: 72 additions & 0 deletions NotificationApi/NotificationApi.DAL/TemplateDataForEnvironments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,42 @@ private static Template CreateTemplate(string guid, NotificationType notificatio
MessageType.Email,
$"{NotifyParams.DayMonthYear},{NotifyParams.StartTime},{NotifyParams.Name},{NotifyParams.CaseName},{NotifyParams.CaseNumber},{NotifyParams.NumberOfDays},{NotifyParams.UserName},{NotifyParams.DayMonthYearCy}")
},
/////////////////////////////////////////////////////// New Professional Templates
{
CreateTemplate("e9257299-49f2-4d9e-a123-335fdb1863d5", NotificationType.NewUserRepresentativeWelcome,
MessageType.Email, $"{NotifyParams.Name},{NotifyParams.CaseName},{NotifyParams.CaseNumber}")
},
{
CreateTemplate("3fc658e9-d689-4b99-9905-960247ece1c8", NotificationType.NewUserRepresentativeConfirmation,
MessageType.Email, $"{NotifyParams.Name},{NotifyParams.CaseName},{NotifyParams.CaseNumber},{NotifyParams.DayMonthYear},{NotifyParams.StartTime},{NotifyParams.UserName},{NotifyParams.RandomPassword},{NotifyParams.DayMonthYearCy}")
},
{
CreateTemplate("fac7d1ea-c863-491a-80d6-e0d7db67e040",
NotificationType.NewUserRepresentativeConfirmationMultiDay,
MessageType.Email, $"{NotifyParams.DayMonthYear},{NotifyParams.StartTime},{NotifyParams.Name},{NotifyParams.CaseName},{NotifyParams.CaseNumber},{NotifyParams.NumberOfDays},{NotifyParams.UserName},{NotifyParams.RandomPassword},{NotifyParams.DayMonthYearCy}")
},
{
CreateTemplate("bd64e5d2-610f-449a-a925-3db10f913019",
NotificationType.ExistingUserRepresentativeConfirmation,
MessageType.Email, $"{NotifyParams.Name},{NotifyParams.CaseName},{NotifyParams.CaseNumber},{NotifyParams.DayMonthYear},{NotifyParams.StartTime},{NotifyParams.UserName},{NotifyParams.DayMonthYearCy}")
},
{
CreateTemplate("bc278f80-69a5-4e91-a0ef-4bfe2a52796e",
NotificationType.ExistingUserRepresentativeConfirmationMultiDay,
MessageType.Email, $"{NotifyParams.Name},{NotifyParams.CaseName},{NotifyParams.CaseNumber},{NotifyParams.DayMonthYear},{NotifyParams.StartTime},{NotifyParams.UserName},{NotifyParams.DayMonthYearCy},{NotifyParams.NumberOfDays}")
},
{
CreateTemplate("cf7b6b30-a702-4542-9d5c-7471fe232ff8",
NotificationType.NewHearingReminderRepresentativeSingleDay,
MessageType.Email,
$"{NotifyParams.DayMonthYear},{NotifyParams.StartTime},{NotifyParams.Name},{NotifyParams.CaseName},{NotifyParams.CaseNumber},{NotifyParams.UserName},{NotifyParams.DayMonthYearCy}")
},
{
CreateTemplate("b465577c-af10-46eb-a94f-97b7d31eb86a",
NotificationType.NewHearingReminderRepresentativeMultiDay,
MessageType.Email,
$"{NotifyParams.DayMonthYear},{NotifyParams.StartTime},{NotifyParams.Name},{NotifyParams.CaseName},{NotifyParams.CaseNumber},{NotifyParams.NumberOfDays},{NotifyParams.UserName},{NotifyParams.DayMonthYearCy}")
}
};

private readonly IList<Template> _sourceTemplatesProd = new List<Template>()
Expand Down Expand Up @@ -460,6 +496,42 @@ private static Template CreateTemplate(string guid, NotificationType notificatio
MessageType.Email,
$"{NotifyParams.DayMonthYear},{NotifyParams.StartTime},{NotifyParams.Name},{NotifyParams.CaseName},{NotifyParams.CaseNumber},{NotifyParams.NumberOfDays},{NotifyParams.UserName},{NotifyParams.DayMonthYearCy}")
},
/////////////////////////////////////////////////////// New Professional Templates
{
CreateTemplate("479a46ca-2716-403a-9cc3-f6f607b57d33", NotificationType.NewUserRepresentativeWelcome,
MessageType.Email, $"{NotifyParams.Name},{NotifyParams.CaseName},{NotifyParams.CaseNumber}")
},
{
CreateTemplate("46c8f6cf-a475-4711-a5bc-2ed80a152334", NotificationType.NewUserRepresentativeConfirmation,
MessageType.Email, $"{NotifyParams.Name},{NotifyParams.CaseName},{NotifyParams.CaseNumber},{NotifyParams.DayMonthYear},{NotifyParams.StartTime},{NotifyParams.UserName},{NotifyParams.RandomPassword},{NotifyParams.DayMonthYearCy}")
},
{
CreateTemplate("2420bcc4-7c35-435c-bfa5-76d83f852854",
NotificationType.NewUserRepresentativeConfirmationMultiDay,
MessageType.Email, $"{NotifyParams.DayMonthYear},{NotifyParams.StartTime},{NotifyParams.Name},{NotifyParams.CaseName},{NotifyParams.CaseNumber},{NotifyParams.NumberOfDays},{NotifyParams.UserName},{NotifyParams.RandomPassword},{NotifyParams.DayMonthYearCy}")
},
{
CreateTemplate("4229a74a-c7e8-4f64-95b1-969dfc85d9c8",
NotificationType.ExistingUserRepresentativeConfirmation,
MessageType.Email, $"{NotifyParams.Name},{NotifyParams.CaseName},{NotifyParams.CaseNumber},{NotifyParams.DayMonthYear},{NotifyParams.StartTime},{NotifyParams.UserName},{NotifyParams.DayMonthYearCy}")
},
{
CreateTemplate("88c51941-534d-4bf0-bd87-b0bca634de3c",
NotificationType.ExistingUserRepresentativeConfirmationMultiDay,
MessageType.Email, $"{NotifyParams.Name},{NotifyParams.CaseName},{NotifyParams.CaseNumber},{NotifyParams.DayMonthYear},{NotifyParams.StartTime},{NotifyParams.UserName},{NotifyParams.DayMonthYearCy},{NotifyParams.NumberOfDays}")
},
{
CreateTemplate("0aa67776-a45b-478a-b0c1-16e4a474b2f6",
NotificationType.NewHearingReminderRepresentativeSingleDay,
MessageType.Email,
$"{NotifyParams.DayMonthYear},{NotifyParams.StartTime},{NotifyParams.Name},{NotifyParams.CaseName},{NotifyParams.CaseNumber},{NotifyParams.UserName},{NotifyParams.DayMonthYearCy}")
},
{
CreateTemplate("606827d7-3714-447b-a6c2-ae457e6a0823",
NotificationType.NewHearingReminderRepresentativeMultiDay,
MessageType.Email,
$"{NotifyParams.DayMonthYear},{NotifyParams.StartTime},{NotifyParams.Name},{NotifyParams.CaseName},{NotifyParams.CaseNumber},{NotifyParams.NumberOfDays},{NotifyParams.UserName},{NotifyParams.DayMonthYearCy}")
}
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ public enum NotificationType
ExistingUserLipConfirmation = 44,
ExistingUserLipConfirmationMultiDay = 45,
NewHearingReminderLipSingleDay = 46,
NewHearingReminderLipMultiDay = 47
NewHearingReminderLipMultiDay = 47,
NewUserRepresentativeWelcome = 48,
NewUserRepresentativeConfirmation = 49,
NewUserRepresentativeConfirmationMultiDay = 50,
ExistingUserRepresentativeConfirmation = 51,
ExistingUserRepresentativeConfirmationMultiDay = 52,
NewHearingReminderRepresentativeSingleDay = 53,
NewHearingReminderRepresentativeMultiDay = 54,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public async Task should_not_send_a_multi_day_reminder_email_for_a_judiciary_off
}

[Test]
public async Task should_not_send_multi_day_reminder_email_for_a_representative()
public async Task should_send_a_multi_day_reminder_email_for_a_representative()
{
// arrange
var request = new MultiDayHearingReminderRequest()
Expand All @@ -92,7 +92,16 @@ public async Task should_not_send_multi_day_reminder_email_for_a_representative(
ApiUriFactory.ParticipantNotificationEndpoints.SendMultiDayHearingReminderEmail, RequestBody.Set(request));

// assert
result.IsSuccessStatusCode.Should().BeFalse(result.Content.ReadAsStringAsync().Result);
result.IsSuccessStatusCode.Should().BeTrue(result.Content.ReadAsStringAsync().Result);

var notifications = await TestDataManager.GetNotifications(request.HearingId,
request.ParticipantId, Domain.Enums.NotificationType.NewHearingReminderRepresentativeMultiDay,
request.ContactEmail);
notifications.Count.Should().Be(1);
_notifyStub.SentEmails.Count.Should().Be(1);
_notifyStub.SentEmails.Exists(x => x.EmailAddress == request.ContactEmail
&& x.ExternalRefId == notifications[0].ExternalId
).Should().BeTrue();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ public async Task should_send_a_multi_day_confirmation_email_for_a_judiciary_jud
}

[Test]
public async Task should_send_a_multi_day_confirmation_email_for_a_representative()
public async Task should_send_a_multi_day_confirmation_email_for_a_representative_feature_toggle_off()
{
// arrange
_featureToggleStub!.UseNew2023Templates = false;
var request = new ExistingUserMultiDayHearingConfirmationRequest
{
RoleName = RoleNames.Representative,
Expand Down Expand Up @@ -202,6 +203,44 @@ public async Task should_send_a_multi_day_confirmation_email_for_a_representativ
).Should().BeTrue();
}

[Test]
public async Task should_send_a_multi_day_confirmation_email_for_a_representative_feature_toggle_on()
{
// arrange
_featureToggleStub!.UseNew2023Templates = true;
var request = new ExistingUserMultiDayHearingConfirmationRequest
{
RoleName = RoleNames.Representative,
Name = $"{Faker.Name.FullName()}",
CaseNumber = $"{Faker.RandomNumber.Next()}",
CaseName = $"{Faker.RandomNumber.Next()}",
HearingId = Guid.NewGuid(),
ParticipantId = Guid.NewGuid(),
ContactEmail = $"{Guid.NewGuid()}@intautomation.com",
Username = $"{Guid.NewGuid()}@intautomation.com",
ScheduledDateTime = DateTime.UtcNow.AddDays(1),
Representee = $"{Faker.Name.FullName()}",
TotalDays = 3
};

// act
using var client = Application.CreateClient();
var result = await client.PostAsync(
ApiUriFactory.ParticipantNotificationEndpoints.SendParticipantMultiDayHearingConfirmationForExistingUserEmail, RequestBody.Set(request));

// assert
result.IsSuccessStatusCode.Should().BeTrue(result.Content.ReadAsStringAsync().Result);

var notifications = await TestDataManager.GetNotifications(request.HearingId.Value,
request.ParticipantId.Value, Domain.Enums.NotificationType.ExistingUserRepresentativeConfirmationMultiDay,
request.ContactEmail);
notifications.Count.Should().Be(1);
_notifyStub.SentEmails.Count.Should().Be(1);
_notifyStub.SentEmails.Exists(x => x.EmailAddress == request.ContactEmail
&& x.ExternalRefId == notifications[0].ExternalId
).Should().BeTrue();
}

[Test]
public async Task should_send_a_multi_day_confirmation_email_for_a_lip_feature_toggle_off()
{
Expand Down Expand Up @@ -230,7 +269,7 @@ public async Task should_send_a_multi_day_confirmation_email_for_a_lip_feature_t
result.IsSuccessStatusCode.Should().BeTrue(result.Content.ReadAsStringAsync().Result);

var notifications = await TestDataManager.GetNotifications(request.HearingId.Value, request.ParticipantId.Value,
(Domain.Enums.NotificationType) Contract.NotificationType.HearingConfirmationLipMultiDay,
Domain.Enums.NotificationType.HearingConfirmationLipMultiDay,
request.ContactEmail);
notifications.Count.Should().Be(1);
_notifyStub.SentEmails.Count.Should().Be(1);
Expand Down Expand Up @@ -267,7 +306,7 @@ public async Task should_send_a_multi_day_confirmation_email_for_a_lip_feature_t
result.IsSuccessStatusCode.Should().BeTrue(result.Content.ReadAsStringAsync().Result);

var notifications = await TestDataManager.GetNotifications(request.HearingId.Value, request.ParticipantId.Value,
(Domain.Enums.NotificationType) Contract.NotificationType.ExistingUserLipConfirmationMultiDay,
Domain.Enums.NotificationType.ExistingUserLipConfirmationMultiDay,
request.ContactEmail);
notifications.Count.Should().Be(1);
_notifyStub.SentEmails.Count.Should().Be(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,24 @@ public void Setup()
_notifyStub!.SentEmails.Clear();
}

[TestCase(RoleNames.Representative)]
[TestCase(RoleNames.Judge)]
[TestCase(RoleNames.JudicialOfficeHolder)]
public async Task should_not_send_a_confirmation_email_for_a(string roleName)
{
// arrange
var request = new NewUserMultiDayHearingConfirmationRequest()
{
RoleName = roleName
RoleName = roleName,
Name = $"{Faker.Name.FullName()}",
CaseNumber = $"{Faker.RandomNumber.Next()}",
CaseName = $"{Faker.RandomNumber.Next()}",
HearingId = Guid.NewGuid(),
ParticipantId = Guid.NewGuid(),
ContactEmail = $"{Guid.NewGuid()}@intautomation.com",
Username = $"{Guid.NewGuid()}@intautomation.com",
RandomPassword = "12345678dusausyd",
ScheduledDateTime = DateTime.UtcNow.AddDays(1),
TotalDays = 1
};

// act
Expand All @@ -32,15 +41,14 @@ public async Task should_not_send_a_confirmation_email_for_a(string roleName)
result.IsSuccessStatusCode.Should().BeFalse();
result.StatusCode.Should().Be(HttpStatusCode.BadRequest);
var validationProblemDetails = await ApiClientResponse.GetResponses<ValidationProblemDetails>(result.Content);
validationProblemDetails.Errors[$"{nameof(request.CaseName)}"].ToList()
.Exists(errorMessage => errorMessage.Contains("must not be empty")).Should().BeTrue();
validationProblemDetails.Errors[$"{nameof(request.RoleName)}"].Should().Contain(NewUserMultiDayHearingConfirmationRequestValidation.UnsupportedRoleMessage);
validationProblemDetails.Errors["request"].ToList()
.Exists(errorMessage => errorMessage.Contains("Role is not supported")).Should().BeTrue();

_notifyStub.SentEmails.Count.Should().Be(0);
}

[Test]
public async Task should_send_a_confirmation_email_for_a_lip()
public async Task should_send_a_multi_day_confirmation_email_for_a_new_lip()
{
// arrange
var request = new NewUserMultiDayHearingConfirmationRequest()
Expand All @@ -67,7 +75,44 @@ public async Task should_send_a_confirmation_email_for_a_lip()
result.IsSuccessStatusCode.Should().BeTrue(result.Content.ReadAsStringAsync().Result);

var notifications = await TestDataManager.GetNotifications(request.HearingId.Value, request.ParticipantId.Value,
(Domain.Enums.NotificationType) Contract.NotificationType.NewUserLipConfirmationMultiDay,
Domain.Enums.NotificationType.NewUserLipConfirmationMultiDay,
request.ContactEmail);
notifications.Count.Should().Be(1);
_notifyStub.SentEmails.Count.Should().Be(1);
_notifyStub.SentEmails.Exists(x => x.EmailAddress == request.ContactEmail
&& x.ExternalRefId == notifications[0].ExternalId
).Should().BeTrue();
}

[Test]
public async Task should_send_a_multi_day_confirmation_email_for_a_new_representative()
{
// arrange
var request = new NewUserMultiDayHearingConfirmationRequest()
{
RoleName = RoleNames.Representative,
Name = $"{Faker.Name.FullName()}",
CaseNumber = $"{Faker.RandomNumber.Next()}",
CaseName = $"{Faker.RandomNumber.Next()}",
HearingId = Guid.NewGuid(),
ParticipantId = Guid.NewGuid(),
ContactEmail = $"{Guid.NewGuid()}@intautomation.com",
Username = $"{Guid.NewGuid()}@intautomation.com",
RandomPassword = "12345678dusausyd",
ScheduledDateTime = DateTime.UtcNow.AddDays(1),
TotalDays = 1
};

// act
using var client = Application.CreateClient();
var result = await client.PostAsync(
ApiUriFactory.ParticipantNotificationEndpoints.SendParticipantMultiDayHearingConfirmationForNewUserEmail, RequestBody.Set(request));

// assert
result.IsSuccessStatusCode.Should().BeTrue(result.Content.ReadAsStringAsync().Result);

var notifications = await TestDataManager.GetNotifications(request.HearingId.Value, request.ParticipantId.Value,
Domain.Enums.NotificationType.NewUserRepresentativeConfirmationMultiDay,
request.ContactEmail);
notifications.Count.Should().Be(1);
_notifyStub.SentEmails.Count.Should().Be(1);
Expand Down
Loading

0 comments on commit 88f5cf3

Please sign in to comment.