/** * Return new Path that has this Path as its prefix and has fieldName as the last element. * * @param fieldName the field name * @return the new Path * @throws PathException if the resulting Path is not valid */ public Path append(String fieldName) throws PathException { return new Path(model, toString() + "." + fieldName); }
/** * Return new Path that has this Path as its prefix and has fieldName as the last element. * * @param fieldName the field name * @return the new Path * @throws PathException if the resulting Path is not valid */ public Path append(String fieldName) throws PathException { return new Path(model, toString() + "." + fieldName); }
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 testValidWithClassConstraintMap() throws Exception { Map<String, String> constraintMap = new HashMap<String, String>(); constraintMap.put("Department.manager", "CEO"); constraintMap.put("Department.manager.company.departments.employees", "Manager"); String stringPath = "Department.manager.company.departments.employees.age"; Path path = new Path(model, stringPath, constraintMap); checkConstrainedPath(path); }
public void testNotValidConstraintMapColon() throws Exception { Map<String, String> constraintMap = new HashMap<String, String>(); constraintMap.put("Department:manager", "CEO"); String stringPath = "Department.manager.name"; try { new Path(model, stringPath, constraintMap); fail("expected IllegalArgumentException"); } catch (IllegalArgumentException e) { // expected } }
public void testToStringNoConstraints() throws Exception { Map<String, String> constraintMap = new HashMap<String, String>(); constraintMap.put("Department.manager", "CEO"); constraintMap.put("Department.manager.company.departments.employees", "Manager"); String stringPath = "Department.manager.company.departments.employees.age"; Path path = new Path(model, stringPath, constraintMap); assertEquals("Department.manager.company.departments.employees.age", path.toStringNoConstraints()); }
public void testSubclassedPath() throws PathException { Path p; String expected; p = new Path(model, "Department.employees[Manager].seniority"); expected = "Abteilung > Angestellter > Seniority"; assertEquals(expected, WebUtil.formatPath(p, config)); p = new Path(model, "Company.departments.employees[Manager].seniority"); expected = "Firma > Abteilungen > Angestellter > Seniority"; assertEquals(expected, WebUtil.formatPath(p, config)); }
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 testNotSuperclass() throws Exception { Path path = new Path(model, "Department.name"); Company c = (Company) DynamicUtil.createObject(Collections.singleton(Company.class)); try { PathUtil.resolvePath(path, c); fail("Expected exception"); } catch (PathException e) { // Fine } }
public void testCollections() throws Exception { Path path = new Path(model, "Company.departments.name"); Company c = (Company) DynamicUtil.createObject(Collections.singleton(Company.class)); try { PathUtil.resolvePath(path, c); fail("Expected exception"); } catch (RuntimeException e) { // Fine } }
public void testResolveShort() throws Exception { Path path = new Path(model, "Department.name"); Department department = (Department) DynamicUtil.createObject(Collections.singleton(Department.class)); department.setName("department name"); assertEquals("department name", PathUtil.resolvePath(path, department)); }
public void testNullRef() throws Exception { Path path = new Path(model, "Department.company.name"); Department d = new Department(); assertNull(PathUtil.resolvePath(path, d)); }
public void testResolve() throws Exception { Path path = new Path(model, "Department.company.name"); Department department = (Department) DynamicUtil.createObject(Collections.singleton(Department.class)); Company company = (Company) DynamicUtil.createObject(Collections.singleton(Company.class)); department.setName("department name"); company.setName("company name"); department.setCompany(company); assertEquals("company name", PathUtil.resolvePath(path, department)); }
public void testResolvePathOneElement() throws Exception { Path path = new Path(model, "Department"); Department department = (Department) DynamicUtil.createObject(Collections.singleton(Department.class)); department.setId(10); assertEquals(department.getId(), ((Department) PathUtil.resolvePath(path, department)).getId()); }
public void testValid2() throws Exception { String stringPath = "Department.company.name"; Path path = new Path(model, stringPath); ClassDescriptor cld = model.getClassDescriptorByName("org.intermine.pathquery.model.testmodel.Department"); assertEquals(String.class, path.getEndType()); assertEquals(cld, path.getStartClassDescriptor()); }
public void testShortPath() throws Exception { String stringPath = "Department"; Path path = new Path(model, stringPath); ClassDescriptor cld = model.getClassDescriptorByName("org.intermine.pathquery.model.testmodel.Department"); assertEquals(cld, path.getStartClassDescriptor()); assertEquals(cld, path.getEndClassDescriptor()); assertNull(path.getEndFieldDescriptor()); //assertEquals(Department.class, path.getEndType()); }