Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests for Grails 7 #354

Merged
merged 4 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ dependencies {

testImplementation 'org.javassist:javassist:3.29.0-GA'
testImplementation "org.apache.groovy:groovy-dateutil"
testImplementation "cglib:cglib-nodep:2.2.2"
testImplementation("org.jodd:jodd-wot:$joddWotVersion") {
exclude module: 'slf4j-api'
exclude module: 'asm'
}

testRuntimeOnly "net.bytebuddy:byte-buddy:$byteBuddyVersion"
}

tasks.withType(GroovyCompile).configureEach {
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ grailsGradlePluginVersion=7.0.0-SNAPSHOT
grailsScaffoldingVersion=2.1.0
groovyVersion=4.0.23
joddWotVersion=3.3.8
byteBuddyVersion=1.14.12
asciidoc=true
githubSlug=gpc/fields
githubBranch=master
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.spockframework.util.VersionNumber
import org.springframework.beans.NotReadablePropertyException
import spock.lang.IgnoreIf
import spock.lang.Issue
import spock.lang.PendingFeature
import spock.lang.Shared
import spock.lang.Unroll
import spock.util.environment.Jvm
Expand Down Expand Up @@ -362,6 +363,7 @@ class DomainClassPropertyAccessorSpec extends BuildsAccessorFactory {
"minor" | false // boolean properties are never considered required
}

@PendingFeature(reason = 'until domain class inheritance works in Groovy 4')
def 'the superclasses of #type.simpleName are #expected'() {
given:
def propertyAccessor = factory.accessorFor(type.getConstructor().newInstance(), path)
Expand All @@ -387,6 +389,7 @@ class DomainClassPropertyAccessorSpec extends BuildsAccessorFactory {
Employee | 'name' | [Person]
}

@IgnoreIf({ VersionNumber.parse(Jvm.current.javaVersion).major >= 17 })
void 'the superclasses of Person.#path are #expected'() {
given:
def propertyAccessor = factory.accessorFor(person, path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ class FormFieldsTemplateServiceSpec extends BuildsAccessorFactory implements Ser
render(template: template.path) == 'DEFAULT FIELD TEMPLATE'
}

@PendingFeature(reason = 'until domain class inheritance works in Groovy 4')
def "resolves template for superclass property"() {
given:
views["/_fields/default/_wrapper.gsp"] = 'DEFAULT FIELD TEMPLATE'
Expand Down
51 changes: 2 additions & 49 deletions src/test/groovy/grails/plugin/formfields/mock/Employee.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,13 @@ package grails.plugin.formfields.mock
import grails.persistence.Entity

@Entity
class Employee { // inheritance currently does not work in Grails 7 // extends Person {
// extended from Person - start
Salutation salutation
String name
String password
Gender gender
Date dateOfBirth
Address address
Map emails = [:]
boolean minor
Date lastUpdated
String excludedProperty
String displayFalseProperty
Boolean grailsDeveloper
Byte[] picture
byte[] anotherPicture
String biography

transient String transientText = "transient text"

static hasMany = [emails: String]
static embedded = ['address']

static constraints = {
salutation nullable: true
name blank: false
dateOfBirth nullable: true
address nullable: true
excludedProperty nullable: true
displayFalseProperty nullable: true, display: false
grailsDeveloper nullable: true
picture nullable: true
anotherPicture nullable: true
password password: true
biography nullable: true, widget: 'textarea'
}

static scaffold = [exclude: ['excludedProperty']]
// static transients = ['transientText']
def onLoad = {
println "loaded"
}
// extended from Person - finish

@Override
String toString() {
name
}
class Employee extends HomoSapiens {

int salary

int getYearlySalary() {
200 * salary
}

static transients = ['transientText','yearlySalary']
static transients = ['yearlySalary']
}
8 changes: 7 additions & 1 deletion src/test/groovy/grails/plugin/formfields/mock/Person.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ package grails.plugin.formfields.mock
import grails.persistence.Entity

@Entity
class Person {
class Person extends HomoSapiens {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matrei nice, I actually had thought about that last night and was wondering why we didn't do that.


/*
Workaround for problem with domain inheritance in Groovy 4.
(Superclasses cannot be Gorm entities).
*/
class HomoSapiens {
Salutation salutation
String name
String password
Expand Down