<commit_before>package gscf

import grails.test.*
import dbnp.studycapturing.*
import dbnp.data.*

/**
 * Test the creation of a Subject and its TemplateEntity functionality on data model level
 *
 * @author keesvb
 * @since 20100511
 * @package dbnp.studycapturing
 *
 * Revision information:
 * $Rev$
 * $Author$
 * $Date$
 */
class StudyTests extends GrailsUnitTestCase {

	final String testStudyName = "Test study"
	final String testStudyTemplateName = "Academic study"
	final Date testStudyStartDate = Date.parse('yyyy-MM-dd','2007-12-11')
	final Date testStudyStartDate2 = Date.parse('yyyy-MM-dd','2008-05-11')
	final String testStudyStartDateString2 = "11-5-2010"
	// The following dates do net yet work:
	//final String testStudyStartDateString2 = "11-05-2010"
	//final String testStudyStartDateString2 = "Tue Dec 13 00:00:00 EST 2008"

	protected void setUp() {
		super.setUp()

		// Look up academic template
		def studyTemplate = Template.findByName(testStudyTemplateName)
		assert studyTemplate

		def study = new Study(
		    title: testStudyName,
		    template: studyTemplate,
		    startDate: testStudyStartDate
		)

		if (!study.validate()) {
			study.errors.each { println it}
		}
		assert study.validate()


		assert study.save(flush: true)

	}

	void testSave() {
		// Try to retrieve the study and make sure it's the same
		def studyDB = Study.findByTitle(testStudyName)
		assert studyDB
		assert studyDB.title.equals(testStudyName)
		assert studyDB.template.name.equals(testStudyTemplateName)
		assert studyDB.startDate.equals(testStudyStartDate)
	}
<commit_msg>added tests for Study domain fields<commit_after>package gscf

import grails.test.*
import dbnp.studycapturing.*
import dbnp.data.*

/**
 * Test the creation of a Subject and its TemplateEntity functionality on data model level
 *
 * @author keesvb
 * @since 20100511
 * @package dbnp.studycapturing
 *
 * Revision information:
 * $Rev$
 * $Author$
 * $Date$
 */
class StudyTests extends GrailsUnitTestCase {

	final String testStudyName = "Test study"
	final String testStudyTemplateName = "Academic study"
	final Date testStudyStartDate = Date.parse('yyyy-MM-dd','2007-12-11')
	final Date testStudyStartDate2 = Date.parse('yyyy-MM-dd','2008-05-11')
	final String testStudyStartDateString2 = "11-5-2010"
	// The following dates do net yet work:
	//final String testStudyStartDateString2 = "11-05-2010"
	//final String testStudyStartDateString2 = "Tue Dec 13 00:00:00 EST 2008"

	protected void setUp() {
		super.setUp()

		// Look up academic template
		def studyTemplate = Template.findByName(testStudyTemplateName)
		assert studyTemplate

		def study = new Study(
		    title: testStudyName,
		    template: studyTemplate,
		    startDate: testStudyStartDate
		)

		if (!study.validate()) {
			study.errors.each { println it}
		}
		assert study.validate()


		assert study.save(flush: true)

	}

	void testSave() {
		// Try to retrieve the study and make sure it's the same
		def studyDB = Study.findByTitle(testStudyName)
		assert studyDB
		assert studyDB.title.equals(testStudyName)
		assert studyDB.template.name.equals(testStudyTemplateName)
		assert studyDB.startDate.equals(testStudyStartDate)

		// A study without a title should not be saveable
		studyDB.title = null
		assert !studyDB.validate()
	}

	void testDomainFields() {
		def study = Study.findByTitle(testStudyName)
		assert study

		// Make sure the domain fields exist
		assert study.fieldExists('title')
		assert study.fieldExists('startDate')

		// Make sure they are domain fields
		assert study.isDomainField('title')
		assert study.isDomainField('startDate')
		
	}

{'fraction_non_alphanumeric': 0.09762824048538334, 'fraction_numerical': 0.03033645890788748, 'mean_word_length': 4.13012729844413, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2258754', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1098, 'n_words': 317}