Exemple #1
0
        public void Query_Value_GT_Multiple_Returns()
        {
            var(set, _, _) = StoreProcessor.GetGraphs("app1");

            var query = new ObjectQueryModel
            {
                Filter = new Dictionary <string, QueryUnit>()
                {
                    ["age"] = new QueryUnit {
                        Operator = "ge", Value = 25
                    }
                },
                PageSize = 10
            };

            var rsp         = new ObjectQueryExecutor().Query(query, (RocksGraph)set);
            var values      = rsp.Values.ToArray();
            var testTriple1 = new Triple("300", "age", TripleObject.FromData(30));
            var testTriple2 = new Triple("700", "age", TripleObject.FromData(30));

            CollectionAssert.Contains(values, testTriple1);
            CollectionAssert.Contains(values, testTriple2);
            Assert.AreEqual(2, rsp.Values.Count());
            Assert.AreEqual(null, rsp.Continuation);
        }
Exemple #2
0
        public void Query_With_Outgoing_Id_Returns()
        {
            var(set, _, _) = StoreProcessor.GetGraphs("app1");

            var query = new ObjectQueryModel
            {
                Filter = new Dictionary <string, QueryUnit>()
                {
                    ["name"] = new QueryUnit {
                        Operator = "contains", Value = "name"
                    }
                },
                PageSize  = 10,
                HasObject = new LinkQuery[]
                {
                    new LinkQuery
                    {
                        Path   = "contains/values",
                        Target = new ObjectQueryModel
                        {
                            Id = "800"
                        }
                    }
                }
            };

            var rsp    = new ObjectQueryExecutor().Query(query, (RocksGraph)set);
            var values = rsp.Values.Select(x => x.Subject).ToArray();

            CollectionAssert.Contains(values, "500");
            CollectionAssert.Contains(values, "800");
            Assert.AreEqual(2, rsp.Values.Count());
        }
Exemple #3
0
        public void Query_Outgoing_One_Level_Star_Returns()
        {
            var(set, _, _) = StoreProcessor.GetGraphs("app1");

            var query = new ObjectQueryModel {
                Filter = new Dictionary <string, QueryUnit>()
                {
                    ["type"] = new QueryUnit {
                        Operator = "eq", Value = "building"
                    }
                },
                PageSize  = 10,
                HasObject = new LinkQuery[]
                {
                    new LinkQuery
                    {
                        Path   = "*",
                        Target = new ObjectQueryModel
                        {
                            Filter = new Dictionary <string, QueryUnit>()
                            {
                                ["type"] = new QueryUnit {
                                    Operator = "eq", Value = "floor"
                                }
                            }
                        }
                    }
                }
            };

            var rsp    = new ObjectQueryExecutor().Query(query, (RocksGraph)set);
            var values = rsp.Values.ToArray();

            CollectionAssert.AreEquivalent(new string[] { "oBZ_JoNOBC", "zKbQyTeF" }, rsp.Values.Select(x => x.Subject).ToArray());
        }
        public void Query_Value_LE_Multiple_Returns()
        {
            var(set, _, _) = StoreProcessor.GetGraphs("app1");

            var query = new ObjectQueryModel
            {
                Filter = new Dictionary <string, QueryUnit>()
                {
                    ["name"] = new QueryUnit {
                        Operator = "contains", Value = "name"
                    },
                    ["age"] = new QueryUnit {
                        Operator = "le", Value = 20
                    }
                },
                PageSize = 10
            };

            var rsp         = new ObjectQueryExecutor().Query(query, (RocksGraph)set);
            var values      = rsp.Values.ToArray();
            var testTriple1 = new Triple("100", "name", (new JValue("name100"), -1));
            var testTriple2 = new Triple("500", "name", (new JValue("name500"), -1));

            CollectionAssert.Contains(values, testTriple1);
            CollectionAssert.Contains(values, testTriple2);
            Assert.AreEqual(2, rsp.Values.Count());
            Assert.AreEqual(null, rsp.Continuation);
        }
Exemple #5
0
        public void Query_Incoming_Two_Level_Star_Returns()
        {
            var(set, _, _) = StoreProcessor.GetGraphs("app1");

            var query = new ObjectQueryModel {
                Filter = new Dictionary <string, QueryUnit>()
                {
                    ["type"] = new QueryUnit {
                        Operator = "eq", Value = "sensor"
                    }
                },
                PageSize   = 64,
                HasSubject = new LinkQuery[]
                {
                    new LinkQuery
                    {
                        Path   = "*/*",
                        Target = new ObjectQueryModel
                        {
                            Id = "fR5pgeHPpH"
                        }
                    }
                }
            };

            var rsp    = new ObjectQueryExecutor().Query(query, (RocksGraph)set);
            var values = rsp.Values.ToArray();

            Assert.AreEqual(4, values.Count());
            Assert.AreEqual(rsp.Continuation, null);
        }
        public void Query_Value_Id_Returns_Empty()
        {
            var(set, _, _) = StoreProcessor.GetGraphs("app1");

            var query = new ObjectQueryModel
            {
                Id = "210",
            };

            var rsp = new ObjectQueryExecutor().Query(query, (RocksGraph)set);

            Assert.AreEqual(0, rsp.Values.Count());
            Assert.AreEqual(rsp.Continuation, null);
        }
