private void VerifyApplicationHasNoFinalOutcome(GetOversightReviewResponse oversightReview)
 {
     if (oversightReview != null && oversightReview.Status != OversightReviewStatus.None && oversightReview.Status != OversightReviewStatus.InProgress)
     {
         throw new InvalidStateException();
     }
 }
Пример #2
0
        public void Before_each_test()
        {
            _applicationId             = Guid.NewGuid();
            _applicationDeterminedDate = DateTime.Today;

            _outcomeApiClient     = new Mock <IOutcomeApiClient>();
            _appealsApiClient     = new Mock <IAppealsApiClient>();
            _applicationApiClient = new Mock <IApplicationApiClient>();
            _logger       = new Mock <ILogger <RoatpAppealsController> >();
            _emailService = new Mock <IRequestInvitationToReapplyEmailService>();

            var signInId   = Guid.NewGuid();
            var givenNames = "Test";
            var familyName = "User";

            var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
            {
                new Claim(ClaimTypes.Name, $"{givenNames} {familyName}"),
                new Claim(ClaimTypes.NameIdentifier, "1"),
                new Claim("Email", "*****@*****.**"),
                new Claim("sub", signInId.ToString()),
                new Claim("custom-claim", "example claim value"),
            }, "mock"));

            var oversightReview = new GetOversightReviewResponse {
                Status = OversightReviewStatus.Unsuccessful, ApplicationDeterminedDate = _applicationDeterminedDate
            };

            _outcomeApiClient.Setup(x => x.GetOversightReview(_applicationId)).ReturnsAsync(oversightReview);

            _outcomeApiClient.Setup(x => x.ReapplicationRequested(It.IsAny <Guid>(), It.IsAny <string>()))
            .ReturnsAsync(true);

            _outcomeApiClient.Setup(x => x.GetWorkingDaysAheadDate(It.IsAny <DateTime>(), It.IsAny <int>())).ReturnsAsync(_applicationDeterminedDate.AddDays(10));

            _appealsApiClient.Setup(x => x.GetAppeal(_applicationId)).ReturnsAsync(default(GetAppealResponse));

            _appealsApiClient.Setup(x => x.GetAppealFileList(_applicationId)).ReturnsAsync(default(GetAppealFileListResponse));

            _controller = new RoatpAppealsController(_outcomeApiClient.Object, _appealsApiClient.Object, _applicationApiClient.Object, _logger.Object, _emailService.Object)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext()
                    {
                        User = user
                    },
                },
                TempData = Mock.Of <ITempDataDictionary>()
            };
        }
        public async Task <ApplicationSummaryViewModel> BuildApplicationSummaryViewModel(Guid applicationId, string emailAddress)
        {
            var application = await _applicationApiClient.GetApplication(applicationId);

            var financialReviewDetails = await _applicationApiClient.GetFinancialReviewDetails(applicationId);

            GetOversightReviewResponse oversightReview = null;
            GetAppealResponse          appeal          = null;

            var applyingJourneyStatuses = new List <string> {
                ApplicationStatus.New, ApplicationStatus.InProgress
            };

            if (!applyingJourneyStatuses.Contains(application.Status))
            {
                oversightReview = await _apiClient.GetOversightReview(applicationId);

                appeal = await _appealsApiClient.GetAppeal(applicationId);
            }

            var applicationData = application.ApplyData.ApplyDetails;

            var model = new ApplicationSummaryViewModel
            {
                ApplicationId                       = application.ApplicationId,
                UKPRN                               = applicationData.UKPRN,
                OrganisationName                    = applicationData.OrganisationName,
                TradingName                         = applicationData.TradingName,
                ApplicationRouteId                  = applicationData.ProviderRoute.ToString(),
                ApplicationReference                = applicationData.ReferenceNumber,
                SubmittedDate                       = applicationData?.ApplicationSubmittedOn,
                GatewayExternalComments             = application.ExternalComments ?? application.ApplyData.GatewayReviewDetails?.ExternalComments,
                EmailAddress                        = emailAddress,
                FinancialReviewStatus               = financialReviewDetails?.Status,
                FinancialGrade                      = financialReviewDetails?.SelectedGrade,
                FinancialExternalComments           = financialReviewDetails?.ExternalComments,
                GatewayReviewStatus                 = application?.GatewayReviewStatus,
                ModerationStatus                    = application?.ModerationStatus,
                SubcontractingLimit                 = application?.ApplyData?.GatewayReviewDetails?.SubcontractingLimit,
                ApplicationStatus                   = application?.ApplicationStatus,
                ApplicationDeterminedDate           = oversightReview?.ApplicationDeterminedDate,
                OversightReviewStatus               = oversightReview?.Status,
                OversightInProgressExternalComments = oversightReview?.InProgressExternalComments,
                AppealRequiredByDate                = oversightReview is null ? null : await _apiClient.GetWorkingDaysAheadDate(oversightReview?.ApplicationDeterminedDate, NumberOfWorkingDaysToAppeal),
                IsAppealSubmitted                   = appeal?.AppealSubmittedDate != null,
                AppealStatus                        = appeal?.Status
            };

            return(model);
        }
        private InProgressDetailsViewModel CreateInProgressDetailsViewModel(GetOversightReviewResponse oversightReview)
        {
            if (oversightReview?.InProgressDate == null)
            {
                return(null);
            }

            return(new InProgressDetailsViewModel
            {
                ApplicationDeterminedDate = oversightReview.InProgressDate.Value,
                InternalComments = oversightReview.InProgressInternalComments,
                ExternalComments = oversightReview.InProgressExternalComments,
                UserName = oversightReview.InProgressUserName
            });
        }
