public async Task CSVExportExecutor_NoCSIB() { var fileName = "gotAFilename"; var coordType = CoordType.LatLon; var outputType = OutputTypes.VedaAllPasses; string[] machineNames = new string[] { "first machineName" }; var userPreferences = new UserPreferences(); var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var request = new CompactionVetaExportRequest( siteModel.ID, null, fileName, coordType, outputType, userPreferences, machineNames, null, null); request.Validate(); var compactionCSVExportRequest = AutoMapperUtility.Automapper.Map <CompactionCSVExportRequest>(request); var executor = RequestExecutorContainer .Build <CSVExportExecutor>(DIContext.Obtain <IConfigurationStore>(), DIContext.Obtain <ILoggerFactory>(), DIContext.Obtain <IServiceExceptionHandler>()); var result = await Assert.ThrowsAsync <ServiceException>(() => executor.ProcessAsync(compactionCSVExportRequest)); result.Code.Should().Be(HttpStatusCode.InternalServerError); result.GetResult.Code.Should().Be(ContractExecutionStatesEnum.InternalProcessingError); result.GetResult.Message.Should().Be("Failed to complete TRex request: CSVExportExecutor with error: Unable to load CSIB for LatLong conversion"); }
public void CSVExportHelper_MapVetaRequestToCommonExportRequest(string decimalSeparator, string thousandsSeparator, UnitsTypeEnum units, string dateSeparator, string timeSeparator, string expectedDateSeparator, string expectedTimeSeparator) { var projectUid = Guid.NewGuid(); FilterResult filter = null; var fileName = "gotAFilename"; var coordType = CoordType.LatLon; var outputType = OutputTypes.VedaAllPasses; var theMachineName = "first machineName"; var machineNames = new[] { theMachineName }; var userPreference = new UserPreferences() { DateSeparator = dateSeparator, TimeSeparator = timeSeparator, DecimalSeparator = decimalSeparator, ThousandsSeparator = thousandsSeparator, Units = (int)units }; var request = new CompactionVetaExportRequest( projectUid, filter, fileName, coordType, outputType, userPreference, machineNames, null, null); request.Validate(); var compactionCsvExportRequest = AutoMapperUtility.Automapper.Map <CompactionCSVExportRequest>(request); compactionCsvExportRequest.CoordType.Should().Be(coordType); compactionCsvExportRequest.OutputType.Should().Be(outputType); compactionCsvExportRequest.UserPreferences.DecimalSeparator.Should().Be(decimalSeparator); compactionCsvExportRequest.UserPreferences.DateSeparator.Should().Be(expectedDateSeparator); compactionCsvExportRequest.UserPreferences.TimeSeparator.Should().Be(expectedTimeSeparator); compactionCsvExportRequest.MachineNames.Should().Equal(machineNames); compactionCsvExportRequest.RestrictOutputSize.Should().Be(false); compactionCsvExportRequest.RawDataAsDBase.Should().Be(false); }
public Task <ContractExecutionResult> GetVetaExport([FromBody] CompactionVetaExportRequest compactionVetaExportRequest) { Log.LogInformation($"{nameof(GetVetaExport)}: {Request.QueryString}"); compactionVetaExportRequest.Validate(); return(Execute(compactionVetaExportRequest)); }
public async Task CSVExportExecutor_SiteModelNotFound() { var projectUid = Guid.NewGuid(); FilterResult filter = null; var fileName = "gotAFilename"; var coordType = CoordType.LatLon; var outputType = OutputTypes.VedaAllPasses; string[] machineNames = new string[] { "first machineName" }; var userPreferences = new UserPreferences(); var request = new CompactionVetaExportRequest( projectUid, filter, fileName, coordType, outputType, userPreferences, machineNames, null, null); request.Validate(); var compactionCSVExportRequest = AutoMapperUtility.Automapper.Map <CompactionCSVExportRequest>(request); var executor = RequestExecutorContainer .Build <CSVExportExecutor>(DIContext.Obtain <IConfigurationStore>(), DIContext.Obtain <ILoggerFactory>(), DIContext.Obtain <IServiceExceptionHandler>()); var result = await Assert.ThrowsAsync <ServiceException>(() => executor.ProcessAsync(compactionCSVExportRequest)); result.Code.Should().Be(HttpStatusCode.BadRequest); result.GetResult.Code.Should().Be(ContractExecutionStatesEnum.InternalProcessingError); result.GetResult.Message.Should().Be($"Site model {projectUid} is unavailable"); }
public void VetaExportRequest_Successful( Guid projectUid, FilterResult filter, string fileName, CoordType coordType, OutputTypes outputType, string[] machineNames) { var userPreferences = new UserPreferences(); var request = new CompactionVetaExportRequest( projectUid, filter, fileName, coordType, outputType, userPreferences, machineNames, null, null); request.Validate(); }
/// <summary> /// Processes the summary pass counts request by passing the request to Raptor and returning the result. /// </summary> protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item) { try { var request = CastRequestObjectTo <ExportReport>(item); #if RAPTOR if (UseTRexGateway(configKeys[request.ExportType])) { #endif var overrides = AutoMapperUtility.Automapper.Map <OverridingTargets>(request.LiftBuildSettings); var liftSettings = AutoMapperUtility.Automapper.Map <LiftSettings>(request.LiftBuildSettings); switch (request.ExportType) { case ExportTypes.SurfaceExport: var compactionSurfaceExportRequest = new CompactionSurfaceExportRequest(request.ProjectUid.Value, request.Filter, request.Filename, request.Tolerance, overrides, liftSettings); log.LogInformation($"Calling TRex SendSurfaceExportRequest for projectUid: {request.ProjectUid}"); return(await trexCompactionDataProxy.SendDataPostRequest <CompactionExportResult, CompactionSurfaceExportRequest>(compactionSurfaceExportRequest, "/export/surface/ttm", customHeaders)); case ExportTypes.VedaExport: default://to satisfy the compiler var compactionVetaExportRequest = new CompactionVetaExportRequest(request.ProjectUid.Value, request.Filter, request.Filename, request.CoordType, request.OutputType, request.UserPrefs, request.MachineList.Select(m => m.MachineName).ToArray(), overrides, liftSettings); //Note: this way of setting the machine name list is slightly different to the code in CompactionExportExecutor so we don't change the historical behaviour log.LogInformation($"Calling TRex SendVetaExportRequest for projectUid: {request.ProjectUid}"); return(await trexCompactionDataProxy.SendDataPostRequest <CompactionExportResult, CompactionVetaExportRequest>(compactionVetaExportRequest, "/export/veta", customHeaders)); case ExportTypes.PassCountExport: var compactionPassCountExportRequest = new CompactionPassCountExportRequest(request.ProjectUid.Value, request.Filter, request.Filename, request.CoordType, request.OutputType, request.UserPrefs, request.RestrictSize, request.RawData, overrides, liftSettings); log.LogInformation($"Calling TRex SendPassCountExportRequest for projectUid: {request.ProjectUid}"); return(await trexCompactionDataProxy.SendDataPostRequest <CompactionExportResult, CompactionPassCountExportRequest>(compactionPassCountExportRequest, "/export/passcount", customHeaders)); } #if RAPTOR } log.LogInformation($"Calling Raptor ProcessWithRaptor for projectUid: {request.ProjectUid}"); return(ProcessWithRaptor(request)); #endif } finally { ContractExecutionStates.ClearDynamic(); } }
public void VetaExportRequest_FilenameUnSuccessful( Guid projectUid, FilterResult filter, string fileName, CoordType coordType, OutputTypes outputType, string[] machineNames) { var userPreferences = new UserPreferences(); var request = new CompactionVetaExportRequest( projectUid, filter, fileName, coordType, outputType, userPreferences, machineNames, null, null); var validate = new ValidFilenameAttribute(256); var result = validate.IsValid(request.FileName); Assert.False(result); }
public void VetaExportRequest_UnSuccessful( Guid projectUid, FilterResult filter, string fileName, CoordType coordType, OutputTypes outputType, string[] machineNames, string errorMessage) { var userPreferences = new UserPreferences(); var request = new CompactionVetaExportRequest( projectUid, filter, fileName, coordType, outputType, userPreferences, machineNames, null, null); var ex = Assert.Throws <ServiceException>(() => request.Validate()); Assert.Equal(HttpStatusCode.BadRequest, ex.Code); Assert.Equal(ContractExecutionStatesEnum.ValidationError, ex.GetResult.Code); Assert.Equal(errorMessage, ex.GetResult.Message); }
public async Task CSVExportExecutor_GotFilterWithContributingMachines() { var fileName = "gotAFilename"; var coordType = CoordType.Northeast; var outputType = OutputTypes.VedaAllPasses; string[] machineNames = { "first machineName" }; var userPreferences = new UserPreferences(); var contributingMachines = new List <MachineDetails>() { new MachineDetails(Consts.NULL_LEGACY_ASSETID, "Machine Name", false, Guid.NewGuid()) }; var filter = new Productivity3D.Filter.Abstractions.Models.Filter( DateTime.SpecifyKind(new DateTime(2018, 1, 10), DateTimeKind.Utc), DateTime.SpecifyKind(new DateTime(2019, 2, 11), DateTimeKind.Utc), "", "", contributingMachines, null, ElevationType.First, null, null, null, null ); var filterResult = new FilterResult(null, filter, null, null, null, null, null, null, null); var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var request = new CompactionVetaExportRequest( siteModel.ID, filterResult, fileName, coordType, outputType, userPreferences, machineNames, null, null); request.Validate(); var compactionCSVExportRequest = AutoMapperUtility.Automapper.Map <CompactionCSVExportRequest>(request); // Mock the CSV export request functionality to return a null CSV export reponse to stimulate tyhe desired internal processing error var mockCompute = IgniteMock.Immutable.mockCompute; mockCompute.Setup(x => x.ApplyAsync(It.IsAny <CSVExportRequestComputeFunc>(), It.IsAny <CSVExportRequestArgument>(), It.IsAny <CancellationToken>())).Returns((CSVExportRequestComputeFunc func, CSVExportRequestArgument argument, CancellationToken token) => Task.FromResult <CSVExportRequestResponse>(null)); var executor = RequestExecutorContainer .Build <CSVExportExecutor>(DIContext.Obtain <IConfigurationStore>(), DIContext.Obtain <ILoggerFactory>(), DIContext.Obtain <IServiceExceptionHandler>()); var result = await Assert.ThrowsAsync <ServiceException>(() => executor.ProcessAsync(compactionCSVExportRequest)); result.Code.Should().Be(HttpStatusCode.InternalServerError); result.GetResult.Code.Should().Be(ContractExecutionStatesEnum.InternalProcessingError); result.GetResult.Message.Should().Be("Failed to complete TRex request: CSVExportExecutor with error: Failed to configure internal pipeline."); }