Exemple #7
0
 public ContinuationTest()
 {
     var(set, _, _) = StoreProcessor.GetGraphs(SetId);
     _set           = (RocksGraph)set;
     foreach (var s in Enumerable.Range(0, 10))
     {
         foreach (var p in Enumerable.Range(0, 10))
         {
             foreach (var o in Enumerable.Range(0, 10))
             {
                 _set.Assert(s.ToString(), p.ToString(), (o.ToString(), o));
             }
         }
     }
 }
        public void Query_Value_Id_Returns()
        {
            var(set, _, _) = StoreProcessor.GetGraphs("app1");

            var query = new ObjectQueryModel
            {
                Id = "300",
            };

            var rsp        = new ObjectQueryExecutor().Query(query, (RocksGraph)set);
            var values     = rsp.Values.ToArray();
            var testTriple = new Triple("300", "age", (new JValue(30), -1));

            CollectionAssert.Contains(values, testTriple);
            Assert.AreEqual(1, values.Count());
            Assert.AreEqual(rsp.Continuation, null);
        }
        public void Query_Value_EQ_Single_Returns_Empty()
        {
            var(set, _, _) = StoreProcessor.GetGraphs("app1");

            var query = new ObjectQueryModel
            {
                Filter = new Dictionary <string, QueryUnit>()
                {
                    ["name"] = new QueryUnit {
                        Operator = "eq", Value = "notpresent"
                    }
                },
                PageSize = 10
            };

            var rsp = new ObjectQueryExecutor().Query(query, (RocksGraph)set);

            Assert.AreEqual(0, rsp.Values.Count());
            Assert.AreEqual(rsp.Continuation, null);
        }
        public void Query_Outgoing_Level_Circular_Returns()
        {
            var(set, _, _) = StoreProcessor.GetGraphs("app1");

            var query = new ObjectQueryModel
            {
                Filter = new Dictionary <string, QueryUnit>()
                {
                    ["name"] = new QueryUnit {
                        Operator = "contains", Value = "name"
                    }
                },
                PageSize  = 10,
                HasObject = new LinkQuery[]
                {
                    new LinkQuery
                    {
                        Path   = "*",
                        Level  = 3,
                        Target = new ObjectQueryModel
                        {
                            Filter = new Dictionary <string, QueryUnit>()
                            {
                                ["name"] = new QueryUnit {
                                    Operator = "eq", Value = "name800"
                                }
                            }
                        }
                    }
                }
            };

            var rsp    = new ObjectQueryExecutor().Query(query, set);
            var values = rsp.Values.Select(x => x.Subject).ToArray();

            CollectionAssert.Contains(values, "500");
            CollectionAssert.Contains(values, "600");
            CollectionAssert.Contains(values, "800");
            Assert.AreEqual(3, rsp.Values.Count());
            Assert.AreEqual(null, rsp.Continuation);
        }
        public void Query_Incoming_Level_Returns()
        {
            var(set, _, _) = StoreProcessor.GetGraphs("app2");

            var query = new ObjectQueryModel
            {
                Filter = new Dictionary <string, QueryUnit>()
                {
                    ["name"] = new QueryUnit {
                        Operator = "contains", Value = "name"
                    }
                },
                PageSize   = 10,
                HasSubject = new LinkQuery[]
                {
                    new LinkQuery
                    {
                        Path   = "*",
                        Level  = 3,
                        Target = new ObjectQueryModel
                        {
                            Filter = new Dictionary <string, QueryUnit>()
                            {
                                ["name"] = new QueryUnit {
                                    Operator = "eq", Value = "root1"
                                }
                            }
                        }
                    }
                }
            };

            var rsp    = new ObjectQueryExecutor().Query(query, set);
            var values = rsp.Values.Select(x => x.Subject).ToArray();

            CollectionAssert.AreEqual(values, new string[] { "i00", "i01", "i02", "i03", "i04", "i05", "i06", "i07", "i08", "i09" });
            Assert.AreEqual((Continuation) new Triple("i09", "name", TripleObject.FromData("name09")), rsp.Continuation);
        }
        public void Query_Incoming_Sub_Level_Returns()
        {
            var(set, _, _) = StoreProcessor.GetGraphs("app2");

            var query = new ObjectQueryModel
            {
                Filter = new Dictionary <string, QueryUnit>()
                {
                    ["name"] = new QueryUnit {
                        Operator = "contains", Value = "name"
                    }
                },
                PageSize   = 10,
                HasSubject = new LinkQuery[]
                {
                    new LinkQuery
                    {
                        Path   = "*",
                        Level  = 2,
                        Target = new ObjectQueryModel
                        {
                            Filter = new Dictionary <string, QueryUnit>()
                            {
                                ["name"] = new QueryUnit {
                                    Operator = "eq", Value = "root1"
                                }
                            }
                        }
                    }
                }
            };

            var rsp    = new ObjectQueryExecutor().Query(query, set);
            var values = rsp.Values.Select(x => x.Subject).ToArray();

            CollectionAssert.AreEqual(values, new string[] { "c1" });
            Assert.AreEqual(null, rsp.Continuation);
        }
