Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
burtbeckwith committed Feb 21, 2013
1 parent 0173a07 commit 65e07e5
Show file tree
Hide file tree
Showing 12 changed files with 155 additions and 286 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Expand Up @@ -5,5 +5,5 @@ target
*.log *.log
*.zip *.zip
.DS_Store .DS_Store
web-app/plugins web-app
web-app/WEB-INF/lib plugin.xml
87 changes: 16 additions & 71 deletions PlasticCriteriaGrailsPlugin.groovy
@@ -1,74 +1,19 @@
class PlasticCriteriaGrailsPlugin { class PlasticCriteriaGrailsPlugin {
// the plugin version def version = "0.6"
def version = "0.6" def grailsVersion = "1.3 > *"
// the version or versions of Grails the plugin is designed for def pluginExcludes = [
def grailsVersion = "1.3 > *" 'grails-app/domain/**',
// the other plugins this plugin depends on
def dependsOn = [:]
// resources that are excluded from plugin packaging
def pluginExcludes = [
'grails-app/views/error.gsp',
'grails-app/domain/plastic/criteria/Artist.groovy',
'grails-app/domain/plastic/criteria/Portrait.groovy',
'src/groovy/plastic/criteria/CriteriaDocTests.groovy' 'src/groovy/plastic/criteria/CriteriaDocTests.groovy'
] ]


// TODO Fill in these fields def title = "Plastic Criteria Plugin"
def title = "Plastic Criteria Plugin" // Headline display name of the plugin def author = "Fabio Issamu Oshiro"
def author = "Fabio Issamu Oshiro" def authorEmail = ""
def authorEmail = "" def description = 'Mock Grails Criteria for Unit Tests'
def description = '''\ def documentation = "http://grails.org/plugin/plastic-criteria"
Mock Grails Criteria for Unit Tests
''' // def license = "WTFPL"

def organization = [ name: "Investtools", url: "http://www.investtools.com.br/" ]
// URL to the plugin's documentation def issueManagement = [ system: "GitHub", url: "https://github.com/fabiooshiro/plastic-criteria/issues" ]
def documentation = "http://grails.org/plugin/plastic-criteria" def scm = [ url: "https://github.com/fabiooshiro/plastic-criteria" ]

// Extra (optional) plugin metadata

// License: one of 'APACHE', 'GPL2', 'GPL3'
// def license = "APACHE"

// Details of company behind the plugin (if there is one)
def organization = [ name: "Investtools", url: "http://www.investtools.com.br/" ]

// Any additional developers beyond the author specified above.
// def developers = [ [ name: "Joe Bloggs", email: "joe@bloggs.net" ]]

// Location of the plugin's issue tracker.
// def issueManagement = [ system: "JIRA", url: "http://jira.grails.org/browse/GPMYPLUGIN" ]

// Online location of the plugin's browseable source code.
def scm = [ url: "https://github.com/fabiooshiro/plastic-criteria" ]

def doWithWebDescriptor = { xml ->
// TODO Implement additions to web.xml (optional), this event occurs before
}

def doWithSpring = {
// TODO Implement runtime spring config (optional)
}

def doWithDynamicMethods = { ctx ->
// TODO Implement registering dynamic methods to classes (optional)
}

def doWithApplicationContext = { applicationContext ->
// TODO Implement post initialization spring config (optional)
}

def onChange = { event ->
// TODO Implement code that is executed when any artefact that this plugin is
// watching is modified and reloaded. The event contains: event.source,
// event.application, event.manager, event.ctx, and event.plugin.
}

def onConfigChange = { event ->
// TODO Implement code that is executed when the project configuration changes.
// The event is the same as for 'onChange'.
}

def onShutdown = { event ->
// TODO Implement code that is executed when the application shuts down (optional)
}
} }
19 changes: 9 additions & 10 deletions README.md
Expand Up @@ -21,9 +21,9 @@ Grails 2.0.x edit your <your-project>/grails-app/conf/BuildConfig.groovy
// (...) // (...)
plugins { plugins {
// (...) another plugins // (...) another plugins
// add this line // add this line
test ":plastic-criteria:0.4" test ":plastic-criteria:0.6"
} }
// (...) // (...)
``` ```
Expand All @@ -36,27 +36,27 @@ package plastic.test
import grails.test.mixin.* import grails.test.mixin.*
// import mockCriteria() static method // import mockCriteria() static method
import static plastic.criteria.PlasticCriteria.* import static plastic.criteria.PlasticCriteria.*
@TestFor(Product) @TestFor(Product)
class ProductTests { class ProductTests {
void testSomething() { void testSomething() {
new Product(name: 'Foo', value: 10).save() new Product(name: 'Foo', value: 10).save()
new Product(name: 'Foo', value: 20).save() new Product(name: 'Foo', value: 20).save()
new Product(name: 'Bar', value: 200).save() new Product(name: 'Bar', value: 200).save()
new Product(name: 'Bar', value: 100).save() new Product(name: 'Bar', value: 100).save()
// replace default criteria mock // replace default criteria mock
mockCriteria([Product]) mockCriteria([Product])
def results = Product.withCriteria{ def results = Product.withCriteria{
projections{ projections{
groupProperty('name') // now you have groupProperty groupProperty('name') // now you have groupProperty
sum('value') sum('value')
} }
} }
assert [['Foo', 30 ], ['Bar', 300]] == results assert [['Foo', 30 ], ['Bar', 300]] == results
} }
} }
Expand All @@ -67,7 +67,7 @@ just
``` ```
import static plastic.criteria.PlasticCriteria.*; import static plastic.criteria.PlasticCriteria.*;
``` ```
and and
``` ```
mockCriteria([Product]) mockCriteria([Product])
``` ```
Expand All @@ -76,4 +76,3 @@ mockCriteria([Product])
<a href="https://twitter.com/fabiooshiro">Sr. Oshiro</a>, <a href="https://twitter.com/fabiooshiro">Sr. Oshiro</a>,
<a href="http://www.facebook.com/MaxMustang23">Max Mustang</a>, <a href="http://www.facebook.com/MaxMustang23">Max Mustang</a>,
<a href="https://twitter.com/dtuler">Danilo Tuler</a> <a href="https://twitter.com/dtuler">Danilo Tuler</a>

