Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Oct 27, 2023
1 parent 0d7560d commit 0723020
Show file tree
Hide file tree
Showing 10 changed files with 300 additions and 309 deletions.
213 changes: 106 additions & 107 deletions tests/Tests/Cluster/ComponentTemplate/ComponentTemplateCrudTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,127 +37,126 @@
using Tests.Framework.EndpointTests;
using Tests.Framework.EndpointTests.TestState;

namespace Tests.Cluster.ComponentTemplate
namespace Tests.Cluster.ComponentTemplate;

public class ComponentTemplateCrudTests
: CrudTestBase<WritableCluster, PutComponentTemplateResponse, GetComponentTemplateResponse, PutComponentTemplateResponse, DeleteComponentTemplateResponse,
ExistsResponse>
{
public class ComponentTemplateCrudTests
: CrudTestBase<WritableCluster, PutComponentTemplateResponse, GetComponentTemplateResponse, PutComponentTemplateResponse, DeleteComponentTemplateResponse,
ExistsResponse>
public ComponentTemplateCrudTests(WritableCluster cluster, EndpointUsage usage) : base(cluster, usage) { }

protected override LazyResponses Exists() =>
Calls<ComponentTemplateExistsDescriptor, ComponentTemplateExistsRequest, IComponentTemplateExistsRequest, ExistsResponse>(
id => new ComponentTemplateExistsRequest(id),
(id, d) => d,
(s, c, f) => c.Cluster.ComponentTemplateExists(s, f),
(s, c, f) => c.Cluster.ComponentTemplateExistsAsync(s, f),
(s, c, r) => c.Cluster.ComponentTemplateExists(r),
(s, c, r) => c.Cluster.ComponentTemplateExistsAsync(r)
);

protected override LazyResponses Create() =>
Calls<PutComponentTemplateDescriptor, PutComponentTemplateRequest, IPutComponentTemplateRequest, PutComponentTemplateResponse>(
CreateInitializer,
CreateFluent,
(s, c, f) => c.Cluster.PutComponentTemplate(s, f),
(s, c, f) => c.Cluster.PutComponentTemplateAsync(s, f),
(s, c, r) => c.Cluster.PutComponentTemplate(r),
(s, c, r) => c.Cluster.PutComponentTemplateAsync(r)
);

private PutComponentTemplateRequest CreateInitializer(string name) => new(name)
{
public ComponentTemplateCrudTests(WritableCluster cluster, EndpointUsage usage) : base(cluster, usage) { }

protected override LazyResponses Exists() =>
Calls<ComponentTemplateExistsDescriptor, ComponentTemplateExistsRequest, IComponentTemplateExistsRequest, ExistsResponse>(
id => new ComponentTemplateExistsRequest(id),
(id, d) => d,
(s, c, f) => c.Cluster.ComponentTemplateExists(s, f),
(s, c, f) => c.Cluster.ComponentTemplateExistsAsync(s, f),
(s, c, r) => c.Cluster.ComponentTemplateExists(r),
(s, c, r) => c.Cluster.ComponentTemplateExistsAsync(r)
);

protected override LazyResponses Create() =>
Calls<PutComponentTemplateDescriptor, PutComponentTemplateRequest, IPutComponentTemplateRequest, PutComponentTemplateResponse>(
CreateInitializer,
CreateFluent,
(s, c, f) => c.Cluster.PutComponentTemplate(s, f),
(s, c, f) => c.Cluster.PutComponentTemplateAsync(s, f),
(s, c, r) => c.Cluster.PutComponentTemplate(r),
(s, c, r) => c.Cluster.PutComponentTemplateAsync(r)
);

private PutComponentTemplateRequest CreateInitializer(string name) => new(name)
Version = 42,
Template = new Template
{
Version = 42,
Template = new Template
Settings = new IndexSettings
{
Settings = new IndexSettings
{
NumberOfShards = 2
}
NumberOfShards = 2
}
};

private IPutComponentTemplateRequest CreateFluent(string name, PutComponentTemplateDescriptor d) => d
.Version(42)
.Template(t => t
.Settings(s => s
.NumberOfShards(2)));

protected override LazyResponses Read() =>
Calls<GetComponentTemplateDescriptor, GetComponentTemplateRequest, IGetComponentTemplateRequest, GetComponentTemplateResponse>(
name => new GetComponentTemplateRequest(name),
(name, d) => d.Name(name),
(s, c, f) => c.Cluster.GetComponentTemplate(s, f),
(s, c, f) => c.Cluster.GetComponentTemplateAsync(s, f),
(s, c, r) => c.Cluster.GetComponentTemplate(r),
(s, c, r) => c.Cluster.GetComponentTemplateAsync(r)
);

protected override void ExpectAfterCreate(GetComponentTemplateResponse response)
{
response.ComponentTemplates.Should().NotBeNull().And.HaveCount(1);
var template = response.ComponentTemplates.First().ComponentTemplate;
template.Version.Should().Be(42);
template.Template.Should().NotBeNull();
template.Template.Settings.Should().NotBeNull().And.NotBeEmpty();
template.Template.Settings.NumberOfShards.Should().Be(2);
}
};

private IPutComponentTemplateRequest CreateFluent(string name, PutComponentTemplateDescriptor d) => d
.Version(42)
.Template(t => t
.Settings(s => s
.NumberOfShards(2)));

protected override LazyResponses Read() =>
Calls<GetComponentTemplateDescriptor, GetComponentTemplateRequest, IGetComponentTemplateRequest, GetComponentTemplateResponse>(
name => new GetComponentTemplateRequest(name),
(name, d) => d.Name(name),
(s, c, f) => c.Cluster.GetComponentTemplate(s, f),
(s, c, f) => c.Cluster.GetComponentTemplateAsync(s, f),
(s, c, r) => c.Cluster.GetComponentTemplate(r),
(s, c, r) => c.Cluster.GetComponentTemplateAsync(r)
);

protected override void ExpectAfterCreate(GetComponentTemplateResponse response)
{
response.ComponentTemplates.Should().NotBeNull().And.HaveCount(1);
var template = response.ComponentTemplates.First().ComponentTemplate;
template.Version.Should().Be(42);
template.Template.Should().NotBeNull();
template.Template.Settings.Should().NotBeNull().And.NotBeEmpty();
template.Template.Settings.NumberOfShards.Should().Be(2);
}

protected override LazyResponses Update() =>
Calls<PutComponentTemplateDescriptor, PutComponentTemplateRequest, IPutComponentTemplateRequest, PutComponentTemplateResponse>(
PutInitializer,
PutFluent,
(s, c, f) => c.Cluster.PutComponentTemplate(s, f),
(s, c, f) => c.Cluster.PutComponentTemplateAsync(s, f),
(s, c, r) => c.Cluster.PutComponentTemplate(r),
(s, c, r) => c.Cluster.PutComponentTemplateAsync(r)
);

private PutComponentTemplateRequest PutInitializer(string name) => new(name)
protected override LazyResponses Update() =>
Calls<PutComponentTemplateDescriptor, PutComponentTemplateRequest, IPutComponentTemplateRequest, PutComponentTemplateResponse>(
PutInitializer,
PutFluent,
(s, c, f) => c.Cluster.PutComponentTemplate(s, f),
(s, c, f) => c.Cluster.PutComponentTemplateAsync(s, f),
(s, c, r) => c.Cluster.PutComponentTemplate(r),
(s, c, r) => c.Cluster.PutComponentTemplateAsync(r)
);

private PutComponentTemplateRequest PutInitializer(string name) => new(name)
{
Version = 84,
Template = new Template
{
Version = 84,
Template = new Template
Settings = new IndexSettings
{
Settings = new IndexSettings
{
NumberOfShards = 1
}
NumberOfShards = 1
}
};
}
};

