@Test public void testOESourceAddNew() throws Exception { ReferenceSource source = new ReferenceSource("My fancy test ontology"); source.setAcc("bii:tests:MY-SRC-1"); OntologyTerm oe = new OntologyTerm("biionto:1010", "test oe", source); OntologyTerm oenew = persister.persist(oe); transaction.commit(); assertNotNull("Uh?! No object returned by the persister!", oenew); assertTrue("Ouch!? The OE returned by the persister should be the same!", oe == oenew); assertTrue("Urp! The OE was not saved!", entityManager.contains(oenew)); assertNotNull("Oh! The saved object should have an ID", oenew.getId()); ReferenceSource sourceDB = oenew.getSource(); assertNotNull("Ouch! No source for the persisted OE!", sourceDB); assertNotNull("Argh! The source of the persisted object should have an ID", source.getId()); }
@Test public void testOESourceExisting() throws Exception { ReferenceSource source = new ReferenceSource(null); source.setAcc("BII-1"); source.setName("TEST ONTOLOGY"); OntologyTerm oe = new OntologyTerm("OBI-EO1", "organism", source); OntologyTerm oenew = persister.persist(oe); transaction.commit(); assertNotNull("Uh?! No object returned by the persister!", oenew); assertTrue("Urp! The OE was not saved!", entityManager.contains(oenew)); assertTrue("Ouch!? The OE returned by the persister should be different!", oe != oenew); assertTrue("Oh! The saved object should have ID=501", oenew.getId() == 501); ReferenceSource sourceDB = oenew.getSource(); assertNotNull("Ouch! No source for the persisted OE!", sourceDB); assertTrue( "Argh! The source of the persisted object should have ID=100", sourceDB.getId() == 100); }