@Test public void testQueryWithBuilder() { Map<String, Object> map; map = new HashMap<>(); map.put("i", "2"); dir.createEntry(map); map = new HashMap<>(); map.put("i", "3"); dir.createEntry(map); try (Session session = memDir.getSession()) { QueryBuilder queryBuilder = new QueryBuilder(); checkQueryResult(session, queryBuilder, "1", "2", "3"); queryBuilder = new QueryBuilder().predicate(Predicates.eq("i", "1")); checkQueryResult(session, queryBuilder, "1"); queryBuilder = new QueryBuilder().predicate(Predicates.eq("i", "1")).or(Predicates.eq("i", "2")); checkQueryResult(session, queryBuilder, "1", "2"); queryBuilder = new QueryBuilder().predicate(Predicates.eq("i", "1")).and(Predicates.eq("a", "NotMe")); checkQueryResult(session, queryBuilder); queryBuilder = new QueryBuilder().order(OrderByExprs.asc("i")).limit(1); checkQueryResult(session, queryBuilder, "1"); queryBuilder = new QueryBuilder().order(OrderByExprs.desc("i")).limit(1).countTotal(true); checkQueryResult(session, queryBuilder, 3, "3"); queryBuilder = new QueryBuilder().order(OrderByExprs.desc("i")).limit(1).offset(1).countTotal(true); checkQueryResult(session, queryBuilder, 3, "2"); queryBuilder = new QueryBuilder().predicate(Predicates.eq("pw", "secreet")); try { session.query(queryBuilder, false); fail("should throw"); } catch (DirectoryException e) { assertEquals("Cannot filter on password", e.getMessage()); } try { session.queryIds(queryBuilder); fail("should throw"); } catch (DirectoryException e) { assertEquals("Cannot filter on password", e.getMessage()); } queryBuilder = new QueryBuilder().predicate(Predicates.eq("notAProperty", "foo")); try { session.query(queryBuilder, false); fail("should throw"); } catch (QueryParseException e) { assertEquals("No column: notAProperty for directory: mydir", e.getMessage()); } try { session.queryIds(queryBuilder); fail("should throw"); } catch (QueryParseException e) { assertEquals("No column: notAProperty for directory: mydir", e.getMessage()); } } }
@Override public MemoryDirectorySession getSession() { MemoryDirectorySession session = new MemoryDirectorySession(this); addSession(session); return session; }
MemoryDirectory extends AbstractDirectory { @Override public MemoryDirectorySession getSession() { MemoryDirectorySession session = new MemoryDirectorySession(this); addSession(session); return session; } }
MemoryDirectory extends AbstractDirectory { @Override public MemoryDirectorySession getSession() { MemoryDirectorySession session = new MemoryDirectorySession(this); addSession(session); return session; } MemoryDirectory(MemoryDirectoryDescriptor descriptor); }
MemoryDirectory extends AbstractDirectory { @Override public MemoryDirectorySession getSession() { MemoryDirectorySession session = new MemoryDirectorySession(this); addSession(session); return session; } MemoryDirectory(MemoryDirectoryDescriptor descriptor); @Override MemoryDirectoryDescriptor getDescriptor(); @Override MemoryDirectorySession getSession(); }
MemoryDirectory extends AbstractDirectory { @Override public MemoryDirectorySession getSession() { MemoryDirectorySession session = new MemoryDirectorySession(this); addSession(session); return session; } MemoryDirectory(MemoryDirectoryDescriptor descriptor); @Override MemoryDirectoryDescriptor getDescriptor(); @Override MemoryDirectorySession getSession(); final Set<String> schemaSet; }