Exemple #13
0
        public void Query_Outgoing_Two_Level_Star_Returns()
        {
            var(set, _, _) = StoreProcessor.GetGraphs("app1");

            var query = new ObjectQueryModel {
                Filter = new Dictionary <string, QueryUnit>()
                {
                    ["type"] = new QueryUnit {
                        Operator = "eq", Value = "building"
                    }
                },
                PageSize  = 10,
                HasObject = new LinkQuery[]
                {
                    new LinkQuery
                    {
                        Path   = "*/*",
                        Target = new ObjectQueryModel
                        {
                            Filter = new Dictionary <string, QueryUnit>()
                            {
                                ["name"] = new QueryUnit {
                                    Operator = "eq", Value = "Entity room 4"
                                }
                            }
                        }
                    }
                }
            };

            var rsp    = new ObjectQueryExecutor().Query(query, (RocksGraph)set);
            var values = rsp.Values.ToArray();

            Assert.AreEqual(1, values.Count());
            Assert.AreEqual(rsp.Continuation, null);
            Assert.AreEqual("oBZ_JoNOBC", values.First().Subject);
        }
Exemple #14
0
        public void Query_With_Incoming_Single_Level_Returns()
        {
            var(set, _, _) = StoreProcessor.GetGraphs("app1");

            var query = new ObjectQueryModel
            {
                Filter = new Dictionary <string, QueryUnit>()
                {
                    ["name"] = new QueryUnit {
                        Operator = "eq", Value = "name300"
                    }
                },
                PageSize   = 10,
                HasSubject = new LinkQuery[]
                {
                    new LinkQuery
                    {
                        Path   = "values",
                        Target = new ObjectQueryModel
                        {
                            Filter = new Dictionary <string, QueryUnit>()
                            {
                                ["name"] = new QueryUnit {
                                    Operator = "eq", Value = "name200"
                                }
                            }
                        }
                    }
                }
            };

            var rsp    = new ObjectQueryExecutor().Query(query, (RocksGraph)set);
            var values = rsp.Values.Select(x => x.Subject).ToArray();

            CollectionAssert.Contains(values, "300");
            Assert.AreEqual(1, values.Length);
        }
        public void Query_With_Continuation_Returns()
        {
            var(set, _, _) = StoreProcessor.GetGraphs("app1");

            var query = new ObjectQueryModel
            {
                Filter = new Dictionary <string, QueryUnit>()
                {
                    ["name"] = new QueryUnit {
                        Operator = "contains", Value = "name"
                    },
                },
                PageSize = 2
            };

            var rsp1 = new ObjectQueryExecutor().Query(query, (RocksGraph)set);

            Assert.AreEqual(2, rsp1.Values.Count());
            Assert.AreEqual(rsp1.Continuation, new Triple("200", "name", TripleObject.FromData("name200")));

            var query2 = new ObjectQueryModel
            {
                Filter = new Dictionary <string, QueryUnit>()
                {
                    ["name"] = new QueryUnit {
                        Operator = "contains", Value = "name"
                    },
                },
                Continuation = rsp1.Continuation,
                PageSize     = 2
            };

            var rsp2 = new ObjectQueryExecutor().Query(query2, (RocksGraph)set);

            Assert.AreEqual(2, rsp2.Values.Count());
            Assert.AreEqual(rsp2.Continuation, new Triple("400", "name", TripleObject.FromData("name400")));

            var query3 = new ObjectQueryModel
            {
                Filter = new Dictionary <string, QueryUnit>()
                {
                    ["name"] = new QueryUnit {
                        Operator = "contains", Value = "name"
                    },
                },
                Continuation = rsp2.Continuation,
                PageSize     = 2
            };

            var rsp3 = new ObjectQueryExecutor().Query(query3, (RocksGraph)set);

            Assert.AreEqual(2, rsp3.Values.Count());
            Assert.AreEqual(rsp3.Continuation, new Triple("600", "name", TripleObject.FromData("name600")));

            var query4 = new ObjectQueryModel
            {
                Filter = new Dictionary <string, QueryUnit>()
                {
                    ["name"] = new QueryUnit {
                        Operator = "contains", Value = "name"
                    },
                },
                Continuation = rsp3.Continuation,
                PageSize     = 2
            };

            var rsp4 = new ObjectQueryExecutor().Query(query4, (RocksGraph)set);

            Assert.AreEqual(2, rsp4.Values.Count());
            Assert.AreEqual(rsp4.Continuation, new Triple("800", "name", TripleObject.FromData("name800")));

            var query5 = new ObjectQueryModel
            {
                Filter = new Dictionary <string, QueryUnit>()
                {
                    ["name"] = new QueryUnit {
                        Operator = "contains", Value = "name"
                    },
                },
                Continuation = rsp4.Continuation,
                PageSize     = 2
            };

            var rsp5 = new ObjectQueryExecutor().Query(query5, (RocksGraph)set);

            Assert.AreEqual(0, rsp5.Values.Count());
            Assert.AreEqual(rsp5.Continuation, null);
        }
