@Test public void testGetCommands() { try { final SelectMultiQuery select = createSelect(); final Bson bsonRoot = QueryToMongodb.getRoots("_up", select.getRoots()); final List<Query> list = select.getQueries(); for (int i = 0; i < list.size(); i++) { System.out.println(i + " = " + list.get(i).toString()); final Bson bsonQuery = QueryToMongodb.getCommand(list.get(i)); final Bson pseudoRequest = QueryToMongodb.getFullCommand(bsonQuery, bsonRoot); System.out.println(i + " = " + MongoDbHelper.bsonToString(pseudoRequest, false)); } } catch (final Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
protected static Iterable<Bson> getCommands(final List<Query> queries) { return new Iterable<Bson>() { @Override public Iterator<Bson> iterator() { return new Iterator<Bson>() { private int rank = 0; @Override public Bson next() { try { return getCommand(queries.get(rank++)); } catch (final InvalidParseOperationException e) { LOGGER.error("Bad request", e); return null; } } @Override public boolean hasNext() { return rank < queries.size(); } }; } }; }
QueryToMongodb { protected static Iterable<Bson> getCommands(final List<Query> queries) { return new Iterable<Bson>() { @Override public Iterator<Bson> iterator() { return new Iterator<Bson>() { private int rank = 0; @Override public Bson next() { try { return getCommand(queries.get(rank++)); } catch (final InvalidParseOperationException e) { LOGGER.error("Bad request", e); return null; } } @Override public boolean hasNext() { return rank < queries.size(); } }; } }; } }
QueryToMongodb { protected static Iterable<Bson> getCommands(final List<Query> queries) { return new Iterable<Bson>() { @Override public Iterator<Bson> iterator() { return new Iterator<Bson>() { private int rank = 0; @Override public Bson next() { try { return getCommand(queries.get(rank++)); } catch (final InvalidParseOperationException e) { LOGGER.error("Bad request", e); return null; } } @Override public boolean hasNext() { return rank < queries.size(); } }; } }; } private  QueryToMongodb(); }
QueryToMongodb { protected static Iterable<Bson> getCommands(final List<Query> queries) { return new Iterable<Bson>() { @Override public Iterator<Bson> iterator() { return new Iterator<Bson>() { private int rank = 0; @Override public Bson next() { try { return getCommand(queries.get(rank++)); } catch (final InvalidParseOperationException e) { LOGGER.error("Bad request", e); return null; } } @Override public boolean hasNext() { return rank < queries.size(); } }; } }; } private  QueryToMongodb(); static Bson getRoots(final String field, final Collection<String> roots); static Bson getFullCommand(final Bson command, final Bson roots); static Bson getCommand(final Query query); }
QueryToMongodb { protected static Iterable<Bson> getCommands(final List<Query> queries) { return new Iterable<Bson>() { @Override public Iterator<Bson> iterator() { return new Iterator<Bson>() { private int rank = 0; @Override public Bson next() { try { return getCommand(queries.get(rank++)); } catch (final InvalidParseOperationException e) { LOGGER.error("Bad request", e); return null; } } @Override public boolean hasNext() { return rank < queries.size(); } }; } }; } private  QueryToMongodb(); static Bson getRoots(final String field, final Collection<String> roots); static Bson getFullCommand(final Bson command, final Bson roots); static Bson getCommand(final Query query);  }