public async Task ProjectChangedExecutor_MetadataChanged_Project(NotificationType notificationType) { var projectUid = Guid.NewGuid(); var projectTrn = TRNHelper.MakeTRN(projectUid, TRNHelper.TRN_ACCOUNT); var notificationHubClient = new Mock <INotificationHubClient>(); notificationHubClient.Setup(n => n.Notify(It.IsAny <Notification>())).Returns(Task.CompletedTask); var request = new ProjectChangeNotificationDto { AccountTrn = null, ProjectTrn = projectTrn, NotificationType = notificationType, CoordinateSystemFileName = null, CoordinateSystemFileContent = null }; var executor = RequestExecutorContainerFactory.Build <ProjectChangedExecutor> (_loggerFactory, _configStore, ServiceExceptionHandler, _customerUid.ToString(), _userUid.ToString(), null, _customHeaders, notificationHubClient: notificationHubClient.Object); var result = await executor.ProcessAsync(request); Assert.Equal(ContractExecutionStatesEnum.ExecutedSuccessfully, result.Code); Assert.Equal(ContractExecutionResult.DefaultMessage, result.Message); }
public async Task <IActionResult> OnProjectChangeNotify([FromBody] ProjectChangeNotificationDto updateDto) { Logger.LogInformation($"{nameof(OnProjectChangeNotify)} Update Notification {JsonConvert.SerializeObject(updateDto)}"); await WithServiceExceptionTryExecuteAsync(() => RequestExecutorContainerFactory .Build <ProjectChangedExecutor>(LoggerFactory, ConfigStore, ServiceExceptionHandler, CustomerUid, UserId, null, customHeaders, Productivity3dV1ProxyCoord, dataOceanClient : DataOceanClient, authn : Authorization, cwsProjectClient : CwsProjectClient, cwsProfileSettingsClient : CwsProfileSettingsClient, notificationHubClient : NotificationHubClient) .ProcessAsync(updateDto) ); Logger.LogInformation($"{nameof(OnProjectChangeNotify)} Processed Notification"); return(Ok()); }
public async Task ProjectChangedExecutor_CoordSystemChanged_MissingProjectUid(NotificationType notificationType) { var request = new ProjectChangeNotificationDto { AccountTrn = _customerTrn, ProjectTrn = null, NotificationType = notificationType, CoordinateSystemFileName = "some file name", CoordinateSystemFileContent = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 } }; var executor = RequestExecutorContainerFactory.Build <ProjectChangedExecutor> (_loggerFactory, _configStore, ServiceExceptionHandler, _customerUid.ToString(), _userUid.ToString(), null, _customHeaders); var ex = await Assert.ThrowsAsync <ServiceException>(() => executor.ProcessAsync(request)); Assert.Contains("2005", ex.GetContent); Assert.Contains("Missing ProjectUID.", ex.GetContent); }
public async Task ProjectChangedExecutor_CoordSystemChanged_MismatchedCustomerUid(NotificationType notificationType) { var projectUid = Guid.NewGuid(); var projectTrn = TRNHelper.MakeTRN(projectUid, TRNHelper.TRN_ACCOUNT); var request = new ProjectChangeNotificationDto { AccountTrn = TRNHelper.MakeTRN(Guid.NewGuid(), TRNHelper.TRN_ACCOUNT), ProjectTrn = projectTrn, NotificationType = notificationType, CoordinateSystemFileName = "some file name", CoordinateSystemFileContent = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 } }; var executor = RequestExecutorContainerFactory.Build <ProjectChangedExecutor> (_loggerFactory, _configStore, ServiceExceptionHandler, _customerUid.ToString(), _userUid.ToString(), null, _customHeaders); var ex = await Assert.ThrowsAsync <ServiceException>(() => executor.ProcessAsync(request)); Assert.Contains("2135", ex.GetContent); Assert.Contains("Mismatched customerUid.", ex.GetContent); }
public async Task ProjectChangedExecutor_CoordSystemChanged_HappyPath(NotificationType notificationType) { var projectUid = Guid.NewGuid(); var projectTrn = TRNHelper.MakeTRN(projectUid, TRNHelper.TRN_ACCOUNT); var coordSystemResult = new CoordinateSystemSettingsResult(); var coordProxy = new Mock <IProductivity3dV1ProxyCoord>(); coordProxy.Setup(cp => cp.CoordinateSystemPost(projectUid, It.IsAny <byte[]>(), It.IsAny <string>(), It.IsAny <IHeaderDictionary>())).ReturnsAsync(coordSystemResult); 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 authn = new Mock <ITPaaSApplicationAuthentication>(); authn.Setup(a => a.GetApplicationBearerToken()).Returns("some token"); var request = new ProjectChangeNotificationDto { AccountTrn = _customerTrn, ProjectTrn = projectTrn, NotificationType = notificationType, CoordinateSystemFileName = "some file name", CoordinateSystemFileContent = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 } }; var executor = RequestExecutorContainerFactory.Build <ProjectChangedExecutor> (_loggerFactory, _configStore, ServiceExceptionHandler, _customerUid.ToString(), _userUid.ToString(), null, _customHeaders, coordProxy.Object, dataOceanClient: dataOceanClient.Object, authn: authn.Object); var result = await executor.ProcessAsync(request); Assert.Equal(ContractExecutionStatesEnum.ExecutedSuccessfully, result.Code); Assert.Equal(ContractExecutionResult.DefaultMessage, result.Message); }