JoinParser extends ParserBase { public static Join[] parse(String expr) { return new JoinParser(expr).joins(); } JoinParser(String expr); static Join[] parse(String expr); Join[] joins();  }
@Test public void testErrorWithoutAlias() { try{ JoinParser.parse("a"); fail("Should thrown exception"); }catch (Exception e) { } }
@Test public void testSingleJoin() { Join[] joins = JoinParser.parse("User u"); assertEquals(1, joins.length); assertEquals("User", joins[0].getRelation()); assertEquals("u", joins[0].getAlias()); joins = JoinParser.parse("User u "); assertEquals(1, joins.length); assertEquals("User", joins[0].getRelation()); assertEquals("u", joins[0].getAlias()); joins = JoinParser.parse(" User u "); assertEquals(1, joins.length); assertEquals("User", joins[0].getRelation()); assertEquals("u", joins[0].getAlias()); }
@Test public void testMultiJoins() { Join[] joins = JoinParser.parse("User1 u1, User2 u2"); assertEquals(2, joins.length); assertEquals("User1", joins[0].getRelation()); assertEquals("u1", joins[0].getAlias()); assertEquals("User2", joins[1].getRelation()); assertEquals("u2", joins[1].getAlias()); }