public void MapEvent_DTO_EffectiveAuthorizationRevoked_Returns_Domain_EffectiveAuthorizationRevoked_With_Valid_Values() { //Arrange var dtoEffectiveAuthorizationRevokedEvent = new EffectiveAuthorizationRevokedEvent(); dtoEffectiveAuthorizationRevokedEvent.EffectiveAuthorization = new EffectiveAuthorization(string1, new ExternalId(string2, string3), new Permission(string4, string5, string6), new ExternalId(string7, string8)); dtoEffectiveAuthorizationRevokedEvent.UntilDateTime = referenceDateTime; //Act var domainEffectiveAuthorizationRevokedEvent = DomainAdapter.MapEvent(dtoEffectiveAuthorizationRevokedEvent); //Assert Assert.IsNotNull(domainEffectiveAuthorizationRevokedEvent); Assert.IsNotNull(domainEffectiveAuthorizationRevokedEvent.EffectiveAuthorization); Assert.AreEqual(dtoEffectiveAuthorizationRevokedEvent.UntilDateTime, domainEffectiveAuthorizationRevokedEvent.Until); Assert.AreEqual(dtoEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.TenantId, domainEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.TenantId); Assert.AreEqual(dtoEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Permission.Application, domainEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Permission.Application); Assert.AreEqual(dtoEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Permission.Description, domainEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Permission.Description); Assert.AreEqual(dtoEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Permission.Id, domainEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Permission.Id); Assert.AreEqual(dtoEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Target.Context, domainEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Target.Context); Assert.AreEqual(dtoEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Target.Id, domainEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Target.Id); Assert.AreEqual(dtoEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.User.Context, domainEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.User.Context); Assert.AreEqual(dtoEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.User.Id, domainEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.User.Id); }
public async Task <IActionResult> LogEffectiveAutorizationRevokedEvent([FromBody] EffectiveAuthorizationRevokedEvent eAEvent) { var innerEvent = DomainAdapter.MapEvent(eAEvent); var id = await _effectiveAuthorizationLogging.AddAuthLogAsync(innerEvent); eAEvent.SetId(id); return(Created("EffectiveAuthorizationRevoked", eAEvent)); }
public async Task Process(string fileUrl) { var allTasks = new List <Task>(); var semaphore = new SemaphoreSlim(10, 10); var filecount = 0; var data = await _azureBlobStorageRepository.FetchFileAsync(fileUrl); var events = Serializer.Deserialize <List <DTOs.EffectiveAuthorizationGrantedEvent> >(data); _logger.LogInformation($"Process Start Time {DateTime.Now}"); events.ForEach(async(eventData) => { var mapEventData = DomainAdapter.MapEvent(eventData); var serlializedJson = ""; await semaphore.WaitAsync(); allTasks.Add( Task.Run(async() => { try { Interlocked.Increment(ref filecount); await _writeRawEventStorage.WriteRawEventAsync(mapEventData); serlializedJson = JsonConvert.SerializeObject(mapEventData); _dataEnrichmentBusiness.Process(serlializedJson.ToString()); _logger.LogInformation($"Data Enrichment Count : {filecount}"); } catch (Exception ex) { _logger.LogError($"The Initial Load Failed due to : {ex.ToString()}"); _logger.LogError($"The failed Event Data is : {eventData.EffectiveAuthorization},{eventData.FromDateTime},{eventData.Id}"); } finally { semaphore.Release(); _logger.LogInformation($"Released in finally"); } })); }); await Task.WhenAll(allTasks); _logger.LogInformation($"Data Enrichment Completed"); _logger.LogInformation($"Process End Time {DateTime.Now}"); }