Exemplo n.º 1
0
        //hide
        private static void AssertVisitedProperties(GetMappingResponse response)
        {
            var visitor = new TestVisitor();
            var b       = TestClient.Configuration.Random.SourceSerializer;

            var supportsFlattenedType   = TestConfiguration.Instance.InRange(">=7.3.0");
            var supportsConstantKeyword = TestConfiguration.Instance.InRange(">=7.7.0");

            var keywordCount = b ? 19 : 18;

            if (!supportsConstantKeyword)
            {
                keywordCount++;
            }

            response.Accept(visitor);
            visitor.CountsShouldContainKeyAndCountBe("type", 1);
            visitor.CountsShouldContainKeyAndCountBe("text", b ? 18 : 17);
            visitor.CountsShouldContainKeyAndCountBe("keyword", keywordCount);
            visitor.CountsShouldContainKeyAndCountBe("object", supportsFlattenedType? 8 : 9);
            visitor.CountsShouldContainKeyAndCountBe("number", 9);
            visitor.CountsShouldContainKeyAndCountBe("ip", 2);
            visitor.CountsShouldContainKeyAndCountBe("geo_point", 3);
            visitor.CountsShouldContainKeyAndCountBe("date", 4);
            visitor.CountsShouldContainKeyAndCountBe("join", 1);
            visitor.CountsShouldContainKeyAndCountBe("completion", 2);
            visitor.CountsShouldContainKeyAndCountBe("date_range", 1);
            visitor.CountsShouldContainKeyAndCountBe("double_range", 1);
            visitor.CountsShouldContainKeyAndCountBe("float_range", 1);
            visitor.CountsShouldContainKeyAndCountBe("integer_range", 1);
            visitor.CountsShouldContainKeyAndCountBe("long_range", 1);
            visitor.CountsShouldContainKeyAndCountBe("ip_range", 1);
            visitor.CountsShouldContainKeyAndCountBe("nested", 1);
            visitor.CountsShouldContainKeyAndCountBe("rank_feature", 1);

            if (supportsFlattenedType)
            {
                visitor.CountsShouldContainKeyAndCountBe("flattened", 1);
            }

            if (supportsConstantKeyword)
            {
                visitor.CountsShouldContainKeyAndCountBe("constant_keyword", 1);
            }
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetMappingResponse response = new GetMappingResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Mapping", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <MappingEntry, MappingEntryUnmarshaller>(MappingEntryUnmarshaller.Instance);
                    response.Mapping = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
Exemplo n.º 3
0
        public static IProperty GetPropertyDefinition(GetMappingResponse mappingResponse,
                                                      string indexName,
                                                      string propertyName)
        {
            IProperty propertyDefinition = null;

            if (!mappingResponse.Indices.ContainsKey(indexName))
            {
                return(null);
            }

            var mapping = mappingResponse.GetMappingFor(indexName);

            if (mapping.Properties.ContainsKey(propertyName))
            {
                propertyDefinition = mapping.Properties[propertyName];
            }

            return(propertyDefinition);
        }
        //hide
        private static void AssertVisitedProperties(GetMappingResponse response)
        {
            var visitor = new TestVisitor();
            var b       = TestClient.Configuration.Random.SourceSerializer;

            response.Accept(visitor);
            visitor.CountsShouldContainKeyAndCountBe("type", 1);
            visitor.CountsShouldContainKeyAndCountBe("text", b ? 18 : 17);
            visitor.CountsShouldContainKeyAndCountBe("keyword", b ? 19 : 18);
            visitor.CountsShouldContainKeyAndCountBe("object", 8);
            visitor.CountsShouldContainKeyAndCountBe("number", 9);
            visitor.CountsShouldContainKeyAndCountBe("ip", 2);
            visitor.CountsShouldContainKeyAndCountBe("geo_point", 3);
            visitor.CountsShouldContainKeyAndCountBe("date", 4);
            visitor.CountsShouldContainKeyAndCountBe("join", 1);
            visitor.CountsShouldContainKeyAndCountBe("completion", 2);
            visitor.CountsShouldContainKeyAndCountBe("date_range", 1);
            visitor.CountsShouldContainKeyAndCountBe("double_range", 1);
            visitor.CountsShouldContainKeyAndCountBe("float_range", 1);
            visitor.CountsShouldContainKeyAndCountBe("integer_range", 1);
            visitor.CountsShouldContainKeyAndCountBe("long_range", 1);
            visitor.CountsShouldContainKeyAndCountBe("ip_range", 1);
            visitor.CountsShouldContainKeyAndCountBe("nested", 1);
        }
 //hide
 private static void AssertExtensionMethods(GetMappingResponse response)
 {
     /** The `GetMappingFor` extension method can be used to get a type mapping easily and safely */
     response.GetMappingFor <Project>().Should().NotBeNull();
     response.GetMappingFor(typeof(Project)).Should().NotBeNull();
 }
 protected override void ExpectResponse(GetMappingResponse response)
 {
     response.Indices.Should().BeEmpty();
     response.ServerError.Should().NotBeNull();
 }