private async Task <ProfileResult> PerformTRexProductionDataProfilePost(ProfileProductionDataRequest request) { if (request.IsAlignmentDesign) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "TRex unsupported request")); } var liftBuildSettings = request.LiftBuildSettings; var productionDataProfileDataRequest = new ProductionDataProfileDataRequest( request.ProjectUid ?? Guid.Empty, request.Filter, request.ReturnAllPassesAndLayers, request.AlignmentDesign?.FileUid, request.AlignmentDesign?.Offset, request.GridPoints != null, request.GridPoints?.x1 ?? request.WGS84Points.lon1, request.GridPoints?.x2 ?? request.WGS84Points.lon2, request.GridPoints?.y1 ?? request.WGS84Points.lat1, request.GridPoints?.y2 ?? request.WGS84Points.lat2, AutoMapperUtility.Automapper.Map <OverridingTargets>(liftBuildSettings), AutoMapperUtility.Automapper.Map <LiftSettings>(liftBuildSettings) ); var trexResult = await trexCompactionDataProxy.SendDataPostRequest <ProfileDataResult <ProfileCellData>, ProductionDataProfileDataRequest>(productionDataProfileDataRequest, "/productiondata/profile", customHeaders); return(trexResult != null?ConvertTRexProfileResult(trexResult) : null); }
public void PD_PostProfileProductionDataFailed() { ProfileProductionDataRequest request = CreateRequest(); MemoryStream raptorResult = null; Assert.IsTrue(RaptorConverters.DesignDescriptor(request.AlignmentDesign).IsNull(), "A linear profile expected."); ProfilesHelper.ConvertProfileEndPositions(request.GridPoints, request.WGS84Points, out TWGS84Point startPt, out var endPt, out bool positionsAreGrid); TASNodeServiceRPCVerb_RequestProfile_Args args = __Global.Construct_RequestProfile_Args (request.ProjectId.Value, -1, // don't care positionsAreGrid, startPt, endPt, RaptorConverters.ConvertFilter(request.Filter), RaptorConverters.ConvertLift(request.LiftBuildSettings, TFilterLayerMethod.flmAutomatic), RaptorConverters.DesignDescriptor(request.AlignmentDesign), request.ReturnAllPassesAndLayers); // Create the mock PDSClient with successful result... var mockRaptorClient = new Mock <IASNodeClient>(); var mockLogger = new Mock <ILoggerFactory>(); var mockConfigStore = new Mock <IConfigurationStore>(); mockRaptorClient.Setup(prj => prj.GetProfile(It.IsAny <TASNodeServiceRPCVerb_RequestProfile_Args>() /*args*/)).Returns(raptorResult); // Create an executor... var executor = RequestExecutorContainerFactory.Build <ProfileProductionDataExecutor>(mockLogger.Object, mockRaptorClient.Object, configStore: mockConfigStore.Object); Assert.ThrowsExceptionAsync <ServiceException>(async() => await executor.ProcessAsync(request)); }
public async Task <ProfileResult> Post([FromBody] ProfileProductionDataRequest request) { request.Validate(); return(await RequestExecutorContainerFactory.Build <ProfileProductionDataExecutor>(logger, #if RAPTOR raptorClient, #endif configStore : ConfigStore, trexCompactionDataProxy : TRexCompactionDataProxy, customHeaders : CustomHeaders, userId : UserId, fileImportProxy : FileImportProxy) .ProcessAsync(request) as ProfileResult); }
private ProfileResult PerformProductionDataProfilePost(ProfileProductionDataRequest request) { MemoryStream memoryStream; if (request.IsAlignmentDesign) { var args = ASNode.RequestAlignmentProfile.RPC.__Global.Construct_RequestAlignmentProfile_Args( request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID, ProfilesHelper.PROFILE_TYPE_NOT_REQUIRED, request.StartStation ?? ValidationConstants3D.MIN_STATION, request.EndStation ?? ValidationConstants3D.MIN_STATION, RaptorConverters.DesignDescriptor(request.AlignmentDesign), RaptorConverters.ConvertFilter(request.Filter, request.ProjectId, raptorClient), RaptorConverters.ConvertLift(request.LiftBuildSettings, TFilterLayerMethod.flmAutomatic), RaptorConverters.DesignDescriptor(request.AlignmentDesign), request.ReturnAllPassesAndLayers); memoryStream = raptorClient.GetAlignmentProfile(args); } else { ProfilesHelper.ConvertProfileEndPositions( request.GridPoints, request.WGS84Points, out VLPDDecls.TWGS84Point startPt, out VLPDDecls.TWGS84Point endPt, out bool positionsAreGrid); var args = ASNode.RequestProfile.RPC.__Global.Construct_RequestProfile_Args( request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID, ProfilesHelper.PROFILE_TYPE_NOT_REQUIRED, positionsAreGrid, startPt, endPt, RaptorConverters.ConvertFilter(request.Filter, request.ProjectId, raptorClient), RaptorConverters.ConvertLift(request.LiftBuildSettings, TFilterLayerMethod.flmAutomatic), RaptorConverters.DesignDescriptor(request.AlignmentDesign), request.ReturnAllPassesAndLayers); memoryStream = raptorClient.GetProfile(args); } return(memoryStream != null ? ConvertProfileResult(memoryStream, request.CallId ?? Guid.NewGuid()) : null); // TODO: return appropriate result }
public void IsAlignmentProfile_Should_return_true_when_AlignmentDesign_file_is_set() { var request = new ProfileProductionDataRequest(0, Guid.NewGuid(), ProductionDataType.All, null, 0, new DesignDescriptor(1, FileDescriptor.CreateFileDescriptor("1", "path", "filename"), 0), null, null, 0, 0, null, false); Assert.IsTrue(request.IsAlignmentDesign); }
public void IsAlignmentProfile_Should_return_false_when_AlignmentDesign_is_null() { var request = new ProfileProductionDataRequest(0, Guid.NewGuid(), ProductionDataType.All, null, 0, null, null, null, 0, 0, null, false); Assert.IsFalse(request.IsAlignmentDesign); }