public void check_orchestrator_builds_with_website_address(string organisationWebsite, string ukrlpApiWebsite) { var applicationId = Guid.NewGuid(); var commonDetails = new GatewayCommonDetails { ApplicationSubmittedOn = DateTime.Now.AddDays(-3), SourcesCheckedOn = DateTime.Now, LegalName = UKRLPLegalName, Ukprn = ukprn }; _applyApiClient.Setup(x => x.GetPageCommonDetails(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(commonDetails); _applyApiClient.Setup(x => x.GetOrganisationWebsiteAddress(applicationId)).ReturnsAsync(organisationWebsite); var ukrlpDetails = new ProviderDetails { ContactDetails = new List <ProviderContact>() { new ProviderContact { ContactWebsiteAddress = ukrlpApiWebsite, ContactType = RoatpGatewayConstants.ProviderContactDetailsTypeLegalIdentifier } } }; _applyApiClient.Setup(x => x.GetUkrlpDetails(applicationId)).ReturnsAsync(ukrlpDetails); var request = new GetWebsiteRequest(applicationId, UserId, UserName); var response = _orchestrator.GetWebsiteViewModel(request); var viewModel = response.Result; Assert.AreEqual(UKRLPLegalName, viewModel.ApplyLegalName); Assert.AreEqual(ukprn, viewModel.Ukprn); Assert.AreEqual(organisationWebsite, viewModel.SubmittedWebsite); Assert.AreEqual(ukrlpApiWebsite, viewModel.UkrlpWebsite); }
public async Task <WebsiteViewModel> GetWebsiteViewModel(GetWebsiteRequest request) { _logger.LogInformation($"Retrieving Website check details for application {request.ApplicationId}"); var model = new WebsiteViewModel(); await model.PopulatePageCommonDetails(_applyApiClient, request.ApplicationId, GatewaySequences.OrganisationChecks, GatewayPageIds.WebsiteAddress, request.UserId, request.UserName, RoatpGatewayConstants.Captions.OrganisationChecks, RoatpGatewayConstants.Headings.Website, NoSelectionErrorMessages.Errors[GatewayPageIds.WebsiteAddress]); model.SubmittedWebsite = await _applyApiClient.GetOrganisationWebsiteAddress(request.ApplicationId); var isSubmittedWebsiteProperUri = StringExtensions.ValidateHttpURL(model.SubmittedWebsite, out Uri submittedWebsiteProperUri); if (isSubmittedWebsiteProperUri) { model.SubmittedWebsiteUrl = submittedWebsiteProperUri?.AbsoluteUri; } var ukrlpDetails = await _applyApiClient.GetUkrlpDetails(request.ApplicationId); if (ukrlpDetails != null && ukrlpDetails.ContactDetails != null) { model.UkrlpWebsite = ukrlpDetails.ContactDetails.FirstOrDefault(x => x.ContactType == RoatpGatewayConstants.ProviderContactDetailsTypeLegalIdentifier)?.ContactWebsiteAddress; var isUkrlpWebsiteProperUri = StringExtensions.ValidateHttpURL(model.UkrlpWebsite, out Uri ukrlpWebsiteProperUri); if (isUkrlpWebsiteProperUri) { model.UkrlpWebsiteUrl = ukrlpWebsiteProperUri?.AbsoluteUri; } } return(model); }