Skip to content

7.x integration tests fixes #4166

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

Merged
merged 2 commits into from
Oct 21, 2019
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 @@ -342,9 +342,6 @@ public static PropertiesDescriptor<TProject> ProjectProperties<TProject>(Propert
.GeoShape(g => g
.Name(p => p.LocationShape)
)
.Shape(g => g
.Name(p => p.ArbitraryShape)
)
.Completion(cm => cm
.Name(p => p.Suggest)
.Contexts(cx => cx
Expand Down Expand Up @@ -377,6 +374,11 @@ public static PropertiesDescriptor<TProject> ProjectProperties<TProject>(Propert
.Enabled(false)
);

if (TestConfiguration.Instance.InRange(">=7.4.0"))
props.Shape(g => g
.Name(p => p.ArbitraryShape)
);

return props;
}

Expand Down
1 change: 0 additions & 1 deletion src/Tests/Tests.Domain/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public class Project
public SimpleGeoPoint LocationPoint { get; set; }
public IGeoShape LocationShape { get; set; }

[Shape] // Explicity map as a shape type
public IGeoShape ArbitraryShape { get; set; }
public Dictionary<string, Metadata> Metadata { get; set; }
public string Name { get; set; }
Expand Down
1 change: 0 additions & 1 deletion src/Tests/Tests/CodeStandards/Serialization/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using FluentAssertions;
using Nest;
using Tests.Core.Serialization;
using Tests.QueryDsl.Geo.Shape;
using Tests.XPack.MachineLearning;

namespace Tests.CodeStandards.Serialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public PutMappingApiTests(WritableCluster cluster, EndpointUsage usage) : base(c
.Name(p => p.Name)
.Index(false)
)
.Shape(shape => shape.Name(p => p.ArbitraryShape))
.Object<Developer>(o => o
.Name(p => p.LeadDeveloper)
.AutoMap()
Expand Down
108 changes: 2 additions & 106 deletions src/Tests/Tests/QueryDsl/Specialized/Shape/ShapeQueryUsageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Tests.Domain;
using Tests.Framework.EndpointTests.TestState;

namespace Tests.QueryDsl.Geo.Shape
namespace Tests.QueryDsl.Specialized.Shape
{
/**
* Like geo_shape, Elasticsearch supports the ability to index arbitrary two dimension (non Geospatial) geometries making
Expand All @@ -14,6 +14,7 @@ namespace Tests.QueryDsl.Geo.Shape
*
* See the Elasticsearch documentation on {ref_current}/query-dsl-shape-query.html[shape queries] for more detail.
*/
[SkipVersion("<7.4.0", "Shape queries introduced in 7.4.0+")]
public abstract class ShapeQueryUsageTestsBase : QueryDslUsageTestsBase
{
protected static readonly GeoCoordinate CircleCoordinates = new GeoCoordinate(-45.0, 45.0);
Expand Down Expand Up @@ -153,58 +154,6 @@ protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project>
);
}

// hide
[SkipVersion(">=7.0.0", "Multipoint queries are not supported in shape queries")]
public class ShapeMultiPointQueryUsageTests : ShapeQueryUsageTestsBase
{
public ShapeMultiPointQueryUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { }

protected override ConditionlessWhen ConditionlessWhen => new ConditionlessWhen<IShapeQuery>(a => a.Shape)
{
q => q.Field = null,
q => q.Shape = null,
q => ((IMultiPointGeoShape)q.Shape).Coordinates = null,
};

protected override QueryContainer QueryInitializer => new ShapeQuery
{
Name = "named_query",
Boost = 1.1,
Field = Infer.Field<Project>(p => p.ArbitraryShape),
Shape = new MultiPointGeoShape(MultiPointCoordinates),
Relation = ShapeRelation.Intersects,
};

protected override object QueryJson => new
{
shape = new
{
_name = "named_query",
boost = 1.1,
arbitraryShape = new
{
relation = "intersects",
shape = new
{
type = "multipoint",
coordinates = MultiPointCoordinates
}
}
}
};

protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project> q) => q
.Shape(c => c
.Name("named_query")
.Boost(1.1)
.Field(p => p.ArbitraryShape)
.Shape(s => s
.MultiPoint(MultiPointCoordinates)
)
.Relation(ShapeRelation.Intersects)
);
}

/**
* [float]
* [[shape-query-linestring]]
Expand Down Expand Up @@ -597,59 +546,6 @@ protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project>
);
}

// hide
[SkipVersion(">=7.0.0", "Circle queries are not supported in shape queries")]
public class ShapeCircleQueryUsageTests : ShapeQueryUsageTestsBase
{
public ShapeCircleQueryUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { }

protected override ConditionlessWhen ConditionlessWhen => new ConditionlessWhen<IShapeQuery>(a => a.Shape)
{
q => q.Field = null,
q => q.Shape = null,
q => ((ICircleGeoShape)q.Shape).Coordinates = null,
};

protected override QueryContainer QueryInitializer => new ShapeQuery
{
Name = "named_query",
Boost = 1.1,
Field = Infer.Field<Project>(p => p.ArbitraryShape),
Shape = new CircleGeoShape(CircleCoordinates, "100m"),
Relation = ShapeRelation.Intersects,
};

protected override object QueryJson => new
{
shape = new
{
_name = "named_query",
boost = 1.1,
arbitraryShape = new
{
relation = "intersects",
shape = new
{
type = "circle",
radius = "100m",
coordinates = CircleCoordinates
}
}
}
};

protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project> q) => q
.Shape(c => c
.Name("named_query")
.Boost(1.1)
.Field(p => p.ArbitraryShape)
.Shape(s => s
.Circle(CircleCoordinates, "100m")
)
.Relation(ShapeRelation.Intersects)
);
}

/**
* [float]
* [[shape-query-indexedshape]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
using Tests.Framework.EndpointTests;
using Tests.Framework.EndpointTests.TestState;

namespace Tests.QueryDsl.Geo.Shape
namespace Tests.QueryDsl.Specialized.Shape
{
[SkipVersion("<7.4.0", "Shape queries introduced in 7.4.0+")]
public abstract class ShapeSerializationTestsBase
: ApiIntegrationTestBase<IntrusiveOperationCluster,
ISearchResponse<Domain.Shape>,
Expand Down