/// <summary> /// Create the project via the web api. /// </summary> public Task <string> CreateProjectViaWebApiV5TBC(string name) { var createProjectV5Request = CreateProjectV5Request.CreateACreateProjectV5Request(name, _boundaryLL, _businessCenterFile); var requestJson = createProjectV5Request == null ? null : JsonConvert.SerializeObject(createProjectV5Request, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); return(CallProjectWebApi("api/v5/projects/", HttpMethod.Post, requestJson, CustomerUid.ToString())); }
public void MapCreateProjectV5RequestToEvent() { var expectedProjectType = CwsProjectType.AcceptsTagFiles; var request = CreateProjectV5Request.CreateACreateProjectV5Request("projectName", _boundaryLL, _businessCenterFile); var projectValidation = MapV5Models.MapCreateProjectV5RequestToProjectValidation(request, _customerUid); Assert.Null(projectValidation.ProjectUid); Guid.TryParse(projectValidation.CustomerUid.ToString(), out var customerUidOut); Assert.Equal(_customerUid, customerUidOut.ToString()); Assert.Equal(expectedProjectType, projectValidation.ProjectType); Assert.Equal(request.ProjectName, projectValidation.ProjectName); Assert.Equal(_checkBoundaryString, projectValidation.ProjectBoundaryWKT); Assert.Equal(_businessCenterFile.Name, projectValidation.CoordinateSystemFileName); }
public async Task CreateProjectV5TBCExecutor_HappyPath() { var request = CreateProjectV5Request.CreateACreateProjectV5Request ("projectName", _boundaryLL, _businessCenterFile); var projectValidation = MapV5Models.MapCreateProjectV5RequestToProjectValidation(request, _customerUid.ToString()); Assert.Equal(_checkBoundaryString, projectValidation.ProjectBoundaryWKT); var coordSystemFileContent = "Some dummy content"; projectValidation.CoordinateSystemFileContent = System.Text.Encoding.ASCII.GetBytes(coordSystemFileContent); var createProjectResponseModel = new CreateProjectResponseModel() { TRN = _projectTrn }; var project = CreateProjectDetailModel(_customerTrn, _projectTrn, request.ProjectName); var projectList = CreateProjectListModel(_customerTrn, _projectTrn); var cwsProjectClient = new Mock <ICwsProjectClient>(); cwsProjectClient.Setup(pr => pr.CreateProject(It.IsAny <CreateProjectRequestModel>(), _customHeaders)).ReturnsAsync(createProjectResponseModel); cwsProjectClient.Setup(ps => ps.GetProjectsForCustomer(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <bool>(), It.IsAny <CwsProjectType?>(), It.IsAny <ProjectStatus?>(), It.IsAny <bool>(), It.IsAny <IHeaderDictionary>())).ReturnsAsync(projectList); cwsProjectClient.Setup(ps => ps.GetMyProject(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <IHeaderDictionary>())).ReturnsAsync(project); var httpContextAccessor = new HttpContextAccessor { HttpContext = new DefaultHttpContext() }; httpContextAccessor.HttpContext.Request.Path = new PathString("/api/v5/projects"); var productivity3dV1ProxyCoord = new Mock <IProductivity3dV1ProxyCoord>(); productivity3dV1ProxyCoord.Setup(p => p.CoordinateSystemValidate(It.IsAny <byte[]>(), It.IsAny <string>(), It.IsAny <HeaderDictionary>())) .ReturnsAsync(new CoordinateSystemSettingsResult()); productivity3dV1ProxyCoord.Setup(p => p.CoordinateSystemPost(It.IsAny <Guid>(), It.IsAny <byte[]>(), It.IsAny <string>(), It.IsAny <HeaderDictionary>())) .ReturnsAsync(new CoordinateSystemSettingsResult()); var dataOceanClient = new Mock <IDataOceanClient>(); dataOceanClient.Setup(f => f.FolderExists(It.IsAny <string>(), It.IsAny <HeaderDictionary>())).ReturnsAsync(true); dataOceanClient.Setup(f => f.PutFile(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Stream>(), It.IsAny <HeaderDictionary>())).ReturnsAsync(true); var projectConfigurationModel = new ProjectConfigurationModel { FileName = "some coord sys file", FileDownloadLink = "some download link" }; var cwsProfileSettingsClient = new Mock <ICwsProfileSettingsClient>(); cwsProfileSettingsClient.Setup(ps => ps.GetProjectConfiguration(It.IsAny <Guid>(), ProjectConfigurationFileType.CALIBRATION, _customHeaders)) .ReturnsAsync((ProjectConfigurationModel)null); cwsProfileSettingsClient.Setup(ps => ps.SaveProjectConfiguration(It.IsAny <Guid>(), ProjectConfigurationFileType.CALIBRATION, It.IsAny <ProjectConfigurationFileRequestModel>(), _customHeaders)) .ReturnsAsync(projectConfigurationModel); var authn = new Mock <ITPaaSApplicationAuthentication>(); authn.Setup(a => a.GetApplicationBearerToken()).Returns("some token"); var executor = RequestExecutorContainerFactory.Build <CreateProjectTBCExecutor> (_loggerFactory, _configStore, ServiceExceptionHandler, _customerUid.ToString(), _userUid.ToString(), null, _customHeaders, productivity3dV1ProxyCoord.Object, httpContextAccessor: httpContextAccessor, dataOceanClient: dataOceanClient.Object, authn: authn.Object, cwsProjectClient: cwsProjectClient.Object, cwsProfileSettingsClient: cwsProfileSettingsClient.Object); var result = await executor.ProcessAsync(projectValidation) as ProjectV6DescriptorsSingleResult; Assert.NotNull(result); Assert.False(string.IsNullOrEmpty(result.ProjectDescriptor.ProjectUid)); Assert.True(result.ProjectDescriptor.ShortRaptorProjectId != 0); Assert.Equal(request.ProjectName, result.ProjectDescriptor.Name); }