Changeset 406 for trunk/test


Ignore:
Timestamp:
May 11, 2010, 3:35:21 PM (10 years ago)
Author:
keesvb
Message:

added study tests, skip study adds when in test environment in bootstrap, refactored TemplateEntity?

Location:
trunk/test/integration/gscf
Files:
1 added
1 edited

Legend:

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

    r402 r406  
    2626        final String testSubjectBMITemplateFieldName = "BMI"
    2727        final double testSubjectBMI = 25.32
     28        final String testSubjectGenderTemplateFieldName = "Gender"
     29        final String testSubjectGender = "female"
     30        final String testSubjectGenderDBName = "Female"
    2831
    2932        /**
     
    98101                def domainFields = subject.giveDomainFields()
    99102                assert domainFields
    100                 println domainFields[0]
    101103                assert domainFields[0].name == 'name'
    102104                assert domainFields[1].name == 'species'
     105
     106                // Also, make sure isDomainField() says the same
     107                assert subject.isDomainField(domainFields[0])
     108                assert subject.isDomainField(domainFields[1])
     109                assert subject.isDomainField('name')
     110                assert subject.isDomainField('species')
     111                // To be sure it just doesn't always return true :-)
     112                assert !subject.isDomainField('123~!name')
     113                assert !subject.isDomainField(testSubjectBMITemplateFieldName)
    103114
    104115                // Get the ontologies from species and make sure this is 1 ontology with NCBO ID 1132
     
    123134                // Assign species, subject should now validate and save
    124135                subject.setFieldValue('species',humanTerm)
     136                if (!subject.validate()) {
     137                        subject.errors.each { println it}
     138                }
    125139                assert subject.validate()
    126140                assert subject.save(flush:true)
     
    139153                def subjectDB = Subject.findByName(testSubjectName)
    140154                assert subjectDB
    141 
    142155                assert subjectDB.getFieldValue('name').equals(testSubjectName)
    143156                assert subjectDB.getFieldValue('species') == Term.findByName(testSubjectSpeciesTerm)
     
    192205        }
    193206
     207        void testSetGender() {
     208                def subject = Subject.findByName(testSubjectName)
     209                assert subject
     210
     211                // Set gender
     212                subject.setFieldValue(testSubjectGenderTemplateFieldName,testSubjectGender)
     213
     214                // Test if gender is set properly (to its canonical database name) via getFieldValue()
     215                assert subject.getFieldValue(testSubjectGenderTemplateFieldName).name == testSubjectGenderDBName
     216
     217                // Try to save object
     218                assert subject.validate()
     219                assert subject.save(flush: true)
     220
     221                // Try to retrieve the subject and make sure the Gender was stored properly
     222                def subjectDB = Subject.findByName(testSubjectName)
     223                assert subjectDB
     224                assert subjectDB.getFieldValue(testSubjectGenderTemplateFieldName).name == testSubjectGenderDBName
     225        }
     226
    194227        protected void tearDown() {
    195228                super.tearDown()
Note: See TracChangeset for help on using the changeset viewer.