6 changes: 0 additions & 6 deletions application.properties
@@ -1,7 +1 @@
#Grails Metadata file
#Mon Jan 21 11:35:17 BRST 2013
app.grails.version=2.1.3 app.grails.version=2.1.3
app.name=plastic-criteria
plugins.hibernate=2.1.3
plugins.rest-client-builder=1.0.2
plugins.svn=1.0.1
49 changes: 17 additions & 32 deletions grails-app/conf/BuildConfig.groovy
@@ -1,39 +1,24 @@
grails.project.class.dir = "target/classes" grails.project.work.dir = 'target'
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.target.level = 1.6 grails.project.target.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"


grails.project.dependency.resolution = { grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
repositories {
grailsCentral()
// uncomment the below to enable remote dependency resolution
// from public Maven repositories
mavenCentral()
mavenLocal()
//mavenRepo "http://snapshots.repository.codehaus.org"
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.


// runtime 'mysql:mysql-connector-java:5.1.5' inherits 'global'
// build ":release:2.0.0" log 'warn'

repositories {
grailsCentral()
mavenLocal()
mavenCentral()
}

dependencies {
compile 'javassist:javassist:3.12.1.GA' compile 'javassist:javassist:3.12.1.GA'
} }


plugins { plugins {
build(":tomcat:$grailsVersion", build(":release:2.0.0") {
":release:2.0.0") { export = false
export = false }
} }
}
} }
28 changes: 4 additions & 24 deletions grails-app/conf/Config.groovy
@@ -1,26 +1,6 @@
// configuration for plugin testing - will not be included in the plugin zip

log4j = { log4j = {
// Example of changing the log pattern for the default console error 'org.codehaus.groovy.grails',
// appender: 'org.springframework',
// 'org.hibernate',
//appenders { 'net.sf.ehcache.hibernate'
// console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
//}

error 'org.codehaus.groovy.grails.web.servlet', // controllers
'org.codehaus.groovy.grails.web.pages', // GSP
'org.codehaus.groovy.grails.web.sitemesh', // layouts
'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
'org.codehaus.groovy.grails.web.mapping', // URL mapping
'org.codehaus.groovy.grails.commons', // core / classloading
'org.codehaus.groovy.grails.plugins', // plugins
'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
'org.springframework',
'org.hibernate',
'net.sf.ehcache.hibernate'

warn 'org.mortbay.log'
} }
grails.views.default.codec="none" // none, html, base64
grails.views.gsp.encoding="UTF-8"
49 changes: 10 additions & 39 deletions grails-app/conf/DataSource.groovy
@@ -1,43 +1,14 @@
dataSource { dataSource {
pooled = true pooled = true
driverClassName = "org.h2.Driver" driverClassName = 'org.h2.Driver'
username = "sa" username = 'sa'
password = "" password = ''
dbCreate = 'update'
url = 'jdbc:h2:mem:testDb'
} }

hibernate { hibernate {
cache.use_second_level_cache = true cache.use_second_level_cache = false
cache.use_query_cache = true cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' cache.provider_class = 'org.hibernate.cache.EhCacheProvider'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:mem:devDb;MVCC=TRUE"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:testDb;MVCC=TRUE"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:prodDb;MVCC=TRUE"
pooled = true
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
}
} }
9 changes: 4 additions & 5 deletions grails-app/domain/plastic/criteria/Artist.groovy
@@ -1,13 +1,12 @@
package plastic.criteria; package plastic.criteria


public class Artist { class Artist {


String name String name

String toString(){ String toString(){
name name
} }

static hasMany = [portraits: Portrait] static hasMany = [portraits: Portrait]

} }
17 changes: 8 additions & 9 deletions grails-app/domain/plastic/criteria/Portrait.groovy
@@ -1,25 +1,24 @@
package plastic.criteria; package plastic.criteria


public class Portrait { class Portrait {


static belongsTo = [artist: Artist] static belongsTo = [artist: Artist]

String name String name

BigDecimal value BigDecimal value

BigDecimal lastSoldPrice BigDecimal lastSoldPrice

String color String color

String toString(){ String toString(){
"${name} (id: ${id})" "${name} (id: ${id})"
} }

static constraints = { static constraints = {
color nullable: true color nullable: true
value nullable: true value nullable: true
lastSoldPrice nullable: true lastSoldPrice nullable: true
} }

} }

0 comments on commit 65e07e5

Please sign in to comment.