Skip to content

Commit

Permalink
Make TransformQuerySource synchronous.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielcweber committed Aug 8, 2024
1 parent 3591400 commit c6aad5f
Show file tree
Hide file tree
Showing 18 changed files with 35 additions and 38 deletions.
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
33 changes: 15 additions & 18 deletions test/Tests.Fixtures/CosmosDbEmulatorFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,20 @@ await cosmosClient
await base.DisposeAsync();
}

protected override async Task<IGremlinQuerySource> TransformQuerySource(IGremlinQuerySource g)
{
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)));
}
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

0 comments on commit c6aad5f

Please sign in to comment.