public void testCreateObjectNothing() throws Exception { try { Object obj = DynamicUtil.createObject(Collections.EMPTY_SET); fail("Expected: IllegalArgumentException"); } catch (IllegalArgumentException e) { } }
private Company createCompanyWithId(String companyName) { Company company = (Company) DynamicUtil.createObject(Collections.singleton(Company.class)); company.setId(new Integer(idCounter++)); company.setName(companyName); return company; }
private Address createAddressWithId(String streetAddress) { Address address = (Address) DynamicUtil.createObject(Collections.singleton(Address.class)); address.setId(new Integer(idCounter++)); address.setAddress(streetAddress); return address; } }
public void testCreateObjectOneInterfaceWithParents() throws Exception { Object obj = DynamicUtil.createObject(Collections.singleton(Employable.class)); assertTrue(obj instanceof Employable); assertTrue(obj instanceof Thing); }
public void testCreateObjectClassAndRedundantInterfaces() { Set intSet = new HashSet(); intSet.add(Employee.class); intSet.add(Employable.class); Object obj = DynamicUtil.createObject(intSet); assertEquals(Employee.class, obj.getClass()); assertTrue(obj instanceof Employee); assertTrue(obj instanceof Employable); }
public void testCreateQueryDisableNullFields3() throws Exception { Source source = new Source("testsource"); Company c = (Company) DynamicUtil.createObject(Collections.singleton(Company.class)); c.setName("company1"); Address a = (Address) DynamicUtil.createObject(Collections.singleton(Address.class)); a.setAddress(null); c.setAddress(a); Query q = eof.createPKQuery(c, source, false); assertNull(q); }
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 } }
@Test public void testWriteInterMineObject() throws Exception { InterMineObject o = (InterMineObject) DynamicUtil.createObject(Collections.singleton(InterMineObject.class)); try { writer.store(o); } finally { writer.delete(o); } }
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 } }
@Test public void testGetEquivalentObjects() throws Exception { Bank b = (Bank) DynamicUtil.createObject(Collections.singleton(Bank.class)); b.setName("bank1"); Source source = iw.getMainSource("testsource", "testsource"); iw.getSkeletonSource("testsource", "testsource"); Set<InterMineObject> objects = iw.getEquivalentObjects(b, source); System.out.println(objects); Assert.assertTrue(objects.isEmpty()); }
public void testObjectPrimaryKeyIsNullNullField3() throws Exception { Department d = (Department) DynamicUtil.createObject(Collections.singleton(Department.class)); d.setName("jkhsdfg"); Company c = (Company) DynamicUtil.createObject(Collections.singleton(Company.class)); c.setAddress(null); c.setVatNumber(765213); d.setCompany(c); ClassDescriptor cld = model.getClassDescriptorByName("org.intermine.model.testmodel.Department"); PrimaryKey pk = (PrimaryKey) PrimaryKeyUtil.getPrimaryKeys(cld).get("key1"); assertTrue(DataLoaderHelper.objectPrimaryKeyNotNull(model, d, cld, pk, null, new IntToIntMap())); }
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 testPopulateTemplateWithObjectNotOneConstraint() throws Exception { InterMineObject obj = (InterMineObject) DynamicUtil.createObject(Employee.class); obj.setId(101); try { TemplatePopulator.populateTemplateWithObject(twoConstraints, obj); fail("Expected a TemplatePopulatorException"); } catch (TemplatePopulatorException e) { } }
public void testCreateObjectOneInterface() throws Exception { Object obj = DynamicUtil.createObject(Collections.singleton(Company.class)); assertTrue(obj instanceof Company); Company c = (Company) obj; c.setName("Flibble"); assertEquals("Flibble", c.getName()); }
public void testCreateQueryDisableNullFields1() throws Exception { Source source = new Source("testsource"); Employable e = (Employable) DynamicUtil.createObject(Collections.singleton(Employable.class)); e.setName(null); Query q = eof.createPKQuery(e, source, false); assertNull(q); }
public void testPopulateTemplateWithObjectWrongType() throws Exception { InterMineObject obj = (InterMineObject) DynamicUtil.createObject(Department.class); obj.setId(101); try { TemplatePopulator.populateTemplateWithObject(simple, obj); fail("Expected a TemplatePopulatorException"); } catch (TemplatePopulatorException e) { } }
public void testCanAssignObjectToType() throws Exception { Employee e = (Employee) DynamicUtil.createObject(Collections.singleton(Employee.class)); assertTrue(PathUtil.canAssignObjectToType(Employee.class, e)); Manager m = (Manager) DynamicUtil.createObject(Collections.singleton(Manager.class)); assertTrue(PathUtil.canAssignObjectToType(Employee.class, m)); assertFalse(PathUtil.canAssignObjectToType(Manager.class, e)); assertFalse(PathUtil.canAssignObjectToType(Department.class, e)); }
public void setUp() { company1 = new QueryClass(Company.class); company2 = new QueryClass(Company.class); employee = new QueryClass(Employee.class); manager = new QueryClass(Manager.class); contractor = new QueryClass(Contractor.class); company1Object = (Company) DynamicUtil.createObject(Collections.singleton(Company.class)); company1Object.setId(new Integer(8762134)); managerObject = new Manager(); managerObject.setId(new Integer(2687634)); }
@Test public void testWriteInterMineObject() throws Exception { InterMineObject o = (InterMineObject) DynamicUtil.createObject(Collections.singleton(InterMineObject.class)); try { writer.store(o); Assert.fail("Expected: error"); } catch (ObjectStoreException e) { Assert.assertEquals("Object [interface org.intermine.model.InterMineObject] does not map onto any database table.", e.getMessage()); } finally { writer.delete(o); } }
public void testPopulateTemplateWithObject() throws Exception { InterMineObject obj = (InterMineObject) DynamicUtil.createObject(Employee.class); obj.setId(101); TemplateQuery res = TemplatePopulator.populateTemplateWithObject(simple, obj); assertEquals(0, res.getEditableConstraints("Employee").size()); assertEquals(0, res.getEditableConstraints("Employee.name").size()); assertEquals(1, res.getEditableConstraints("Employee.id").size()); PathConstraint resCon = res.getEditableConstraints().get(0); assertEquals(ConstraintOp.EQUALS, resCon.getOp()); assertEquals("101", ((PathConstraintAttribute) resCon).getValue()); }