/** * @param constraint constraint to convert * @param code code for constraint, e.g. A * @return constraint in JSON format */ protected String constraintToJson(PathConstraint constraint, String code) { if (PathConstraint.getType(constraint) != null) { // Would be nice to test code instead... return typeConstraintToJson(constraint); } else { return valueConstraintToJson(code, constraint); } }
private void getVariableNames(Set<String> variables, Node node) { if (node instanceof Operator) { for (Node child : ((Operator) node).getChildren()) { getVariableNames(variables, child); } } else { variables.add(((Variable) node).getName()); } }
private PathQuery getQuery1(Model model) { PathQuery q = new PathQuery(model); q.addView("Employee.name"); q.addConstraint(new PathConstraintAttribute("Employee.age", ConstraintOp.LESS_THAN, "50")); return q; }
public void testHeaderAttributes() { PathQuery query = createQuery("HeaderAttributes.xml"); assertEquals(Collections.EMPTY_LIST, query.verifyQuery()); assertEquals(query.getTitle(), "Query Title"); assertEquals(query.getDescription(), "Query Description"); }
public void testOldStyleJoins() throws PathException { PathQuery query = createQuery("OldStyleJoins.xml"); assertEquals(Collections.EMPTY_LIST, query.verifyQuery()); assertEquals(query.getOuterJoinStatus("Employee.department.employees"), OuterJoinStatus.OUTER); }
public void testAppend2() throws Exception { Path expDeptPath = new Path(model, "Department.manager[CEO].company.departments"); Path expEmpPath = new Path(model, "Department.manager[CEO].company.departments.employees"); String testPathStr = "Department.manager[CEO].company"; Path path = new Path(model, testPathStr); Path depPath = path.append("departments"); assertEquals(expDeptPath.toString(), depPath.toString()); Path empPath = depPath.append("employees"); assertEquals(expEmpPath.toString(), empPath.toString()); }
public void testIsRootPath() throws Exception { Path path = new Path(model, "Department"); assertTrue(path.isRootPath()); path = new Path(model, "Department.manager"); assertFalse(path.isRootPath()); }
public void testBrackets2() { LogicExpression l = new LogicExpression("A and (B or C)"); assertEquals("A and (B or C)", l.toString()); }
public void testContainsCollections() throws Exception { String stringPath = "Department.company"; Path path = new Path(model, stringPath); assertFalse(path.containsCollections()); stringPath = "Department.employees.name"; path = new Path(model, stringPath); assertTrue(path.containsCollections()); }
public void testIsOnlyAttribute() throws Exception { String stringPath = "Department.company"; Path path = new Path(model, stringPath); assertFalse(path.isOnlyAttribute()); stringPath = "Department.employees.name"; path = new Path(model, stringPath); assertFalse(path.isOnlyAttribute()); stringPath = "Department.name"; path = new Path(model, stringPath); assertTrue(path.isOnlyAttribute()); }
public void testContainsReferences() throws Exception { String stringPath = "Department.company"; Path path = new Path(model, stringPath); assertTrue(path.containsReferences()); stringPath = "Department.employees.name"; path = new Path(model, stringPath); assertFalse(path.containsReferences()); }
public void testAppend() throws Exception { Path expDepNamePath = new Path(model, "Department.name"); Path path = new Path(model, "Department"); Path depNamePath = path.append("name"); assertEquals(expDepNamePath, depNamePath); }
public void testValidWithClassConstraint() throws Exception { String stringPath = "Department.manager[CEO].company.departments.employees[Manager].age"; Path path = new Path(model, stringPath); checkConstrainedPath(path); }
public void testEquals() throws Exception { Path path1 = new Path(model, "Department.manager.name"); Path path2 = new Path(model, "Department.manager.name"); assertEquals(path1, path2); }
public void testInvalidSortOrder() { PathQuery query = createQuery("InvalidSortOrder.xml"); assertTrue("Invalid sort orders are not tolerated", !query.isValid()); }
public void testInvalidNot() { try { fail("" + new LogicExpression("A not B")); } catch (IllegalArgumentException e) { } }
public void testInvalidConstraintLogic() { PathQuery query = createQuery("InvalidConstraintLogic.xml"); assertEquals(Collections.EMPTY_LIST, query.verifyQuery()); }
public void testExplicitJoins() throws PathException { PathQuery query = createQuery("ExplicitJoins.xml"); assertEquals(Collections.EMPTY_LIST, query.verifyQuery()); assertEquals(query.getOuterJoinStatus("Employee.department.company"), OuterJoinStatus.OUTER); assertEquals(query.getOuterJoinStatus("Employee.department"), OuterJoinStatus.INNER); }
public void testOrderlessSortOrder() { PathQuery query = createQuery("OrderlessSortOrder.xml"); assertTrue("Orderless sort orders are tolerated", query.isValid()); }
/** * @param constraint constraint to convert * @param code code for constraint, e.g. A * @return constraint in JSON format */ protected String constraintToJson(PathConstraint constraint, String code) { if (PathConstraint.getType(constraint) != null) { // Would be nice to test code instead... return typeConstraintToJson(constraint); } else { return valueConstraintToJson(code, constraint); } }