Exemplo n.º 1
0
        public async Task GetOverviewViewModel_with_clarifications_returns_model()
        {
            var applyData = new ApplyData
            {
                ApplyDetails = new ApplyDetails
                {
                    UKPRN            = Ukprn,
                    OrganisationName = OrganisationName
                }
            };

            var returnedRoatpApplicationResponse = new Apply
            {
                ApplicationId       = _applicationId,
                ApplyData           = applyData,
                GatewayReviewStatus = GatewayReviewStatus.InProgress
            };

            var contactDetails = new ContactDetails {
                Email = Email
            };

            _applyApiClient.Setup(x => x.GetApplication(_applicationId)).ReturnsAsync(returnedRoatpApplicationResponse);
            _applyApiClient.Setup(x => x.GetContactDetails(_applicationId)).ReturnsAsync(contactDetails);
            _applyApiClient.Setup(x => x.GetOversightDetails(_applicationId)).ReturnsAsync(() =>
                                                                                           new ApplicationOversightDetails {
                OversightStatus = OversightReviewStatus.None
            });

            const string sectionReviewStatus = SectionReviewStatus.Clarification;
            const string comment             = "comments go here";

            var returnedGatewayPageAnswers = new List <GatewayPageAnswerSummary>
            {
                new GatewayPageAnswerSummary
                {
                    ApplicationId = _applicationId,
                    PageId        = GatewayPageIds.OrganisationRisk,
                    Status        = sectionReviewStatus,
                    Comments      = comment
                }
            };

            _applyApiClient.Setup(x => x.GetGatewayPageAnswers(_applicationId)).ReturnsAsync(returnedGatewayPageAnswers);

            var gatewayReviewStatus = GatewayReviewStatus.InProgress;
            var request             = new GetApplicationOverviewRequest(_applicationId, UserName);

            var viewModel = await _orchestrator.GetOverviewViewModel(request);

            Assert.AreEqual(_applicationId, viewModel.ApplicationId);
            Assert.AreEqual(viewModel.ApplicationEmailAddress, Email);
            Assert.AreEqual(Ukprn, viewModel.Ukprn);
            Assert.AreEqual(OrganisationName, viewModel.OrganisationName);
            Assert.AreEqual(gatewayReviewStatus, viewModel.GatewayReviewStatus);
            Assert.AreEqual(sectionReviewStatus, viewModel.Sequences.FirstOrDefault(seq => seq.SequenceNumber == 1).Sections.FirstOrDefault(sec => sec.PageId == GatewayPageIds.OrganisationRisk).Status);
            Assert.AreEqual(false, viewModel.IsClarificationsSelectedAndAllFieldsSet);
            Assert.AreEqual(false, viewModel.ReadyToConfirm);
        }
        public async Task GetConfirmOverviewViewModel_returns_model(string ukprn, string organisationName, string sectionReviewStatus, string comment, bool isClarificationSet)
        {
            var applicationId       = Guid.NewGuid();
            var gatewayReviewStatus = GatewayReviewStatus.InProgress;

            var applyData = new ApplyData
            {
                ApplyDetails = new ApplyDetails
                {
                    UKPRN            = ukprn,
                    OrganisationName = organisationName
                }
            };

            var application = new Apply
            {
                ApplicationId       = applicationId,
                ApplyData           = applyData,
                GatewayReviewStatus = GatewayReviewStatus.InProgress
            };

            _applyApiClient.Setup(x => x.GetApplication(applicationId)).ReturnsAsync(application);
            _applyApiClient.Setup(x => x.GetOversightDetails(applicationId)).ReturnsAsync(() =>
                                                                                          new ApplicationOversightDetails {
                OversightStatus = OversightReviewStatus.None
            });

            var returnedGatewayPageAnswers = new List <GatewayPageAnswerSummary>
            {
                new GatewayPageAnswerSummary
                {
                    ApplicationId = applicationId,
                    PageId        = GatewayPageIds.OrganisationRisk,
                    Status        = sectionReviewStatus,
                    Comments      = comment
                }
            };

            _applyApiClient.Setup(x => x.GetGatewayPageAnswers(applicationId)).ReturnsAsync(returnedGatewayPageAnswers);

            var request = new GetApplicationOverviewRequest(applicationId, UserName);

            var viewModel = await _orchestrator.GetConfirmOverviewViewModel(request);

            Assert.AreEqual(applicationId, viewModel.ApplicationId);
            Assert.AreEqual(ukprn, viewModel.Ukprn);
            Assert.AreEqual(organisationName, viewModel.OrganisationName);
            Assert.AreEqual(gatewayReviewStatus, viewModel.GatewayReviewStatus);
            Assert.AreEqual(sectionReviewStatus, viewModel.Sequences.FirstOrDefault(seq => seq.SequenceNumber == 1).Sections.FirstOrDefault(sec => sec.PageId == GatewayPageIds.OrganisationRisk).Status);
            Assert.AreEqual(comment, viewModel.Sequences.FirstOrDefault(seq => seq.SequenceNumber == 1).Sections.FirstOrDefault(sec => sec.PageId == GatewayPageIds.OrganisationRisk).Comment);
            Assert.AreEqual(viewModel.IsClarificationsSelectedAndAllFieldsSet, isClarificationSet);
        }
