Project

General

Profile

Revision dca4d4c1

IDdca4d4c1ec73cf8a64d98a0539c3d4a58a3c20d9
Parent 0e40f189
Child 9214e186

Added by Andreas Müller almost 8 years ago

add lazy load GenBankAccession test

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/molecular/Locus.java
58 58
	
59 59
//*********************** CONSTRUCTOR ****************************************************/
60 60

  
61
	//Locus currently does not allow private constructor (javassist can't lazy load 
62
	// and create  class).
63
	//Still need to find out why.
61 64
	protected Locus() {
62 65

  
63 66
	}
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/molecular/MolecularHibernateImplTest.java
11 11
import org.unitils.spring.annotation.SpringBeanByType;
12 12

  
13 13
import eu.etaxonomy.cdm.model.molecular.DnaSample;
14
import eu.etaxonomy.cdm.model.molecular.GenBankAccession;
14 15
import eu.etaxonomy.cdm.model.molecular.Locus;
15 16
import eu.etaxonomy.cdm.model.molecular.Sequence;
16 17
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
......
34 35

  
35 36
//**************** TESTS ************************************************	
36 37
	
37
	//Test if DnaSample, Sequence and Locus data can be retrieved from database
38
	//Locus currently does not allow private constructor (javassist can't create class).
39
	//Still need to find out why.
38
	//Test if DnaSample can be loaded and if Sequence, Locus and GenBankAccession data can 
39
	//be lazy loaded from database
40 40
	//#3340
41 41
	@Test
42
	public void testRetrieveLocus() {
42
	public void testLazyLoadSequenceLocusGenbankaccession() {
43 43
		createTestData();
44 44
		DnaSample sample1 = (DnaSample)occurrenceDao.findByUuid(uuidSample1);
45 45
		Set<Sequence> sequences = sample1.getSequences();
......
47 47
		Sequence sequence = sequences.iterator().next();
48 48
		Locus locus = sequence.getLocus();
49 49
		Assert.assertEquals("Locus", locus.getName());
50
		Set<GenBankAccession> accessions = sequence.getGenBankAccession();
51
		GenBankAccession accession = accessions.iterator().next();
52
		Assert.assertEquals("123", accession.getAccessionNumber());
50 53
		commit();
51 54
	}
52 55

  
......
59 62
		Locus locus = Locus.NewInstance("Locus", null);
60 63
		sequence.setLocus(locus);
61 64
		
65
		GenBankAccession accession = GenBankAccession.NewInstance("123");
66
		sequence.addGenBankAccession(accession);
67
		
62 68
		occurrenceDao.save(sample);
63 69
		commitAndStartNewTransaction(new String[]{"DnaSample", "SpecimenOrObservationBase", "Locus"});
64 70
	}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)