Represents a filter on the set of Series. This is used to query a set of series with specific properties. A filter can include ids, keys, tags and attributes. An empty filter is created and filter predicates are added. For example a filter to return series with keys myagley-1 and myagley-2 looks like this:
 {@code Filter filter = new Filter(); filter.addKey("myagley-1"); filter.addKey("myagley-1"); } 
示例#1
0
            public void RequestUrl()
            {
                var mockclient = TestCommon.GetMockRestClient<List<DataSet>>(new List<DataSet>());
                var client = TestCommon.GetClient(mockclient.Object);

                var filter = new Filter();
                filter.AddKey("series1");
                filter.AddKey("series2");
                client.ReadMultipleSeries(new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), filter, IntervalParameter.Raw());

                Expression<Func<RestRequest, bool>> assertion = req => req.Resource == "/data/";
                mockclient.Verify(cl => cl.Execute<List<DataSet>>(It.Is<RestRequest>(assertion)));
            }
示例#2
0
        public void SmokeTest()
        {
            var mockclient = TestCommon.GetMockRestClient<DeleteSummary>(new DeleteSummary());
            var client = TestCommon.GetClient(mockclient.Object);

            var filter = new Filter();
            filter.AddTag("tag1");

            client.DeleteSeries(filter);
            mockclient.Verify(cl => cl.Execute<DeleteSummary>(It.Is<RestRequest>(req => req.Method == Method.DELETE)));
            mockclient.Verify(cl => cl.Execute<DeleteSummary>(It.Is<RestRequest>(req => req.Resource == "/series/")));
            mockclient.Verify(cl => cl.Execute<DeleteSummary>(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "tag", "tag1"))));
        }
示例#3
0
            public void RequestFilter()
            {
                var mockclient = TestCommon.GetMockRestClient<List<DataSet>>(new List<DataSet>());
                var client = TestCommon.GetClient(mockclient.Object);

                var filter = new Filter();
                filter.AddKey("series1");
                filter.AddKey("series2");
                client.ReadMultipleSeries(new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), filter, IntervalParameter.Raw());

                mockclient.Verify(cl => cl.Execute<List<DataSet>>(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "key", "series1"))));
                mockclient.Verify(cl => cl.Execute<List<DataSet>>(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "key", "series2"))));
            }
示例#4
0
            public void SmokeTest()
            {
                List<DataSet> ret = new List<DataSet> {
                new DataSet
                {
                Series = new Series { Key = "series1" }
                },
                new DataSet
                {
                Series = new Series { Key = "series2" }
                }};

                var restClient = TestCommon.GetMockRestClient<List<DataSet>>(ret).Object;
                var client = TestCommon.GetClient(restClient);
                var filter = new Filter();
                filter.AddKey("series1");
                filter.AddKey("series2");
                var results = client.ReadMultipleSeries(new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), filter, IntervalParameter.Raw());
                Assert.AreEqual(2, results.Count);
                Assert.AreEqual("series1", results[0].Series.Key);
                Assert.AreEqual("series2", results[1].Series.Key);
            }
示例#5
0
        public void Filter()
        {
            var mockclient = TestCommon.GetMockRestClient<List<Series>>(new List<Series> {});
            var client = TestCommon.GetClient(mockclient.Object);

            var filter = new Filter();
            filter.AddAttribute("key1", "value1");
            filter.AddAttribute("key2", "value2");
            filter.AddId("id1");
            filter.AddId("id2");
            filter.AddTag("tag1");
            filter.AddTag("tag2");

            client.ListSeries(filter);

            mockclient.Verify(cl => cl.Execute<List<Series>>(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "attr[key1]", "value1"))));
            mockclient.Verify(cl => cl.Execute<List<Series>>(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "attr[key2]", "value2"))));
            mockclient.Verify(cl => cl.Execute<List<Series>>(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "tag", "tag1"))));
            mockclient.Verify(cl => cl.Execute<List<Series>>(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "tag", "tag2"))));
            mockclient.Verify(cl => cl.Execute<List<Series>>(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "id", "id1"))));
            mockclient.Verify(cl => cl.Execute<List<Series>>(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "id", "id2"))));
        }