private void addOuterJoinSimpleTest() { // This one does not really make sense, however its simple and tests that the syntax works. ExpressionBuilder emp = new ExpressionBuilder(); Expression expression = emp.getAllowingNull("address").get("city").equal("Ottawa"); ReadAllExpressionTest test = new ReadAllOuterJoinExpressionTest(Employee.class, 1); test.setName("OuterJoinSimpleTest"); test.setDescription("Test expression with outer joins"); test.setExpression(expression); addTest(test); }
private void addOuterJoinJoiningTest() { ExpressionBuilder emp = new ExpressionBuilder(); ReadAllExpressionTest test = new ReadAllOuterJoinExpressionTest(Employee.class, 12); test.setName("OuterJoinJoiningTest"); test.setDescription("Test joining with outer joins"); ReadAllQuery query = new ReadAllQuery(Employee.class); query.addJoinedAttribute(emp.getAllowingNull("address")); test.setQuery(query); addTest(test); }
private void addOuterJoinJoiningComplexTest() { ExpressionBuilder emp = new ExpressionBuilder(); ReadAllExpressionTest test = new ReadAllOuterJoinExpressionTest(Project.class, 15); test.setName("OuterJoinJoiningComplexTest"); test.setDescription("Test joining with outer joins"); ReadAllQuery query = new ReadAllQuery(Project.class); query.addJoinedAttribute(emp.getAllowingNull("teamLeader")); test.setQuery(query); addTest(test); }
private void addOuterJoinOrderByTest() { ExpressionBuilder emp = new ExpressionBuilder(); ReadAllExpressionTest test = new ReadAllOuterJoinExpressionTest(Employee.class, 12); test.setName("OuterJoinOrderByTest"); test.setDescription("Test order by with outer joins"); ReadAllQuery query = new ReadAllQuery(Employee.class); query.addOrdering(emp.getAllowingNull("address").get("city")); test.setQuery(query); addTest(test); }
private void addOuterJoinManyToManyTest() { ExpressionBuilder emp = new ExpressionBuilder(); Expression expression = emp.get("firstName") .like("%") .or(emp.anyOfAllowingNone("projects").get("description").like("%")); ReadAllExpressionTest test = new ReadAllOuterJoinExpressionTest(Employee.class, 12); test.setName("OuterJoinManytoManyTest"); test.setDescription("Tests manytomany relationships with outer joins"); test.setExpression(expression); addTest(test); }
private void addOuterJoinDirectCollectionTest() { ExpressionBuilder emp = new ExpressionBuilder(); Expression expression = emp.get("firstName") .equal("Nancy") .or(emp.anyOfAllowingNone("responsibilitiesList").equal("Write lots of Java code.")); ReadAllExpressionTest test = new ReadAllOuterJoinExpressionTest(Employee.class, 2); test.setName("OuterJoinDirectCollectionTest"); test.setDescription("Tests direct collection relationships with outer joins"); test.setExpression(expression); addTest(test); }
private void addOuterJoinOrWhereClauseTest2() { ExpressionBuilder emp = new ExpressionBuilder(); Expression expression = emp.get("firstName") .like("Sarah%") .or(emp.getAllowingNull("manager").get("firstName").like("Sarah%")); ReadAllExpressionTest test = new ReadAllOuterJoinExpressionTest(Employee.class, 3); test.setName("OuterJoinOrWhereClauseTest2"); test.setDescription("Test expression with outer joins"); test.setExpression(expression); addTest(test); }
private void addOuterJoinOrAnyWhereClauseTest() { ExpressionBuilder emp = new ExpressionBuilder(); Expression expression = emp.get("firstName") .like("Sarah%") .or(emp.anyOfAllowingNone("phoneNumbers").get("areaCode").equal("613")); ReadAllExpressionTest test = new ReadAllOuterJoinExpressionTest(Employee.class, 10); test.setName("OuterJoinOrAnyWhereClauseTest"); test.setDescription("Test expression anyof with outer joins"); test.setExpression(expression); addTest(test); }
private void addOuterJoinJoiningTest2() { ExpressionBuilder emp = new ExpressionBuilder(); ReadAllExpressionTest test = new ReadAllOuterJoinExpressionTest2( org.eclipse.persistence.testing.models.insurance.PolicyHolder.class, 4); test.setName("OuterJoinJoiningTest2"); test.setDescription("Test joining with outer joins"); ReadAllQuery query = new ReadAllQuery(org.eclipse.persistence.testing.models.insurance.PolicyHolder.class); query.addJoinedAttribute(emp.getAllowingNull("address")); test.setQuery(query); addTest(test); }
private void addOuterJoinIsNullTest() { ExpressionBuilder emp = new ExpressionBuilder(); Expression expression = emp.get("firstName") .equal("Bob") .or(emp.getAllowingNull("address").isNull()) .or(emp.getAllowingNull("address").get("city").equal("Ottawa")); ReadAllExpressionTest test = new ReadAllOuterJoinExpressionTest(Employee.class, 2); test.setName("OuterJoinIsNullTest"); test.setDescription("Test using isNull with outer joins"); test.setExpression(expression); addTest(test); }
private void addOuterJoinAcrossInheritanceTest() { ExpressionBuilder emp = new ExpressionBuilder(); ReadAllExpressionTest test = new ReadAllOuterJoinExpressionTest( org.eclipse.persistence.testing.models.inheritance.Person.class, 1); test.setName("OuterJoinAcrossInheritanceTest"); test.setDescription("Test joining with outer joins across inheritance"); ReadAllQuery query = new ReadAllQuery(org.eclipse.persistence.testing.models.inheritance.Person.class); // This test used to make no sense... // query.setSelectionCriteria(emp.getAllowingNull("representitive").get("name").equalOuterJoin("Richard")); query.addOrdering(emp.getAllowingNull("representitive").get("name")); test.setQuery(query); addTest(test); }
private void addOuterJoinOrWhereClauseTest4() { ExpressionBuilder emp = new ExpressionBuilder(); Expression expression = emp.get("firstName") .like("Bob%") .or( emp.getAllowingNull("address") .get("city") .like("Ot%") .and(emp.getAllowingNull("address").get("city").like("%wa"))); ReadAllExpressionTest test = new ReadAllOuterJoinExpressionTest(Employee.class, 2); test.setName("OuterJoinOrWhereClauseTest4"); test.setDescription("Test expression with outer joins"); test.setExpression(expression); addTest(test); }
public void setup() { if (this.getSession().getLogin().getPlatform().isOracle() || getSession().getLogin().getPlatform().isMySQL()) { ExpressionBuilder emp = new ExpressionBuilder(); expression = emp.get("firstName").getFunction("CONCAT", " is cool!").equal("Sarah" + " is cool!"); getQuery(true).setSelectionCriteria(expression); super.setup(); } else { throw new TestWarningException("This test can only be done on Oracle"); } }