[
https://issues.apache.org/jira/browse/GROOVY-10598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17530444#comment-17530444
]
Daniel Geiselman commented on GROOVY-10598:
-------------------------------------------
The groovy file for the code
package com.moo.wholesaler.admin
import com.moo.wholesaler.AuditSearchForm
import com.moo.wholesaler.util.AuditLog
import grails.gorm.DetachedCriteria
import org.springframework.security.access.annotation.Secured
@Secured('ROLE_ADMIN')
class AuditLoggingController {
static defaultAction = "list"
def list(AuditSearchForm auditSearchForm) {
params.max = Math.min(params.long('max') ?: 50, 100)
params.order = params.order ?: 'desc'
params.sort = params.sort ?: 'dateCreated'
DetachedCriteria searchCriteria = new DetachedCriteria(AuditLog).build {
and {
if (auditSearchForm.className) {
eq 'className', auditSearchForm.className
}
if (auditSearchForm.id) {
eq 'persistedObjectId', auditSearchForm.id
}
if (auditSearchForm.user) {
eq 'actor', auditSearchForm.user
}
if (auditSearchForm.date) {
ge 'dateCreated', auditSearchForm.date
}
}
}
List<AuditLog> audits = searchCriteria.list(params)
render view: 'list', model: [
auditSearchForm: auditSearchForm,
reportData: audits,
reportDataTotal: searchCriteria.count()
]
}
}
The spec code
package com.moo.wholesaler.admin
import com.moo.wholesaler.AuditSearchForm
import com.moo.wholesaler.util.AuditLog
import grails.test.mixin.Mock
import grails.test.mixin.TestFor
import spock.lang.Specification
/**
* Created by req86346 on 02/12/2016.
*/
@TestFor(AuditLoggingController)
@Mock(AuditLog)
class AuditLoggingControllerSpec extends Specification {
void "Do a Search"() {
given:
AuditSearchForm auditSearchForm =Mock(AuditSearchForm)
when:
controller.list(auditSearchForm)
then:
2* auditSearchForm.getClassName() >> "TestClass"
2* auditSearchForm.getUser()>> 'user'
2* auditSearchForm.getId() >> 1
2* auditSearchForm.getDate() >> new Date()
model.auditSearchForm==auditSearchForm
}
}
I am learning a little bit on Grails through this process of gradle and grails
upgrades so if you see something odd, let me know.
> BUG! exception in phase 'instruction selection' unexpected
> NullPointerException
> -------------------------------------------------------------------------------
>
> Key: GROOVY-10598
> URL: https://issues.apache.org/jira/browse/GROOVY-10598
> Project: Groovy
> Issue Type: Bug
> Components: groovy-jdk
> Affects Versions: 5.x
> Environment: Windows 10, Powershell, IntelliJ 2020.3
> Reporter: Daniel Geiselman
> Assignee: Eric Milles
> Priority: Major
> Fix For: 5.0.0-alpha-1
>
>
> I am getting this in my gradle build after upgrading Gradle to 6.9.2 and
> Grails to
> classpath "org.grails:grails-gradle-plugin:5.1.4"
> implementation 'org.grails:grails-dependencies:5.1.7'
> implementation 'org.grails:grails-web-boot:5.1.7'
> implementation 'org.grails:grails-gradle-plugin:5.1.4'
> implementation 'org.grails:grails-core:5.1.7'
> runtimeOnly 'org.grails.plugins:hibernate:4.3.10.7'
> implementation 'org.grails.plugins:spring-security-core:5.0.0'
> implementation group: 'org.grails.plugins', name: 'cache', version: '5.0.1'
> testImplementation 'org.grails:grails-plugin-testing:3.3.0.M2'
> testImplementation 'org.grails:grails-test-mixins:3.3.0'
> testImplementation group: 'org.grails.plugins', name: 'geb', version: '2.0.0'
> compileOnly 'org.grails:grails-console:5.1.7'
>
> FAILURE: Build failed with an exception.
>
> * What went wrong:
> Execution failed for task ':compileTestGroovy'.
> > BUG! exception in phase 'instruction selection' in source unit
> > 'C:\SVNWorkspace\wholesaler-card-utility\src\test\groovy\com\moo\wholesaler\admin\AuditLoggingControllerSpec.groovy'
> > unexpected NullPointerException
>
> When I try to use IntelliJ to debug the code so I can step in and find where
> it is giving this, it gives me the same failure without hitting a break point.
>
> Any advice will be helpful.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)