Skip to content

Instantly share code, notes, and snippets.

View ddelponte's full-sized avatar

Dean Del Ponte ddelponte

View GitHub Profile
@ddelponte
ddelponte / configurations
Last active August 29, 2015 13:58
Grails IntelliJ Settings
run-app -debug -reloading
-XX:MaxPermSize=512m -Xmx4096m
// To run in grails 2.4
grails -debug test-app
@ddelponte
ddelponte / BuildConfig.groovy
Last active August 29, 2015 13:59
Inline Plugin configuration
// Inline Testing
grails.plugin.location."platform-ui" = "../grails-platform-ui"
@ddelponte
ddelponte / Config.groovy
Last active August 29, 2015 13:59
Config.groovy for platform-ui and grails 2.3.x
plugin.platformCore.events.catchFlushExceptions = true
@ddelponte
ddelponte / BuildConfig.groovy
Created May 21, 2014 14:27
Write everything to target directory so it's easy to cleanup
//grails.project.class.dir = "target/classes"
//grails.project.test.class.dir = "target/test-classes"
//grails.project.test.reports.dir = "target/test-reports"
grails.project.work.dir="target"
@ddelponte
ddelponte / CriteriaProjections.groovy
Last active August 29, 2015 14:01
Have criteria projections return a map
import org.hibernate.criterion.CriteriaSpecification
BlogEntry.withCriteria {
maxResults 5
resultTransformer(CriteriaSpecification.ALIAS_TO_ENTITY_MAP)
projections {
count('id', 'total')
groupProperty('author', 'author')
}
}
@ddelponte
ddelponte / SomeIntegrationSpec.groovy
Created May 28, 2014 14:29
Integration tests pass individually but fail when run as a suite
// Convert
myCoolemailService.myEmailService = Mock(MyEmailService)
// to
myCoolemailService.myEmailService = Mock([useObjenesis: false], MyEmailService)
@ddelponte
ddelponte / EmptyListInfo.groovy
Created June 6, 2014 15:45
When to use Collections.emptyList()
Collections.emptyList()
// Use Collections.emptyList() when you do not wish to modify the returned list, otherwise []
// That's what you use if you want to pass a default parameter that will not be modified by the called funciton
// http://stackoverflow.com/questions/5552258/collections-emptylist-vs-new-instance
@ddelponte
ddelponte / GroovyPagesGoodness.groovy
Created June 11, 2014 15:07
Unit testing tricks - groovyPages
// Templates rendered by TagLib may be verified as follows
class SomeAwesomeSpec extends Specification {
public static final String BLAH = "BLAH"
void "test something"() {
given:
groovyPages.put("/path/to/_blah.gsp", BLAH)
when:
@ddelponte
ddelponte / JobSpec.groovy
Last active August 29, 2015 14:03
How to Gain access to applicaiton data
@TestFor(MyQuartzJob)
@TestMixin(ControllerUnitTestMixin) // This allows access to grailsApplication
class MyQuartzJobSpec extends Specification {
def job
def setup() {
grailsApplication.config.some.config.stuff = true
job = new MyQuartzJob()
}
}
@ddelponte
ddelponte / Config.groovy
Created July 23, 2014 00:59
Log SQL statements and values
log4j = {
...
debug 'org.hibernate.SQL'
trace 'org.hibernate.type.descriptor.sql.BasicBinder'
}