コード例 #1
0
        public static void HearingDetailsResponse(HearingDetailsResponse response, CreateHearingRequest request)
        {
            response.AudioRecordingRequired.Should().Be(request.AudioRecordingRequired);
            response.CancelReason.Should().BeNull();
            response.CaseTypeName.Should().Be(request.CaseType);
            response.Cases.First().Name.Should().Contain(request.TestType.ToString());
            response.Cases.First().Number.Should().NotBeNullOrWhiteSpace();
            response.Cases.First().IsLeadCase.Should().Be(HearingData.IS_LEAD_CASE);
            response.ConfirmedBy.Should().BeNull();
            response.ConfirmedDate.Should().BeNull();
            VerifyCreatedBy(response, request);
            response.CreatedDate.Should().BeCloseTo(DateTime.UtcNow, TimeSpan.FromSeconds(30));
            response.HearingRoomName.Should().Be(HearingData.HEARING_ROOM_NAME);

            response.HearingTypeName.Should().Be(request.CaseType.Equals(HearingData.CASE_TYPE_NAME)
                ? HearingData.HEARING_TYPE_NAME
                : HearingData.CACD_HEARING_TYPE_NAME);

            response.HearingVenueName.Should().Be(request.Venue);
            response.Id.Should().NotBeEmpty();
            response.OtherInformation.Should().Be(HearingData.OTHER_INFORMATION);
            var expectedCount = UsersIncludeCaseAdminOrVho(request.Users) ? request.Users.Count - 1 : request.Users.Count;

            response.Participants.Count.Should().Be(expectedCount);
            response.QuestionnaireNotRequired.Should().Be(request.QuestionnaireNotRequired);
            response.ScheduledDateTime.Should().Be(request.ScheduledDateTime);
            response.ScheduledDuration.Should().Be(HearingData.SCHEDULED_DURATION);
            response.Status.Should().Be(BookingStatus.Booked);
            response.UpdatedBy.Should().BeNull();
            response.UpdatedDate.Should().BeCloseTo(DateTime.UtcNow, TimeSpan.FromSeconds(30));
            VerifyHearingParticipants(response.Participants, request.Users);
        }
コード例 #2
0
 private static void VerifyCreatedBy(HearingDetailsResponse response, CreateHearingRequest request)
 {
     response.CreatedBy.Should().Be(
         UsersIncludeCaseAdminOrVho(request.Users)
             ? request.Users.First(x =>
                                   x.UserType == UserType.CaseAdmin || x.UserType == UserType.VideoHearingsOfficer).Username
             : UserData.DEFAULT_CREATED_BY_USER);
 }
コード例 #3
0
 public BookHearingRequestBuilder(CreateHearingRequest createHearingRequest)
 {
     _request = new BookNewHearingRequest
     {
         CaseTypeName = createHearingRequest.CaseType,
         Cases        = new List <CaseRequest>(),
         Participants = new List <ParticipantRequest>()
     };
     _createHearingRequest = createHearingRequest;
     _randomNumber         = new Random();
 }
コード例 #4
0
 public HearingRequestBuilder()
 {
     _request = new CreateHearingRequest()
     {
         Application              = Application.AdminWeb,
         AudioRecordingRequired   = false,
         QuestionnaireNotRequired = false,
         ScheduledDateTime        = DateTime.UtcNow.AddHours(1),
         TestType = TestType.Automated,
         Users    = new List <UserDto>(),
         Venue    = DEFAULT_VENUE
     };
 }
コード例 #5
0
 public HearingRequestBuilder()
 {
     _request = new CreateHearingRequest()
     {
         Application            = Application.VideoWeb,
         AudioRecordingRequired = false,
         CaseType = CASE_TYPE_NAME,
         QuestionnaireNotRequired = true,
         ScheduledDateTime        = DateTime.UtcNow,
         TestType = TestType.Automated,
         Users    = new List <UserDto>(),
         Venue    = DEFAULT_VENUE
     };
 }
コード例 #6
0
ファイル: DataSetupSteps.cs プロジェクト: lulzzz/vh-video-web
        private void SendTheHearingRequest(CreateHearingRequest request)
        {
            var hearingResponse = _c.Apis.TestApi.CreateHearing(request);

            hearingResponse.StatusCode.Should().Be(HttpStatusCode.Created,
                                                   $"Hearing not created with error '{hearingResponse.Content}'");
            var hearing = RequestHelper.Deserialise <HearingDetailsResponse>(hearingResponse.Content);

            hearing.Should().NotBeNull();
            _c.Test.Hearing             = hearing;
            _c.Test.NewHearingId        = hearing.Id;
            _c.Test.Case                = hearing.Cases.First();
            _c.Test.HearingParticipants = hearing.Participants;
            NUnit.Framework.TestContext.WriteLine($"Hearing created with Hearing Id {hearing.Id}");
        }
コード例 #7
0
 public HearingBuilder(List <UserDto> users)
 {
     _request = new CreateHearingRequest
     {
         Application            = Application.TestApi,
         AudioRecordingRequired = HearingData.AUDIO_RECORDING_REQUIRED,
         CaseType  = HearingData.CASE_TYPE_NAME,
         Endpoints = HearingData.NUMBER_OF_ENDPOINTS,
         QuestionnaireNotRequired = HearingData.QUESTIONNAIRE_NOT_REQUIRED,
         ScheduledDateTime        = DateTime.UtcNow,
         TestType = TestType.Automated,
         Users    = users,
         Venue    = HearingData.VENUE_NAME
     };
 }