private IPutComponentTemplateRequest PutFluent(string name, PutComponentTemplateDescriptor d) => d
.Version(84)
.Template(t => t
.Settings(s => s
.NumberOfShards(1)));
private IPutComponentTemplateRequest PutFluent(string name, PutComponentTemplateDescriptor d) => d
.Version(84)
.Template(t => t
.Settings(s => s
.NumberOfShards(1)));

protected override void ExpectAfterUpdate(GetComponentTemplateResponse response)
{
response.ComponentTemplates.Should().NotBeNull().And.HaveCount(1);
var template = response.ComponentTemplates.First().ComponentTemplate;
template.Version.Should().Be(84);
template.Template.Should().NotBeNull();
template.Template.Settings.Should().NotBeNull().And.NotBeEmpty();
template.Template.Settings.NumberOfShards.Should().Be(1);
}
protected override void ExpectAfterUpdate(GetComponentTemplateResponse response)
{
response.ComponentTemplates.Should().NotBeNull().And.HaveCount(1);
var template = response.ComponentTemplates.First().ComponentTemplate;
template.Version.Should().Be(84);
template.Template.Should().NotBeNull();
template.Template.Settings.Should().NotBeNull().And.NotBeEmpty();
template.Template.Settings.NumberOfShards.Should().Be(1);
}