Пример #5
0
        public async Task MakeAppeal_shows_ProcessApplicationStatus_page_if_outside_appeal_window()
        {
            var oversightReview = new GetOversightReviewResponse {
                Status = OversightReviewStatus.Unsuccessful, ApplicationDeterminedDate = _applicationDeterminedDate
            };

            _outcomeApiClient.Setup(x => x.GetOversightReview(_applicationId)).ReturnsAsync(oversightReview);
            _outcomeApiClient.Setup(x => x.GetWorkingDaysAheadDate(It.IsAny <DateTime>(), It.IsAny <int>())).ReturnsAsync(_applicationDeterminedDate.AddDays(-10));

            var result = await _controller.MakeAppeal(_applicationId);

            var viewResult = result as RedirectToActionResult;

            viewResult.Should().NotBeNull();
            viewResult.ActionName.Should().Be("ProcessApplicationStatus");
        }
        private OverallOutcomeViewModel CreateOverallOutcomeViewModel(GetOversightReviewResponse oversightReview)
        {
            if (oversightReview == null)
            {
                return(new OverallOutcomeViewModel());
            }

            return(new OverallOutcomeViewModel
            {
                OversightStatus = oversightReview.Status,
                ApplicationDeterminedDate = oversightReview.ApplicationDeterminedDate,
                OversightUserName = oversightReview.UserName,
                InternalComments = oversightReview.InternalComments,
                ExternalComments = oversightReview.ExternalComments,
                IsGatewayOutcome = oversightReview.Status == OversightReviewStatus.Rejected ||
                                   oversightReview.Status == OversightReviewStatus.Withdrawn
            });
        }
        private ModerationOutcomeViewModel CreateModerationOutcomeViewModel(ApplicationDetails applicationDetails, GetOversightReviewResponse oversightReview)
        {
            var result = new ModerationOutcomeViewModel
            {
                ModerationReviewStatus  = applicationDetails.ModerationReviewStatus,
                ModerationOutcomeMadeOn = applicationDetails.ModerationOutcomeMadeOn,
                ModeratedBy             = applicationDetails.ModeratedBy,
                ModerationComments      = applicationDetails.ModerationComments
            };

            if (oversightReview?.ModerationApproved != null)
            {
                if (applicationDetails.ModerationReviewStatus == ModerationReviewStatus.Pass)
                {
                    result.GovernanceOutcome = oversightReview.ModerationApproved.Value
                        ? PassFailStatus.Passed
                        : PassFailStatus.Failed;
                }
                else if (applicationDetails.ModerationReviewStatus == ModerationReviewStatus.Fail)
                {
                    result.GovernanceOutcome = oversightReview.ModerationApproved.Value
                        ? PassFailStatus.Failed
                        : PassFailStatus.Passed;
                }
            }

            return(result);
        }
        private GatewayOutcomeViewModel CreateGatewayOutcomeViewModel(ApplicationDetails applicationDetails, GetOversightReviewResponse oversightReview)
        {
            var result = new GatewayOutcomeViewModel
            {
                GatewayReviewStatus = applicationDetails.ApplicationStatus == ApplicationStatus.Removed
                    ? ApplicationStatus.Removed
                    : applicationDetails.GatewayReviewStatus,
                GatewayOutcomeMadeDate = applicationDetails.ApplicationStatus == ApplicationStatus.Removed
                    ? applicationDetails.ApplicationRemovedOn
                    : applicationDetails.GatewayOutcomeMadeDate,
                GatewayOutcomeMadeBy = applicationDetails.ApplicationStatus == ApplicationStatus.Removed
                    ? applicationDetails.ApplicationRemovedBy
                    : applicationDetails.GatewayOutcomeMadeBy,
                GatewayComments = applicationDetails.ApplicationStatus == ApplicationStatus.Removed
                    ? applicationDetails.ApplyInternalComments
                    : applicationDetails.GatewayComments,
                GatewayExternalComments = applicationDetails.ApplicationStatus == ApplicationStatus.Removed
                    ? applicationDetails.ApplyExternalComments
                    : applicationDetails.GatewayExternalComments
            };

            if (oversightReview?.GatewayApproved != null)
            {
                if (applicationDetails.GatewayReviewStatus == GatewayReviewStatus.Pass)
                {
                    result.GovernanceOutcome = oversightReview.GatewayApproved.Value
                        ? PassFailStatus.Passed
                        : PassFailStatus.Failed;
                }
                else if (applicationDetails.GatewayReviewStatus == GatewayReviewStatus.Fail)
                {
                    result.GovernanceOutcome = oversightReview.GatewayApproved.Value
                        ? PassFailStatus.Failed
                        : PassFailStatus.Passed;
                }
            }

            return(result);
        }