コード例 #8
0
        protected async Task <HearingDetailsResponse> CreateHearing(CreateHearingRequest request)
        {
            var uri = ApiUriFactory.HearingEndpoints.CreateHearing;

            await SendPostRequest(uri, RequestHelper.Serialise(request));

            VerifyResponse(HttpStatusCode.Created, true);

            var response = RequestHelper.Deserialise <HearingDetailsResponse>(Json);

            response.Should().NotBeNull();

            HearingsToDelete.Add(response);

            return(response);
        }
コード例 #9
0
        public async Task <IActionResult> CreateHearing(CreateHearingRequest request)
        {
            _logger.LogDebug("CreateHearing");

            try
            {
                var response = await _testApiClient.CreateHearingAsync(request);

                _logger.LogDebug($"New Hearing Created with id {response.Id}");
                return(Created(nameof(CreateHearing), response));
            }
            catch (TestApiException e)
            {
                _logger.LogError(e, "Unable to create hearing with error '{message}'", e.Message);
                return(StatusCode(e.StatusCode, e.Response));
            }
        }
コード例 #10
0
ファイル: DataSetUp.cs プロジェクト: abitec/vh-service-web
        public void CreateNewHearingRequest(TestContext testContext)
        {
            var requestBody = CreateHearingRequest.BuildRequest(testContext.TestUserSecrets.Individual, testContext.TestUserSecrets.Representative);

            testContext.Request  = testContext.Post("/hearings", requestBody);
            testContext.Response = testContext.Client().Execute(testContext.Request);
            testContext.Response.StatusCode.Should().Be(HttpStatusCode.Created);
            var model = ApiRequestHelper.DeserialiseSnakeCaseJsonToResponse <HearingDetailsResponse>(testContext.Response.Content);

            testContext.HearingId = model.Id.ToString();
            var individual = model.Participants.Single(p => p.Username.Equals(testContext.TestUserSecrets.Individual));

            testContext.IndividualParticipantId = individual.Id.ToString();
            var representative = model.Participants.Single(p => p.Username.Equals(testContext.TestUserSecrets.Representative));

            testContext.RepresentativeParticipantId = representative.Id.ToString();
        }
コード例 #11
0
        public async Task <IActionResult> CreateHearing(CreateHearingRequest request)
        {
            _logger.LogDebug("CreateHearing");

            var bookHearingRequest = new BookHearingRequestBuilder(request).Build();

            try
            {
                var response = await _bookingsApiClient.BookNewHearingAsync(bookHearingRequest);

                _logger.LogDebug("New Hearing Created with id {id}", response.Id);

                return(CreatedAtAction(nameof(CreateHearing), new { hearingId = response.Id }, response));
            }
            catch (BookingsApiException e)
            {
                return(StatusCode(e.StatusCode, e.Response));
            }
        }
コード例 #12
0
        public CreateHearingRequestBuilder()
        {
            var judge          = new UserBuilder().Judge().Build();
            var individual     = new UserBuilder().Individual().Build();
            var representative = new UserBuilder().Representative().Build();
            var users          = new List <UserDto>()
            {
                judge, individual, representative
            };

            _request = new CreateHearingRequest()
            {
                AudioRecordingRequired = HearingsData.AUDIO_RECORDING_REQUIRED,
                Application            = HearingsData.APPLICATION,
                CaseType = HearingsData.CASE_TYPE,
                QuestionnaireNotRequired = HearingsData.QUESTIONNAIRE_NOT_REQUIRED,
                ScheduledDateTime        = DateTime.UtcNow,
                TestType = HearingsData.TEST_TYPE,
                Users    = users,
                Venue    = HearingsData.VENUE
            };
        }
コード例 #13
0
 public HearingsResponseBuilder(CreateHearingRequest request)
 {
     _response = new HearingDetailsResponse()
     {
         AudioRecordingRequired = request.AudioRecordingRequired,
         CancelReason           = null,
         CaseTypeName           = request.CaseType,
         Cases = new List <CaseResponse>()
         {
             new CaseResponse()
             {
                 IsLeadCase = HearingsData.IS_LEAD_CASE,
                 Name       = HearingsData.CASE_NAME,
                 Number     = HearingsData.CASE_NUMBER
             }
         },
         ConfirmedBy      = null,
         ConfirmedDate    = null,
         CreatedBy        = HearingsData.CREATED_BY,
         CreatedDate      = DateTime.UtcNow,
         Endpoints        = new List <EndpointResponse>(),
         GroupId          = null,
         HearingRoomName  = HearingsData.HEARING_ROOM_NAME,
         HearingTypeName  = HearingsData.HEARING_TYPE_NAME,
         HearingVenueName = request.Venue,
         Id = Guid.NewGuid(),
         OtherInformation         = HearingsData.OTHER_INFORMATION,
         Status                   = HearingsData.HEARING_STATUS,
         QuestionnaireNotRequired = request.QuestionnaireNotRequired,
         ScheduledDateTime        = request.ScheduledDateTime,
         ScheduledDuration        = HearingsData.SCHEDULED_DURATION,
         UpdatedBy                = HearingsData.UPDATED_BY,
         UpdatedDate              = DateTime.UtcNow
     };
     SetTheParticipants(request.Users);
 }
コード例 #14
0
 public GetAllHearingsControllerTests()
 {
     _loggerMock = new Mock <ILogger <HearingsController> >();
     _request    = new CreateHearingRequestBuilder().Build();
 }