blob: afd1710adfa34332cb98f7a091f5997021f75381 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.example
import grails.gorm.transactions.Rollback
import grails.plugins.redis.RedisService
import grails.testing.mixin.integration.Integration
import org.springframework.beans.factory.annotation.Autowired
import spock.lang.Specification
import java.time.LocalDate
@Integration
@Rollback
class RedisMemoizeDomainSpec extends Specification {
@Autowired RedisService redisService
def setup() {
redisService.flushDB()
}
def "get AST transformed domain object method"() {
given:
def title = 'all the things'
LocalDate date1 = LocalDate.now()
LocalDate date2 = date1.plusDays(1)
Book book = new Book(title: title).save(flush: true)
when:
def string1 = book.getMemoizedTitle(date1)
then:
string1 == "$title $date1"
when:
def string2 = book.getMemoizedTitle(date2)
then:
string2 != "$title $date2"
string2 == "$title $date1"
}
}