protected override LazyResponses Delete() =>
Calls<DeleteComponentTemplateDescriptor, DeleteComponentTemplateRequest, IDeleteComponentTemplateRequest, DeleteComponentTemplateResponse>(
name => new DeleteComponentTemplateRequest(name),
(name, d) => d,
(s, c, f) => c.Cluster.DeleteComponentTemplate(s, f),
(s, c, f) => c.Cluster.DeleteComponentTemplateAsync(s, f),
(s, c, r) => c.Cluster.DeleteComponentTemplate(r),
(s, c, r) => c.Cluster.DeleteComponentTemplateAsync(r)
);
protected override LazyResponses Delete() =>
Calls<DeleteComponentTemplateDescriptor, DeleteComponentTemplateRequest, IDeleteComponentTemplateRequest, DeleteComponentTemplateResponse>(
name => new DeleteComponentTemplateRequest(name),
(name, d) => d,
(s, c, f) => c.Cluster.DeleteComponentTemplate(s, f),
(s, c, f) => c.Cluster.DeleteComponentTemplateAsync(s, f),
(s, c, r) => c.Cluster.DeleteComponentTemplate(r),
(s, c, r) => c.Cluster.DeleteComponentTemplateAsync(r)
);

protected override async Task GetAfterDeleteIsValid() => await AssertOnGetAfterDelete(r => r.ShouldNotBeValid());
protected override async Task GetAfterDeleteIsValid() => await AssertOnGetAfterDelete(r => r.ShouldNotBeValid());

