-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VIH-10218 Fix for UpdateParticipantDetails Command parameters overwri…
…te hearing and case type (#607) * Fix for prod issue, where null parameters overwrite hearing and case role values * Tidy up
- Loading branch information
1 parent
a8c6578
commit fd3f94b
Showing
3 changed files
with
98 additions
and
35 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
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 |
---|---|---|
|
@@ -65,7 +65,8 @@ public async Task Should_update_participant_details() | |
var participant = seededConference.GetParticipants().First(); | ||
|
||
var command = new UpdateParticipantDetailsCommand(_newConferenceId, participant.Id, "fullname", "firstName", | ||
"lastName", "displayname", String.Empty, "[email protected]", "0123456789", new List<LinkedParticipantDto>(), | ||
"lastName", "displayname", String.Empty, "[email protected]", "0123456789", | ||
new List<LinkedParticipantDto>(), | ||
UserRole.Individual, "Litigant in person", "Applicant"); | ||
await _handler.Handle(command); | ||
|
||
|
@@ -88,30 +89,30 @@ public async Task Should_update_participant_details() | |
|
||
updatedParticipant.UpdatedAt.Should().BeAfter(updatedParticipant.CreatedAt.Value); | ||
} | ||
|
||
[Test] | ||
public async Task Should_update_participant_details_and_linked_participants() | ||
{ | ||
var conference = new ConferenceBuilder(true, null, DateTime.UtcNow.AddMinutes(5)) | ||
.WithConferenceStatus(ConferenceState.InSession) | ||
.Build(); | ||
|
||
var participantA = new ParticipantBuilder(true).Build(); | ||
var participantB = new ParticipantBuilder(true).Build(); | ||
var participantC = new ParticipantBuilder(true).Build(); | ||
|
||
participantA.LinkedParticipants.Add(new LinkedParticipant(participantA.Id, participantB.Id, LinkedParticipantType.Interpreter)); | ||
participantB.LinkedParticipants.Add(new LinkedParticipant(participantB.Id, participantA.Id, LinkedParticipantType.Interpreter)); | ||
|
||
conference.AddParticipant(participantA); | ||
conference.AddParticipant(participantB); | ||
conference.Participants.Add(participantC); | ||
|
||
var seededConference = await TestDataManager.SeedConference(conference); | ||
|
||
TestContext.WriteLine($"New seeded conference id: {seededConference.Id}"); | ||
_newConferenceId = seededConference.Id; | ||
|
||
var participant = seededConference.GetParticipants().First(); | ||
|
||
var newLinkedParticipants = new List<LinkedParticipantDto>() | ||
|
@@ -129,11 +130,11 @@ public async Task Should_update_participant_details_and_linked_participants() | |
Type = LinkedParticipantType.Interpreter | ||
} | ||
}; | ||
|
||
var command = new UpdateParticipantDetailsCommand(_newConferenceId, participant.Id, "fullname", "firstName", | ||
"lastName", "displayname", String.Empty, "[email protected]", "0123456789", newLinkedParticipants, | ||
UserRole.Individual, "Litigant in person", "Applicant"); | ||
|
||
await _handler.Handle(command); | ||
|
||
var updatedConference = await _conferenceByIdHandler.Handle(new GetConferenceByIdQuery(_newConferenceId)); | ||
|
@@ -156,7 +157,8 @@ public async Task Should_update_participant_details_and_linked_participants() | |
} | ||
|
||
[Test] | ||
public async Task Should_update_participant_details_and_linked_participants_When_linked_participant_only_on_one_participant() | ||
public async Task | ||
Should_update_participant_details_and_linked_participants_When_linked_participant_only_on_one_participant() | ||
{ | ||
var conference = new ConferenceBuilder(true, null, DateTime.UtcNow.AddMinutes(5)) | ||
.WithConferenceStatus(ConferenceState.InSession) | ||
|
@@ -166,7 +168,8 @@ public async Task Should_update_participant_details_and_linked_participants_When | |
var participantB = new ParticipantBuilder(true).Build(); | ||
var participantC = new ParticipantBuilder(true).Build(); | ||
|
||
participantA.LinkedParticipants.Add(new LinkedParticipant(participantA.Id, participantB.Id, LinkedParticipantType.Interpreter)); | ||
participantA.LinkedParticipants.Add(new LinkedParticipant(participantA.Id, participantB.Id, | ||
LinkedParticipantType.Interpreter)); | ||
|
||
conference.AddParticipant(participantA); | ||
conference.AddParticipant(participantB); | ||
|
@@ -213,35 +216,37 @@ public async Task Should_update_participant_details_and_linked_participants_When | |
updatedParticipantC.LinkedParticipants.Should().NotContain(x => x.LinkedId == participantB.Id); | ||
updatedParticipantC.LinkedParticipants.Should().Contain(x => x.LinkedId == participantA.Id); | ||
} | ||
|
||
[Test] | ||
public async Task Should_throw_participant_link_exception_when_id_doesnt_match() | ||
{ | ||
var conference = new ConferenceBuilder(true, null, DateTime.UtcNow.AddMinutes(5)) | ||
.WithConferenceStatus(ConferenceState.InSession) | ||
.Build(); | ||
|
||
var participantA = new ParticipantBuilder(true).Build(); | ||
var participantB = new ParticipantBuilder(true).Build(); | ||
var participantC = new ParticipantBuilder(true).Build(); | ||
|
||
participantA.LinkedParticipants.Add(new LinkedParticipant(participantA.Id, participantB.Id, LinkedParticipantType.Interpreter)); | ||
participantB.LinkedParticipants.Add(new LinkedParticipant(participantB.Id, participantA.Id, LinkedParticipantType.Interpreter)); | ||
|
||
participantA.LinkedParticipants.Add(new LinkedParticipant(participantA.Id, participantB.Id, | ||
LinkedParticipantType.Interpreter)); | ||
participantB.LinkedParticipants.Add(new LinkedParticipant(participantB.Id, participantA.Id, | ||
LinkedParticipantType.Interpreter)); | ||
|
||
conference.AddParticipant(participantA); | ||
conference.AddParticipant(participantB); | ||
conference.Participants.Add(participantC); | ||
|
||
var seededConference = await TestDataManager.SeedConference(conference); | ||
|
||
TestContext.WriteLine($"New seeded conference id: {seededConference.Id}"); | ||
_newConferenceId = seededConference.Id; | ||
|
||
var participant = seededConference.GetParticipants().First(); | ||
|
||
var fakeIdA = Guid.NewGuid(); | ||
var fakeIdC = Guid.NewGuid(); | ||
|
||
var newLinkedParticipants = new List<LinkedParticipantDto>() | ||
{ | ||
new LinkedParticipantDto() | ||
|
@@ -257,16 +262,16 @@ public async Task Should_throw_participant_link_exception_when_id_doesnt_match() | |
Type = LinkedParticipantType.Interpreter | ||
} | ||
}; | ||
|
||
var command = new UpdateParticipantDetailsCommand(_newConferenceId, participant.Id, "fullname", "firstName", | ||
"lastName", "displayname", String.Empty, "[email protected]", "0123456789", newLinkedParticipants, | ||
UserRole.Individual, "Litigant in person", "Applicant"); | ||
|
||
var exception = Assert.ThrowsAsync<ParticipantLinkException>(() => _handler.Handle(command)); | ||
exception.LinkRefId.Should().Be(participantA.ParticipantRefId); | ||
exception.ParticipantRefId.Should().Be(fakeIdC); | ||
} | ||
|
||
[Test] | ||
public async Task Should_update_participant_username_when_provided() | ||
{ | ||
|
@@ -276,7 +281,8 @@ public async Task Should_update_participant_username_when_provided() | |
var participant = seededConference.GetParticipants().First(); | ||
|
||
var command = new UpdateParticipantDetailsCommand(_newConferenceId, participant.Id, "fullname", "firstName", | ||
"lastName", "displayname", String.Empty, "[email protected]", "0123456789", new List<LinkedParticipantDto>(), | ||
"lastName", "displayname", String.Empty, "[email protected]", "0123456789", | ||
new List<LinkedParticipantDto>(), | ||
UserRole.Individual, "Litigant in person", "Applicant") | ||
{ | ||
Username = "[email protected]" | ||
|
@@ -302,6 +308,44 @@ public async Task Should_update_participant_username_when_provided() | |
} | ||
} | ||
|
||
[Test] | ||
public async Task Update_participant_details_when_case_hearing_user_role_properties_are_null() | ||
{ | ||
|
||
var seededConference = await TestDataManager.SeedConference(); | ||
|
||
_newConferenceId = seededConference.Id; | ||
var judge = seededConference.GetParticipants().First(e => e.HearingRole == "Judge"); | ||
|
||
var command = new UpdateParticipantDetailsCommand(_newConferenceId, judge.Id, "fullname", "firstName", | ||
"lastName", "displayname", String.Empty, "[email protected]", "0123456789", new List<LinkedParticipantDto>(), | ||
UserRole.None, null, null); | ||
|
||
await _handler.Handle(command); | ||
|
||
var updatedConference = await _conferenceByIdHandler.Handle(new GetConferenceByIdQuery(_newConferenceId)); | ||
var updatedJudge = | ||
updatedConference.GetParticipants().Single(x => x.Id == judge.Id); | ||
|
||
if (updatedJudge is Participant updatedParticipantCasted) | ||
{ | ||
//userRole assertion | ||
updatedParticipantCasted.UserRole.Should().NotBe(UserRole.None); | ||
updatedParticipantCasted.UserRole.Should().Be(judge.UserRole); | ||
|
||
//HearingRole assertion | ||
updatedParticipantCasted.HearingRole.Should().NotBeNullOrEmpty(); | ||
updatedParticipantCasted.HearingRole.Should().Be(judge.HearingRole); | ||
|
||
//HearingRole assertion | ||
updatedParticipantCasted.CaseTypeGroup.Should().NotBeNullOrEmpty(); | ||
} | ||
else | ||
{ | ||
Assert.Fail("Participant is not of type Participant"); | ||
} | ||
|
||
} | ||
|
||
[TearDown] | ||
public async Task TearDown() | ||
|
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