Exemple #16
0
        public void Query_With_PageSize_Returns()
        {
            var(set, _, _) = StoreProcessor.GetGraphs("app1");

            var query = new ObjectQueryModel
            {
                Filter = new Dictionary <string, QueryUnit>()
                {
                    ["name"] = new QueryUnit {
                        Operator = "contains", Value = "name"
                    }
                },
                PageSize  = 10,
                HasObject = new LinkQuery[]
                {
                    new LinkQuery
                    {
                        Path   = "contains/values",
                        Target = new ObjectQueryModel
                        {
                            Filter = new Dictionary <string, QueryUnit>()
                            {
                                ["name"] = new QueryUnit {
                                    Operator = "eq", Value = "namev0"
                                }
                            }
                        }
                    }
                }
            };

            var rsp    = new ObjectQueryExecutor().Query(query, (RocksGraph)set);
            var values = rsp.Values.Select(x => x.Subject).ToArray();

            CollectionAssert.AreEqual(values, new string[] { "i00", "i01", "i02", "i03", "i04", "i05", "i06", "i07", "i08", "i09" });
            Assert.AreEqual(new Triple("i09", "name", TripleObject.FromData("name09")), rsp.Continuation);

            var query2 = new ObjectQueryModel
            {
                Continuation = rsp.Continuation,
                Filter       = new Dictionary <string, QueryUnit>()
                {
                    ["name"] = new QueryUnit {
                        Operator = "contains", Value = "name"
                    }
                },
                PageSize  = 10,
                HasObject = new LinkQuery[]
                {
                    new LinkQuery
                    {
                        Path   = "contains/values",
                        Target = new ObjectQueryModel
                        {
                            Filter = new Dictionary <string, QueryUnit>()
                            {
                                ["name"] = new QueryUnit {
                                    Operator = "eq", Value = "namev0"
                                }
                            }
                        }
                    }
                }
            };

            var rsp2    = new ObjectQueryExecutor().Query(query2, (RocksGraph)set);
            var values2 = rsp2.Values.Select(x => x.Subject).ToArray();

            CollectionAssert.AreEqual(values2, new string[] { "i10", "i11", "i12", "i13", "i14", "i15", "i16", "i17", "i18", "i19" });
            Assert.AreEqual(new Triple("i19", "name", TripleObject.FromData("name19")), rsp2.Continuation);

            var query3 = new ObjectQueryModel
            {
                Continuation = rsp2.Continuation,
                Filter       = new Dictionary <string, QueryUnit>()
                {
                    ["name"] = new QueryUnit {
                        Operator = "contains", Value = "name"
                    }
                },
                PageSize  = 1000,
                HasObject = new LinkQuery[]
                {
                    new LinkQuery
                    {
                        Path   = "contains/values",
                        Target = new ObjectQueryModel
                        {
                            Filter = new Dictionary <string, QueryUnit>()
                            {
                                ["name"] = new QueryUnit {
                                    Operator = "eq", Value = "namev0"
                                }
                            }
                        }
                    }
                }
            };

            var rsp3    = new ObjectQueryExecutor().Query(query3, (RocksGraph)set);
            var values3 = rsp3.Values.Select(x => x.Subject).ToArray();

            Assert.AreEqual(80, values3.Length);
            Assert.AreEqual(null, rsp3.Continuation);
        }
Exemple #17
0
 public TripleTest()
 {
     var(set, _, _) = StoreProcessor.GetGraphs(SetId);
     _set           = set;
 }