public async Task should_return_room_with_linked_participant() { var participant = _conference.Participants[0]; var participantB = _conference.Participants[1]; var emptyInterpreterRoom = new ParticipantRoom(_conference.Id, "Interpreter2", VirtualCourtRoomType.Civilian); emptyInterpreterRoom.SetProtectedProperty(nameof(emptyInterpreterRoom.Id), 2); var interpreterRoom = new ParticipantRoom(_conference.Id, "Interpreter3", VirtualCourtRoomType.Civilian); interpreterRoom.SetProtectedProperty(nameof(emptyInterpreterRoom.Id), 3); interpreterRoom.AddParticipant(new RoomParticipant(participantB.Id)); _mocker.Mock <IQueryHandler>().Setup(x => x.Handle <GetParticipantRoomsForConferenceQuery, List <ParticipantRoom> >(It.Is <GetParticipantRoomsForConferenceQuery>(q => q.ConferenceId == _conference.Id))) .ReturnsAsync(new List <ParticipantRoom> { emptyInterpreterRoom, interpreterRoom }); var room = await _service.GetOrCreateAnInterpreterVirtualRoom(_conference, participant); room.Should().NotBeNull(); room.Should().BeEquivalentTo(interpreterRoom); }
public void should_return_interpreter_when_participant_is_in_an_interpreter_room() { var conferenceId = Guid.NewGuid(); var participant = new ParticipantBuilder().WithUserRole(UserRole.Individual) .WithCaseTypeGroup("Applicant") .Build(); var consultationRoom = new ConsultationRoom(conferenceId, "ConsultationRoom1", VirtualCourtRoomType.Participant, false); consultationRoom.SetProtectedProperty(nameof(consultationRoom.Id), 998); var interpreterRoom = new ParticipantRoom(conferenceId, "Interpreter1", VirtualCourtRoomType.Civilian); interpreterRoom.SetProtectedProperty(nameof(interpreterRoom.Id), 999); var consultationRoomParticipant = new RoomParticipant(participant.Id) { Room = consultationRoom, RoomId = consultationRoom.Id }; var interpreterRoomParticipant = new RoomParticipant(participant.Id) { Room = interpreterRoom, RoomId = interpreterRoom.Id }; consultationRoom.AddParticipant(consultationRoomParticipant); interpreterRoom.AddParticipant(interpreterRoomParticipant); participant.RoomParticipants.Add(interpreterRoomParticipant); participant.RoomParticipants.Add(consultationRoomParticipant); participant.GetParticipantRoom().Should().Be(interpreterRoom); }
public async Task should_add_participant_to_interpreter_room() { var conference = await TestDataManager.SeedConference(); _newConferenceId = conference.Id; var interpreterRoom = new ParticipantRoom(_newConferenceId, "InterpreterRoom1", VirtualCourtRoomType.Witness); var rooms = await TestDataManager.SeedRooms(new[] { interpreterRoom }); interpreterRoom = (ParticipantRoom)rooms[0]; var participant = conference.Participants.First(x => x.UserRole == UserRole.Individual); var command = new AddParticipantToParticipantRoomCommand(interpreterRoom.Id, participant.Id); await _handler.Handle(command); await using var db = new VideoApiDbContext(VideoBookingsDbContextOptions); var updatedRoom = await db.Rooms.OfType <ParticipantRoom>().AsNoTracking() .Include(r => r.RoomParticipants) .SingleAsync(r => r.Id == interpreterRoom.Id); updatedRoom.RoomParticipants.Any(p => p.ParticipantId == participant.Id).Should().BeTrue(); var updatedParticipantFromDb = await db.Participants.Include(x => x.RoomParticipants).ThenInclude(x => x.Room).AsNoTracking() .SingleAsync(p => p.Id == participant.Id); updatedParticipantFromDb.RoomParticipants.Any(r => r.RoomId == interpreterRoom.Id).Should().BeTrue(); var updatedConference = await _conferenceByIdHandler.Handle(new GetConferenceByIdQuery(_newConferenceId)); var updatedParticipant = updatedConference.Participants.First(x => x.Id == participant.Id); updatedParticipant.GetParticipantRoom().Should().NotBeNull(); updatedParticipant.GetParticipantRoom().Id.Should().Be(interpreterRoom.Id); }
public async Task should_move_room_into_hearing_room() { var conferenceId = TestConference.Id; var participant = TestConference.Participants.First(x => x.UserRole == UserRole.Individual); var interpreterRoom = new ParticipantRoom(TestConference.Id, "Interpreter1", VirtualCourtRoomType.Civilian); interpreterRoom.SetProtectedProperty(nameof(interpreterRoom.Id), 999); var roomParticipant = new RoomParticipant(participant.Id) { Room = interpreterRoom, RoomId = interpreterRoom.Id }; interpreterRoom.AddParticipant(roomParticipant); participant.RoomParticipants.Add(roomParticipant); UpdateConferenceQueryMock(); var request = new TransferParticipantRequest { ParticipantId = participant.Id, TransferType = TransferType.Call }; var result = await Controller.TransferParticipantAsync(conferenceId, request); result.Should().BeOfType <AcceptedResult>(); VideoPlatformServiceMock.Verify( x => x.TransferParticipantAsync(conferenceId, interpreterRoom.Id.ToString(), RoomType.WaitingRoom.ToString(), RoomType.HearingRoom.ToString()), Times.Once); }
public void should_map_participant_to_response_wit_interpreter_room() { var consultationRoom = new ConsultationRoom(Guid.NewGuid(), "ParticipantRoom1", VirtualCourtRoomType.Participant, true); var participant = new ParticipantBuilder().WithUserRole(UserRole.Individual).Build(); participant.UpdateCurrentConsultationRoom(consultationRoom); var interpreterRoom = new ParticipantRoom(Guid.NewGuid(), "Interpreter1", VirtualCourtRoomType.Witness); var response = ParticipantToDetailsResponseMapper.MapParticipantToResponse(participant, interpreterRoom); response.Should().BeEquivalentTo(participant, options => options .Excluding(x => x.ParticipantRefId) .Excluding(x => x.TestCallResultId) .Excluding(x => x.TestCallResult) .Excluding(x => x.CurrentConsultationRoomId) .Excluding(x => x.CurrentConsultationRoom) .Excluding(x => x.CurrentRoom) .Excluding(x => x.State) .Excluding(x => x.LinkedParticipants) .Excluding(x => x.RoomParticipants)); response.CurrentInterpreterRoom.Should().NotBeNull(); response.CurrentInterpreterRoom.Id.Should().Be(interpreterRoom.Id); response.CurrentInterpreterRoom.Label.Should().Be(interpreterRoom.Label); response.CurrentInterpreterRoom.Locked.Should().BeFalse(); response.CurrentRoom.Should().NotBeNull(); response.CurrentRoom.Id.Should().Be(consultationRoom.Id); response.CurrentRoom.Label.Should().Be(consultationRoom.Label); response.CurrentRoom.Locked.Should().Be(consultationRoom.Locked); }
public async Task should_update_room_with_new_details() { var seededConference = await TestDataManager.SeedConference(); _newConferenceId = seededConference.Id; var room = new ParticipantRoom(_newConferenceId, VirtualCourtRoomType.Civilian); await TestDataManager.SeedRooms(new [] { room }); var label = "Interpreter1"; var ingestUrl = "dummyurl"; var node = "node"; var uri = "fakeuri"; var command = new UpdateParticipantRoomConnectionDetailsCommand(_newConferenceId, room.Id, label, ingestUrl, node, uri); await _handler.Handle(command); var roomId = command.RoomId; await using var db = new VideoApiDbContext(VideoBookingsDbContextOptions); var updatedRoom = await db.Rooms.OfType <ParticipantRoom>().AsNoTracking() .SingleAsync(c => c.Id == roomId); updatedRoom.Label.Should().Be(label); updatedRoom.IngestUrl.Should().Be(ingestUrl); updatedRoom.PexipNode.Should().Be(node); updatedRoom.ParticipantUri.Should().Be(uri); }
public async Task should_return_existing_judicial_officer_holder_room() { // arrange var existingInterpreterRoom = new ParticipantRoom(_conference.Id, "Interpreter2", VirtualCourtRoomType.Civilian); existingInterpreterRoom.SetProtectedProperty(nameof(existingInterpreterRoom.Id), 2); var existingJohRoom = new ParticipantRoom(_conference.Id, "PanelMember1", VirtualCourtRoomType.JudicialShared); existingJohRoom.SetProtectedProperty(nameof(existingJohRoom.Id), 1); var joh = _conference.Participants.First(x => x.UserRole == UserRole.JudicialOfficeHolder); _mocker.Mock <IQueryHandler>().Setup(x => x.Handle <GetParticipantRoomsForConferenceQuery, List <ParticipantRoom> >( It.Is <GetParticipantRoomsForConferenceQuery>(q => q.ConferenceId == _conference.Id))) .ReturnsAsync(new List <ParticipantRoom> { existingInterpreterRoom, existingJohRoom }); // act var room = await _service.GetOrCreateAJudicialVirtualRoom(_conference, joh); // assert room.Should().Be(existingJohRoom); }
private Task <ParticipantRoom> CreateRoom(Conference conference, Participant participant, VirtualCourtRoomType type, string label, string joinUri) { var ids = participant.LinkedParticipants.Select(x => x.Id).ToList(); ids.Add(participant.Id); foreach (var(key, value) in _rooms) { var roomParticipantIds = value.Select(x => x.Id); if (!roomParticipantIds.Any(rpid => ids.Contains(rpid))) { continue; } _rooms[key].Add(participant); return(Task.FromResult(key)); } var ingest = $"{conference.IngestUrl}/{_roomCount}"; var node = "sip.node.com"; var room = new ParticipantRoom(Guid.NewGuid(), type); room.UpdateConnectionDetails(label, ingest, node, joinUri); _roomCount++; _rooms.Add(room, new List <Participant> { participant }); return(Task.FromResult(room)); }
public static ParticipantDetailsResponse MapParticipantToResponse(Participant participant, ParticipantRoom participantRoom = null) { var participantRoomMapped = participantRoom == null ? null : RoomToDetailsResponseMapper.MapConsultationRoomToResponse(participantRoom); return(new ParticipantDetailsResponse { Id = participant.Id, RefId = participant.ParticipantRefId, Name = participant.Name, FirstName = participant.FirstName, LastName = participant.LastName, Username = participant.Username, DisplayName = participant.DisplayName, UserRole = participant.UserRole.MapToContractEnum(), HearingRole = participant.HearingRole, CaseTypeGroup = participant.CaseTypeGroup, Representee = participant.Representee, CurrentStatus = participant.State.MapToContractEnum(), ContactEmail = participant.ContactEmail, ContactTelephone = participant.ContactTelephone, LinkedParticipants = participant.LinkedParticipants .Select(LinkedParticipantToResponseMapper.MapLinkedParticipantsToResponse).ToList(), CurrentRoom = RoomToDetailsResponseMapper.MapConsultationRoomToResponse(participant.CurrentConsultationRoom), CurrentInterpreterRoom = participantRoomMapped }); }
public static CivilianRoomResponse MapToResponse(ParticipantRoom consultationRoom) { return(new CivilianRoomResponse { Id = consultationRoom.Id, Label = consultationRoom.Label, Participants = consultationRoom.RoomParticipants.Select(x => x.ParticipantId).ToList() }); }
public Task <ParticipantRoom> GetOrCreateAJudicialVirtualRoom(Conference conference, Participant participant) { var node = "sip.node.com"; var joinUri = "panelmember__waiting_room"; var room = new ParticipantRoom(conference.Id, VirtualCourtRoomType.JudicialShared); room.UpdateConnectionDetails("PanelMemberRoom1", null, node, joinUri); return(Task.FromResult(room)); }
public async Task GivenIHaveACivilianInterpreterRoom() { var conference = _context.Test.Conference; var interpreterRoom = new ParticipantRoom(conference.Id, $"InterpreterRoom{DateTime.UtcNow.Ticks}", VirtualCourtRoomType.Civilian); var seedRooms = await _context.TestDataManager.SeedRooms(new [] { interpreterRoom }); _context.Test.Room = seedRooms.First(); }
public async Task should_create_vmr_with_kinly_if_room_is_not_available() { var expectedRoomId = 2; var participant = _conference.Participants.First(x => !x.IsJudge()); var expectedRoom = new ParticipantRoom(_conference.Id, VirtualCourtRoomType.Witness); expectedRoom.SetProtectedProperty(nameof(expectedRoom.Id), expectedRoomId); var newVmrRoom = new BookedParticipantRoomResponse { Room_label = "Interpreter2", Uris = new Uris { Participant = "wertyui__interpreter", Pexip_node = "test.node.com" } }; _mocker.Mock <IQueryHandler>().SetupSequence(x => x.Handle <GetParticipantRoomsForConferenceQuery, List <ParticipantRoom> >(It.Is <GetParticipantRoomsForConferenceQuery>(q => q.ConferenceId == _conference.Id))) .ReturnsAsync(new List <ParticipantRoom>()) .ReturnsAsync(new List <ParticipantRoom> { expectedRoom }); _mocker.Mock <ICommandHandler>().Setup(x => x.Handle(It.IsAny <CreateParticipantRoomCommand>())).Callback <CreateParticipantRoomCommand>(command => { command.SetProtectedProperty(nameof(command.NewRoomId), expectedRoomId); }); _mocker.Mock <ICommandHandler>().Setup(x => x.Handle(It.IsAny <UpdateParticipantRoomConnectionDetailsCommand>())).Callback(() => expectedRoom.UpdateConnectionDetails(newVmrRoom.Room_label, "ingesturl", newVmrRoom.Uris.Pexip_node, newVmrRoom.Uris.Participant)); _mocker.Mock <IKinlyApiClient>().Setup(x => x.CreateParticipantRoomAsync(_conference.Id.ToString(), It.Is <CreateParticipantRoomParams>(vmrRequest => vmrRequest.Participant_type == "Witness"))) .ReturnsAsync(newVmrRoom); var room = await _service.GetOrCreateAWitnessVirtualRoom(_conference, participant); room.Should().NotBeNull(); room.Label.Should().Be(newVmrRoom.Room_label); room.PexipNode.Should().Be(newVmrRoom.Uris.Pexip_node); room.ParticipantUri.Should().Be(newVmrRoom.Uris.Participant); _mocker.Mock <IKinlyApiClient>().Verify(x => x.CreateParticipantRoomAsync(_conference.Id.ToString(), It.Is <CreateParticipantRoomParams>(createParams => createParams.Room_label_prefix == "Interpreter" && createParams.Participant_type == "Witness" && createParams.Participant_room_id == expectedRoomId.ToString() )), Times.Once); }
public static SharedParticipantRoomResponse MapRoomToResponse(ParticipantRoom consultationRoom) { return(new SharedParticipantRoomResponse { Label = consultationRoom.Label, ParticipantJoinUri = consultationRoom.ParticipantUri, PexipNode = consultationRoom.PexipNode, RoomType = Enum.Parse <VirtualCourtRoomType>(consultationRoom.Type.ToString(), true) }); }
public async Task Handle(CreateParticipantRoomCommand command) { var conference = await _context.Conferences.SingleOrDefaultAsync(x => x.Id == command.ConferenceId); if (conference == null) { throw new ConferenceNotFoundException(command.ConferenceId); } var room = new ParticipantRoom(command.ConferenceId, command.Type); _context.Rooms.Add(room); await _context.SaveChangesAsync(); command.NewRoomId = room.Id; }
public void Setup() { _mocker = AutoMock.GetLoose(); _service = _mocker.Create <VirtualRoomService>(); _conference = InitConference(); var emptyWitnessInterpreterRoom = new ParticipantRoom(_conference.Id, "Interpreter1", VirtualCourtRoomType.Witness); emptyWitnessInterpreterRoom.SetProtectedProperty(nameof(emptyWitnessInterpreterRoom.Id), 1); _mocker.Mock <IQueryHandler>().Setup(x => x.Handle <GetParticipantRoomsForConferenceQuery, List <ParticipantRoom> >(It.Is <GetParticipantRoomsForConferenceQuery>(q => q.ConferenceId == _conference.Id))) .ReturnsAsync(new List <ParticipantRoom> { emptyWitnessInterpreterRoom }); }
private async Task SetupRoomWithParticipant(Conference conference) { var interpreterRoom = new ParticipantRoom(_newConferenceId, "InterpreterRoom1", VirtualCourtRoomType.Witness); var rooms = await TestDataManager.SeedRooms(new[] { interpreterRoom }); _room = (ParticipantRoom)rooms[0]; var participant = conference.Participants.First(x => x.UserRole == UserRole.Individual); await using var db = new VideoApiDbContext(VideoBookingsDbContextOptions); var room = await db.Rooms.OfType <ParticipantRoom>() .Include(r => r.RoomParticipants) .SingleAsync(r => r.Id == _room.Id); room.AddParticipant(new RoomParticipant(participant.Id)); await db.SaveChangesAsync(); _room = room; }
public async Task GivenIHaveACivilianInterpreterRoomWithAParticipant() { var conference = _context.Test.Conference; var participant = conference.Participants.First(x => x.UserRole == UserRole.Individual); var interpreterRoom = new ParticipantRoom(conference.Id, $"InterpreterRoom{DateTime.UtcNow.Ticks}", VirtualCourtRoomType.Civilian); interpreterRoom.AddParticipant(new RoomParticipant(participant.Id)); var seedRooms = await _context.TestDataManager.SeedRooms(new [] { interpreterRoom }); _context.Test.Room = seedRooms.First(); await using var db = new VideoApiDbContext(_context.VideoBookingsDbContextOptions); var dbParticipant = db.Participants.First(x => x.Id == participant.Id); dbParticipant.UpdateCurrentRoom(RoomType.WaitingRoom); await db.SaveChangesAsync(); }
public void should_update_room_connection_details() { var room = new ParticipantRoom(Guid.NewGuid(), VirtualCourtRoomType.Civilian); room.Label.Should().BeNull(); var label = "Interpreter1"; var ingestUrl = $"rtmps://hostserver/hearingId1/hearingId1/{room.Id}"; var node = "sip.test.com"; var participantUri = "env-foo-interpeterroom"; room.UpdateConnectionDetails(label, ingestUrl, node, participantUri); room.Label.Should().Be(label); room.IngestUrl.Should().Be(ingestUrl); room.PexipNode.Should().Be(node); room.ParticipantUri.Should().Be(participantUri); }
public async Task should_use_interpreter_room_when_participant_is_in_an_interpreter_room_on_leave() { var fromRoom = "ParticipantConsultationRoom1"; var toRoom = RoomType.WaitingRoom.ToString(); var participant = TestConference.Participants.First(x => x.Id.Equals(_request.RequestedBy)); var interpreterRoom = new ParticipantRoom(TestConference.Id, "Interpreter1", VirtualCourtRoomType.Civilian); interpreterRoom.SetProtectedProperty(nameof(interpreterRoom.Id), 999); var roomParticipant = new RoomParticipant(participant.Id) { Room = interpreterRoom, RoomId = interpreterRoom.Id }; interpreterRoom.AddParticipant(roomParticipant); participant.RoomParticipants.Add(roomParticipant); _queryHandler.Setup(x => x.Handle <GetConferenceByIdQuery, Conference>(It.IsAny <GetConferenceByIdQuery>())) .ReturnsAsync(TestConference); await _consultationService.LeaveConsultationAsync(_request.ConferenceId, participant.Id, fromRoom, toRoom); var request = new TransferParticipantParams { From = fromRoom, To = toRoom, Part_id = interpreterRoom.Id.ToString() }; _kinlyApiClient.Verify(x => x.TransferParticipantAsync(It.Is <string>( y => y.Equals(_request.ConferenceId.ToString())), It.Is <TransferParticipantParams>( y => y.From.Equals(request.From) && y.To.Equals(request.To) && y.Part_id.Equals(request.Part_id))), Times.Once); }
public async Task should_create_a_judicial_officer_holder_room_if_one_does_not_exist() { // arrange var expectedRoomId = 2937; var existingInterpreterRoom = new ParticipantRoom(_conference.Id, "Interpreter2", VirtualCourtRoomType.Civilian); existingInterpreterRoom.SetProtectedProperty(nameof(existingInterpreterRoom.Id), 9999); var expectedJohRoom = new ParticipantRoom(_conference.Id, "PanelMember1", VirtualCourtRoomType.JudicialShared); expectedJohRoom.SetProtectedProperty(nameof(expectedJohRoom.Id), expectedRoomId); var newVmrRoom = new BookedParticipantRoomResponse { Room_label = "PanelMember1", Uris = new Uris { Participant = "wertyui__panelmember", Pexip_node = "test.node.com" } }; var joh = _conference.Participants.First(x => x.UserRole == UserRole.JudicialOfficeHolder); _mocker.Mock <IQueryHandler>().SetupSequence(x => x.Handle <GetParticipantRoomsForConferenceQuery, List <ParticipantRoom> >( It.Is <GetParticipantRoomsForConferenceQuery>(q => q.ConferenceId == _conference.Id))) .ReturnsAsync(new List <ParticipantRoom> { existingInterpreterRoom }) .ReturnsAsync(new List <ParticipantRoom> { existingInterpreterRoom, expectedJohRoom }); _mocker.Mock <ICommandHandler>().Setup(x => x.Handle(It.IsAny <CreateParticipantRoomCommand>())).Callback <CreateParticipantRoomCommand>(command => { command.SetProtectedProperty(nameof(command.NewRoomId), expectedRoomId); }); _mocker.Mock <ICommandHandler>().Setup(x => x.Handle(It.IsAny <UpdateParticipantRoomConnectionDetailsCommand>())).Callback(() => expectedJohRoom.UpdateConnectionDetails(newVmrRoom.Room_label, null, newVmrRoom.Uris.Pexip_node, newVmrRoom.Uris.Participant)); _mocker.Mock <IKinlyApiClient>().Setup(x => x.CreateParticipantRoomAsync(_conference.Id.ToString(), It.Is <CreateParticipantRoomParams>(vmrRequest => vmrRequest.Room_type == KinlyRoomType.Panel_Member))) .ReturnsAsync(newVmrRoom); // act var room = await _service.GetOrCreateAJudicialVirtualRoom(_conference, joh); // assert room.Should().NotBeNull(); room.Label.Should().Be(newVmrRoom.Room_label); room.PexipNode.Should().Be(newVmrRoom.Uris.Pexip_node); room.ParticipantUri.Should().Be(newVmrRoom.Uris.Participant); _mocker.Mock <IKinlyApiClient>().Verify(x => x.CreateParticipantRoomAsync(_conference.Id.ToString(), It.Is <CreateParticipantRoomParams>(createParams => createParams.Room_label_prefix == "Panel Member" && createParams.Participant_type == "Civilian" && createParams.Room_type == KinlyRoomType.Panel_Member && createParams.Participant_room_id == expectedRoomId.ToString() && createParams.Audio_recording_url == string.Empty )), Times.Once); }
public static ParticipantSummaryResponse MapParticipantToSummary(Participant participant, ParticipantRoom participantRoom = null) { var interpreterRoomMapped = participantRoom == null ? null : RoomToDetailsResponseMapper.MapConsultationRoomToResponse(participantRoom); var participantStatus = participant.GetCurrentStatus() != null ? participant.GetCurrentStatus().ParticipantState : ParticipantState.None; var caseGroup = participant.CaseTypeGroup ?? string.Empty; var links = participant.LinkedParticipants.Select(LinkedParticipantToResponseMapper.MapLinkedParticipantsToResponse) .ToList(); return(new ParticipantSummaryResponse { Id = participant.Id, Username = participant.Username, DisplayName = participant.DisplayName, Status = participantStatus.MapToContractEnum(), UserRole = participant.UserRole.MapToContractEnum(), HearingRole = participant.HearingRole, Representee = participant.Representee, CaseGroup = caseGroup, FirstName = participant.FirstName, LastName = participant.LastName, ContactEmail = participant.ContactEmail, ContactTelephone = participant.ContactTelephone, CurrentRoom = RoomToDetailsResponseMapper.MapConsultationRoomToResponse(participant.CurrentConsultationRoom), LinkedParticipants = links, CurrentInterpreterRoom = interpreterRoomMapped }); }