Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: 5959961188 - CosmosDB Optimistic concurrency through e-tags #16

Open
wants to merge 16 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
### Version 5.1.0

- Improvement: Refactoring the pagination patterns to better suit both Repository and EF DbContext approaches.

### Version 5.0.0
### Version 5.0.0

- Improvement: Updated the `AutoMapper.Extensions.Microsoft.DependencyInjection` NuGet package version to 12.0.1.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
### Version 5.0.5

- Improvement: Updating various modules to use the more sophisticated CSharp mapping resolution systems.

### Version 5.0.4
### Version 5.0.4

- Improvement: Updated version for `Intent.Metadata.WebApi` dependency.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
### Version 3.5.11

- Improvement: Upgraded module to support new 4.1 SDK features.

### Version 3.5.0

- Improvement: Updated MediatR version.
- Deprecated: This functionality is now covered the `Intent.Application.MediatR` module itself.

### Version 3.4.2

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
### Version 4.1.0

- Improvement: Upgraded module to support new 4.1 SDK features.
-
### Version 4.0.7

- Improvement: Updated to be compatible with .NET 8.
Expand Down
4 changes: 0 additions & 4 deletions Modules/Intent.Modules.Application.Dtos/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
### Version 4.2.0

- Improvement: Upgraded module to support new 4.1 SDK features.

### Version 4.1.1

- Fixed: Protected Constructor added when parameter constructor is introduced for mapping libraries to instantiate using reflection.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
### Version 3.8.9

- Improvement: Upgraded module to support new 4.1 SDK features.

### Version 3.8.7

- Improvement: Added CascadeMode option on Fluent Validations to specify this behaviour.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

### Version 3.5.1

- Improvement: The generated `AuthorizeAttribute` will no longer cause nullable warnings.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<id>Intent.Application.MediatR.Behaviours</id>
<version>4.2.10-pre.3</version>
<version>4.2.10-pre.2</version>
<supportedClientVersions>[4.1.0-a, 5.0.0-a)</supportedClientVersions>
<summary>Additional MediatR middleware pipeline behaviours</summary>
<description>Additional MediatR middleware pipeline behaviours</description>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
### Version 4.2.10

- Improvement: Added `ArgumentNullException` check on `IUnitOfWork` dependency injection.
- Improvement: Allow support for Redis OM Unit of Work.

### Version 4.2.7

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
### Version 4.5.1

- Improvement: Upgraded module to support new 4.1 SDK features.

### Version 4.5.0

- Improvement: Removed `// IntentMatch(...)` code management instructions from templates which are no longer needed since version `4.4.0` of the `Intent.OutputManager.RoslynWeaver` module.
Expand Down
6 changes: 1 addition & 5 deletions Modules/Intent.Modules.Application.MediatR/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
### Version 4.2.2

- Improvement: Upgraded module to support new 4.1 SDK features.

### Version 4.2.0
### Version 4.2.0

- Improvement: Added Support for `+` in roles, to describe `and` relationships between roles e.g. `Admin,Manager` (or) vs `Admin+Manager` (and)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
### Version 1.0.10

- Improvement: Few small fixes on using directives.

### Version 1.0.6

- Updated to ensure variable name of entity to publish event for matches that in generated method implmentation by the CRUD module.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
### Version 4.5.1

- Improvement: Upgraded module to support new 4.1 SDK features.

### Version 4.4.0

- Update: Constructors will now be "Merge" by default. This will make user based injections and code-gen injections feasible.
Expand Down
4 changes: 0 additions & 4 deletions Modules/Intent.Modules.Ardalis.Repositories/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
### Version 4.0.4

- Improvement: Fixed the optional filters for queries that access the data with the DbContext; Refactored the way the query filters are constructed.

### Version 4.0.3

- Improvement: Resolve compiler warnings.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
### Version 5.5.0

- Improvement: Upgraded module to support new 4.1 SDK features.

### Version 5.4.2

- Improvement: Added Support for `+` in roles, to describe `and` relationships between roles e.g. `Admin,Manager` (or) vs `Admin+Manager` (and)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<id>Intent.AspNetCore.Controllers.Dispatch.ServiceContract</id>
<version>5.2.4-pre.2</version>
<version>5.2.4-pre.1</version>
<supportedClientVersions>[4.1.0-a, 5.0.0-a)</supportedClientVersions>
<summary>Instructs ASP.NET Core Controllers to dispatch requests to a separate handler via Application Contract interfaces.</summary>
<description>Instructs ASP.NET Core Controllers to dispatch requests to a separate handler via Application Contract interfaces.</description>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
### Version 6.0.2

- Improvement: Dependent modules changed, version bumped.

### Version 6.0.0

