public void ProjectStatisticsExecutor_TRexValidation_Success() { var excludedSurveyedSurfaceUids = new[] { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() }; var request = new ProjectStatisticsTRexRequest(Guid.NewGuid(), excludedSurveyedSurfaceUids); request.Validate(); }
public void SiteModelStatisticsExecutor_EmptySiteModel() { var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var request = new ProjectStatisticsTRexRequest(siteModel.ID, null); request.Validate(); var executor = RequestExecutorContainer .Build <SiteModelStatisticsExecutor>(DIContext.Obtain <IConfigurationStore>(), DIContext.Obtain <ILoggerFactory>(), DIContext.Obtain <IServiceExceptionHandler>()); var result = executor.Process(request) as ProjectStatisticsResult; result.Code.Should().Be(ContractExecutionStatesEnum.ExecutedSuccessfully); result.cellSize.Should().Be(SubGridTreeConsts.DefaultCellSize); result.startTime.Should().Be(Consts.MAX_DATETIME_AS_UTC); result.endTime.Should().Be(Consts.MIN_DATETIME_AS_UTC); result.extents.MinX.Should().Be(BoundingWorldExtent3D.Inverted().MinX); result.extents.MaxX.Should().Be(BoundingWorldExtent3D.Inverted().MaxX); result.extents.MinY.Should().Be(BoundingWorldExtent3D.Inverted().MinY); result.extents.MaxY.Should().Be(BoundingWorldExtent3D.Inverted().MaxY); result.extents.MinZ.Should().Be(BoundingWorldExtent3D.Inverted().MinZ); result.extents.MaxZ.Should().Be(BoundingWorldExtent3D.Inverted().MaxZ); result.indexOriginOffset.Should().Be((int)SubGridTreeConsts.DefaultIndexOriginOffset); var expectedJson = "{\"startTime\":\"9999-12-31T23:59:59.9999999\",\"endTime\":\"0001-01-01T00:00:00\",\"cellSize\":0.34,\"indexOriginOffset\":536870912,\"extents\":{\"maxX\":-1E+100,\"maxY\":-1E+100,\"maxZ\":-1E+100,\"minX\":1E+100,\"minY\":1E+100,\"minZ\":1E+100},\"Code\":0,\"Message\":\"success\"}"; var json = JsonConvert.SerializeObject(result); json.Should().Be(expectedJson); }
protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item) { var request = item as ProjectStatisticsMultiRequest; log.LogInformation($"ProjectStatisticsExecutor: {JsonConvert.SerializeObject(request)}, UseTRexGateway: {UseTRexGateway("ENABLE_TREX_GATEWAY_PROJECTSTATISTICS")}"); #if RAPTOR if (UseTRexGateway("ENABLE_TREX_GATEWAY_PROJECTSTATISTICS") && request.ProjectUid != null) #endif { var tRexRequest = new ProjectStatisticsTRexRequest(request.ProjectUid.Value, request.ExcludedSurveyedSurfaceUids); var result = await trexCompactionDataProxy.SendDataPostRequest <ProjectStatisticsResult, ProjectStatisticsTRexRequest>( tRexRequest, $"/sitemodels/statistics", customHeaders); if (!result.extents.ValidExtents) { result.Empty(); } return(result); } #if RAPTOR bool success = raptorClient.GetDataModelStatistics( request.ProjectId, RaptorConverters.convertSurveyedSurfaceExlusionList(request.ExcludedSurveyedSurfaceIds), out var statistics); if (success) { return(ConvertProjectStatistics(statistics)); } #endif throw CreateServiceException <ProjectStatisticsExecutor>(); }
public void ProjectStatisticsExecutor_TRexValidation_SSUidFailure() { var excludedSurveyedSurfaceUids = new[] { Guid.Empty, Guid.NewGuid(), Guid.NewGuid() }; var request = new ProjectStatisticsTRexRequest(Guid.NewGuid(), excludedSurveyedSurfaceUids); var ex = Assert.ThrowsException <ServiceException>(() => request.Validate()); Assert.IsNotNull(ex, "should be exception"); Assert.AreEqual(HttpStatusCode.BadRequest, ex.Code, "Invalid HttpStatusCode."); Assert.AreEqual(ContractExecutionStatesEnum.ValidationError, ex.GetResult.Code, "Invalid executionState."); Assert.AreEqual("Excluded Surface Uid is invalid", ex.GetResult.Message, "Invalid error message."); }
public ProjectStatisticsResult GetStatistics([FromBody] ProjectStatisticsTRexRequest projectStatisticsTRexRequest) { Log.LogInformation($"#In# {nameof(GetStatistics)}: projectStatisticsTRexRequest: {JsonConvert.SerializeObject(projectStatisticsTRexRequest)}"); try { projectStatisticsTRexRequest.Validate(); GatewayHelper.ValidateAndGetSiteModel(nameof(GetStatistics), projectStatisticsTRexRequest.ProjectUid); return(WithServiceExceptionTryExecute(() => RequestExecutorContainer .Build <SiteModelStatisticsExecutor>(ConfigStore, LoggerFactory, ServiceExceptionHandler) .Process(projectStatisticsTRexRequest) as ProjectStatisticsResult)); } finally { Log.LogInformation($"#Out# {nameof(GetStatistics)}: projectStatisticsTRexRequest: {JsonConvert.SerializeObject(projectStatisticsTRexRequest)}"); } }