Adding a new boolean property to ObjectProperty. NIHVIVO-118

This commit is contained in:
bdc34 2010-03-22 22:04:47 +00:00
parent b00f1c50e2
commit 87a97cd8df
7 changed files with 85 additions and 8 deletions

View file

@ -0,0 +1,50 @@
package edu.cornell.mannlib.vitro.webapp.dao.jena;
import org.junit.Assert;
import org.junit.Test;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
public class ObjectPropertyDaoJenaTest {
@Test
public void testCollateBySubclass(){
/* Check that we can save collateBySubclass */
OntModel model = ModelFactory.createOntologyModel();
WebappDaoFactory wdf = new WebappDaoFactoryJena(model);
ObjectProperty op1 = new ObjectProperty();
String propURI = "http://example.com/testObjectProp" ;
op1.setURI(propURI);
Assert.assertFalse(op1.getCollateBySubclass());
try {
wdf.getObjectPropertyDao().insertObjectProperty(op1);
ObjectProperty op2 = wdf.getObjectPropertyDao().getObjectPropertyByURI(propURI);
Assert.assertNotNull(op2);
Assert.assertFalse(op2.getCollateBySubclass());
op2.setCollateBySubclass(true);
wdf.getObjectPropertyDao().updateObjectProperty(op2);
ObjectProperty op3 = wdf.getObjectPropertyDao().getObjectPropertyByURI(propURI);
Assert.assertNotNull(op3);
Assert.assertTrue(op3.getCollateBySubclass());
op3.setCollateBySubclass(false);
wdf.getObjectPropertyDao().updateObjectProperty(op3);
ObjectProperty op4 = wdf.getObjectPropertyDao().getObjectPropertyByURI(propURI);
Assert.assertNotNull(op4);
Assert.assertFalse(op4.getCollateBySubclass());
} catch (InsertException e) {
Assert.fail(e.getMessage());
}
}
}