- Improvement: Updated to support use of top-level statements and minimal hosting model improvements introduced in [`Intent.AspNetCore` version 6.0.0](https://github.com/IntentArchitect/Intent.Modules.NET/blob/development/Modules/Intent.Modules.AspNetCore/release-notes.md#version-600).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<decorators></decorators>
<factoryExtensions></factoryExtensions>
<moduleSettings></moduleSettings>
<releaseNotes>release-notes.md</releaseNotes>
<dependencies>
<dependency id="Intent.AspNetCore.Cors" version="3.3.11" />
</dependencies>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
### Version 2.0.2

- Improvement: Added support for Oracle databases.
- Improvement: Added support for Redis Stack.

### Version 2.0.0

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
### Version 2.0.0

- Improvement: Upgraded module to support new 4.1 SDK features.

### Version 1.0.2

- Updated dependencies and supported client versions to prevent warnings when used with Intent Architect 4.x.
Expand Down
4 changes: 0 additions & 4 deletions Modules/Intent.Modules.AspNetCore.Identity/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
### Version 4.1.0

- Improvement: Upgraded module to support new 4.1 SDK features.

### Version 4.0.8

- Improvement: Updated to be compatible with .NET 8.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<id>Intent.AspNetCore.IntegrationTesting</id>
<version>1.0.0-pre.2</version>
<version>1.0.0-pre.3</version>
<supportedClientVersions>[4.1.0-beta.21,5.0.0)</supportedClientVersions>
<summary>The module adds support for Integration Testing Asp.Net Core applications.</summary>
<description>The module adds support for Integration Testing Asp.Net Core applications.</description>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### Version 1.0.0

- New Feature: Asp.Net Core Integration Testing module.
- New Feature: Integration Testing module.
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ private void DoCreateTest(ICSharpFileBuilderTemplate template, CrudMap crudTest)

method
.Async()
.AddAttribute("Fact");
FixCosmosTests(crudTest, method);
method
.AddAttribute("Fact")
.AddStatement("//Arrange")
.AddStatement($"var client = new {template.GetTypeName("Intent.AspNetCore.IntegrationTesting.HttpClient", crudTest.Proxy.Id)}(CreateClient());")
.AddStatement($"var dataFactory = new TestDataFactory(WebAppFactory);", s => s.SeparatedFromPrevious());
Expand Down Expand Up @@ -162,9 +160,7 @@ private void DoGetByIdTest(ICSharpFileBuilderTemplate template, CrudMap crudTest

method
.Async()
.AddAttribute("Fact");
FixCosmosTests(crudTest, method);
method
.AddAttribute("Fact")
.AddStatement("//Arrange")
.AddStatement($"var client = new {template.GetTypeName("Intent.AspNetCore.IntegrationTesting.HttpClient", crudTest.Proxy.Id)}(CreateClient());")

Expand Down Expand Up @@ -196,9 +192,7 @@ private void DoGetAllTest(ICSharpFileBuilderTemplate template, CrudMap crudTest)

method
.Async()
.AddAttribute("Fact");
FixCosmosTests(crudTest, method);
method
.AddAttribute("Fact")
.AddStatement("//Arrange")
.AddStatement($"var client = new {template.GetTypeName("Intent.AspNetCore.IntegrationTesting.HttpClient", crudTest.Proxy.Id)}(CreateClient());")

Expand Down Expand Up @@ -236,9 +230,7 @@ private void DoDeleteTest(ICSharpFileBuilderTemplate template, CrudMap crudTest)

method
.Async()
.AddAttribute("Fact");
FixCosmosTests(crudTest, method);
method
.AddAttribute("Fact")
.AddStatement("//Arrange")
.AddStatement($"var client = new {template.GetTypeName("Intent.AspNetCore.IntegrationTesting.HttpClient", crudTest.Proxy.Id)}(CreateClient());")
.AddStatement($"var dataFactory = new TestDataFactory(WebAppFactory);", s => s.SeparatedFromPrevious())
Expand Down Expand Up @@ -273,21 +265,15 @@ private void DoUpdateTest(ICSharpFileBuilderTemplate template, CrudMap crudTest)

method
.Async()
.AddAttribute("Fact");
FixCosmosTests(crudTest, method);
method
.AddAttribute("Fact")
.AddStatement("//Arrange")
.AddStatement($"var client = new {template.GetTypeName("Intent.AspNetCore.IntegrationTesting.HttpClient", crudTest.Proxy.Id)}(CreateClient());")

.AddStatement($"var dataFactory = new TestDataFactory(WebAppFactory);", s => s.SeparatedFromPrevious())
.AddStatement($"var {$"{createVarName}"} = await dataFactory.Create{crudTest.Entity.Name}();")
.AddStatement($"var command = dataFactory.CreateCommand<{template.GetTypeName(updateDtoModel.TypeReference)}>();", s => s.SeparatedFromPrevious());


method
.AddStatement($"command.{GetDtoPkFieldName(operation)} = {sutId};");
.AddStatement($"var command = dataFactory.CreateCommand<{template.GetTypeName(updateDtoModel.TypeReference)}>();", s => s.SeparatedFromPrevious())
.AddStatement($"command.Id = {sutId};")

method
.AddStatement("//Act", s => s.SeparatedFromPrevious())
.AddStatement($"await client.{crudTest.Update!.Name}Async({sutId}, command);")

Expand Down Expand Up @@ -317,46 +303,6 @@ private void DoUpdateTest(ICSharpFileBuilderTemplate template, CrudMap crudTest)
});
}

