public void TestFullTextTermRightOperandAnalyzed() { IRemoteCache<String, Transaction> transactionCache = remoteManager.GetCache<String, Transaction>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); qr.QueryString = "from sample_bank_account.Transaction t where longDescription:'RENT'"; QueryResponse result = transactionCache.Query(qr); List<Transaction> transactions = RemoteQueryUtils.unwrapResults<Transaction>(result); Assert.AreEqual(1, transactions.Count); }
public void TestExactMatch() { IRemoteCache<String, Transaction> transactionCache = remoteManager.GetCache<String, Transaction>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); qr.QueryString = "from sample_bank_account.Transaction t where t.description = 'Birthday present'"; QueryResponse result = transactionCache.Query(qr); List<Transaction> transactions = RemoteQueryUtils.unwrapResults<Transaction>(result); Assert.AreEqual(1, transactions.Count); }
public void GetAllTest() { IRemoteCache<int, User> userCache = remoteManager.GetCache<int, User>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); // JpqlString will be deprecated please use QueryString // qr.JpqlString = "from sample_bank_account.User"; qr.QueryString = "from sample_bank_account.User"; QueryResponse result = userCache.Query(qr); List<User> listOfUsers = RemoteQueryUtils.unwrapResults<User>(result); Assert.AreEqual(3, listOfUsers.Count); }
public void Eq1Test() { IRemoteCache<int, User> userCache = remoteManager.GetCache<int, User>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); // JpqlString will be deprecated please use QueryString // qr.JpqlString = "from sample_bank_account.User u where u.name = \"John\""; qr.QueryString = "from sample_bank_account.User u where u.name = \"John\""; QueryResponse result = userCache.Query(qr); List<User> listOfUsers = RemoteQueryUtils.unwrapResults<User>(result); Assert.AreEqual(1, listOfUsers.Count); Assert.AreEqual("John", listOfUsers.ElementAt(0).Name); Assert.AreEqual("Doe", listOfUsers.ElementAt(0).Surname); }
public void ContainsAnyTest() { IRemoteCache<int, User> userCache = remoteManager.GetCache<int, User>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); // JpqlString will be deprecated please use QueryString // qr.JpqlString = "from sample_bank_account.User u where u.accountIds = 2 or u.accountIds = 3 order by u.id asc"; qr.QueryString = "from sample_bank_account.User u where u.accountIds = 2 or u.accountIds = 3 order by u.id asc"; QueryResponse result = userCache.Query(qr); List<User> listOfUsers = RemoteQueryUtils.unwrapResults<User>(result); Assert.AreEqual(2, listOfUsers.Count); Assert.AreEqual(1, listOfUsers.ElementAt(0).Id); Assert.AreEqual(2, listOfUsers.ElementAt(1).Id); }
public void RejectProjectionOfRepeatedPropertyTest() { IRemoteCache<int, User> userCache = remoteManager.GetCache<int, User>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); // JpqlString will be deprecated please use QueryString // qr.JpqlString = "select u.addresses.postcode from sample_bank_account.User u"; qr.QueryString = "select u.addresses.postcode from sample_bank_account.User u"; userCache.Query(qr); }
public void InvalidEmbeddedAttributeTest() { IRemoteCache<int, User> userCache = remoteManager.GetCache<int, User>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); // JpqlString will be deprecated please use QueryString // qr.JpqlString = "select u.addresses from sample_bank_account.User u"; qr.QueryString = "select u.addresses from sample_bank_account.User u"; userCache.Query(qr); }
public void OrTest() { IRemoteCache<int, User> userCache = remoteManager.GetCache<int, User>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); // JpqlString will be deprecated please use QueryString // qr.JpqlString = "from sample_bank_account.User u where (u.surname = \"Man\") or (u.surname = \"Woman\")"; qr.QueryString = "from sample_bank_account.User u where (u.surname = \"Man\") or (u.surname = \"Woman\")"; QueryResponse result = userCache.Query(qr); List<User> listOfUsers = RemoteQueryUtils.unwrapResults<User>(result); Assert.AreEqual(2, listOfUsers.Count); foreach (User u in listOfUsers) { Assert.AreEqual("Spider", u.Name); } }
public void TestFullTextRegexpFuzzyNotAllowed() { IRemoteCache<String, Transaction> transactionCache = remoteManager.GetCache<String, Transaction>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); qr.QueryString = "from sample_bank_account.Transaction t where t.longDescription : /[R|r]ent/~2"; transactionCache.Query(qr); }
public void CountTest() { IRemoteCache<int, User> userCache = remoteManager.GetCache<int, User>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); // JpqlString will be deprecated please use QueryString // qr.JpqlString = "select u.name, count(u.age) from sample_bank_account.User u group by u.name"; qr.QueryString = "select u.name, count(u.age) from sample_bank_account.User u group by u.name"; QueryResponse result = userCache.Query(qr); List<Object[]> projections = RemoteQueryUtils.unwrapWithProjection(result); Assert.AreEqual(2, projections.Count); Assert.AreEqual("John" ,projections.ElementAt(0)[0]); Assert.AreEqual(1, projections.ElementAt(0)[1]); Assert.AreEqual("Spider", projections.ElementAt(1)[0]); Assert.AreEqual(0, projections.ElementAt(1)[1]); }
public void EqHybridQueryWithParamTest() { IRemoteCache<int, User> userCache = remoteManager.GetCache<int, User>(NAMED_CACHE); QueryRequest.Types.NamedParameter param = new QueryRequest.Types.NamedParameter(); WrappedMessage wm = new WrappedMessage(); wm.WrappedString = "Doe"; param.Name = "surnameParam"; param.Value = wm; QueryRequest qr = new QueryRequest(); // JpqlString will be deprecated please use QueryString // qr.JpqlString = "from sample_bank_account.User u where (u.notes = \"Lorem ipsum dolor sit amet\") and (u.surname = :surnameParam)"; qr.QueryString = "from sample_bank_account.User u where (u.notes = \"Lorem ipsum dolor sit amet\") and (u.surname = :surnameParam)"; qr.NamedParameters.Add(param); QueryResponse result = userCache.Query(qr); List<User> listOfUsers = RemoteQueryUtils.unwrapResults<User>(result); Assert.AreEqual(1, listOfUsers.Count); Assert.AreEqual(1, listOfUsers.ElementAt(0).Id); }
public void EqNonIndexedFieldTest() { IRemoteCache<int, User> userCache = remoteManager.GetCache<int, User>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); // JpqlString will be deprecated please use QueryString // qr.JpqlString = "from sample_bank_account.User u where u.notes = \"Lorem ipsum dolor sit amet\""; qr.QueryString = "from sample_bank_account.User u where u.notes = \"Lorem ipsum dolor sit amet\""; QueryResponse result = userCache.Query(qr); List<User> listOfUsers = RemoteQueryUtils.unwrapResults<User>(result); Assert.AreEqual(1, listOfUsers.Count); Assert.AreEqual(1, listOfUsers.ElementAt(0).Id); }
public void TestFullTextTermBoost() { IRemoteCache<String, Transaction> transactionCache = remoteManager.GetCache<String, Transaction>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); qr.QueryString = "from sample_bank_account.Transaction t where t.longDescription:('rent'^8 'shoes')"; QueryResponse result = transactionCache.Query(qr); List<Transaction> transactions = RemoteQueryUtils.unwrapResults<Transaction>(result); Assert.AreEqual(51, transactions.Count); }
public void TestFullTextTermOnNonAnalyzedFieldNotAllowed() { IRemoteCache<String, Transaction> transactionCache = remoteManager.GetCache<String, Transaction>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); qr.QueryString = "from sample_bank_account.Transaction t where t.description:'rent'"; transactionCache.Query(qr); }
public void TestExactMatchOnAnalyzedFieldNotAllowed() { IRemoteCache<String, Transaction> transactionCache = remoteManager.GetCache<String, Transaction>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); qr.QueryString = "from sample_bank_account.Transaction t where t.longDescription = 'Birthday present'"; transactionCache.Query(qr); }
public void StringLiteralEscapeTest() { IRemoteCache<int, Account> userCache = remoteManager.GetCache<int, Account>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); // JpqlString will be deprecated please use QueryString // qr.JpqlString = "from sample_bank_account.Account a where a.description = 'John Doe''s first bank account'"; qr.QueryString = "from sample_bank_account.Account a where a.description = 'John Doe''s first bank account'"; QueryResponse result = userCache.Query(qr); List<User> listOfAccounts = RemoteQueryUtils.unwrapResults<User>(result); Assert.AreEqual(1, listOfAccounts.Count); Assert.AreEqual(1, listOfAccounts.ElementAt(0).Id); }
public void HavingWithAvgTest() { IRemoteCache<int, Transaction> userCache = remoteManager.GetCache<int, Transaction>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); // JpqlString will be deprecated please use QueryString // qr.JpqlString = "select t.accountId, avg(t.amount) from sample_bank_account.Transaction t group by t.accountId having avg(t.amount) < 100"; qr.QueryString = "select t.accountId, avg(t.amount) from sample_bank_account.Transaction t group by t.accountId having avg(t.amount) < 100"; QueryResponse result = userCache.Query(qr); List<Object[]> projections = RemoteQueryUtils.unwrapWithProjection(result); Assert.AreEqual(1, projections.Count); Assert.AreEqual(2, projections.ElementAt(0)[0]); Assert.AreEqual(48.0, (double)projections.ElementAt(0)[1], 0.001d); }
public void EqInNested1Test() { IRemoteCache<int, User> userCache = remoteManager.GetCache<int, User>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); // JpqlString will be deprecated please use QueryString // qr.JpqlString = "from sample_bank_account.User u where u.addresses.postCode = \"X1234\""; qr.QueryString = "from sample_bank_account.User u where u.addresses.postCode = \"X1234\""; QueryResponse result = userCache.Query(qr); List<User> listOfUsers = RemoteQueryUtils.unwrapResults<User>(result); Assert.AreEqual(1, listOfUsers.Count); Assert.AreEqual("X1234", listOfUsers.ElementAt(0).Addresses.ElementAt(0).PostCode); }
public void GlobalSumTest() { IRemoteCache<int, Transaction> userCache = remoteManager.GetCache<int, Transaction>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); // JpqlString will be deprecated please use QueryString // qr.JpqlString = "select sum(t.amount) from sample_bank_account.Transaction t"; qr.QueryString = "select sum(t.amount) from sample_bank_account.Transaction t"; QueryResponse result = userCache.Query(qr); List<Object[]> projections = RemoteQueryUtils.unwrapWithProjection(result); Assert.AreEqual(1, projections.Count); Assert.AreEqual(3467.0, (double)projections.ElementAt(0)[0], 0.001d); }
public void BetweenTest() { IRemoteCache<int, Transaction> txCache = remoteManager.GetCache<int, Transaction>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); // JpqlString will be deprecated please use QueryString // qr.JpqlString = "from sample_bank_account.Transaction t where t.date between \""+ MakeDate("2013-01-01") +"\" and \"" + MakeDate("2013-01-31") + "\""; qr.QueryString = "from sample_bank_account.Transaction t where t.date between \""+ MakeDate("2013-01-01") +"\" and \"" + MakeDate("2013-01-31") + "\""; QueryResponse result = txCache.Query(qr); List<Transaction> listOfTx = RemoteQueryUtils.unwrapResults<Transaction>(result); Assert.AreEqual(4, listOfTx.Count); foreach (Transaction tx in listOfTx) { Assert.True(tx.Date >= MakeDate("2013-01-01") && tx.Date <= MakeDate("2013-01-31")); } }
public void GreaterThanTest() { IRemoteCache<int, Transaction> txCache = remoteManager.GetCache<int, Transaction>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); // JpqlString will be deprecated please use QueryString // qr.JpqlString = "from sample_bank_account.Transaction t where t.amount > 1500"; qr.QueryString = "from sample_bank_account.Transaction t where t.amount > 1500"; QueryResponse result = txCache.Query(qr); List<Transaction> listOfTx = RemoteQueryUtils.unwrapResults<Transaction>(result); Assert.AreEqual(1, listOfTx.Count); Assert.True(listOfTx.ElementAt(0).Amount > 1500); }
public void TestFullTextWithAggregation() { IRemoteCache<String, Transaction> transactionCache = remoteManager.GetCache<String, Transaction>(NAMED_CACHE); QueryRequest qr = new QueryRequest(); qr.QueryString = "select t.accountId, max(t.amount), max(t.description) from sample_bank_account.Transaction t where t.longDescription : (+'beer' -'food') group by t.accountId"; QueryResponse result = transactionCache.Query(qr); List<Object[]> projections = RemoteQueryUtils.unwrapWithProjection(result); Assert.AreEqual(1, projections.Count); Assert.AreEqual(2, projections.ElementAt(0)[0]); Assert.AreEqual(149.0, (double)projections.ElementAt(0)[1], 0.001d); Assert.AreEqual("Expensive shoes 9", projections.ElementAt(0)[2]); }