Ignore:
Timestamp:
Aug 4, 2010, 4:12:38 PM (11 years ago)
Author:
keesvb
Message:

added deleteSubject method to Study, updated Study and Sample integration tests, disabled unused ontology tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/integration/gscf/SampleTests.groovy

    r737 r774  
    77import dbnp.studycapturing.Sample
    88import dbnp.studycapturing.TemplateFieldType
     9import dbnp.studycapturing.Subject
    910
    1011/**
     
    5455                        samplingEvent.errors.each { println it}
    5556                }
     57                // The SamplingEvent should not validate at this point because it doesn't have a parent study
     58                assert !samplingEvent.validate()
     59
     60                study.addToSamplingEvents(samplingEvent)
     61                // It should do fine now
    5662                assert samplingEvent.validate()
    57 
    5863                assert samplingEvent.save(flush:true)
    5964
     
    125130                // Make sure the sample doesn't exist anymore at this point
    126131                assert !Sample.findByName(testSampleName)
     132                assert Sample.count() == 0
    127133                assert study.samples.size() == 0
     134        }
     135
     136        void testDeleteViaParentSubject() {
     137
     138                def sampleDB = Sample.findByName(testSampleName)
     139                assert sampleDB
     140
     141                // Retrieve the parent study
     142                def study = Study.findByTitle(testStudyName)
     143                assert study
     144
     145                def subject = SubjectTests.createSubject(study)
     146                assert subject
     147
     148                sampleDB.parentSubject = subject
     149                assert sampleDB.validate()
     150                assert sampleDB.save()
     151
     152                // Use the deleteSubject method
     153                def msg = study.deleteSubject(subject)
     154                println msg
     155                assert study.save()
     156
     157                assert !study.subjects.contains(subject)
     158
     159                assert !Subject.findByName(testSampleName)
     160                assert !Sample.findByName(testSampleName)
     161
     162                assert Subject.count() == 0
     163                assert Sample.count() == 0
     164
    128165        }
    129166
Note: See TracChangeset for help on using the changeset viewer.