private void FixCosmosTests(CrudMap test, CSharpClassMethod method)
{
if (IsCosmosTest(test.Entity.InternalElement))
{
method.AddAttribute("Trait", att =>
{
att
.AddArgument("\"Category\"")
.AddArgument("\"ExcludeOnCI\"")
;
});
method.WithComments(new[]
{
"/// <summary>",
"/// The Cosmos DB Linux Emulator Docker image does not run on Microsoft's CI environment (GitHub, Azure DevOps).\")] // https://github.com/Azure/azure-cosmos-db-emulator-docker/issues/45.",
"/// Filter this test out of your CI/CD if appropriate e.g. dotnet test --filter Category!=ExcludeOnCI",
"/// </summary>",
});
}
}

private const string CosmosDbProviderId = "3e1a00f7-c6f1-4785-a544-bbcb17602b31";

private static bool IsCosmosTest(IElement sut)
{

if (!sut.Package.HasStereotype("Document Database"))
return false;

var setting = sut.Package.GetStereotypeProperty<IElement>("Document Database", "Provider");
return setting == null ||setting.Id == CosmosDbProviderId;
}

private string GetDtoPkFieldName(IHttpEndpointModel operation)
{

var result = TestDataFactoryHelper.GetDtoPkFieldName(operation);
return result?.ToPascalCase() ?? "Id";
}

private void PopulateTestDataFactory(ICSharpFileBuilderTemplate template, List<CrudMap> crudTests)
{
TestDataFactoryHelper.PopulateTestDataFactory(template, crudTests);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,30 +110,6 @@ public static void PopulateTestDataFactory(ICSharpFileBuilderTemplate template,

}

internal static string? GetDtoPkFieldName(IHttpEndpointModel operation)
{
var mapping = GetMapEntityQueryMapping(operation.InternalElement);
if (mapping != null) // We only doing Test for services on new mapping system
{
foreach (var mappedEnd in mapping.MappedEnds.Where(me => me.MappingType == "Filter Mapping"))
{
var attributeModel = (mappedEnd.TargetElement as IElement)?.AsAttributeModel();
if (attributeModel is not null && attributeModel.HasStereotype("Primary Key"))
{
return mappedEnd.SourceElement.Name;
}

}
}
return null;
}
private static IElementToElementMapping? GetMapEntityQueryMapping(IElement mappedElement)
{
return mappedElement.AssociatedElements.FirstOrDefault(a => a.Association.SpecializationTypeId == "9ea0382a-4617-412a-a8c8-af987bbce226")//Update Entity Action
?.Mappings.FirstOrDefault(mappingModel => mappingModel.TypeId == "25f25af9-c38b-4053-9474-b0fabe9d7ea7");// Query Entity Mapping
}


private static Dictionary<string, HashSet<string>> GetKeyAliases(List<CrudMap> crudTests)
{
var keyAliases = new Dictionary<string, HashSet<string>>();
Expand Down Expand Up @@ -162,20 +138,6 @@ private static Dictionary<string, HashSet<string>> GetKeyAliases(List<CrudMap> c
}
}
}
var dtoFieldPkName = GetDtoPkFieldName(crudTest.Update);
if (dtoFieldPkName != null)
{
string entityId = $"{crudTest.Entity.Name}Id";
if (dtoFieldPkName != entityId && string.Compare(dtoFieldPkName, "Id", true) != 0)
{
if (!keyAliases.TryGetValue(entityId, out var aliases))
{
aliases = new HashSet<string>();
keyAliases[entityId] = aliases;
}
aliases.Add(dtoFieldPkName);
}
}
}

return keyAliases;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<id>Intent.AspNetCore.IntegrationTests.CRUD</id>
<version>1.0.0-pre.4</version>
<version>1.0.0-pre.1</version>
<supportedClientVersions>[4.1.0-beta.21,5.0.0)</supportedClientVersions>
<summary>The module adds implements integration tests for CRUD Services.</summary>
<description>The module adds implements integration tests for CRUD Services.</description>
Expand Down Expand Up @@ -34,7 +34,7 @@
</factoryExtensions>
<moduleSettings></moduleSettings>
<dependencies>
<dependency id="Intent.AspNetCore.IntegrationTesting" version="1.0.0-pre.2" />
<dependency id="Intent.AspNetCore.IntegrationTesting" version="1.0.0-pre.1" />
<dependency id="Intent.Common" version="3.5.0" />
<dependency id="Intent.Common.CSharp" version="3.4.1" />
<dependency id="Intent.Common.Types" version="3.3.9" />
Expand Down
Loading