Exemplo n.º 3
0
        public async Task <RoatpGatewayApplicationViewModel> GetOverviewViewModel(GetApplicationOverviewRequest request)
        {
            var application = await _applyApiClient.GetApplication(request.ApplicationId);

            if (application is null)
            {
                return(null);
            }

            var oversightDetails = await _applyApiClient.GetOversightDetails(request.ApplicationId);

            var contact = await _applyApiClient.GetContactDetails(request.ApplicationId);

            var viewmodel = new RoatpGatewayApplicationViewModel(application, oversightDetails)
            {
                ApplicationEmailAddress = contact?.Email,
                Sequences = GetCoreGatewayApplicationViewModel()
            };

            var savedStatuses = await _applyApiClient.GetGatewayPageAnswers(request.ApplicationId);

            if (savedStatuses != null && !savedStatuses.Any())
            {
                var providerRoute = application.ApplyData.ApplyDetails.ProviderRoute;
                await _sectionsNotRequiredService.SetupNotRequiredLinks(request.ApplicationId, request.UserName, viewmodel, providerRoute);
            }
            else
            {
                foreach (var currentStatus in savedStatuses ?? new List <GatewayPageAnswerSummary>())
                {
                    // Inject the statuses and comments into viewmodel
                    viewmodel.Sequences.SelectMany(seq => seq.Sections).FirstOrDefault(sec => sec.PageId == currentStatus.PageId).Status  = currentStatus?.Status;
                    viewmodel.Sequences.SelectMany(seq => seq.Sections).FirstOrDefault(sec => sec.PageId == currentStatus.PageId).Comment = currentStatus?.Comments;
                }
            }

            var sections = viewmodel.Sequences.SelectMany(seq => seq.Sections);

            viewmodel.IsClarificationsSelectedAndAllFieldsSet = IsAskForClarificationActive(sections);
            viewmodel.ReadyToConfirm = IsReadyToConfirm(sections);

            return(viewmodel);
        }
        public async Task GetConfirmOverviewViewModel_returns_model_no_saved_statuses(string ukprn, string organisationName)
        {
            var applicationId       = Guid.NewGuid();
            var gatewayReviewStatus = GatewayReviewStatus.InProgress;

            var applyData = new ApplyData
            {
                ApplyDetails = new ApplyDetails
                {
                    UKPRN            = ukprn,
                    OrganisationName = organisationName
                }
            };

            var application = new Apply
            {
                ApplicationId       = applicationId,
                ApplyData           = applyData,
                GatewayReviewStatus = GatewayReviewStatus.InProgress
            };

            _applyApiClient.Setup(x => x.GetApplication(applicationId)).ReturnsAsync(application);
            _applyApiClient.Setup(x => x.GetOversightDetails(applicationId)).ReturnsAsync(() =>
                                                                                          new ApplicationOversightDetails {
                OversightStatus = OversightReviewStatus.None
            });

            // No Saved Statuses
            var returnedGatewayPageAnswers = new List <GatewayPageAnswerSummary>();

            _applyApiClient.Setup(x => x.GetGatewayPageAnswers(applicationId)).ReturnsAsync(returnedGatewayPageAnswers);

            var request = new GetApplicationOverviewRequest(applicationId, UserName);

            var viewModel = await _orchestrator.GetConfirmOverviewViewModel(request);

            viewModel.ApplicationId.Should().Be(applicationId);
            viewModel.Ukprn.Should().Be(ukprn);
            viewModel.OrganisationName.Should().Be(organisationName);
            viewModel.GatewayReviewStatus.Should().Be(gatewayReviewStatus);
            viewModel.ReadyToConfirm.Should().Be(false);
        }
Exemplo n.º 5
0
        public async Task <RoatpGatewayApplicationViewModel> GetConfirmOverviewViewModel(GetApplicationOverviewRequest request)
        {
            var application = await _applyApiClient.GetApplication(request.ApplicationId);

            if (application is null)
            {
                return(null);
            }

            var oversightDetails = await _applyApiClient.GetOversightDetails(request.ApplicationId);

            var viewmodel = new RoatpGatewayApplicationViewModel(application, oversightDetails)
            {
                Sequences = GetCoreGatewayApplicationViewModel()
            };

            var savedStatuses = await _applyApiClient.GetGatewayPageAnswers(request.ApplicationId);

            if (savedStatuses != null && !savedStatuses.Any())
            {
                viewmodel.ReadyToConfirm = false;
                return(viewmodel);
            }
            else
            {
                foreach (var currentStatus in savedStatuses ?? new List <GatewayPageAnswerSummary>())
                {
                    // Inject the statuses and comments into viewmodel
                    viewmodel.Sequences.SelectMany(seq => seq.Sections).FirstOrDefault(sec => sec.PageId == currentStatus.PageId).Status  = currentStatus?.Status;
                    viewmodel.Sequences.SelectMany(seq => seq.Sections).FirstOrDefault(sec => sec.PageId == currentStatus.PageId).Comment = currentStatus?.Comments;
                }
            }

            var sections = viewmodel.Sequences.SelectMany(seq => seq.Sections);

            viewmodel.IsClarificationsSelectedAndAllFieldsSet = sections.Any(x => x.Status == SectionReviewStatus.Clarification);
            viewmodel.ReadyToConfirm = IsReadyToConfirm(sections);

            return(viewmodel);
        }