RestQueryGenerator { public static String generatorQuery(BlockOperation block) throws RemoteException { StringBuilder builder = new StringBuilder(); handleBlockOperation(builder, block); return builder.toString(); } private  RestQueryGenerator(); static String generatorQuery(BlockOperation block); static String generateOrderParams(List<SortParameter> sortParameterList); static final String STRING_ESCAPE; }
@Test public void testComplexQueryGenerator() throws RemoteException { OrBlock orBlock = new OrBlock(); AndBlock block1 = new AndBlock(); block1.addCondition("field1", new EqualsCondition(new StringKey("value1"))); block1.addCondition("field2", new EqualsCondition(new LongKey(1099))); AndBlock block2 = new AndBlock(); block2.addCondition("field3", new RangeCondition(new LongKey(10), true, new LongKey(100), true)); orBlock.addChildBlock(block1); orBlock.addChildBlock(block2); orBlock.addCondition("age", new EqualsCondition(new StringKey("100"))); String generatedQuery = RestQueryGenerator.generatorQuery(orBlock); assertTrue("Unexpected Query", generatedQuery.contains("age='100'")); assertTrue("Unexpected Query", generatedQuery.contains("field3>=10")); assertTrue("Unexpected Query", generatedQuery.contains("field3<=100")); assertTrue("Unexpected Query", generatedQuery.contains("field2=1099")); assertTrue("Unexpected Query", generatedQuery.contains("field1='value1'")); assertEquals("Unexpected query", 2, gatherCharacterCount('|', generatedQuery)); assertEquals("Unexpected query", 2, gatherCharacterCount(',', generatedQuery)); assertEquals("Unexpected query", 2, gatherCharacterCount('(', generatedQuery)); assertEquals("Unexpected query", 2, gatherCharacterCount(')', generatedQuery)); }