protected override void ExpectDeleteNotFoundResponse(DeleteComponentTemplateResponse response)
{
response.ServerError.Should().NotBeNull();
response.ServerError.Status.Should().Be(404);
response.ServerError.Error.Reason.Should().Contain("missing");
}
protected override void ExpectDeleteNotFoundResponse(DeleteComponentTemplateResponse response)
{
response.ServerError.Should().NotBeNull();
response.ServerError.Status.Should().Be(404);
response.ServerError.Error.Reason.Should().Contain("missing");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,26 @@
using Tests.Framework.EndpointTests;
using Tests.Framework.EndpointTests.TestState;

namespace Tests.Cluster.ComponentTemplate
namespace Tests.Cluster.ComponentTemplate;

public class ComponentTemplateExistsApiTests
: ApiTestBase<WritableCluster, ExistsResponse, IComponentTemplateExistsRequest, ComponentTemplateExistsDescriptor, ComponentTemplateExistsRequest>
{
public class ComponentTemplateExistsApiTests
: ApiTestBase<WritableCluster, ExistsResponse, IComponentTemplateExistsRequest, ComponentTemplateExistsDescriptor, ComponentTemplateExistsRequest>
{
public ComponentTemplateExistsApiTests(WritableCluster cluster, EndpointUsage usage) : base(cluster, usage) { }
public ComponentTemplateExistsApiTests(WritableCluster cluster, EndpointUsage usage) : base(cluster, usage) { }

protected override Func<ComponentTemplateExistsDescriptor, IComponentTemplateExistsRequest> Fluent => d => d;
protected override Func<ComponentTemplateExistsDescriptor, IComponentTemplateExistsRequest> Fluent => d => d;

protected override HttpMethod HttpMethod => HttpMethod.HEAD;
protected override HttpMethod HttpMethod => HttpMethod.HEAD;

protected override ComponentTemplateExistsRequest Initializer => new ComponentTemplateExistsRequest(CallIsolatedValue);
protected override string UrlPath => $"/_component_template/{CallIsolatedValue}";
protected override ComponentTemplateExistsRequest Initializer => new(CallIsolatedValue);
protected override string UrlPath => $"/_component_template/{CallIsolatedValue}";

protected override LazyResponses ClientUsage() => Calls(
(client, f) => client.Cluster.ComponentTemplateExists(CallIsolatedValue, f),
(client, f) => client.Cluster.ComponentTemplateExistsAsync(CallIsolatedValue, f),
(client, r) => client.Cluster.ComponentTemplateExists(r),
(client, r) => client.Cluster.ComponentTemplateExistsAsync(r)
);
protected override LazyResponses ClientUsage() => Calls(
(client, f) => client.Cluster.ComponentTemplateExists(CallIsolatedValue, f),
(client, f) => client.Cluster.ComponentTemplateExistsAsync(CallIsolatedValue, f),
(client, r) => client.Cluster.ComponentTemplateExists(r),
(client, r) => client.Cluster.ComponentTemplateExistsAsync(r)
);

protected override ComponentTemplateExistsDescriptor NewDescriptor() => new ComponentTemplateExistsDescriptor(CallIsolatedValue);
}
protected override ComponentTemplateExistsDescriptor NewDescriptor() => new(CallIsolatedValue);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@
using Tests.Framework.EndpointTests;
using static Tests.Framework.EndpointTests.UrlTester;

namespace Tests.Cluster.ComponentTemplate
namespace Tests.Cluster.ComponentTemplate;

public class ComponentTemplateExistsUrlTests
{
public class ComponentTemplateExistsUrlTests
[U] public async Task Urls()
{
[U] public async Task Urls()
{
var name = "temp";
await HEAD($"/_component_template/{name}")
.Fluent(c => c.Cluster.ComponentTemplateExists(name))
.Request(c => c.Cluster.ComponentTemplateExists(new ComponentTemplateExistsRequest(name)))
.FluentAsync(c => c.Cluster.ComponentTemplateExistsAsync(name))
.RequestAsync(c => c.Cluster.ComponentTemplateExistsAsync(new ComponentTemplateExistsRequest(name)))
;
}
var name = "temp";
await HEAD($"/_component_template/{name}")
.Fluent(c => c.Cluster.ComponentTemplateExists(name))
.Request(c => c.Cluster.ComponentTemplateExists(new ComponentTemplateExistsRequest(name)))
.FluentAsync(c => c.Cluster.ComponentTemplateExistsAsync(name))
.RequestAsync(c => c.Cluster.ComponentTemplateExistsAsync(new ComponentTemplateExistsRequest(name)))
;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,25 @@
using Tests.Framework.EndpointTests;
using Tests.Framework.EndpointTests.TestState;

namespace Tests.Cluster.ComponentTemplate
namespace Tests.Cluster.ComponentTemplate;

public class DeleteComponentTemplateApiTests
: ApiTestBase<WritableCluster, DeleteComponentTemplateResponse, IDeleteComponentTemplateRequest, DeleteComponentTemplateDescriptor,
DeleteComponentTemplateRequest>
{
public class DeleteComponentTemplateApiTests
: ApiTestBase<WritableCluster, DeleteComponentTemplateResponse, IDeleteComponentTemplateRequest, DeleteComponentTemplateDescriptor,
DeleteComponentTemplateRequest>
{
public DeleteComponentTemplateApiTests(WritableCluster cluster, EndpointUsage usage) : base(cluster, usage) { }
public DeleteComponentTemplateApiTests(WritableCluster cluster, EndpointUsage usage) : base(cluster, usage) { }

protected override Func<DeleteComponentTemplateDescriptor, IDeleteComponentTemplateRequest> Fluent => d => d;
protected override HttpMethod HttpMethod => HttpMethod.DELETE;
protected override DeleteComponentTemplateRequest Initializer => new DeleteComponentTemplateRequest(CallIsolatedValue);
protected override string UrlPath => $"/_component_template/{CallIsolatedValue}";
protected override Func<DeleteComponentTemplateDescriptor, IDeleteComponentTemplateRequest> Fluent => d => d;
protected override HttpMethod HttpMethod => HttpMethod.DELETE;
protected override DeleteComponentTemplateRequest Initializer => new(CallIsolatedValue);
protected override string UrlPath => $"/_component_template/{CallIsolatedValue}";

protected override LazyResponses ClientUsage() => Calls(
(client, f) => client.Cluster.DeleteComponentTemplate(CallIsolatedValue, f),
(client, f) => client.Cluster.DeleteComponentTemplateAsync(CallIsolatedValue, f),
(client, r) => client.Cluster.DeleteComponentTemplate(r),
(client, r) => client.Cluster.DeleteComponentTemplateAsync(r)
);
protected override LazyResponses ClientUsage() => Calls(
(client, f) => client.Cluster.DeleteComponentTemplate(CallIsolatedValue, f),
(client, f) => client.Cluster.DeleteComponentTemplateAsync(CallIsolatedValue, f),
(client, r) => client.Cluster.DeleteComponentTemplate(r),
(client, r) => client.Cluster.DeleteComponentTemplateAsync(r)
);

protected override DeleteComponentTemplateDescriptor NewDescriptor() => new DeleteComponentTemplateDescriptor(CallIsolatedValue);
}
protected override DeleteComponentTemplateDescriptor NewDescriptor() => new(CallIsolatedValue);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@
using Tests.Framework.EndpointTests;
using static Tests.Framework.EndpointTests.UrlTester;

namespace Tests.Cluster.ComponentTemplate
namespace Tests.Cluster.ComponentTemplate;

public class DeleteComponentTemplateUrlTests
{
public class DeleteComponentTemplateUrlTests
[U] public async Task Urls()
{
[U] public async Task Urls()
{
var name = "temp";
await DELETE($"/_component_template/{name}")
.Fluent(c => c.Cluster.DeleteComponentTemplate(name))
.Request(c => c.Cluster.DeleteComponentTemplate(new DeleteComponentTemplateRequest(name)))
.FluentAsync(c => c.Cluster.DeleteComponentTemplateAsync(name))
.RequestAsync(c => c.Cluster.DeleteComponentTemplateAsync(new DeleteComponentTemplateRequest(name)))
;
}
var name = "temp";
await DELETE($"/_component_template/{name}")
.Fluent(c => c.Cluster.DeleteComponentTemplate(name))
.Request(c => c.Cluster.DeleteComponentTemplate(new DeleteComponentTemplateRequest(name)))
.FluentAsync(c => c.Cluster.DeleteComponentTemplateAsync(name))
.RequestAsync(c => c.Cluster.DeleteComponentTemplateAsync(new DeleteComponentTemplateRequest(name)))
;
}
}
}
Loading

0 comments on commit 0723020

Please sign in to comment.