private static HearingIsReadyForVideoIntegrationEvent CreateEvent()
        {
            var hearingDto = new HearingDto
            {
                HearingId         = Guid.NewGuid(),
                CaseNumber        = "Test1234",
                CaseType          = "Generic",
                CaseName          = "Automated Case vs Humans",
                ScheduledDuration = 60,
                ScheduledDateTime = DateTime.UtcNow,
                HearingVenueName  = "MyVenue",
                RecordAudio       = true
            };
            var participants = Builder <ParticipantDto> .CreateListOfSize(4)
                               .All().With(x => x.UserRole = UserRole.Individual.ToString()).Build().ToList();

            var endpoints = Builder <EndpointDto> .CreateListOfSize(4).Build().ToList();

            var message = new HearingIsReadyForVideoIntegrationEvent
            {
                Hearing      = hearingDto,
                Participants = participants,
                Endpoints    = endpoints
            };

            return(message);
        }
        public void should_load_handler_for_message()
        {
            var messageHandlerFactory = (IMessageHandlerFactory)ServiceProviderFactory.ServiceProvider.GetService(typeof(IMessageHandlerFactory));
            var integrationEvent      = new HearingIsReadyForVideoIntegrationEvent();
            var handler = messageHandlerFactory.Get(integrationEvent);

            handler.Should().BeOfType <HearingReadyForVideoHandler>();
        }
Exemple #3
0
        public async Task <IActionResult> UpdateBookingStatus(Guid hearingId, UpdateBookingStatusRequest updateBookingStatusRequest)
        {
            if (hearingId == Guid.Empty)
            {
                ModelState.AddModelError(nameof(hearingId), $"Please provide a valid {nameof(hearingId)}");
                return(BadRequest(ModelState));
            }

            var result = new UpdateBookingStatusRequestValidation().Validate(updateBookingStatusRequest);

            if (!result.IsValid)
            {
                ModelState.AddFluentValidationErrors(result.Errors);
                return(BadRequest(ModelState));
            }

            try
            {
                var bookingStatus = MapUpdateBookingStatus(updateBookingStatusRequest.Status);
                var command       = new UpdateHearingStatusCommand(hearingId, bookingStatus, updateBookingStatusRequest.UpdatedBy,
                                                                   updateBookingStatusRequest.CancelReason);
                await _commandHandler.Handle(command);

                switch (bookingStatus)
                {
                case BookingStatus.Booked:
                    break;

                case BookingStatus.Created:
                    var queriedVideoHearing = await GetHearingToPublish(hearingId);

                    var createVideoHearingEvent = new HearingIsReadyForVideoIntegrationEvent(queriedVideoHearing);
                    await _eventPublisher.PublishAsync(createVideoHearingEvent);

                    break;

                case BookingStatus.Cancelled:
                    await _eventPublisher.PublishAsync(new HearingCancelledIntegrationEvent(hearingId));

                    break;

                default:
                    break;
                }

                return(NoContent());
            }
            catch (HearingNotFoundException)
            {
                return(NotFound());
            }
            catch (DomainRuleException exception)
            {
                exception.ValidationFailures.ForEach(x => ModelState.AddModelError(x.Name, x.Message));
                return(Conflict(ModelState));
            }
        }
        public void Should_publish_message_to_queue_when_HearingIsReadyForVideoIntegrationEvent_is_raised()
        {
            var hearing = new VideoHearingBuilder().Build();

            hearing.CaseType = new CaseType(1, "test");
            hearing.AddCase("1234", "test", true);
            var individuals = hearing.GetParticipants().Where(x => x is Individual).ToList();

            var individual1 = individuals.First();

            individual1.HearingRole = new HearingRole(1, "Claimant LIP")
            {
                UserRole = new UserRole(1, "Individual")
            };
            individual1.CaseRole = new CaseRole(1, "test");

            var individual2 = individuals.Last();

            individual2.HearingRole = new HearingRole(2, "Defendant LIP")
            {
                UserRole = new UserRole(1, "Individual")
            };
            individual2.CaseRole = new CaseRole(2, "test2");

            var representative = hearing.GetParticipants().Single(x => x is Representative);

            representative.HearingRole = new HearingRole(5, "Representative")
            {
                UserRole = new UserRole(2, "Representative")
            };
            representative.CaseRole = new CaseRole(3, "test3");

            var judge = hearing.GetParticipants().Single(x => x is Judge);

            judge.HearingRole = new HearingRole(5, "Judge")
            {
                UserRole = new UserRole(2, "Judge")
            };
            judge.CaseRole = new CaseRole(3, "test4");

            var hearingIsReadyForVideoIntegrationEvent = new HearingIsReadyForVideoIntegrationEvent(hearing);

            _eventPublisher.PublishAsync(hearingIsReadyForVideoIntegrationEvent);

            _serviceBusQueueClient.Count.Should().Be(1);
            var @event = _serviceBusQueueClient.ReadMessageFromQueue();

            @event.IntegrationEvent.Should().BeOfType <HearingIsReadyForVideoIntegrationEvent>();
            var typedEvent = (HearingIsReadyForVideoIntegrationEvent)@event.IntegrationEvent;

            typedEvent.Hearing.RecordAudio.Should().Be(hearing.AudioRecordingRequired);
            typedEvent.Participants.Count.Should().Be(hearing.GetParticipants().Count);
        }
Exemple #5
0
        public void Should_publish_message_to_queue_when_HearingIsReadyForVideoIntegrationEvent_is_raised()
        {
            var hearing = new VideoHearingBuilder().Build();

            hearing.CaseType = new CaseType(1, "test");
            hearing.AddCase("1234", "test", true);
            var individuals = hearing.GetParticipants().Where(x => x is Individual).ToList();

            var individual1 = individuals.First();

            individual1.CaseRole = new CaseRole(1, "test");

            var individual2 = individuals.Last();

            individual2.CaseRole = new CaseRole(2, "test2");

            var representative = hearing.GetParticipants().Single(x => x is Representative);

            representative.CaseRole = new CaseRole(3, "test3");

            var judge = hearing.GetParticipants().Single(x => x is Judge);

            judge.CaseRole = new CaseRole(3, "test4");

            var joh = hearing.GetParticipants().Single(x => x is JudicialOfficeHolder);

            joh.CaseRole = new CaseRole(4, "test5");
            var staffMember = hearing.GetParticipants().Single(x => x is StaffMember);

            staffMember.CaseRole = new CaseRole(5, "test5");

            hearing.AddEndpoints(new List <Endpoint>
            {
                new Endpoint("one", Guid.NewGuid().ToString(), "1234", null),
                new Endpoint("two", Guid.NewGuid().ToString(), "1234", representative)
            });

            var hearingIsReadyForVideoIntegrationEvent = new HearingIsReadyForVideoIntegrationEvent(hearing);

            _eventPublisher.PublishAsync(hearingIsReadyForVideoIntegrationEvent);

            _serviceBusQueueClient.Count.Should().Be(1);
            var @event = _serviceBusQueueClient.ReadMessageFromQueue();

            @event.IntegrationEvent.Should().BeOfType <HearingIsReadyForVideoIntegrationEvent>();
            var typedEvent = (HearingIsReadyForVideoIntegrationEvent)@event.IntegrationEvent;

            typedEvent.Hearing.RecordAudio.Should().Be(hearing.AudioRecordingRequired);
            typedEvent.Participants.Count.Should().Be(hearing.GetParticipants().Count);
            typedEvent.Endpoints.Should().NotBeNull();
            typedEvent.Endpoints.Count.Should().Be(hearing.GetEndpoints().Count);
        }