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

Sync TransformQuerySource in tests #1682

Merged
merged 2 commits into from
Aug 8, 2024
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class EmptyProjectionValueProtectionSerializationTest : QueryExecutionTes
{
public class EmptyProjectionValueProtectionFixture : GremlinqFixture
{
protected override async Task<IGremlinQuerySource> TransformQuerySource(IGremlinQuerySource g) => g
protected override IGremlinQuerySource TransformQuerySource(IGremlinQuerySource g) => g
.ConfigureEnvironment(_ => _
.ConfigureOptions(o => o.SetValue(GremlinqOption.EnableEmptyProjectionValueProtection, true)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class NoPasswordFixture : GremlinqFixture
private const string CosmosDbEmulatorDatabaseName = "db";
private const string CosmosDbEmulatorCollectionName = "graph";

protected override async Task<IGremlinQuerySource> TransformQuerySource(IGremlinQuerySource g) => g
protected override IGremlinQuerySource TransformQuerySource(IGremlinQuerySource g) => g
.UseCosmosDb<Vertex, Edge>(conf => conf
.At(new Uri("ws://localhost:8901"), CosmosDbEmulatorDatabaseName, CosmosDbEmulatorCollectionName)
.WithPartitionKey(x => x.Label!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public WrongPasswordGremlinServerContainerFixture() : base("PasswordSecureGremli
{
}

protected override async Task<IGremlinQuerySource> TransformQuerySource(IContainer container, IGremlinQuerySource g) => g
protected override IGremlinQuerySource TransformQuerySource(IContainer container, IGremlinQuerySource g) => g
.UseGremlinServer<Vertex, Edge>(_ => _
.At(new UriBuilder("ws", container.Hostname, container.GetMappedPublicPort(8182)).Uri)
.ConfigureClientFactory(factory => factory
Expand Down
36 changes: 19 additions & 17 deletions test/Tests.Fixtures/CosmosDbEmulatorFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ public class CosmosDbEmulatorFixture : GremlinqFixture
private readonly string _collectionName = Guid.NewGuid().ToString("N");
private bool _containerCreated;

protected override async Task<IGremlinQuerySource> TransformQuerySource(IGremlinQuerySource g)
public override async Task InitializeAsync()
{
await base.InitializeAsync();

using (var cosmosClient = new CosmosClient("https://localhost:8081", CosmosDbEmulatorAuthKey))
{
await Policy
Expand All @@ -33,22 +35,6 @@ await Policy
});

_containerCreated = true;

return g
.UseCosmosDb<Vertex, Edge>(conf => conf
.At(new Uri("ws://localhost:8901"), CosmosDbEmulatorDatabaseName, _collectionName)
.AuthenticateBy(CosmosDbEmulatorAuthKey)
.WithPartitionKey(x => x.PartitionKey!)
.UseNewtonsoftJson()
.ConfigureClientFactory(factory => factory
.ConfigureClient(client => client
.ObserveResultStatusAttributes((_, attributes) =>
{
Console.WriteLine(JsonSerializer.Serialize(attributes));
}))))
.ConfigureEnvironment(env => env
.ConfigureOptions(options => options
.SetValue(GremlinqOption.StringComparisonTranslationStrictness, StringComparisonTranslationStrictness.Lenient)));
}
}

Expand All @@ -67,5 +53,21 @@ await cosmosClient

await base.DisposeAsync();
}

protected override IGremlinQuerySource TransformQuerySource(IGremlinQuerySource g) => g
.UseCosmosDb<Vertex, Edge>(conf => conf
.At(new Uri("ws://localhost:8901"), CosmosDbEmulatorDatabaseName, _collectionName)
.AuthenticateBy(CosmosDbEmulatorAuthKey)
.WithPartitionKey(x => x.PartitionKey!)
.UseNewtonsoftJson()
.ConfigureClientFactory(factory => factory
.ConfigureClient(client => client
.ObserveResultStatusAttributes((_, attributes) =>
{
Console.WriteLine(JsonSerializer.Serialize(attributes));
}))))
.ConfigureEnvironment(env => env
.ConfigureOptions(options => options
.SetValue(GremlinqOption.StringComparisonTranslationStrictness, StringComparisonTranslationStrictness.Lenient)));
}
}
2 changes: 1 addition & 1 deletion test/Tests.Fixtures/CosmosDbFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace ExRam.Gremlinq.Tests.Fixtures
{
public class CosmosDbFixture : GremlinqFixture
{
protected override async Task<IGremlinQuerySource> TransformQuerySource(IGremlinQuerySource g) => g
protected override IGremlinQuerySource TransformQuerySource(IGremlinQuerySource g) => g
.UseCosmosDb<Vertex, Edge>(
builder => builder
.AtLocalhost("db", "graph")
Expand Down
2 changes: 1 addition & 1 deletion test/Tests.Fixtures/ElasticSearchNeptuneFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace ExRam.Gremlinq.Providers.Neptune.Tests
{
public class ElasticSearchNeptuneFixture : GremlinqFixture
{
protected override async Task<IGremlinQuerySource> TransformQuerySource(IGremlinQuerySource g) => g
protected override IGremlinQuerySource TransformQuerySource(IGremlinQuerySource g) => g
.UseNeptune<Vertex, Edge>(builder => builder
.AtLocalhost()
.UseElasticSearch(new Uri("http://elastic.search.server")))
Expand Down
2 changes: 1 addition & 1 deletion test/Tests.Fixtures/GremlinServerContainerFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public GremlinServerContainerFixture() : base("tinkerpop/gremlin-server:3.7.2")
{
}

protected override async Task<IGremlinQuerySource> TransformQuerySource(IContainer container, IGremlinQuerySource g) => g
protected override IGremlinQuerySource TransformQuerySource(IContainer container, IGremlinQuerySource g) => g
.UseGremlinServer<Vertex, Edge>(_ => _
.At(new UriBuilder("ws", container.Hostname, container.GetMappedPublicPort(8182)).Uri)
.UseNewtonsoftJson())
Expand Down
2 changes: 1 addition & 1 deletion test/Tests.Fixtures/GremlinServerFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace ExRam.Gremlinq.Tests.Fixtures
{
public class GremlinServerFixture : GremlinqFixture
{
protected override async Task<IGremlinQuerySource> TransformQuerySource(IGremlinQuerySource g) => g
protected override IGremlinQuerySource TransformQuerySource(IGremlinQuerySource g) => g
.UseGremlinServer<Vertex, Edge>(_ => _
.AtLocalhost()
.UseNewtonsoftJson())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public GremlinServerWithoutProjectionContainerFixture() : base("tinkerpop/gremli
{
}

protected override async Task<IGremlinQuerySource> TransformQuerySource(IContainer container, IGremlinQuerySource g) => g
protected override IGremlinQuerySource TransformQuerySource(IContainer container, IGremlinQuerySource g) => g
.UseGremlinServer<Vertex, Edge>(_ => _
.At(new UriBuilder("ws", container.Hostname, container.GetMappedPublicPort(8182)).Uri)
.UseNewtonsoftJson())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace ExRam.Gremlinq.Tests.Fixtures
{
public class GroovyGremlinQuerySerializationFixture : GremlinqFixture
{
protected override async Task<IGremlinQuerySource> TransformQuerySource(IGremlinQuerySource g) => g
protected override IGremlinQuerySource TransformQuerySource(IGremlinQuerySource g) => g
.ConfigureEnvironment(env => env
.ConfigureSerializer(ser => ser
.Add(ConverterFactory
Expand Down
2 changes: 1 addition & 1 deletion test/Tests.Fixtures/JanusGraphContainerFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public JanusGraphContainerFixture() : base("janusgraph/janusgraph:1.0.0")

}

protected override async Task<IGremlinQuerySource> TransformQuerySource(IContainer container, IGremlinQuerySource g) => g
protected override IGremlinQuerySource TransformQuerySource(IContainer container, IGremlinQuerySource g) => g
.UseJanusGraph<Vertex, Edge>(builder => builder
.At(new UriBuilder("ws", container.Hostname, container.GetMappedPublicPort(8182)).Uri)
.UseNewtonsoftJson())
Expand Down
2 changes: 1 addition & 1 deletion test/Tests.Fixtures/JanusGraphFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace ExRam.Gremlinq.Tests.Fixtures
{
public class JanusGraphFixture : GremlinqFixture
{
protected override async Task<IGremlinQuerySource> TransformQuerySource(IGremlinQuerySource g) => g
protected override IGremlinQuerySource TransformQuerySource(IGremlinQuerySource g) => g
.UseJanusGraph<Vertex, Edge>(builder => builder
.AtLocalhost()
.UseNewtonsoftJson())
Expand Down
2 changes: 1 addition & 1 deletion test/Tests.Fixtures/NeptuneContainerFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public NeptuneContainerFixture() : base("tinkerpop/gremlin-server:3.7.2")
{
}

protected override async Task<IGremlinQuerySource> TransformQuerySource(IContainer container, IGremlinQuerySource g) => g
protected override IGremlinQuerySource TransformQuerySource(IContainer container, IGremlinQuerySource g) => g
.UseNeptune<Vertex, Edge>(_ => _
.At(new UriBuilder("ws", container.Hostname, container.GetMappedPublicPort(8182)).Uri)
.UseNewtonsoftJson())
Expand Down
2 changes: 1 addition & 1 deletion test/Tests.Fixtures/NeptuneFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace ExRam.Gremlinq.Tests.Fixtures
{
public class NeptuneFixture : GremlinqFixture
{
protected override async Task<IGremlinQuerySource> TransformQuerySource(IGremlinQuerySource g) => g
protected override IGremlinQuerySource TransformQuerySource(IGremlinQuerySource g) => g
.UseNeptune<Vertex, Edge>(_ => _
.AtLocalhost()
.UseNewtonsoftJson())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public PasswordSecuredGremlinServerContainerFixture() : base("PasswordSecureGrem
{
}

protected override async Task<IGremlinQuerySource> TransformQuerySource(IContainer container, IGremlinQuerySource g) => g
protected override IGremlinQuerySource TransformQuerySource(IContainer container, IGremlinQuerySource g) => g
.UseGremlinServer<Vertex, Edge>(_ => _
.At(new UriBuilder("ws", container.Hostname, container.GetMappedPublicPort(8182)).Uri)
.ConfigureClientFactory(factory => factory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace ExRam.Gremlinq.Providers.GremlinServer.Tests
{
public class RequestMessageWithAliasGremlinServerFixture : GremlinqFixture
{
protected override async Task<IGremlinQuerySource> TransformQuerySource(IGremlinQuerySource g) => g
protected override IGremlinQuerySource TransformQuerySource(IGremlinQuerySource g) => g
.UseGremlinServer<Vertex, Edge>(builder => builder
.AtLocalhost())
.ConfigureEnvironment(env => env
Expand Down
6 changes: 3 additions & 3 deletions test/Tests.Fixtures/TestContainerFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ protected TestContainerFixtureBase(int port = 8182)
_port = port;
}

protected sealed override async Task<IGremlinQuerySource> TransformQuerySource(IGremlinQuerySource g)
protected sealed override IGremlinQuerySource TransformQuerySource(IGremlinQuerySource g)
{
if (_container is { } container)
return await TransformQuerySource(_container, new ContainerAttachedGremlinQuerySource(container, g));
return TransformQuerySource(_container, new ContainerAttachedGremlinQuerySource(container, g));

throw new InvalidOperationException();
}
Expand Down Expand Up @@ -168,6 +168,6 @@ public override async Task DisposeAsync()

protected virtual ContainerBuilder CustomizeContainer(ContainerBuilder builder) => builder;

protected abstract Task<IGremlinQuerySource> TransformQuerySource(IContainer container, IGremlinQuerySource g);
protected abstract IGremlinQuerySource TransformQuerySource(IContainer container, IGremlinQuerySource g);
}
}
4 changes: 2 additions & 2 deletions test/Tests.Infrastructure/GremlinqFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ public class GremlinqFixture : IAsyncLifetime
{
private IGremlinQuerySource? _g;

protected virtual async Task<IGremlinQuerySource> TransformQuerySource(IGremlinQuerySource g) => g;
protected virtual IGremlinQuerySource TransformQuerySource(IGremlinQuerySource g) => g;

public virtual async Task InitializeAsync()
{
_g = await TransformQuerySource(g
_g = TransformQuerySource(g
.ConfigureEnvironment(env => env
.UseModel(GraphModel.FromBaseTypes<Vertex, Edge>())
.AddGraphSonBinarySupport()));
Expand Down